@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================================
   Riverdale Admin — design system from scratch.
   No Bootstrap. Inspired by Linear/Stripe/Vercel.
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
    /* Brand */
    --brand: #4f46e5;
    --brand-50: #eef2ff;
    --brand-100: #e0e7ff;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --brand-grad-hover: linear-gradient(135deg, #5558e8 0%, #7c4ef0 100%);

    /* Slate scale */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --slate-950: #020617;

    /* Status */
    --green-50: #ecfdf5;
    --green-500: #10b981;
    --green-600: #059669;
    --red-50: #fef2f2;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --amber-50: #fffbeb;
    --amber-500: #f59e0b;
    --amber-600: #d97706;
    --blue-50: #eff6ff;
    --blue-500: #3b82f6;

    /* Surfaces / borders */
    --bg: var(--slate-50);
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: var(--slate-200);
    --border-strong: var(--slate-300);
    --text: var(--slate-900);
    --text-soft: var(--slate-700);
    --text-muted: var(--slate-500);
    --text-faint: var(--slate-400);

    /* Sidebar */
    --sb-bg: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
    --sb-border: rgba(255, 255, 255, 0.06);
    --sb-text: #cbd5e1;
    --sb-text-active: #ffffff;
    --sb-hover: rgba(255, 255, 255, 0.06);
    --sb-active: rgba(99, 102, 241, 0.18);
    --sb-w: 260px;
    --sb-w-mobile: 240px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.04), 0 10px 15px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08), 0 20px 50px rgba(15, 23, 42, 0.10);
    --shadow-xl: 0 25px 60px rgba(15, 23, 42, 0.14);
    --ring: 0 0 0 3px rgba(99, 102, 241, 0.15);

    /* Radii */
    --r-xs: 4px;
    --r-sm: 6px;
    --r: 10px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 24px;
    --r-full: 999px;

    /* Spacing scale */
    --topbar-h: 64px;

    /* Motion */
    --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
    --t: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01', 'ss03';
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand-600); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--brand-700); }
code, pre, kbd, samp { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 22px; line-height: 1.25; }
h3 { font-size: 18px; line-height: 1.3; }
h4 { font-size: 16px; line-height: 1.35; }
h5, h6 { font-size: 14px; line-height: 1.4; }

p { margin: 0 0 12px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); background-clip: padding-box; border: 2px solid transparent; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- 3. App shell layout ---------- */
.app {
    display: grid;
    grid-template-columns: var(--sb-w) 1fr;
    min-height: 100vh;
}
.sidebar {
    background: var(--sb-bg);
    color: var(--sb-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sb-w);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sb-border);
    z-index: 50;
    overflow-y: auto;
}
.main {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}
.topbar {
    height: var(--topbar-h);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 12px;
}
.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.topbar-spacer { flex: 1; }
.topbar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 12px;
    border-radius: var(--r);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 500;
}
.topbar-user .avatar {
    width: 28px; height: 28px;
    border-radius: var(--r-full);
    background: var(--brand-grad);
    color: #fff;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
}
.page {
    flex: 1 0 auto;
    padding: 32px 40px 48px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    animation: fadeUp 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.page-head { margin-bottom: 28px; }
.page-head h1 { margin-bottom: 6px; }
.page-head p { color: var(--text-muted); margin: 0; font-size: 14.5px; }

/* Footer pinned at bottom */
.foot {
    flex-shrink: 0;
    padding: 18px 28px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.foot a { color: var(--text-soft); font-weight: 500; }
.foot a:hover { color: var(--brand-600); }
.foot .sep { margin: 0 10px; color: var(--text-faint); }

/* ---------- 4. Sidebar internals ---------- */
.sb-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--sb-border);
    text-decoration: none;
    color: #fff;
}
.sb-brand:hover { color: #fff; }
.sb-brand-mark {
    width: 36px; height: 36px;
    background: var(--brand-grad);
    border-radius: 10px;
    display: grid; place-items: center;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}
.sb-brand-name {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.sb-brand-sub {
    font-size: 11px;
    color: var(--slate-400);
    font-weight: 500;
    letter-spacing: 0.02em;
}
.sb-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-section {
    text-transform: uppercase;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--slate-500);
    letter-spacing: 0.08em;
    padding: 14px 10px 6px;
}
.sb-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    color: var(--sb-text);
    font-weight: 500;
    font-size: 13.5px;
    letter-spacing: -0.005em;
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
    position: relative;
}
.sb-item:hover {
    background: var(--sb-hover);
    color: var(--sb-text-active);
}
.sb-item.is-active {
    background: var(--sb-active);
    color: var(--sb-text-active);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
}
.sb-item.is-active::before {
    content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
    background: var(--brand-grad); border-radius: 0 4px 4px 0;
}
.sb-item svg {
    width: 18px; height: 18px;
    stroke: currentColor;
    stroke-width: 1.75;
    fill: none;
    flex-shrink: 0;
    opacity: 0.85;
}
.sb-item.is-active svg { opacity: 1; }
.sb-badge {
    margin-left: auto;
    background: rgba(99, 102, 241, 0.18);
    color: #c7d2fe;
    font-size: 10.5px; font-weight: 700;
    padding: 2px 7px; border-radius: var(--r-full);
}
.sb-foot {
    border-top: 1px solid var(--sb-border);
    padding: 14px 12px;
    display: flex; flex-direction: column; gap: 4px;
}

/* Mobile sidebar */
.sb-toggle {
    display: none;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--r);
    margin-right: 4px;
}
.sb-toggle svg { width: 20px; height: 20px; margin: auto; stroke: var(--text); stroke-width: 2; fill: none; }
.sb-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 45;
    animation: fadeIn 200ms;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 1024px) {
    .app { grid-template-columns: 1fr; }
    .main { grid-column: 1; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--t);
        width: var(--sb-w-mobile);
    }
    body.sb-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-xl); }
    body.sb-open .sb-overlay { display: block; }
    .sb-toggle { display: grid; place-items: center; }
}

/* ---------- 5. Cards / Panels (alias .panel for legacy templates) ---------- */
.card, .panel, .panel-default, .well {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card + .card, .panel + .panel { margin-top: 20px; }
.card-head, .panel-heading {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    letter-spacing: -0.01em;
}
.card-head h4, .panel-heading h4,
.card-head h3, .panel-heading h3 { margin: 0; font-size: 16px; }
.card-body, .panel-body { padding: 22px; }
.card-foot, .panel-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}
.well { padding: 28px; }

/* ---------- 6. Buttons ---------- */
.btn, input[type="submit"], button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.005em;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), color var(--t-fast);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:focus-visible, input[type="submit"]:focus-visible { box-shadow: var(--ring); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-default { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-default:hover { background: var(--surface-2); border-color: var(--border-strong); }

.btn-primary, input.btn-primary, input[type="submit"] {
    background: var(--brand-grad);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover, input[type="submit"]:hover {
    background: var(--brand-grad-hover);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
    color: #fff;
}
.btn-success { background: var(--green-500); color: #fff; border-color: transparent; }
.btn-success:hover { background: var(--green-600); color: #fff; }
.btn-danger { background: var(--red-500); color: #fff; border-color: transparent; }
.btn-danger:hover { background: var(--red-600); color: #fff; }
.btn-warning { background: var(--amber-500); color: #fff; border-color: transparent; }
.btn-warning:hover { background: var(--amber-600); color: #fff; }
.btn-link { background: transparent; box-shadow: none; color: var(--brand-600); border-color: transparent; padding: 4px 6px; }
.btn-link:hover { background: var(--brand-50); }

.btn-sm, .btn-xs { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }

/* ---------- 7. Forms ---------- */
form { margin: 0; }
.form-group { margin-bottom: 18px; }
label, .control-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.005em;
}
.form-control, input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
    appearance: none; -webkit-appearance: none;
}
.form-control:hover, input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--ring);
    background: var(--surface);
}
.form-control::placeholder { color: var(--text-faint); }
textarea, textarea.form-control { min-height: 120px; line-height: 1.55; resize: vertical; font-family: inherit; }

select, select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 2l1.5-1.5L6 5l4.5-4.5L12 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
select[multiple], select[size] { background-image: none; padding: 8px; min-height: 200px; }
select[multiple] option, select[size] option { padding: 7px 10px; border-radius: 4px; }

.help-block, .form-text {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.45;
}
.has-error label, .has-error .control-label { color: var(--red-600); }
.has-error input, .has-error select, .has-error .form-control { border-color: var(--red-500); }
.has-error .help-block { color: var(--red-600); }

/* Bootstrap horizontal grid emulation (editform.tpl uses col-md-4 / col-sm-8) */
.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
[class*="col-"] { padding: 0 10px; box-sizing: border-box; width: 100%; }
@media (min-width: 768px) {
    .col-sm-4 { width: 33.333%; } .col-sm-6 { width: 50%; } .col-sm-8 { width: 66.667%; }
    .col-sm-offset-3 { margin-left: 25%; }
}
@media (min-width: 992px) {
    .col-md-4 { width: 33.333%; } .col-md-6 { width: 50%; } .col-md-8 { width: 66.667%; }
}
.form-horizontal .form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--slate-100);
}
.form-horizontal .form-group:last-of-type { border-bottom: 0; padding-bottom: 0; }
.form-horizontal .control-label {
    padding: 0;
    text-align: left !important;
    margin-bottom: 6px;
    width: auto !important;
    max-width: none !important;
    float: none !important;
}
.form-horizontal [class*="col-"] { width: 100% !important; max-width: none; padding: 0; }
@media (min-width: 768px) {
    .form-horizontal .form-group {
        display: grid;
        grid-template-columns: 200px 1fr;
        gap: 20px;
        align-items: start;
    }
    .form-horizontal .control-label { padding-top: 10px; text-align: right !important; }
}

/* Custom checkbox */
.checkbox, .radio { padding-left: 0; }
.checkbox label, .radio label {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding-left: 28px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
}
.checkbox label::before, .radio label::before {
    content: '';
    position: absolute;
    left: 0; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px;
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    transition: all var(--t-fast);
}
.radio label::before { border-radius: 50%; }
.checkbox label::after {
    content: '';
    position: absolute;
    left: 6px; top: 50%; transform: translate(0, -65%) rotate(45deg) scale(0);
    width: 6px; height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transition: transform var(--t-fast);
}
.checkbox input[type="checkbox"], .radio input[type="radio"] {
    position: absolute; opacity: 0; pointer-events: none;
}
.checkbox:has(input:checked) label::before {
    background: var(--brand-600);
    border-color: var(--brand-600);
}
.checkbox:has(input:checked) label::after {
    transform: translate(0, -65%) rotate(45deg) scale(1);
}
.radio:has(input:checked) label::before {
    border-color: var(--brand-600);
    border-width: 5px;
}

/* ---------- 8. Tables ---------- */
.table, table.table {
    width: 100%;
    background: var(--surface);
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.table thead th, .table > thead > tr > th {
    text-align: left;
    padding: 12px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.table tbody td, .table > tbody > tr > td {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
    font-size: 13.5px;
    color: var(--text);
}
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--brand-50); }
.table-striped tbody tr:nth-child(odd) { background: var(--surface-2); }
.table-striped tbody tr:nth-child(odd):hover { background: var(--brand-50); }
.table-bordered { border: 1px solid var(--border); }
.table-bordered td, .table-bordered th { border: 1px solid var(--border); }

/* ---------- 9. Alerts / flash ---------- */
.alert, #flash_info, #flash_error {
    padding: 14px 18px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    border-left: 4px solid;
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 18px;
    background: var(--surface);
}
.alert-success, #flash_info { background: var(--green-50); border-left-color: var(--green-500); color: #064e3b; }
.alert-danger, .alert-error, #flash_error { background: var(--red-50); border-left-color: var(--red-500); color: #7f1d1d; }
.alert-warning { background: var(--amber-50); border-left-color: var(--amber-500); color: #78350f; }
.alert-info { background: var(--blue-50); border-left-color: var(--blue-500); color: #1e3a8a; }

/* ---------- 10. Badges / labels ---------- */
.label, .badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--r-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.5;
}
.label-success { background: #d1fae5; color: #065f46; }
.label-danger { background: #fee2e2; color: #991b1b; }
.label-warning { background: #fef3c7; color: #92400e; }
.label-info { background: #dbeafe; color: #1e40af; }
.label-primary { background: var(--brand-100); color: #3730a3; }
.label-default { background: var(--slate-100); color: var(--text-muted); }
.text-success { color: var(--green-600); font-weight: 600; }
.text-danger { color: var(--red-600); font-weight: 600; }
.text-warning { color: var(--amber-600); font-weight: 600; }
.text-info { color: var(--blue-500); font-weight: 600; }
.text-muted { color: var(--text-muted); }

/* ---------- 11. Tabs / pagination / nav-tabs ---------- */
.nav-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 22px; padding: 0; list-style: none; }
.nav-tabs > li > a { display: inline-block; padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 0; }
.nav-tabs > li > a:hover { color: var(--brand-600); background: var(--brand-50); }
.nav-tabs > .active > a { color: var(--brand-600); border-bottom-color: var(--brand-600); background: transparent; }

.pagination { display: inline-flex; padding: 0; margin: 18px 0; gap: 2px; list-style: none; }
.pagination > li > a, .pagination > li > span {
    display: inline-block;
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    border-radius: var(--r-sm);
}
.pagination > li > a:hover { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-500); }
.pagination > .active > a, .pagination > .active > span { background: var(--brand-grad); color: #fff; border-color: transparent; }

/* ---------- 12. Modals ---------- */
.modal-backdrop { background: rgba(15, 23, 42, 0.5); }
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-title { font-weight: 700; font-size: 16px; margin: 0; }

/* ---------- 13. Dashboard / login / setup specific ---------- */

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
    position: relative;
    overflow: hidden;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-100); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; color: var(--text); letter-spacing: -0.03em; line-height: 1; }
.stat-icon {
    position: absolute; top: 16px; right: 16px;
    width: 32px; height: 32px;
    background: var(--brand-50); color: var(--brand-600);
    border-radius: var(--r); display: grid; place-items: center;
}
.stat-icon svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.75; fill: none; }

/* Action grid (dashboard) */
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.action {
    display: flex; flex-direction: column; gap: 8px;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    text-decoration: none;
    transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
    color: inherit;
}
.action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-200, #c7d2fe);
    color: inherit;
}
.action-icon {
    width: 40px; height: 40px;
    background: var(--brand-grad);
    color: #fff;
    border-radius: var(--r);
    display: grid; place-items: center;
    margin-bottom: 4px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.action-icon svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.75; fill: none; }
.action-title { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.action-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* Setup-page code blocks */
body[class*="setup"] code, body[class*="setup"] pre, body.page-setup code, body.page-setup pre {
    background: var(--slate-900); color: #e2e8f0;
    padding: 12px 14px; border-radius: var(--r-sm);
    font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
    line-height: 1.55; word-break: break-all;
}
body[class*="setup"] :not(pre) > code { display: inline; padding: 1px 6px; font-size: 12px; }

/* ---------- 14. Login page ---------- */
body.page-login,
body[class*="page-login"],
body.page-password-recover,
body.page-password-change {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center;
    align-items: center;
    padding: 24px;
}
body.page-login::before, body[class*="page-login"]::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.15), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,0.08), transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(0,0,0,0.15), transparent 60%);
    pointer-events: none;
}
body.page-login .app, body[class*="page-login"] .app { display: block; min-height: auto; }
body.page-login .sidebar, body[class*="page-login"] .sidebar,
body.page-login .topbar, body[class*="page-login"] .topbar { display: none !important; }
body.page-login .main, body[class*="page-login"] .main { display: block; grid-column: 1; min-height: auto; }
body.page-login .page, body[class*="page-login"] .page { padding: 0; max-width: 440px; }

.login-wrap { position: relative; z-index: 1; width: 100%; max-width: 440px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 28px; color: #fff; }
.login-brand-mark {
    width: 48px; height: 48px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    display: grid; place-items: center;
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}
.login-brand-name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; text-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.login-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--r-xl);
    box-shadow: 0 25px 80px rgba(15, 23, 42, 0.3);
    padding: 36px;
    animation: fadeUp 320ms cubic-bezier(0.4, 0, 0.2, 1);
}
.login-card h2 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.login-card .lead { color: var(--text-muted); text-align: center; margin-bottom: 24px; font-size: 14px; }
.login-card .form-group:last-of-type { margin-bottom: 22px; }
.login-card .btn-primary { width: 100%; padding: 12px; font-size: 15px; }
.login-card .form-signin > .form-group:first-child + .form-group + .form-group { margin-bottom: 22px; }

/* ---------- 15. Hide things we don't need ---------- */
/* Old logo image */
img#login_header_logo { display: none !important; }
/* Old bootstrap navbars (we replace them) */
body > nav.navbar.navbar-default.navbar-fixed-top:not(.keep) { display: none !important; }
/* Smarty datetimepicker icon override is handled inline via Bootstrap JS still */
.bootstrap-datetimepicker-widget { z-index: 100; }
/* Old container constraints from index.tpl inline style */
.page > .container,
.app .container { min-width: 0 !important; width: auto !important; max-width: none !important; padding: 0 !important; }

/* ---------- 16. Misc helpers ---------- */
.searchresult { background: #fef3c7; color: #92400e; padding: 1px 5px; border-radius: 3px; font-weight: 600; }
.input-group { display: flex; align-items: stretch; }
.input-group .form-control { border-radius: var(--r) 0 0 var(--r); }
.input-group-addon, .input-group-btn .btn {
    border: 1px solid var(--border);
    background: var(--surface-2);
    padding: 0 14px;
    display: flex; align-items: center;
    border-radius: 0 var(--r) var(--r) 0;
    border-left: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.breadcrumb { background: transparent; padding: 0 0 16px; margin: 0 0 18px; list-style: none; display: flex; gap: 8px; font-size: 13px; border-bottom: 1px solid var(--border); }
.breadcrumb > li::before { content: '/'; color: var(--text-faint); margin-right: 8px; }
.breadcrumb > li:first-child::before { content: ''; margin: 0; }

/* Hide footer-only legacy chunks duplicated */
.footer { display: none; }

/* Loading spinner (used by disabled buttons) */
@keyframes spin { to { transform: rotate(360deg); } }
.btn[disabled]::before, .btn.is-loading::before {
    content: '';
    width: 12px; height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    opacity: 0.7;
}
.btn[disabled] { opacity: 0.7; cursor: not-allowed; transform: none; }

/* Print: hide sidebar */
@media print {
    .sidebar, .topbar, .foot, .sb-toggle, .sb-overlay { display: none !important; }
    .main { grid-column: 1; }
    .page { padding: 0; }
}
