/* ==========================================================================
   GlobalDebrid v16 — admin dashboard (/admin)
   ========================================================================== */
.admin { display: flex; min-height: 100dvh; }

/* Sidebar */
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 80; width: var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transform: translateX(-100%); transition: transform var(--t-slow), width var(--t-base);
}
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: var(--topbar-h); padding: 0 16px 0 18px; border-bottom: 1px solid var(--border); }
.sidebar-head .brand { font-size: var(--fs-md); }
.sidebar-head .brand small { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin-top: -2px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); text-decoration: none !important; transition: background var(--t-fast), color var(--t-fast); position: relative; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .icon { flex: 0 0 auto; }
.nav-item .nav-badge { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--warning-soft); color: var(--warning); padding: 1px 7px; border-radius: var(--r-full); }
.sidebar-foot { padding: 12px 10px; border-top: 1px solid var(--border); display: grid; gap: 2px; }
.sidebar-foot .nav-item { padding: 9px 12px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.sidebar-user .who { min-width: 0; line-height: 1.2; }
.sidebar-user .who b { display: block; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who span { font-size: 11px; color: var(--text-3); }
.sidebar-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(2, 6, 23, 0.5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity var(--t-base); }
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* Desktop: sidebar always visible, collapsible */
@media (min-width: 1000px) {
    .sidebar { transform: none; box-shadow: none; }
    .sidebar-overlay { display: none; }
    .admin-main { margin-left: var(--sidebar-w); }
    .admin.collapsed .sidebar { width: var(--sidebar-w-collapsed); }
    .admin.collapsed .admin-main { margin-left: var(--sidebar-w-collapsed); }
    .admin.collapsed .sidebar-head .brand span, .admin.collapsed .nav-group, .admin.collapsed .nav-item span, .admin.collapsed .sidebar-user .who, .admin.collapsed .nav-item .nav-badge { display: none; }
    .admin.collapsed .sidebar-head { justify-content: center; padding: 0; }
    .admin.collapsed .sidebar-head .brand { display: none; }
    .admin.collapsed .nav-item { justify-content: center; padding: 11px; }
    .admin.collapsed .sidebar-user { justify-content: center; }
    .admin.collapsed .nav-item[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); background: var(--text); color: var(--bg); font-size: var(--fs-xs); padding: 5px 9px; border-radius: 6px; white-space: nowrap; z-index: 5; box-shadow: var(--shadow-md); }
    .sidebar-collapse { display: inline-flex; }
    .topbar .hamburger { display: none; }
}
.sidebar-collapse { display: none; }

/* Main */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; transition: margin var(--t-base); }
.topbar { position: sticky; top: 0; z-index: 60; height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--border); }
@media (min-width: 640px) { .topbar { padding: 0 24px; gap: 14px; } }
.topbar h1 { font-size: var(--fs-lg); letter-spacing: -0.02em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar h1 small { display: block; font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar .status-pill { display: none; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
@media (min-width: 900px) { .topbar .status-pill { display: inline-flex; } }
.page { padding: 20px 16px 80px; max-width: 1400px; width: 100%; margin: 0 auto; }
@media (min-width: 640px) { .page { padding: 28px 24px 80px; } }
@media (min-width: 1200px) { .page { padding: 32px 32px 80px; } }
.admin .section { display: none; padding: 0; background: transparent; border: 0; }
.admin .section.active { display: block; animation: fadeIn var(--t-slow) both; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: var(--fs-xl); letter-spacing: -0.02em; }
.page-head p { font-size: var(--fs-sm); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) { .page-head .actions { width: 100%; } .page-head .actions .btn { flex: 1 1 auto; } }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 1fr 1fr; gap: 20px; } }
.grid-3-1 { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1000px) { .grid-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; } }
.stack { display: grid; gap: 16px; }
@media (min-width: 1000px) { .stack { gap: 20px; } }

/* Overview */
.chart-wrap { position: relative; width: 100%; height: 220px; }
@media (min-width: 1000px) { .chart-wrap { height: 300px; } }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.chart-wrap .bar { fill: var(--primary); opacity: 0.85; transition: opacity var(--t-fast); rx: 3; }
.chart-wrap .bar:hover { opacity: 1; }
.chart-wrap .grid-line { stroke: var(--border); stroke-width: 1; }
.chart-wrap .axis-text { font-size: 10px; fill: var(--text-3); font-family: var(--font); }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: var(--fs-xs); padding: 6px 9px; border-radius: 6px; transform: translate(-50%, -110%); white-space: nowrap; opacity: 0; transition: opacity var(--t-fast); box-shadow: var(--shadow-md); }
.chart-tip.show { opacity: 1; }
.role-bars { display: grid; gap: 12px; }
.role-bar { display: grid; grid-template-columns: 80px 1fr 40px; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.role-bar .progress { height: 10px; }
.role-bar .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.health-list { display: grid; gap: 10px; }
.health-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); font-size: var(--fs-sm); background: var(--surface-2); }
.health-item .hl { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.health-item .hl .icon { color: var(--text-3); }
.activity { display: grid; gap: 4px; }
.activity-item { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.activity-item:hover { background: var(--surface-2); }
.activity-item .avatar { width: 30px; height: 30px; font-size: 11px; }
.activity-item .a-body { min-width: 0; flex: 1; }
.activity-item .a-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-item .a-sub { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-item time { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.quick-controls { display: grid; gap: 0; }

/* Users */
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-cell .avatar { width: 32px; height: 32px; font-size: 11px; }
.user-cell .u-body { min-width: 0; }
.user-cell .u-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-cell .u-sub { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { background: var(--warning-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.usage-cell { display: flex; flex-direction: column; gap: 4px; min-width: 72px; }
.usage-cell .progress { height: 5px; }
.usage-cell small { font-size: var(--fs-xs); color: var(--text-3); }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-full); border: 1px solid var(--border-strong); font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); background: var(--surface); transition: all var(--t-fast); }
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .chip.active { color: #0b0f1a; }
.chip .count { opacity: 0.7; }

/* Drawer content */
.drawer-section { margin-bottom: 22px; }
.drawer-section h5 { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.drawer-user { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.drawer-user .avatar { width: 52px; height: 52px; font-size: var(--fs-lg); }
.drawer-user h4 { font-size: var(--fs-lg); }
.drawer-user .badges { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.action-list { display: grid; gap: 8px; }
.action-list .btn { justify-content: flex-start; }

/* API keys */
.key-cell { display: flex; align-items: center; gap: 6px; }
.key-cell code { font-size: var(--fs-xs); background: var(--surface-3); padding: 3px 8px; border-radius: 6px; letter-spacing: 0.02em; white-space: nowrap; }
.reveal-box { border: 1px solid var(--warning); background: var(--warning-soft); border-radius: var(--r-md); padding: 16px; }
.reveal-box .copy-field .input { font-size: var(--fs-sm); }

/* Broadcast */
.preview-bubble { background: var(--surface-3); border-radius: 14px 14px 14px 4px; padding: 12px 14px; font-size: var(--fs-sm); white-space: pre-wrap; line-height: 1.5; max-width: 460px; }
.preview-bubble b { display: block; margin-bottom: 6px; }
.preview-bubble em { display: block; margin-top: 10px; color: var(--text-3); font-size: var(--fs-xs); }
.count-hint { font-size: var(--fs-xs); color: var(--text-3); }
.count-hint.warn { color: var(--warning); }
.count-hint.over { color: var(--danger); }

/* Settings */
.settings-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .settings-grid { grid-template-columns: 1fr 1fr; gap: 20px; } }
.settings-grid .span-2 { grid-column: 1 / -1; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row:first-child { padding-top: 0; }
.setting-row .s-text { min-width: 200px; flex: 1 1 220px; }
.setting-row .s-title { font-weight: 600; font-size: var(--fs-sm); }
.setting-row .s-desc { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.setting-row .s-ctl { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; }
.setting-row .s-ctl .input { width: 110px; }
@media (max-width: 640px) { .setting-row .s-ctl { width: 100%; } .setting-row .s-ctl .input { flex: 1; width: auto; } }
.rl-row td .input { width: 90px; }

/* Monitoring */
.maint-result { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; font-family: var(--mono); font-size: var(--fs-xs); white-space: pre-wrap; max-height: 260px; overflow: auto; }

/* Misc */
.inline-edit { display: inline-flex; align-items: center; gap: 4px; }
.inline-edit .input { width: 84px; }
.hint { font-size: var(--fs-xs); color: var(--text-3); }
.kbd-hint { display: none; }
@media (min-width: 900px) { .kbd-hint { display: inline-flex; gap: 4px; align-items: center; font-size: var(--fs-xs); color: var(--text-3); } }
