:root {
    --bg-0: #070b11;
    --bg-1: #0d1420;
    --bg-2: #121b2a;
    --card: rgba(18, 28, 42, 0.86);
    --card-strong: rgba(16, 24, 36, 0.95);
    --line: rgba(165, 186, 214, 0.2);
    --text: #ebf1fa;
    --muted: #95a7c1;
    --ok: #39d98a;
    --warn: #f7b955;
    --danger: #ff6075;
    --accent: #2ec5ff;
    --accent-2: #49f8d5;
    --radius-lg: 20px;
    --radius-md: 14px;
    --shadow: 0 18px 44px rgba(2, 7, 14, 0.55);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: radial-gradient(1200px 800px at 8% 8%, rgba(37, 157, 224, 0.16), transparent 55%),
                radial-gradient(900px 700px at 92% 12%, rgba(48, 227, 194, 0.1), transparent 55%),
                linear-gradient(135deg, var(--bg-0), var(--bg-1) 48%, #060b12);
    color: var(--text);
    font-family: "Plus Jakarta Sans", sans-serif;
    line-height: 1.45;
}

body.ajax-loading {
    cursor: progress;
}

.bg-layer {
    pointer-events: none;
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(circle at center, #000 40%, transparent 100%);
    z-index: -1;
}

h1,
h2,
h3,
p {
    margin: 0;
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(520px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
    padding: 28px;
}

.landing-shell {
    position: relative;
    min-height: 72vh;
    display: grid;
    place-items: center;
}

.landing-glow {
    position: absolute;
    width: 560px;
    height: 560px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(46, 197, 255, 0.22), rgba(73, 248, 213, 0.08), transparent 72%);
    filter: blur(14px);
    pointer-events: none;
}

.landing-core {
    position: relative;
    width: min(640px, 100%);
    border: 1px solid rgba(153, 177, 207, 0.24);
    border-radius: 22px;
    background: rgba(8, 14, 22, 0.86);
    box-shadow: var(--shadow);
    padding: 28px;
}

.landing-tag {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(46, 197, 255, 0.4);
    color: #a9dfff;
    font-size: 12px;
    margin-bottom: 12px;
}

.landing-title {
    font-size: 30px;
    line-height: 1.14;
    margin-bottom: 10px;
}

.landing-desc {
    color: #9cb3d0;
    margin-bottom: 18px;
}

.landing-form {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.landing-foot {
    color: #8ea8c9;
    font-size: 13px;
}

.landing-foot a {
    color: #a6f6e2;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, rgba(46, 197, 255, 0.18), rgba(73, 248, 213, 0.11));
    border: 1px solid rgba(46, 197, 255, 0.35);
    color: var(--accent);
    font-size: 20px;
}

.brand-row h1 {
    font-size: 20px;
    letter-spacing: 0.02em;
}

.brand-row p {
    color: var(--muted);
    font-size: 13px;
}

.form-block {
    display: grid;
    gap: 14px;
}

.field-label {
    display: block;
    margin-bottom: 7px;
    color: #c2d3e9;
    font-size: 13px;
    font-weight: 600;
}

.input-wrap {
    position: relative;
}

.input-wrap i {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 12px;
    color: #7d95b4;
    font-size: 14px;
}

.input,
.code-input,
textarea {
    width: 100%;
    border: 1px solid rgba(150, 177, 212, 0.25);
    background: rgba(8, 13, 22, 0.86);
    color: var(--text);
    border-radius: 11px;
    padding: 12px 12px 12px 38px;
    font-size: 14px;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

select.input {
    appearance: none;
}

.input-plain {
    padding-left: 12px;
}

.code-input {
    padding-left: 14px;
    text-align: center;
    letter-spacing: 0.22em;
    font-family: "JetBrains Mono", monospace;
    font-size: 20px;
}

textarea {
    padding: 12px;
    min-height: 110px;
    font-family: "JetBrains Mono", monospace;
}

.input:focus,
.code-input:focus,
textarea:focus {
    border-color: rgba(46, 197, 255, 0.65);
    box-shadow: 0 0 0 3px rgba(46, 197, 255, 0.15);
}

.checkline {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: #c5d7ed;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 700;
    color: #0b121c;
    background: linear-gradient(130deg, var(--accent), #53ffc4);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .12s ease, filter .18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.btn:active {
    transform: translateY(0);
}

.btn.ghost {
    background: rgba(13, 20, 31, 0.9);
    border: 1px solid rgba(153, 177, 207, 0.25);
    color: #d8e7fa;
}

.btn.warn {
    background: linear-gradient(135deg, #ffd26a, #ff954c);
}

.btn.danger {
    background: linear-gradient(135deg, #ff7187, #ff4b5f);
}

.btn.full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    filter: grayscale(0.22);
}

.helper {
    color: var(--muted);
    font-size: 12px;
}

.alert {
    border-radius: 11px;
    padding: 11px 13px;
    border: 1px solid transparent;
    margin-bottom: 14px;
    font-size: 13px;
}

.alert.error {
    background: rgba(255, 97, 123, 0.12);
    border-color: rgba(255, 97, 123, 0.35);
    color: #ffd0d8;
}

.alert.success {
    background: rgba(57, 217, 138, 0.14);
    border-color: rgba(57, 217, 138, 0.34);
    color: #cdf9e3;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 7, 14, 0.7);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
    z-index: 70;
}

.app-shell {
    min-height: 100vh;
    max-width: 1880px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: minmax(250px, 280px) minmax(0, 1fr);
    gap: 16px;
}

.panel-sidebar {
    position: sticky;
    top: 12px;
    z-index: 80;
    height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 13px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(10, 16, 26, 0.9);
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 26px rgba(2, 7, 14, 0.45);
}

.panel-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.panel-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e8f4ff;
    text-decoration: none;
    font-weight: 800;
    letter-spacing: .02em;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
}

.panel-brand:hover {
    border-color: rgba(151, 176, 212, 0.3);
    background: rgba(18, 28, 41, 0.82);
}

.panel-brand i {
    color: var(--accent-2);
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(153, 177, 207, 0.3);
    background: rgba(12, 20, 31, 0.86);
    color: #d8e7fa;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.topbar-menu-toggle {
    flex: 0 0 auto;
}

.panel-nav {
    display: grid;
    gap: 8px;
    align-content: start;
    min-height: 0;
    overflow: auto;
    padding-right: 2px;
    flex: 1 1 auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    color: #b9cee8;
    text-decoration: none;
    border: 1px solid rgba(153, 177, 207, 0.2);
    background: rgba(9, 14, 22, 0.74);
    padding: 10px 12px;
    border-radius: 10px;
    transition: all .18s ease;
}

.nav-item:hover {
    color: #eaf4ff;
    border-color: rgba(46, 197, 255, 0.35);
    background: rgba(16, 26, 39, 0.9);
}

.nav-item.active {
    color: #eaf8ff;
    border-color: rgba(46, 197, 255, 0.42);
    background: linear-gradient(130deg, rgba(46, 197, 255, 0.18), rgba(73, 248, 213, 0.09));
}

.nav-logout {
    margin: 0;
    width: 100%;
}

.sidebar-footer {
    margin-top: auto;
}

.nav-button {
    width: 100%;
    font: inherit;
    cursor: pointer;
}

.content-shell {
    min-width: 0;
    padding: 2px;
}

.topbar {
    position: sticky;
    top: 12px;
    z-index: 65;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(10, 16, 26, 0.9);
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 26px rgba(2, 7, 14, 0.45);
    padding: 12px 14px;
    margin-bottom: 18px;
}

.topbar-title h2 {
    font-size: 25px;
}

.topbar-title p {
    color: var(--muted);
    margin-top: 5px;
}

.dashboard-live {
    display: grid;
    gap: 14px;
}

.settings-shell {
    display: grid;
    gap: 10px;
}

.tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(153, 177, 207, 0.2);
    background: rgba(8, 14, 22, 0.72);
}

.tab-btn {
    border: 1px solid rgba(153, 177, 207, 0.24);
    border-radius: 10px;
    padding: 10px 13px;
    background: rgba(9, 15, 24, 0.78);
    color: #c5d8f0;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all .16s ease;
}

.tab-btn:hover {
    border-color: rgba(46, 197, 255, 0.38);
    color: #ecf6ff;
}

.tab-btn.active {
    border-color: rgba(46, 197, 255, 0.5);
    background: linear-gradient(130deg, rgba(46, 197, 255, 0.2), rgba(73, 248, 213, 0.1));
    color: #ebf9ff;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.status-note {
    margin-top: 12px;
    border-radius: 10px;
    border: 1px solid rgba(153, 177, 207, 0.24);
    background: rgba(7, 11, 18, 0.82);
    padding: 10px 12px;
    font-size: 13px;
    color: #b8cee8;
}

.status-note.ok {
    border-color: rgba(57, 217, 138, 0.42);
    color: #c9f8e2;
}

.status-note.bad {
    border-color: rgba(255, 96, 117, 0.35);
    color: #ffd5dc;
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-all {
    grid-column: 1 / -1;
}

.card {
    background: var(--card-strong);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 18px;
}

.card h3 {
    font-size: 17px;
    margin-bottom: 13px;
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 9px;
}

.kbd {
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid rgba(157, 182, 214, 0.24);
    background: rgba(10, 15, 22, 0.8);
    font-family: "JetBrains Mono", monospace;
    color: #d4e8ff;
    font-size: 12px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
}

.pill.ok {
    color: #cafce2;
    background: rgba(57, 217, 138, 0.14);
    border-color: rgba(57, 217, 138, 0.45);
}

.pill.bad {
    color: #ffd5dc;
    background: rgba(255, 96, 117, 0.12);
    border-color: rgba(255, 96, 117, 0.35);
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.mini-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.btn.mini {
    padding: 6px 9px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.1;
}

.btn.mini-lg {
    padding: 8px 11px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 1.15;
}

.kbd-button {
    appearance: none;
    cursor: pointer;
    background: rgba(10, 15, 22, 0.8);
}

.script-filter-row .kbd-button.active {
    border-color: rgba(46, 197, 255, 0.5);
    background: linear-gradient(130deg, rgba(46, 197, 255, 0.22), rgba(73, 248, 213, 0.12));
    color: #ebf9ff;
}

.script-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 700;
}

.script-status.running {
    color: #c9f8e2;
    border-color: rgba(57, 217, 138, 0.45);
    background: rgba(57, 217, 138, 0.14);
}

.script-status.paused {
    color: #ffeac6;
    border-color: rgba(247, 185, 85, 0.45);
    background: rgba(247, 185, 85, 0.15);
}

.script-status.service-active {
    color: #daf4ff;
    border-color: rgba(46, 197, 255, 0.45);
    background: rgba(46, 197, 255, 0.13);
}

.script-status.service-stopped {
    color: #ffeac6;
    border-color: rgba(247, 185, 85, 0.4);
    background: rgba(247, 185, 85, 0.14);
}

.script-status.inactive {
    color: #cad7ea;
    border-color: rgba(153, 177, 207, 0.34);
    background: rgba(153, 177, 207, 0.12);
}

.runtime-shell {
    display: grid;
    gap: 14px;
}

.runtime-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.runtime-kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.runtime-kpi {
    border-radius: 11px;
    border: 1px solid rgba(153, 177, 207, 0.2);
    background: rgba(8, 14, 22, 0.68);
    padding: 10px 11px;
    display: grid;
    gap: 6px;
}

.runtime-kpi span {
    color: #a7bdd8;
    font-size: 12px;
}

.runtime-kpi strong {
    color: #e7f4ff;
    font-size: 21px;
    line-height: 1;
}

.runtime-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1.2fr);
    gap: 10px;
    align-items: center;
}

.runtime-search-wrap {
    position: relative;
}

.runtime-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #8fa9c8;
    font-size: 13px;
}

.runtime-search {
    padding-left: 34px;
}

.runtime-bulk-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.runtime-table-wrap {
    max-height: 520px;
}

.runtime-launch {
    border-radius: 12px;
    border: 1px solid rgba(153, 177, 207, 0.2);
    background: rgba(8, 14, 22, 0.68);
    padding: 12px;
    display: grid;
    gap: 10px;
}

.runtime-launch-head h4 {
    margin: 0;
    font-size: 15px;
}

.runtime-launch-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.runtime-launch-actions {
    display: flex;
    justify-content: flex-end;
}

.log-box {
    background: #060a11;
    border: 1px solid rgba(130, 156, 192, 0.22);
    border-radius: 12px;
    padding: 12px;
    max-height: 560px;
    overflow: auto;
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    white-space: pre-wrap;
    color: #cce4ff;
}

.meta-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 7px;
    font-size: 13px;
}

.meta-list li {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: #c8dbf2;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.prompt-editor-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.prompt-editor-grid .setting-item {
    display: grid;
    gap: 10px;
}

.runtime-config-shell {
    display: grid;
    gap: 14px;
}

.runtime-config-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.runtime-accordion {
    display: grid;
    gap: 10px;
}

.runtime-accordion-item {
    border: 1px solid rgba(153, 177, 207, 0.22);
    border-radius: 12px;
    background: rgba(8, 14, 22, 0.76);
    overflow: hidden;
}

.runtime-accordion-head {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 11px 12px;
    user-select: none;
}

.runtime-accordion-head::-webkit-details-marker {
    display: none;
}

.runtime-accordion-title {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #e7f4ff;
}

.runtime-accordion-title i {
    color: var(--accent);
}

.runtime-accordion-body {
    border-top: 1px solid rgba(153, 177, 207, 0.18);
    padding: 12px;
}

.setting-item {
    border: 1px solid rgba(153, 177, 207, 0.2);
    border-radius: 12px;
    background: rgba(8, 14, 22, 0.72);
    padding: 12px;
}

.textarea-lg {
    min-height: 170px;
}

.textarea-xl {
    min-height: 360px;
}

.table-wrap {
    max-height: 320px;
    overflow: auto;
    border: 1px solid rgba(153, 177, 207, 0.22);
    border-radius: 12px;
}

.simple-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.simple-table th,
.simple-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(153, 177, 207, 0.16);
    text-align: left;
    vertical-align: top;
}

.simple-table th {
    color: #9fb6d8;
    font-weight: 700;
    position: sticky;
    top: 0;
    background: rgba(8, 14, 22, 0.95);
}

.mono-cell {
    font-family: "JetBrains Mono", monospace;
    color: #d6e8ff;
    word-break: break-word;
}

.file-list {
    display: grid;
    gap: 8px;
    max-height: 420px;
    overflow: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(153, 177, 207, 0.18);
    background: rgba(8, 14, 22, 0.72);
    border-radius: 10px;
    color: #d8e7fa;
    text-decoration: none;
    padding: 9px 10px;
    font-size: 12px;
}

.file-item.dir {
    border-style: dashed;
}

.file-item:hover {
    border-color: rgba(46, 197, 255, 0.45);
    background: rgba(10, 18, 28, 0.92);
}

.secret-box {
    margin-top: 10px;
    border-radius: 10px;
    border: 1px dashed rgba(160, 183, 210, 0.38);
    background: rgba(6, 10, 18, 0.88);
    padding: 10px;
    font-family: "JetBrains Mono", monospace;
    word-break: break-all;
    font-size: 13px;
}

.qr-wrap {
    margin-top: 12px;
    display: grid;
    place-items: center;
    padding: 10px;
    border-radius: 10px;
    background: rgba(9, 15, 23, 0.82);
    border: 1px solid rgba(149, 173, 209, 0.22);
}

.qr-wrap img {
    width: 190px;
    height: 190px;
    border-radius: 8px;
}

@media (max-width: 1080px) {
    .app-shell {
        padding: 14px;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .panel-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(84vw, 320px);
        height: 100vh;
        border-radius: 0 14px 14px 0;
        border-left: none;
        transform: translateX(-102%);
        transition: transform .18s ease;
    }

    .panel-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .topbar {
        top: 8px;
    }

    .panel-brand span {
        font-size: 16px;
    }

    .grid.cols-2,
    .grid.cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .runtime-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .runtime-toolbar {
        grid-template-columns: 1fr;
    }

    .runtime-bulk-actions {
        justify-content: flex-start;
    }

    .runtime-launch-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .runtime-accordion-head {
        padding: 10px;
    }

    .runtime-accordion-body {
        padding: 10px;
    }
}

@media (max-width: 760px) {
    .content-shell {
        padding-top: 0;
    }

    .grid.cols-2,
    .grid.cols-3,
    .button-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .topbar-title h2 {
        font-size: 22px;
    }

    .card {
        padding: 14px;
    }

    .tabs-nav {
        padding: 8px;
    }

    .tab-btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .runtime-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        align-items: flex-start;
        flex-direction: row;
    }

    .runtime-head {
        flex-direction: column;
        align-items: stretch;
    }

    .runtime-launch-grid {
        grid-template-columns: 1fr;
    }

    .runtime-launch-actions .btn {
        width: 100%;
    }
}
