:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface2: #1c1c1c;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-dim: #888;
    --accent: #6c5ce7;
    --accent-hover: #7c6cf7;
    --danger: #e74c3c;
    --success: #2ecc71;
    --warning: #f39c12;
    --radius: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #f0f0f0;
    --surface: #ffffff;
    --surface2: #f5f5f5;
    --border: #e0e0e0;
    --text: #1a1a1a;
    --text-dim: #666;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Login page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    flex-direction: column;
    gap: 24px;
}
.login-container h1 { font-size: 24px; font-weight: 600; }
.login-container p { color: var(--text-dim); }

/* Panel layout */
.panel {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}
.sidebar-brand {
    padding: 0 20px 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition);
    border-right: 2px solid transparent;
}
.sidebar a:hover { color: var(--text); background: var(--surface2); }
.sidebar a.active { color: var(--accent); background: var(--surface2); border-right-color: var(--accent); }
.sidebar-footer {
    margin-top: auto;
    padding: 16px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
}
.sidebar-footer .user-name { color: var(--text); font-weight: 500; }

/* Main content */
.main {
    margin-left: 220px;
    flex: 1;
    padding: 24px;
    min-height: 100vh;
}
.page-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
}

/* Page transition */
.page-enter {
    animation: pageIn 0.25s ease forwards;
}
@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Cards grid */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
.card-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.card-value { font-size: 28px; font-weight: 700; margin-top: 4px; transition: color var(--transition); }
.card-value.online { color: var(--success); }
.card-value.danger { color: var(--danger); }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
th, td { padding: 10px 14px; text-align: left; font-size: 13px; }
th { background: var(--surface2); color: var(--text-dim); font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
td { border-top: 1px solid var(--border); transition: background var(--transition); }
tr:hover td { background: var(--surface2); }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    transition: all var(--transition);
}
.badge-success { background: rgba(46,204,113,0.15); color: var(--success); }
.badge-danger { background: rgba(231,76,60,0.15); color: var(--danger); }
.badge-warning { background: rgba(243,156,18,0.15); color: var(--warning); }
.badge-dim { background: rgba(136,136,136,0.15); color: var(--text-dim); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    color: #fff;
    position: relative;
    overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background var(--transition);
}
.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: var(--success); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn:disabled::after { display: none; }

/* Tab buttons */
.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; }
.tab-btn {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-dim);
    background: transparent;
}
.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { color: #fff; background: var(--accent); }

/* Inputs */
input[type="text"], input[type="number"], input[type="search"], input[type="password"], textarea, select {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    outline: none;
    width: 100%;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(108,92,231,0.2);
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    max-width: 400px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: overlayIn 0.2s ease forwards;
}
@keyframes overlayIn {
    from { background: rgba(0,0,0,0); }
    to   { background: rgba(0,0,0,0.7); }
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 250px;
}
.toast.removing {
    animation: toastOut 0.2s ease forwards;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
@keyframes toastIn { from { transform: translateX(100%) scale(0.9); opacity: 0; } to { transform: translateX(0) scale(1); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* DLL upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-dim);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    color: var(--text);
    background: rgba(108,92,231,0.05);
}

/* Node card */
.node-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color var(--transition);
}
.node-card:hover { border-color: var(--accent); }
.node-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: background var(--transition);
}
.node-dot.alive { background: var(--success); box-shadow: 0 0 6px rgba(46,204,113,0.5); }
.node-dot.dead { background: var(--danger); }

/* Promo codes output */
.promo-list {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    font-family: monospace;
    font-size: 13px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-line;
}

/* Form group */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }

/* Flex utils */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; }

/* ── Mobile header (hamburger) ── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    z-index: 20;
}
.mobile-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}
.hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: background var(--transition);
}

/* ── Sidebar close button (mobile only) ── */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

/* ── Sidebar overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 15;
}
.sidebar-overlay.active { display: block; }

/* ── Responsive table wrapper ── */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}
.table-scroll table {
    min-width: 520px;
}

/* ── Responsive breakpoints ── */
@media (max-width: 768px) {
    /* Show mobile header */
    .mobile-header { display: flex; }

    /* Sidebar becomes a drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 18;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }

    /* Push content down past mobile header, no left offset */
    .main {
        margin-left: 0;
        padding: 16px;
        padding-top: calc(52px + 16px);
    }

    /* Modal fits the screen */
    .modal {
        min-width: unset;
        width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        padding: 18px;
    }

    /* Cards: 2 columns on phone */
    .cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Search bar full width */
    .search-bar { max-width: 100%; }

    /* Tab bar wraps */
    .tab-bar { flex-wrap: wrap; }

    /* Toast: left aligned and narrower */
    .toast-container {
        top: auto;
        bottom: 16px;
        right: 12px;
        left: 12px;
    }
    .toast { min-width: unset; width: 100%; }
    @keyframes toastIn { from { transform: translateY(30px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
    @keyframes toastOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(30px); opacity: 0; } }
}

@media (max-width: 400px) {
    .cards { grid-template-columns: 1fr; }
    .card-value { font-size: 22px; }
}
