/* ═══════════════════════════════════════════════════════════════════
   XFS Bot Control Panel — Cyberpunk Theme
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --bg:           #0a0a12;
    --surface:      #12121e;
    --surface2:     #1a1a2e;
    --border:       #2a2a3e;
    --text:         #d0d0e0;
    --text-dim:     #6666aa;
    --neon-cyan:    #00ddff;
    --neon-pink:    #ff3388;
    --neon-green:   #00ff88;
    --neon-yellow:  #ffee00;
    --neon-orange:  #ff6600;
    --neon-purple:  #aa66ff;
    --neon-red:     #ff3355;
    --font-mono:    'Consolas', 'Courier New', monospace;
    --radius:       8px;
    --shadow-glow:  0 0 20px rgba(0, 221, 255, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-mono);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Screens ──────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: flex; }

/* ── Login ────────────────────────────────────────────────────────── */
#login-screen {
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at center, #12122e, var(--bg));
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 380px;
    text-align: center;
    box-shadow: var(--shadow-glow);
    overflow: visible;
}

.logo-pulse {
    font-size: 64px;
    animation: pulse 2s ease-in-out infinite;
    color: var(--neon-cyan);
    text-shadow: 0 0 30px var(--neon-cyan);
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.05); }
}

.login-box h1 {
    color: var(--neon-cyan);
    font-size: 24px;
    letter-spacing: 6px;
    margin: 8px 0 4px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 3px;
    margin-bottom: 24px;
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-dim);
    font-size: 10px;
}
.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.login-divider span { padding: 0 12px; }

#login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

input[type="text"], input[type="password"], input[type="number"],
textarea, select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 221, 255, 0.2);
}

.error-text {
    color: var(--neon-red);
    font-size: 12px;
    margin-top: 8px;
    min-height: 16px;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn-neon {
    background: transparent;
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    padding: 10px 20px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-neon:hover {
    background: rgba(0, 221, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 221, 255, 0.3);
}

.btn-small {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 3px;
    cursor: pointer;
    border: 1px solid;
    background: transparent;
    font-family: var(--font-mono);
    transition: all 0.2s;
}

.btn-danger  { color: var(--neon-red);   border-color: var(--neon-red); }
.btn-danger:hover { background: rgba(255, 51, 85, 0.15); }
.btn-success { color: var(--neon-green); border-color: var(--neon-green); }
.btn-success:hover { background: rgba(0, 255, 136, 0.15); }
.btn-warn    { color: var(--neon-orange); border-color: var(--neon-orange); }
.btn-warn:hover { background: rgba(255, 102, 0, 0.15); }
.btn-info    { color: var(--neon-cyan);  border-color: var(--neon-cyan); }
.btn-info:hover { background: rgba(0, 221, 255, 0.15); }
.btn-warning { color: var(--neon-yellow); border-color: var(--neon-yellow); }
.btn-warning:hover { background: rgba(255, 238, 0, 0.15); }

/* Active scraper tab — bright filled background */
.btn-scraper-active {
    background: rgba(0, 221, 255, 0.2) !important;
    box-shadow: 0 0 12px rgba(0, 221, 255, 0.4), inset 0 0 8px rgba(0, 221, 255, 0.1);
    border-color: var(--neon-cyan) !important;
    color: #fff !important;
    text-shadow: 0 0 6px var(--neon-cyan);
}

/* ── Main Layout ──────────────────────────────────────────────────── */
#main-screen {
    min-height: 100vh;
}

#sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-logo {
    padding: 20px 16px;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 3px;
    color: var(--neon-cyan);
    text-shadow: 0 0 15px var(--neon-cyan);
    border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 18px; }

#nav-links {
    list-style: none;
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

#nav-links li {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-dim);
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
#nav-links li:hover {
    color: var(--text);
    background: rgba(0, 221, 255, 0.05);
}
#nav-links li.active {
    color: var(--neon-cyan);
    border-left-color: var(--neon-cyan);
    background: rgba(0, 221, 255, 0.08);
}

.nav-icon { font-size: 15px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-dim);
}

#content {
    margin-left: 220px;
    padding: 24px;
    flex: 1;
    min-height: 100vh;
}

/* ── Cards / Panels ───────────────────────────────────────────────── */
.hud-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}
.hud-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--neon-cyan), transparent);
}
.hud-panel .panel-title {
    padding: 12px 16px;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}
.hud-panel .panel-body {
    padding: 16px;
}

/* ── Stat Cards ───────────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}
.stat-card.cyan::before   { background: var(--neon-cyan); }
.stat-card.pink::before   { background: var(--neon-pink); }
.stat-card.green::before  { background: var(--neon-green); }
.stat-card.yellow::before { background: var(--neon-yellow); }
.stat-card.orange::before { background: var(--neon-orange); }
.stat-card.purple::before { background: var(--neon-purple); }

.stat-card .stat-label {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: bold;
}
.stat-card.cyan .stat-value   { color: var(--neon-cyan); }
.stat-card.pink .stat-value   { color: var(--neon-pink); }
.stat-card.green .stat-value  { color: var(--neon-green); }
.stat-card.yellow .stat-value { color: var(--neon-yellow); }
.stat-card.orange .stat-value { color: var(--neon-orange); }
.stat-card.purple .stat-value { color: var(--neon-purple); }

/* ── Download Cards ───────────────────────────────────────────────── */
.dl-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.dl-card .dl-info { flex: 1; }
.dl-card .dl-name {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 4px;
    word-break: break-all;
}
.dl-card .dl-meta {
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}
.progress-bar .progress-fill {
    height: 100%;
    background: var(--neon-cyan);
    border-radius: 2px;
    transition: width 0.3s;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    letter-spacing: 1px;
    font-weight: bold;
}
.badge-cyan   { color: var(--neon-cyan);   border: 1px solid var(--neon-cyan); }
.badge-green  { color: var(--neon-green);  border: 1px solid var(--neon-green); }
.badge-red    { color: var(--neon-red);    border: 1px solid var(--neon-red); }
.badge-yellow { color: var(--neon-yellow); border: 1px solid var(--neon-yellow); }
.badge-orange { color: var(--neon-orange); border: 1px solid var(--neon-orange); }
.badge-purple { color: var(--neon-purple); border: 1px solid var(--neon-purple); }
.badge-filled { background: rgba(0,221,255,0.12); }

/* Status badges */
.status-downloading { color: var(--neon-cyan); }
.status-completed   { color: var(--neon-green); }
.status-error       { color: var(--neon-red); }
.status-queued      { color: var(--text-dim); }
.status-uploading   { color: var(--neon-purple); }

/* ── Tables ───────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text-dim);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 8px 12px;
    font-size: 13px;
    border-bottom: 1px solid rgba(42, 42, 62, 0.5);
}
.data-table tr:hover td {
    background: rgba(0, 221, 255, 0.03);
}

/* ── Page Headers ─────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h2 {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 3px;
}

/* ── Toolbar ──────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.toolbar input[type="text"] {
    flex: 1;
    min-width: 200px;
}

/* ── Logs ─────────────────────────────────────────────────────────── */
.log-container {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.6;
}
.log-entry { white-space: pre-wrap; word-break: break-all; }
.log-entry.info    { color: var(--text-dim); }
.log-entry.warn    { color: var(--neon-yellow); }
.log-entry.error   { color: var(--neon-red); }
.log-entry.success { color: var(--neon-green); }

/* ── Search Results ───────────────────────────────────────────────── */
.search-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.search-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}
.search-card:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 221, 255, 0.08);
}
.search-card.selected {
    border-color: var(--neon-green);
    box-shadow: 0 0 0 2px rgba(0, 255, 128, 0.2);
}
.search-card .card-row {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    align-items: center;
    cursor: pointer;
}
.search-card .card-cover {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.search-card .card-cover-placeholder {
    width: 60px;
    height: 80px;
    background: var(--surface);
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 24px;
}
.search-card .card-body {
    flex: 1;
    min-width: 0;
}
.search-card .card-title {
    font-size: 13px;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.3;
}
.search-card .card-meta {
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.search-card .card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Host Group Tree ──────────────────────────────────────────────── */
.host-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}
.host-group-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.host-group-header .hg-name {
    font-weight: bold;
    font-size: 13px;
    color: var(--neon-purple);
}
.host-group-header .hg-count {
    font-size: 11px;
    color: var(--text-dim);
}
.host-group-header .hg-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}
.host-group-tree {
    padding: 2px 0;
}
.host-link-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px;
    font-size: 12px;
    transition: background 0.1s;
}
.host-link-row:hover {
    background: rgba(0, 221, 255, 0.04);
}
.tree-branch {
    font-family: var(--font-mono);
    color: var(--text-dim);
    width: 16px;
    flex-shrink: 0;
    font-size: 11px;
    user-select: none;
}
.host-link-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
}
.badge-rev {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    font-weight: bold;
}
.badge-fc {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-weight: bold;
}
.host-link-actions {
    display: flex;
    gap: 2px;
    opacity: 0.6;
    flex-shrink: 0;
}
.host-link-row:hover .host-link-actions {
    opacity: 1;
}
.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.15s;
}
.btn-icon:hover {
    border-color: var(--border);
    color: var(--neon-cyan);
    background: rgba(0, 221, 255, 0.08);
}

/* ── Detail Panel (inline expand) ─────────────────────────────────── */
.detail-panel {
    border-top: 1px solid var(--border);
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.detail-panel .detail-password {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 6px;
    padding: 6px 12px;
    margin-bottom: 10px;
    font-size: 12px;
    color: #f59e0b;
}
.detail-panel .detail-password code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 3px;
    font-family: var(--font-mono);
    color: var(--text);
    user-select: all;
}
.detail-summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    align-items: center;
}
.detail-summary-bar .ds-info {
    font-size: 12px;
    color: var(--text-dim);
}

/* ── File List ────────────────────────────────────────────────────── */
.file-list .file-row {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 12px;
    border-bottom: 1px solid rgba(42, 42, 62, 0.3);
    cursor: pointer;
    transition: background 0.15s;
}
.file-row:hover { background: rgba(0, 221, 255, 0.03); }
.file-row .file-icon { font-size: 18px; width: 24px; text-align: center; }
.file-row .file-name { flex: 1; font-size: 13px; }
.file-row .file-size { font-size: 11px; color: var(--text-dim); width: 80px; text-align: right; }

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 16px;
}
.pagination button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 12px;
    transition: all 0.2s;
}
.pagination button.active,
.pagination button:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

/* ── Spinner ──────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--neon-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────────────── */

/* ── Tablet ( ≤ 900px ) ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .form-row  { grid-template-columns: 1fr; }
    .form-row label { text-align: left; }
}

/* ── Mobile ( ≤ 768px ) ──────────────────────────────────────────── */
@media (max-width: 768px) {

    /* ── Sidebar → bottom nav bar ─────────────────────────────────── */
    #sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        z-index: 100;
        overflow: visible;
        background: var(--surface);
    }
    .sidebar-logo { display: none; }
    .sidebar-footer { display: none; }

    /* Hide text labels in nav, show only icons */
    #nav-links li .nav-label { display: none; }

    #nav-links {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0;
        gap: 0;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #nav-links::-webkit-scrollbar { display: none; }

    #nav-links li {
        flex: 0 0 auto;
        flex-direction: column;
        gap: 2px;
        padding: 8px 12px 6px;
        font-size: 9px;
        letter-spacing: 0.5px;
        text-align: center;
        border-left: none;
        border-top: 2px solid transparent;
        white-space: nowrap;
        min-width: 56px;
    }
    #nav-links li.active {
        border-left-color: transparent;
        border-top-color: var(--neon-cyan);
    }
    .nav-icon { font-size: 17px; width: auto; }

    /* ── Content area ─────────────────────────────────────────────── */
    #content {
        margin-left: 0;
        padding: 12px 10px 72px;  /* bottom padding for nav bar */
        min-height: 100vh;
    }

    /* ── Page headers ─────────────────────────────────────────────── */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 14px;
    }
    .page-header h2 {
        font-size: 16px;
        letter-spacing: 2px;
    }

    /* ── Stat cards ───────────────────────────────────────────────── */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 14px;
    }
    .stat-card {
        padding: 10px 12px;
    }
    .stat-card .stat-value {
        font-size: 22px;
    }
    .stat-card .stat-label {
        font-size: 9px;
    }

    /* ── Toolbar ──────────────────────────────────────────────────── */
    .toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        align-items: stretch;
    }
    .toolbar input[type="text"] {
        min-width: 0;
        width: 100%;
        flex: 1 1 100%;
    }
    .toolbar .btn-neon {
        flex: 1 1 100%;
        text-align: center;
    }
    .toolbar .btn-small,
    .toolbar button:not(.btn-neon) {
        flex: 1 1 auto;
        text-align: center;
        white-space: nowrap;
    }

    /* ── Download cards ───────────────────────────────────────────── */
    .dl-card {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
    }
    .dl-card .dl-name {
        font-size: 12px;
        word-break: break-word;
    }
    .dl-card .dl-meta {
        flex-direction: column;
        gap: 4px;
        font-size: 10px;
    }
    .dl-card .dl-meta span {
        word-break: break-all;
    }

    /* ── Search / Scraper cards ───────────────────────────────────── */
    .search-card .card-row {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    .search-card .card-cover,
    .search-card .card-cover-placeholder {
        width: 50px;
        height: 66px;
    }
    .search-card .card-body {
        flex: 1 1 calc(100% - 120px);
        min-width: 0;
    }
    .search-card .card-title {
        font-size: 12px;
    }
    .search-card .card-meta {
        font-size: 10px;
    }
    .search-card .card-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* ── Category buttons in scraper page ─────────────────────────── */
    .btn-small {
        padding: 6px 10px;
        font-size: 10px;
    }

    /* ── Host group tree (extract detail) ─────────────────────────── */
    .host-group-header {
        padding: 8px;
        gap: 6px;
        flex-wrap: wrap;
    }
    .host-group-header .hg-name { font-size: 12px; }
    .host-group-header .hg-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
    .host-link-row {
        padding: 5px 8px;
        gap: 4px;
    }
    .host-link-name {
        font-size: 11px;
    }

    /* ── Detail panel (expanded cards) ────────────────────────────── */
    .detail-panel {
        padding: 10px;
    }
    .detail-summary-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 8px;
    }
    .detail-panel .detail-password {
        font-size: 11px;
        flex-wrap: wrap;
    }

    /* ── File manager ─────────────────────────────────────────────── */
    .file-row {
        gap: 8px;
        padding: 8px;
    }
    .file-row .file-name {
        font-size: 12px;
        word-break: break-word;
        white-space: normal;
    }
    .file-row .file-size {
        font-size: 10px;
        width: auto;
        flex-shrink: 0;
    }

    /* ── Tables ───────────────────────────────────────────────────── */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table th,
    .data-table td {
        padding: 6px 8px;
        font-size: 11px;
        white-space: nowrap;
    }

    /* ── Logs ─────────────────────────────────────────────────────── */
    .log-container {
        max-height: calc(100vh - 160px);
        padding: 8px;
        font-size: 10px;
    }

    /* ── Pagination ───────────────────────────────────────────────── */
    .pagination {
        flex-wrap: wrap;
        gap: 3px;
    }
    .pagination button {
        padding: 5px 8px;
        font-size: 11px;
    }

    /* ── HUD Panels ───────────────────────────────────────────────── */
    .hud-panel .panel-body {
        padding: 10px;
    }
    .hud-panel .panel-title {
        padding: 8px 10px;
        font-size: 10px;
    }

    /* ── Login ────────────────────────────────────────────────────── */
    .login-box {
        width: calc(100vw - 32px);
        max-width: 380px;
        padding: 24px 20px;
    }
    .login-box h1 {
        font-size: 20px;
        letter-spacing: 4px;
    }
    .logo-pulse {
        font-size: 48px;
    }

    /* ── Form rows → stacked ──────────────────────────────────────── */
    .form-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .form-row label {
        text-align: left;
        font-size: 11px;
    }

    /* ── Generic small-screen helpers ─────────────────────────────── */
    .badge {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* ── Small phones ( ≤ 400px ) ─────────────────────────────────────── */
@media (max-width: 400px) {
    #content {
        padding: 8px 6px 72px;
    }
    .stats-row {
        grid-template-columns: 1fr;
    }
    .stat-card .stat-value {
        font-size: 20px;
    }
    #nav-links li {
        padding: 6px 8px 4px;
        min-width: 48px;
        font-size: 8px;
    }
    .nav-icon { font-size: 15px; }
    .page-header h2 { font-size: 14px; }
    .search-card .card-cover,
    .search-card .card-cover-placeholder {
        width: 42px;
        height: 56px;
    }
}

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Form sections ────────────────────────────────────────────────── */
.form-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}
.form-row label {
    font-size: 12px;
    color: var(--text-dim);
    text-align: right;
}


/* Telegram Login Widget */
.tg-login-section {
    text-align: center;
    margin: 20px 0 10px;
    overflow: visible;
    min-height: 50px;
}
#tg-widget-container {
    text-align: center;
    overflow: visible;
    min-height: 50px;
}
#tg-widget-container iframe {
    border: none !important;
    overflow: hidden !important;
    display: block !important;
    margin: 0 auto !important;
}
.login-divider {
    display: flex;
    align-items: center;
    margin: 15px 0;
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #333;
}
.login-divider span {
    padding: 0 12px;
    color: #0ff;
}
