/* ==========================================================================
   Mahira Web Panel — minimalist control panel UI
   ========================================================================== */

:root {
    --bg: #f4f5f7;
    --bg-soft: #eef0f4;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-3: #eef1f6;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;
    --text-soft: #344054;
    --muted: #667085;
    --faint: #98a2b3;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-border: #c7d2fe;
    --primary-text: #4338ca;
    --accent: #0ea5e9;
    --success: #059669;
    --success-soft: #ecfdf5;
    --success-border: #a7f3d0;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --warning-border: #fde68a;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --danger-border: #fecaca;
    --info: #0284c7;
    --info-soft: #f0f9ff;
    --info-border: #bae6fd;
    --sidebar-w: 260px;
    --topbar-h: 72px;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, .07);
    --shadow-lg: 0 24px 64px rgba(16, 24, 40, .18);
    --font: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    --mono: "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0a0c11;
    --bg-soft: #0e1118;
    --surface: #11151d;
    --surface-2: #0d1117;
    --surface-3: #1a202c;
    --border: #202634;
    --border-strong: #2d3648;
    --text: #e8eaf0;
    --text-soft: #cbd2df;
    --muted: #98a2b3;
    --faint: #667085;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: #1b2138;
    --primary-border: #313c66;
    --primary-text: #c7d2fe;
    --accent: #38bdf8;
    --success: #34d399;
    --success-soft: #0b2a22;
    --success-border: #14532d;
    --warning: #fbbf24;
    --warning-soft: #2a2111;
    --warning-border: #57410f;
    --danger: #f87171;
    --danger-soft: #2b1417;
    --danger-border: #5c1e23;
    --info: #38bdf8;
    --info-soft: #0b2333;
    --info-border: #0d4560;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
::selection { background: var(--primary); color: #fff; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

/* ==========================================================================
   Shell / sidebar
   ========================================================================== */

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 60;
    transition: transform .25s ease;
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 18px 18px;
    min-height: var(--topbar-h);
}
.brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #0ea5e9 130%);
    box-shadow: 0 6px 16px rgba(79, 70, 229, .35), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.brand-mark svg { width: 25px; height: 25px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text strong { font-size: 14.5px; font-weight: 700; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 10.5px; color: var(--faint); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; }
.sidebar-close { display: none; margin-left: auto; }

.nav { flex: 1; overflow-y: auto; padding: 2px 12px 12px; }
.nav-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--faint);
    padding: 16px 10px 7px;
}
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: 10px;
    color: var(--text-soft);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
    margin-bottom: 1px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav-item.active .nav-icon { color: var(--primary-text); }
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    height: 18px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
    transform: translateY(-50%);
}
.nav-icon { color: var(--muted); display: inline-flex; flex: 0 0 auto; }
.nav-item:hover .nav-icon { color: var(--text-soft); }
.nav-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.server-mini {
    display: block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 12px;
    color: var(--text);
    transition: border-color .15s ease;
}
.server-mini:hover { border-color: var(--border-strong); color: var(--text); }
.server-mini-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.server-mini-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server-mini-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.server-mini-row span:last-child { color: var(--text-soft); font-weight: 600; }
.server-mini-foot { font-size: 10.5px; color: var(--faint); margin-top: 6px; }
.sidebar-version { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 10.5px; color: var(--faint); padding-top: 10px; }
.dot-sep { opacity: .6; }

/* Main / topbar */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--topbar-h);
    padding: 12px 28px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.page-heading { min-width: 0; }
.page-heading h1 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-heading p { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.search-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 10px 0 11px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 9px;
    color: var(--muted);
    font-size: 12.5px;
    min-width: 190px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-soft); }
.search-trigger span { flex: 1; text-align: left; }
.search-trigger kbd { font-size: 10px; padding: 2px 5px; }
kbd {
    font-family: var(--font);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 1px 5px;
}
.server-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-soft);
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: 5px 10px;
}
.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.bordered { border-color: var(--border); background: var(--surface); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu-btn { display: none; }

.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: block; }

.user-menu { position: relative; }
.user-trigger {
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    padding: 3px 6px 3px 3px;
    transition: background .15s ease, border-color .15s ease;
}
.user-trigger:hover, .user-menu.open .user-trigger { background: var(--surface); border-color: var(--border); }
.avatar {
    width: 33px;
    height: 33px;
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -.2px;
    flex: 0 0 auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.avatar-lg { width: 40px; height: 40px; border-radius: 12px; font-size: 14px; }
.user-trigger-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.user-trigger-text strong { font-size: 12.5px; font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-trigger-text small { font-size: 10.5px; color: var(--faint); }
.muted-icon { color: var(--faint); }

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 248px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 7px;
    display: none;
    z-index: 80;
    animation: dropIn .16s ease;
}
.user-menu.open .dropdown-menu { display: block; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-5px) scale(.98); } to { opacity: 1; transform: none; } }
.dropdown-head { display: flex; align-items: center; gap: 10px; padding: 9px 9px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head strong { display: block; font-size: 13px; }
.dropdown-head small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 4px; }

.content { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 24px 28px 40px; }
.footer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11.5px;
    color: var(--faint);
    padding: 16px 28px;
    border-top: 1px solid var(--border);
}
.footer .spacer { flex: 1; }
.footer-muted { color: var(--faint); }

/* ==========================================================================
   Page primitives
   ========================================================================== */

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header h2 { font-size: 21px; font-weight: 700; letter-spacing: -.4px; }
.page-header p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.stack.sm { gap: 10px; }
.stack.lg { gap: 24px; }
.mt-0 { margin-top: 0 !important; } .mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.ml-auto { margin-left: auto; }
.ml-8 { margin-left: 8px; }
.mb-4 { margin-bottom: 4px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.break-all { word-break: break-all; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.divider.dashed { border-top: 1px dashed var(--border); background: none; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid .span-2 { grid-column: span 2; }
.grid .span-3 { grid-column: span 3; }
.split { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.split.wide { grid-template-columns: minmax(0, 2.4fr) minmax(320px, 1fr); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}
.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 0;
}
.card-head.bordered { padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14.5px; font-weight: 650; letter-spacing: -.15px; }
.card-head .card-sub { font-size: 12px; color: var(--muted); }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }
.card-body.pt0 { padding-top: 0; }
.card-pad { padding: 20px; }
.card-title { font-size: 14px; font-weight: 650; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card.hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card.accent { background: linear-gradient(135deg, var(--primary-soft), var(--surface) 65%); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .1s ease;
    text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn .ico { flex: 0 0 auto; }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
[data-theme="dark"] .btn-primary { color: #0b0d12; }
[data-theme="dark"] .btn-primary:hover { color: #0b0d12; }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-text); }
.btn-soft:hover { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger-soft:hover { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.94); color: #fff; }
.btn-outline { background: transparent; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-sm .ico { width: 15px; height: 15px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { width: 34px; height: 34px; padding: 0; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 12.5px; font-weight: 600; color: var(--text-soft); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--danger); }
.input, .select, .textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--faint); cursor: not-allowed; }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.textarea.mono, .input.mono { font-family: var(--mono); font-size: 12.5px; }
.select {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 15px;
}
.input-sm { height: 34px; font-size: 12.5px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 9px 0 0 9px; }
.input-group .btn { border-radius: 0 9px 9px 0; height: auto; border-left: 0; }
.input-icon { position: relative; }
.input-icon .input { padding-left: 38px; }
.input-icon > .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-action { position: relative; }
.input-action .input { padding-right: 42px; }
.input-action .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.hint code { font-size: 11px; }
.error-text { font-size: 11.5px; color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.check { display: inline-flex; align-items: flex-start; gap: 9px; font-size: 13px; color: var(--text-soft); cursor: pointer; line-height: 1.45; }
.check input[type="checkbox"], .check input[type="radio"] { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--primary); flex: 0 0 auto; cursor: pointer; }
.switch { position: relative; display: inline-flex; align-items: center; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .16s ease; pointer-events: none; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .16s ease; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: 0; padding-bottom: 0; }
.switch-row:first-child { padding-top: 0; }
.switch-row .switch-text strong { display: block; font-size: 13px; font-weight: 600; }
.switch-row .switch-text small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; max-width: 520px; }

.strength { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.strength-track { flex: 1; height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.strength-bar { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--danger); transition: width .25s ease, background .25s ease; }
.strength-bar.weak { background: var(--danger); }
.strength-bar.fair { background: var(--warning); }
.strength-bar.strong { background: var(--success); }
.strength-text { font-size: 10.5px; color: var(--muted); min-width: 52px; text-align: right; }

/* ==========================================================================
   Badges / status / progress
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.4;
    letter-spacing: .01em;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); border-color: var(--primary-border); }
.badge-muted { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.badge-lg { font-size: 12px; padding: 4px 10px; }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
    background: var(--faint);
}
.status-dot.on { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .15); }
.status-dot.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.status-dot.warn { background: var(--warning); box-shadow: 0 0 0 3px rgba(217, 119, 6, .14); }

.progress { width: 100%; height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-xs { height: 4px; }
.progress-lg { height: 10px; }
.progress .bar { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .5s ease; min-width: 2px; }
.progress .bar.ok { background: linear-gradient(90deg, #34d399, #10b981); }
.progress .bar.warning { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.progress .bar.danger { background: linear-gradient(90deg, #fb7185, #ef4444); }
.progress .bar.primary { background: linear-gradient(90deg, #818cf8, #4f46e5); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table th:first-child { border-left: 1px solid var(--border); border-radius: 10px 0 0 0; }
.table th:last-child { border-right: 1px solid var(--border); border-radius: 0 10px 0 0; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table.compact th { padding: 8px 12px; }
.table.compact td { padding: 9px 12px; }
.table .actions-cell { text-align: right; white-space: nowrap; }
.table .actions-cell .row { justify-content: flex-end; gap: 3px; }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-name { font-weight: 600; font-size: 13px; }
.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.cell-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); flex: 0 0 auto; }
.ellipsis { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Stat cards
   ========================================================================== */

.stat { padding: 18px; display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 750; letter-spacing: -.8px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.stat-sub { font-size: 11.5px; color: var(--muted); }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: 0 0 auto; }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.blue { background: var(--info-soft); color: var(--info); }
.metric-bar { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.metric-bar .progress { height: 5px; }
.metric-foot { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); }

/* Sparkline */
.sparkline { width: 100%; height: 34px; overflow: visible; }
.sparkline path.line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sparkline path.area { fill: color-mix(in srgb, var(--primary) 14%, transparent); stroke: none; }

/* Quick actions */
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quick {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
    min-width: 0;
}
.quick:hover { border-color: var(--primary-border); background: var(--primary-soft); color: var(--text); transform: translateY(-1px); }
.quick-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); flex: 0 0 auto; border: 1px solid var(--border); }
.quick:hover .quick-icon { background: var(--surface); }
.quick-text { min-width: 0; }
.quick-text strong { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-text small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Service list */
.service-list { display: flex; flex-direction: column; }
.service-item { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.service-item:last-child { border-bottom: 0; }
.service-item:first-child { padding-top: 0; }
.service-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); border: 1px solid var(--border); }
.service-text { min-width: 0; flex: 1; }
.service-text strong { display: block; font-size: 12.5px; font-weight: 600; }
.service-text small { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Info list */
.info-list { display: flex; flex-direction: column; }
.info-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.info-row:last-child { border-bottom: 0; }
.info-row .k { color: var(--muted); flex: 0 0 auto; }
.info-row .v { color: var(--text-soft); font-weight: 550; text-align: right; min-width: 0; word-break: break-word; }
.info-row .v.mono { font-size: 11.5px; }

/* Activity feed */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--border); position: relative; }
.feed-item:last-child { border-bottom: 0; }
.feed-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: 0 0 auto; box-shadow: 0 0 0 3px var(--primary-soft); }
.feed-body { min-width: 0; flex: 1; }
.feed-title { font-size: 12.5px; line-height: 1.45; }
.feed-title strong { font-weight: 600; }
.feed-meta { font-size: 10.5px; color: var(--faint); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }
.feed-detail { font-size: 11.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Alerts / notices / empty
   ========================================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 12.5px;
    line-height: 1.55;
}
.alert .ico { flex: 0 0 auto; margin-top: 1px; }
.alert strong { font-weight: 650; }
.alert a { font-weight: 600; }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }
.alert-primary { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-text); }
.alert .alert-body { min-width: 0; flex: 1; }
.alert .alert-title { font-weight: 650; margin-bottom: 2px; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 44px 20px; gap: 5px; }
.empty-icon { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--faint); margin-bottom: 8px; }
.empty h3 { font-size: 14px; font-weight: 650; }
.empty p { font-size: 12.5px; color: var(--muted); max-width: 380px; line-height: 1.55; }
.empty .btn { margin-top: 10px; }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    position: relative;
    padding: 10px 13px;
    font-size: 12.5px;
    font-weight: 550;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 650; }
.tab-panel { padding-top: 18px; }
.tab-panel[hidden] { display: none; }

/* ==========================================================================
   Modal / palette / toast
   ========================================================================== */

.modal-backdrop, .palette-backdrop {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(9, 12, 20, .55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn .15s ease;
}

/* The author display:flex above overrides the browser's [hidden] (display:none),
   so backdrops stay visible even when the markup carries the hidden attribute.
   Re-establish hiding here so modals/palette/overlay start out of the way. */
.modal-backdrop[hidden],
.palette-backdrop[hidden],
.overlay[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    animation: modalIn .18s cubic-bezier(.2, .9, .3, 1.1);
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 980px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-head h3 { font-size: 15.5px; font-weight: 700; letter-spacing: -.2px; }
.modal-body { padding: 16px 20px 20px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.confirm-text { font-size: 13px; color: var(--text-soft); line-height: 1.6; }

.palette-backdrop { align-items: flex-start; padding-top: 12vh; }
.palette {
    width: 100%;
    max-width: 600px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalIn .18s cubic-bezier(.2, .9, .3, 1.1);
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 14.5px; color: var(--text); }
.palette-input input::placeholder { color: var(--faint); }
.palette-list { max-height: 380px; overflow-y: auto; padding: 7px; }
.palette-group { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 9px 11px 4px; }
.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 9px;
    color: var(--text-soft);
    font-size: 13px;
}
.palette-item .p-icon { width: 27px; height: 27px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--muted); flex: 0 0 auto; }
.palette-item .p-label { flex: 1; }
.palette-item .p-enter { font-size: 10px; color: var(--faint); opacity: 0; }
.palette-item.active, .palette-item:hover { background: var(--primary-soft); color: var(--primary-text); }
.palette-item.active .p-icon { background: var(--surface); color: var(--primary); border-color: var(--primary-border); }
.palette-item.active .p-enter { opacity: 1; }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 10.5px; color: var(--faint); background: var(--surface-2); }
.palette-foot kbd { margin-right: 3px; }
.palette-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 36px)); pointer-events: none; }
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 11px;
    box-shadow: var(--shadow-md);
    padding: 12px 12px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-soft);
    pointer-events: auto;
    animation: toastIn .22s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.toast-icon { flex: 0 0 auto; margin-top: 1px; color: var(--primary); }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }
.toast-text { flex: 1; min-width: 0; }
.toast-close { border: 0; background: transparent; color: var(--faint); padding: 1px; border-radius: 4px; }
.toast-close:hover { color: var(--text); }

.overlay { position: fixed; inset: 0; background: rgba(9, 12, 20, .45); z-index: 55; backdrop-filter: blur(2px); }

/* ==========================================================================
   File manager
   ========================================================================== */

.fm-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fm-toolbar .spacer { flex: 1; }
.breadcrumb { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 12.5px; padding: 2px 0; }
.crumb { color: var(--muted); padding: 3px 6px; border-radius: 6px; display: inline-flex; align-items: center; gap: 5px; }
.crumb:hover { background: var(--surface-3); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--faint); font-size: 11px; }
.fm-path {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 6px 10px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--muted);
    min-width: 0;
}
.fm-path .truncate { flex: 1; }
.file-table td { padding-top: 9px; padding-bottom: 9px; }
.file-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-name .cell-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px; }
.file-badge { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--primary); flex: 0 0 auto; }
.file-badge.folder { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.file-badge.image { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.file-badge.code { background: var(--primary-soft); color: var(--primary-text); border-color: var(--primary-border); }
.file-badge.archive { background: var(--surface-3); color: var(--muted); }
.row-menu { position: relative; display: inline-flex; }
.row-menu > .dropdown-menu { min-width: 170px; }
.dropdown-menu.flip { right: 0; left: auto; }
.upload-drop {
    border: 1.5px dashed var(--border-strong);
    background: var(--surface-2);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    transition: border-color .15s ease, background .15s ease;
}
.upload-drop.dragover { border-color: var(--primary); background: var(--primary-soft); }
.upload-drop .ico { margin: 0 auto 8px; color: var(--primary); }
.upload-drop strong { display: block; font-size: 13px; }
.upload-drop small { font-size: 11.5px; color: var(--muted); }
.upload-drop input[type="file"] { margin-top: 10px; width: 100%; font-size: 12px; }
.editor-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.editor-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.editor-bar .file-name { font-family: var(--mono); font-size: 12px; color: var(--text-soft); }
.editor-main { display: flex; max-height: 62vh; overflow: hidden; }
.editor-gutter {
    flex: 0 0 52px;
    padding: 12px 8px;
    text-align: right;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.65;
    color: var(--faint);
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    overflow: hidden;
    user-select: none;
    white-space: pre;
}
.editor-textarea {
    flex: 1;
    min-height: 420px;
    border: 0;
    outline: 0;
    resize: none;
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
    background: var(--surface);
    color: var(--text);
    tab-size: 4;
    overflow: auto;
    white-space: pre;
}
.editor-foot { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 11px; color: var(--muted); flex-wrap: wrap; }

/* Terminal */
.terminal {
    background: #080b11;
    border: 1px solid #1e2633;
    border-radius: 13px;
    overflow: hidden;
    color: #d7dde8;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}
.terminal-bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: #0d121a; border-bottom: 1px solid #1a2230; }
.terminal-dots { display: flex; gap: 5px; }
.terminal-dots span { width: 9px; height: 9px; border-radius: 50%; background: #3a4454; }
.terminal-dots span:nth-child(1) { background: #f87171; }
.terminal-dots span:nth-child(2) { background: #fbbf24; }
.terminal-dots span:nth-child(3) { background: #34d399; }
.terminal-title { font-size: 10.5px; color: #7d8a9e; margin-left: 6px; font-family: var(--mono); }
.terminal-body {
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.65;
    min-height: 320px;
    max-height: 56vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.terminal-body .cmd { color: #8ea0bd; }
.terminal-body .cmd b { color: #67e8f9; font-weight: 600; }
.terminal-body .out { color: #c7d2e1; }
.terminal-body .err { color: #fca5a5; }
.terminal-input-row { display: flex; align-items: stretch; }
.terminal-input-row .terminal-prompt {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 9px 0 0 9px;
    color: var(--success);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
}
.terminal-input-row .input { border-radius: 0; border-left: 0; }
.terminal-input-row .btn { border-radius: 0 9px 9px 0; margin-left: -1px; }
.terminal-output {
    margin: 0;
    padding: 14px 16px;
    background: #0a0d13;
    color: #c7d2e1;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    max-height: 46vh;
}
.terminal-output .terminal-stderr { color: #fca5a5; }
.terminal-output .faint { color: #5d6b80; }

/* Logs */
.logview { background: #0a0d13; border-radius: 12px; border: 1px solid #1c2432; overflow: auto; max-height: 58vh; }
.log-line { display: flex; gap: 10px; font-family: var(--mono); font-size: 11.5px; line-height: 1.65; padding: 1px 12px; color: #b6c2d4; white-space: pre-wrap; word-break: break-word; }
.log-line:hover { background: #111722; }
.log-ln { flex: 0 0 46px; text-align: right; color: #4c5a6e; user-select: none; }
.log-text { flex: 1; min-width: 0; }
.log-line.error .log-text { color: #fca5a5; }
.log-line.warn .log-text { color: #fcd34d; }
.log-line.info .log-text { color: #93c5fd; }

/* ==========================================================================
   Charts
   ========================================================================== */

.chart-wrap { position: relative; width: 100%; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis-label { fill: var(--faint); font-size: 9px; font-family: var(--font); }
.chart .area { fill: url(#trafficGradient); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart .point { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart .bar { fill: var(--primary); opacity: .22; rx: 3; }
.chart-legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--primary); }
.legend-dot.soft { background: color-mix(in srgb, var(--primary) 25%, transparent); }

/* Ring chart */
.ring { position: relative; width: 88px; height: 88px; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring .track { stroke: var(--surface-3); }
.ring .value { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring .ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 17px; font-weight: 750; letter-spacing: -.4px; }
.ring .ring-text small { font-size: 9px; font-weight: 600; color: var(--faint); letter-spacing: .05em; text-transform: uppercase; }

/* ==========================================================================
   Auth
   ========================================================================== */

.auth { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(430px, .92fr); min-height: 100vh; background: var(--bg); }
.auth-aside {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 40px 46px;
    color: #e8ecf8;
    background:
        radial-gradient(900px 600px at 12% 8%, rgba(99, 102, 241, .34), transparent 60%),
        radial-gradient(700px 500px at 95% 92%, rgba(14, 165, 233, .22), transparent 55%),
        linear-gradient(160deg, #0a0c12 10%, #10142a 55%, #0a0d16 100%);
}
.auth-aside::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 45% 40%, #000 20%, transparent 78%);
    pointer-events: none;
}
.auth-aside::after {
    content: "";
    position: absolute;
    width: 360px;
    height: 360px;
    right: -120px;
    bottom: -140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79, 70, 229, .45), transparent 62%);
    filter: blur(40px);
    pointer-events: none;
}
.auth-brand { display: flex; align-items: center; gap: 11px; position: relative; z-index: 1; }
.auth-brand .brand-mark { width: 42px; height: 42px; flex-basis: 42px; border-radius: 13px; }
.auth-brand strong { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.auth-brand small { display: block; font-size: 10.5px; color: #8b98b8; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.auth-content { margin: auto 0; position: relative; z-index: 1; max-width: 520px; padding: 48px 0; }
.auth-eyebrow { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #a5b4fc; background: rgba(99, 102, 241, .13); border: 1px solid rgba(129, 140, 248, .28); padding: 5px 10px; border-radius: 999px; margin-bottom: 22px; }
.auth-headline { font-size: clamp(30px, 3.4vw, 44px); line-height: 1.1; font-weight: 750; letter-spacing: -1.6px; margin-bottom: 16px; }
.auth-headline span { background: linear-gradient(120deg, #c7d2fe, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-sub { font-size: 14px; line-height: 1.65; color: #9aa7c2; max-width: 440px; }
.auth-features { list-style: none; padding: 0; margin: 30px 0 0; display: grid; gap: 13px; }
.auth-features li { display: flex; align-items: flex-start; gap: 11px; font-size: 13px; color: #c3cde0; }
.auth-features .f-icon { width: 28px; height: 28px; border-radius: 8px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .09); display: grid; place-items: center; color: #a5b4fc; flex: 0 0 auto; }
.auth-features strong { display: block; color: #eef2fa; font-weight: 600; font-size: 12.5px; }
.auth-features small { display: block; color: #8b98b8; font-size: 11.5px; margin-top: 1px; line-height: 1.5; }
.auth-aside-foot { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; font-size: 11px; color: #7c89a6; }
.auth-main { display: grid; place-items: center; padding: 40px 28px; position: relative; }
.auth-card { width: 100%; max-width: 392px; }
.auth-card-head { margin-bottom: 26px; }
.auth-card-head h1 { font-size: 24px; font-weight: 750; letter-spacing: -.7px; margin-bottom: 6px; }
.auth-card-head p { font-size: 13px; color: var(--muted); line-height: 1.55; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form .btn { margin-top: 4px; }
.auth-foot { margin-top: 24px; font-size: 11.5px; color: var(--faint); text-align: center; line-height: 1.6; }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth-mobile-brand strong { font-size: 14px; }
.auth-card .alert { margin-bottom: 16px; }
.auth-card .divider-text { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; margin: 4px 0; }
.auth-card .divider-text::before, .auth-card .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-note { display: flex; gap: 9px; padding: 11px 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; color: var(--muted); line-height: 1.55; }
.auth-note .ico { flex: 0 0 auto; margin-top: 1px; }

/* Setup steps */
.setup-steps { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.setup-step { display: flex; gap: 10px; align-items: flex-start; font-size: 12px; color: #9aa7c2; }
.setup-step .num { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 10px; font-weight: 700; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); color: #c7d2fe; flex: 0 0 auto; }
.setup-step.done .num { background: rgba(16, 185, 129, .16); border-color: rgba(16, 185, 129, .3); color: #6ee7b7; }

/* ==========================================================================
   Misc components
   ========================================================================== */

.codeblock {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.6;
    overflow-x: auto;
    color: var(--text-soft);
    white-space: pre;
}
.codeblock.small { font-size: 10.5px; padding: 9px 11px; }
.copy-field { display: flex; align-items: stretch; }
.copy-field .input { border-radius: 9px 0 0 9px; font-family: var(--mono); font-size: 11.5px; }
.copy-field .btn { border-radius: 0 9px 9px 0; border-left: 0; }
.copy-field .input:focus { position: relative; z-index: 1; }
.pill-list { display: flex; flex-wrap: wrap; gap: 5px; }
.metric-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--border); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.metric-strip > div { background: var(--surface); padding: 13px 15px; }
.metric-strip .ms-label { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.metric-strip .ms-value { font-size: 17px; font-weight: 700; letter-spacing: -.3px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.health-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.health-item:last-child { border-bottom: 0; }
.health-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; }
.health-icon.ok { background: var(--success-soft); color: var(--success); }
.health-icon.warn { background: var(--warning-soft); color: var(--warning); }
.health-icon.bad { background: var(--danger-soft); color: var(--danger); }
.health-text { flex: 1; min-width: 0; }
.health-text strong { display: block; font-weight: 600; font-size: 12.5px; }
.health-text small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.stars { color: var(--warning); letter-spacing: 1px; font-size: 11px; }
.cert-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.cert-card .cert-domain { font-weight: 650; font-size: 13px; }
.cert-card .cert-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; }
.inline-form .input { height: 32px; width: auto; min-width: 120px; font-size: 12px; }
.search-inline { position: relative; min-width: 190px; }
.search-inline .input { height: 34px; padding-left: 32px; font-size: 12.5px; }
.search-inline .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-link { min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; color: var(--muted); background: var(--surface); }
.page-link:hover { border-color: var(--border-strong); color: var(--text); }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page-link.disabled { opacity: .45; pointer-events: none; }
.notice-bar { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
.notice-bar .ico { flex: 0 0 auto; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.kv-grid .info-row { padding: 8px 0; }

/* Terminal quick commands */
.quick-command {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    text-align: left;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    transition: border-color .15s ease, background .15s ease;
}
.quick-command:hover { border-color: var(--primary); background: var(--surface-3); }
.quick-command .mono { color: var(--text); }

/* PHP extension grid */
.ext-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ext-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}
.ext-item .tiny.muted { margin-left: auto; }
.ext-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.ext-item.ok .ext-dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.ext-item.missing .ext-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* Pills */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.4;
}

/* Avatar color picker */
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.color-dot {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
    transition: transform .12s ease, box-shadow .12s ease;
}
.color-dot:hover { transform: translateY(-1px); }
.color-dot input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.color-dot:has(input:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }

/* Profile */
.avatar-xl { width: 58px; height: 58px; border-radius: 16px; font-size: 20px; }
.profile-head { display: flex; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }

/* Segmented input affixes (reveal / generate password) */
.input-group .input-affix {
    align-self: stretch;
    height: auto;
    width: 38px;
    flex: 0 0 38px;
    border-radius: 0;
    border: 1px solid var(--border);
    border-left: 0;
    background: var(--surface-2);
    margin-left: -1px;
}
.input-group .input-affix:hover { background: var(--surface-3); color: var(--text); }
.input-group .input-affix:last-child { border-radius: 0 9px 9px 0; }

/* Skeleton / loading */
.spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; background: rgba(9, 12, 20, .45); z-index: 300; display: none; place-items: center; backdrop-filter: blur(2px); }
.loading-overlay.show { display: grid; }
.loading-box { background: var(--surface); border: 1px solid var(--border); padding: 18px 22px; border-radius: 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; box-shadow: var(--shadow-md); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1240px) {
    .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .split, .split.wide { grid-template-columns: minmax(0, 1fr); }
    .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    :root { --sidebar-w: 250px; }
    .search-trigger { min-width: 42px; width: 36px; padding: 0; justify-content: center; }
    .search-trigger span, .search-trigger kbd { display: none; }
    .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth { grid-template-columns: minmax(0, 1fr) minmax(400px, .9fr); }
    .auth-aside { padding: 32px 34px; }
}

@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .sidebar-close { display: inline-grid; }
    .main { margin-left: 0; }
    .topbar { padding: 11px 18px; }
    .content { padding: 20px 18px 32px; }
    .footer { padding: 14px 18px; }
    .menu-btn { display: inline-grid; }
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth-aside { display: none; }
    .auth-main { min-height: 100vh; }
    .auth-mobile-brand { display: flex; }
    .topbar-actions .server-pill { display: none; }
}

@media (max-width: 720px) {
    .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-5 { grid-template-columns: minmax(0, 1fr); }
    .grid .span-2, .grid .span-3 { grid-column: auto; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .ext-grid { grid-template-columns: minmax(0, 1fr); }
    .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .user-trigger-text { display: none; }
    .page-heading p { display: none; }
    .page-heading h1 { font-size: 16px; }
    .topbar { gap: 10px; }
    .content { padding: 16px 14px 28px; }
    .card-head { padding: 15px 15px 0; }
    .card-body { padding: 15px; }
    .card-body.p0 { padding: 0; }
    .card-pad { padding: 15px; }
    .page-header h2 { font-size: 18px; }
    .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kv-grid { grid-template-columns: minmax(0, 1fr); }
    .modal { max-height: 92vh; }
    .modal-backdrop { padding: 12px; align-items: flex-end; }
    .modal { border-radius: 16px; }
    .toast-stack { top: 10px; right: 10px; width: calc(100vw - 20px); }
    .palette-backdrop { padding-top: 8vh; }
    .file-name .cell-name { max-width: 160px; }
    .table th, .table td { padding: 10px 12px; }
    .page-header { gap: 12px; }
    .footer .footer-muted { display: none; }
}

@media (max-width: 480px) {
    .quick-grid { grid-template-columns: minmax(0, 1fr); }
    .search-trigger { display: none; }
    .theme-icon-light, .theme-icon-dark { display: none; }
    .topbar-actions .icon-btn[data-theme-toggle] { display: none; }
    .topbar-actions { gap: 4px; }
    .server-pill { padding: 4px 8px; }
    .row.wrap-mobile { flex-wrap: wrap; }
    .actions { width: 100%; }
    .actions .btn { flex: 1 1 auto; }
    .metric-strip { grid-template-columns: minmax(0, 1fr); }
    .editor-gutter { flex-basis: 42px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
    .sidebar, .topbar, .footer, .actions, .toast-stack { display: none !important; }
    .main { margin-left: 0; }
    .card { box-shadow: none; border-color: #ddd; }
}
