:root {
    --bg: #0d0f14;
    --bg2: #13161e;
    --bg3: #1a1e28;
    --bg4: #222638;
    --border: #2a2f42;
    --border2: #353b54;
    --text: #e2e6f0;
    --muted: #7b82a0;
    --dim: #4a5070;
    --green: #4ade80;
    --green2: #166534;
    --green3: #052e16;
    --red: #f87171;
    --red2: #991b1b;
    --red3: #450a0a;
    --amber: #fbbf24;
    --amber2: #92400e;
    --amber3: #451a03;
    --blue: #60a5fa;
    --blue2: #1e3a5f;
    --cyan: #22d3ee;
    --radius: 8px;
    --radius2: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
}

/* ===== LOGIN ===== */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 380px;
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius2);
    padding: 2.5rem;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2rem;
}

    .login-logo svg {
        color: var(--cyan);
    }

.login-logo-text {
    font-size: 20px;
    font-weight: 600;
}

.login-logo-sub {
    font-size: 12px;
    color: var(--muted);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

    .field label {
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
    }

    .field input {
        background: var(--bg3);
        border: 0.5px solid var(--border);
        border-radius: var(--radius);
        color: var(--text);
        font-size: 14px;
        padding: 0 12px;
        height: 40px;
        font-family: inherit;
        outline: none;
        transition: border-color 0.2s;
    }

        .field input:focus {
            border-color: var(--cyan);
        }

.btn-login {
    width: 100%;
    height: 42px;
    background: var(--cyan);
    color: #0a1628;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}

    .btn-login:hover {
        opacity: 0.9;
    }

#login-error {
    font-size: 12px;
    color: var(--red);
    text-align: center;
    margin-top: 12px;
    min-height: 20px;
}

/* ===== APP ===== */
#app-screen {
    display: none;
    min-height: 100vh;
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: var(--bg2);
    border-bottom: 0.5px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

    .topbar-logo svg {
        color: var(--cyan);
    }

.topbar-sep {
    width: 0.5px;
    height: 28px;
    background: var(--border);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hub-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    padding: 4px 14px;
    background: var(--bg3);
    border: 0.5px solid var(--border);
    border-radius: 99px;
}

.hub-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dim);
    transition: all 0.3s;
}

    .hub-dot.on {
        background: var(--green);
        box-shadow: 0 0 8px var(--green);
    }

    .hub-dot.off {
        background: var(--red);
        animation: blink 1.2s infinite;
    }

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--blue2);
    border: 0.5px solid var(--border2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--blue);
}

.btn-logout {
    height: 32px;
    padding: 0 14px;
    background: transparent;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

    .btn-logout:hover {
        border-color: var(--red2);
        color: var(--red);
    }

/* ===== MAIN CONTENT ===== */
.main {
    padding: 24px;
    max-width: 1440px;
    margin: 0 auto;
}

/* ===== METRICS ===== */
.metrics {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.metric {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius2);
    padding: 16px 20px;
}

.metric-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.metric-val {
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
}

.metric-sub {
    font-size: 11px;
    color: var(--dim);
    margin-top: 6px;
}

.val-green {
    color: var(--green);
}

.val-red {
    color: var(--red);
}

.val-amber {
    color: var(--amber);
}

.val-muted {
    color: var(--muted);
}

/* ===== TAB ROW ===== */
.tab-row {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 4px;
    border: 0.5px solid var(--border);
}

.tab-btn {
    flex: 1;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

    .tab-btn.active {
        background: var(--bg4);
        color: var(--text);
    }

    .tab-btn:hover:not(.active) {
        color: var(--text);
    }

.tab-pane {
    display: none;
}

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

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-wrap {
    flex: 1;
    min-width: 200px;
    position: relative;
}

    .search-wrap svg {
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--dim);
        pointer-events: none;
    }

    .search-wrap input {
        width: 100%;
        height: 38px;
        background: var(--bg2);
        border: 0.5px solid var(--border);
        border-radius: var(--radius);
        color: var(--text);
        font-size: 13px;
        padding: 0 12px 0 36px;
        font-family: inherit;
        outline: none;
        transition: border-color 0.2s;
    }

        .search-wrap input:focus {
            border-color: var(--cyan);
        }

select.filter-sel {
    height: 38px;
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    padding: 0 12px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.2s;
}

    .btn:hover {
        border-color: var(--border2);
        background: var(--bg3);
    }

    .btn svg {
        width: 14px;
        height: 14px;
    }

.btn-cyan {
    border-color: #0e7490;
    color: var(--cyan);
}

.btn-red {
    border-color: var(--red2);
    color: var(--red);
}

.btn-green {
    border-color: var(--green2);
    color: var(--green);
}

.btn-amber {
    border-color: var(--amber2);
    color: var(--amber);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== TABLE ===== */
.table-wrap {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius2);
    overflow: hidden;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg3);
}

th {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 0.5px solid var(--border);
}

td {
    padding: 10px 14px;
    border-bottom: 0.5px solid var(--border);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr.data-row:hover td {
    background: var(--bg3);
}

.mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--cyan);
}

.machine-name {
    color: var(--muted);
    font-size: 13px;
}

.ver-tag {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 2px 10px;
    background: var(--bg4);
    border: 0.5px solid var(--border2);
    border-radius: 4px;
    color: var(--muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 12px;
    border-radius: 99px;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-online {
    background: var(--green3);
    color: var(--green);
    border: 0.5px solid var(--green2);
}

.badge-offline {
    background: var(--red3);
    color: var(--red);
    border: 0.5px solid var(--red2);
}

.badge-updating {
    background: var(--amber3);
    color: var(--amber);
    border: 0.5px solid var(--amber2);
}

.badge-failed {
    background: var(--red3);
    color: var(--red);
    border: 0.5px solid var(--red2);
}

.upd-progress {
    margin-top: 4px;
    font-size: 11px;
    color: var(--dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.hb-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hb-ago {
    font-size: 11px;
    color: var(--dim);
    font-family: 'JetBrains Mono', monospace;
}

.hb-bar {
    width: 80px;
    height: 3px;
    background: var(--bg4);
    border-radius: 99px;
    overflow: hidden;
}

.hb-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.5s;
}

.toggle-btn {
    width: 40px;
    height: 22px;
    border: none;
    border-radius: 99px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.3s;
}

    .toggle-btn::after {
        content: '';
        position: absolute;
        width: 16px;
        height: 16px;
        background: white;
        border-radius: 50%;
        top: 3px;
        transition: all 0.3s;
    }

.toggle-on {
    background: #166534;
}

    .toggle-on::after {
        left: 21px;
    }

.toggle-off {
    background: var(--bg4);
    border: 0.5px solid var(--border2);
}

    .toggle-off::after {
        left: 3px;
    }

.action-wrap {
    display: flex;
    gap: 4px;
}

.icon-btn {
    width: 30px;
    height: 30px;
    background: transparent;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
}

    .icon-btn:hover {
        border-color: var(--border2);
        color: var(--text);
        background: var(--bg3);
    }

.ip-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--dim);
}

.empty-row td {
    text-align: center;
    padding: 40px;
    color: var(--dim);
    font-size: 13px;
}

/* ===== PANELS ===== */
.panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.panel {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius2);
    padding: 18px 20px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-title {
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

    .panel-title svg {
        color: var(--muted);
        width: 16px;
        height: 16px;
    }

.btn-clear {
    font-size: 11px;
    color: var(--dim);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

    .btn-clear:hover {
        background: var(--bg3);
        color: var(--text);
    }

.log-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 240px;
    overflow-y: auto;
}

.log-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: var(--bg3);
    font-size: 12px;
    line-height: 1.5;
}

.log-time {
    color: var(--dim);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    white-space: nowrap;
    min-width: 60px;
}

.log-msg {
    color: var(--muted);
    flex: 1;
}

.log-empty {
    font-size: 12px;
    color: var(--dim);
    text-align: center;
    padding: 24px 0;
}

/* ===== CONFIG MANAGEMENT ===== */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.config-file-list {
    max-height: 300px;
    overflow-y: auto;
}

.config-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius);
    background: var(--bg3);
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: 0.5px solid transparent;
}

    .config-file-item:hover {
        background: var(--bg4);
    }

    .config-file-item.selected {
        border-color: var(--cyan);
        background: #0c2233;
    }

.config-actions {
    display: flex;
    gap: 4px;
}

    .config-actions button {
        padding: 2px 10px;
        font-size: 11px;
        background: var(--bg4);
        border: 0.5px solid var(--border);
        border-radius: 4px;
        color: var(--muted);
        cursor: pointer;
        font-family: inherit;
        transition: all 0.2s;
    }

        .config-actions button:hover {
            border-color: var(--border2);
            color: var(--text);
        }

.config-preview {
    background: var(--bg3);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 8px;
    max-height: 300px;
    overflow: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    white-space: pre-wrap;
    word-break: break-all;
}

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 500;
}

    .status-badge.success {
        background: var(--green3);
        color: var(--green);
    }

    .status-badge.error {
        background: var(--red3);
        color: var(--red);
    }

    .status-badge.pending {
        background: var(--amber3);
        color: var(--amber);
    }

.command-result {
    padding: 8px 12px;
    border-radius: var(--radius);
    margin-top: 8px;
    font-size: 12px;
}

    .command-result.success {
        background: var(--green3);
        color: var(--green);
        border: 0.5px solid var(--green2);
    }

    .command-result.error {
        background: var(--red3);
        color: var(--red);
        border: 0.5px solid var(--red2);
    }

    .command-result.info {
        background: var(--blue2);
        color: var(--blue);
        border: 0.5px solid var(--border2);
    }

/* ===== DROP ZONE ===== */
.drop-zone {
    border: 1.5px dashed var(--border2);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    background: var(--bg3);
    transition: all 0.3s;
}

    .drop-zone:hover,
    .drop-zone.dragover {
        border-color: var(--cyan);
        background: #0c2233;
    }

    .drop-zone svg {
        color: var(--dim);
        margin-bottom: 8px;
    }

.drop-zone-text {
    font-size: 13px;
    color: var(--muted);
}

.drop-zone-sub {
    font-size: 11px;
    color: var(--dim);
    margin-top: 4px;
}

.file-selected {
    display: none;
    align-items: center;
    gap: 12px;
    background: var(--bg3);
    border: 0.5px solid var(--border2);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-top: 10px;
}

    .file-selected.show {
        display: flex;
    }

    .file-selected svg {
        color: var(--cyan);
        flex-shrink: 0;
    }

.file-selected-info {
    flex: 1;
    min-width: 0;
}

.file-selected-name {
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-selected-size {
    font-size: 11px;
    color: var(--dim);
}

.file-remove {
    background: none;
    border: none;
    color: var(--dim);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 14px;
    transition: color 0.2s;
}

    .file-remove:hover {
        color: var(--red);
    }

.upload-progress {
    display: none;
    margin-top: 10px;
}

    .upload-progress.show {
        display: block;
    }

.upload-progress-bar {
    height: 4px;
    background: var(--bg4);
    border-radius: 99px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--cyan);
    border-radius: 99px;
    width: 0%;
    transition: width 0.3s;
}

.upload-progress-text {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

/* ===== MODAL ===== */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

    .modal-backdrop.open {
        display: flex;
    }

.modal {
    background: var(--bg2);
    border: 0.5px solid var(--border2);
    border-radius: var(--radius2);
    padding: 28px;
    width: 480px;
    max-width: 96vw;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

    .modal-head h3 {
        font-size: 16px;
        font-weight: 500;
    }

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--bg3);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

    .modal-close:hover {
        border-color: var(--red2);
        color: var(--red);
    }

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

    .modal-field label {
        font-size: 12px;
        color: var(--muted);
        font-weight: 500;
    }

    .modal-field input,
    .modal-field select,
    .modal-field textarea {
        background: var(--bg3);
        border: 0.5px solid var(--border);
        border-radius: var(--radius);
        color: var(--text);
        font-size: 13px;
        padding: 8px 12px;
        font-family: inherit;
        outline: none;
        transition: border-color 0.2s;
    }

        .modal-field input:focus,
        .modal-field select:focus,
        .modal-field textarea:focus {
            border-color: var(--cyan);
        }

    .modal-field textarea {
        resize: vertical;
        min-height: 60px;
    }

.btn-submit {
    width: 100%;
    height: 42px;
    background: var(--cyan);
    color: #0a1628;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.2s;
}

    .btn-submit:hover {
        opacity: 0.9;
    }

    .btn-submit:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

/* ===== TOAST ===== */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg3);
    border: 0.5px solid var(--border2);
    border-radius: var(--radius);
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text);
    z-index: 999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

    #toast.show {
        transform: translateY(0);
        opacity: 1;
    }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .metrics {
        grid-template-columns: repeat(3, 1fr);
    }

    .config-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .panels {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 12px;
        flex-wrap: wrap;
        height: auto;
        min-height: 60px;
        gap: 8px;
    }

    .topbar-left {
        flex-wrap: wrap;
    }

    .main {
        padding: 12px;
    }

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

    .search-wrap {
        min-width: unset;
    }

    .modal {
        padding: 20px;
        width: 100%;
        max-width: 100%;
    }

    .table-wrap {
        overflow-x: auto;
    }

    table {
        min-width: 800px;
    }
}

@media (max-width: 480px) {
    .metrics {
        grid-template-columns: 1fr 1fr;
    }

    .metric-val {
        font-size: 22px;
    }
}
