:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #1d4ed8;
    --primary-soft: #eff6ff;
    --ok: #15803d;
    --ok-soft: #dcfce7;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --bad: #b91c1c;
    --bad-soft: #fee2e2;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
}

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

body {
    font-family: Vazirmatn, "Segoe UI", Tahoma, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.15rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.brand-name { color: #fff; font-weight: 600; font-size: .95rem; }
.brand-sub { font-size: .74rem; color: #64748b; }

.nav { padding: .8rem .6rem; flex: 1; overflow-y: auto; }

.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .58rem .75rem;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    font-size: .88rem;
    margin-bottom: 2px;
    transition: background .12s, color .12s;
}

.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }

.nav-link.active { background: var(--primary); color: #fff; font-weight: 500; }

.nav-icon { width: 18px; text-align: center; opacity: .85; font-size: .95rem; }

.sidebar-foot { padding: .85rem; border-top: 1px solid rgba(255, 255, 255, .08); }

.who { margin-bottom: .6rem; }
.who-name { color: #fff; font-size: .85rem; font-weight: 500; }
.who-mail { font-size: .72rem; color: #64748b; direction: ltr; text-align: right; word-break: break-all; }

/* ── Main ────────────────────────────────────────────── */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .8rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.page-title { font-size: 1.05rem; font-weight: 600; flex: 1; }

.topbar-meta { display: flex; align-items: center; gap: .8rem; }
.clock { font-size: .82rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.burger {
    display: none;
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    padding: .25rem .5rem;
    cursor: pointer;
    color: var(--text);
}

.content { padding: 1.4rem; flex: 1; }

/* ── Cards ───────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.1rem;
}

.card-head {
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.card-head h2 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 1.1rem; }

/* ── Stats ───────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
}

.stat-label { font-size: .78rem; color: var(--text-muted); margin-bottom: .3rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.stat-note { font-size: .74rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Tables ──────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .86rem; }

thead th {
    text-align: right;
    padding: .6rem .8rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

tbody td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; direction: ltr; }

/* ── Forms ───────────────────────────────────────────── */

.field { margin-bottom: 1rem; }

.field label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: .32rem; }

.field input, .field select {
    width: 100%;
    padding: .5rem .7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .87rem;
    background: var(--surface);
    color: var(--text);
}

.field input:focus, .field select:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.field .hint { font-size: .74rem; color: var(--text-muted); margin-top: .25rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }

/* ── Buttons ─────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1e40af; text-decoration: none; color: #fff; }

.btn-ghost { background: transparent; border-color: var(--border-strong); color: inherit; }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }

.btn-block { width: 100%; }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }

.hint { font-size: .8rem; color: var(--text-muted); line-height: 1.7; }

.check {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .86rem;
    font-weight: 400;
    margin-bottom: .7rem;
}

.check input { width: auto; margin: 0; }

/* ── Expand panels (user rows) ────────────────────────── */

.expand {
    display: none;
    margin-top: .7rem;
    padding: .9rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ── Pagination ───────────────────────────────────────── */

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: .9rem;
    border-top: 1px solid var(--border);
}

.pager-info { font-size: .82rem; color: var(--text-muted); }
.pager-links { display: flex; align-items: center; gap: .5rem; }

/* ── Key/value detail rows ────────────────────────────── */

.kv { display: grid; gap: .1rem; }

.kv-row {
    display: grid;
    grid-template-columns: 11rem 1fr;
    gap: 1rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--border);
}

.kv-row:last-child { border-bottom: 0; }

.kv-key { color: var(--text-muted); font-size: .84rem; }
.kv-val { font-size: .88rem; word-break: break-word; }

@media (max-width: 720px) {
    .kv-row { grid-template-columns: 1fr; gap: .15rem; }
}

.badge-bad { color: var(--bad); }
.bad { color: var(--bad); }
.ok { color: var(--ok); }

tfoot th {
    padding-top: .8rem;
    border-top: 2px solid var(--border);
    font-size: .85rem;
}

tfoot th.num { text-align: left; }

/* ── Alerts ──────────────────────────────────────────── */

.alert {
    padding: .7rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .86rem;
    border: 1px solid;
}

.alert ul { margin: 0; padding-right: 1.1rem; }
.alert-ok { background: var(--ok-soft); border-color: #86efac; color: var(--ok); }
.alert-bad { background: var(--bad-soft); border-color: #fca5a5; color: var(--bad); }
.alert-warn { background: var(--warn-soft); border-color: #fcd34d; color: var(--warn); }

/* ── Status rows ─────────────────────────────────────── */

.status-row {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--border);
}

.status-row:last-child { border-bottom: 0; }

.pill {
    display: inline-block;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
}

.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-muted { background: var(--surface-2); color: var(--text-muted); }

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    direction: ltr;
    text-align: left;
    word-break: break-word;
    display: block;
    color: var(--text-muted);
}

/* ── Login ───────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #0f172a;
    padding: 1.5rem;
}

.login-box {
    background: var(--surface);
    border-radius: 14px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
}

.login-box h1 { font-size: 1.15rem; margin-bottom: .3rem; }
.login-box .sub { font-size: .84rem; color: var(--text-muted); margin-bottom: 1.4rem; }

/* ── Misc ────────────────────────────────────────────── */

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-icon { font-size: 2rem; opacity: .35; margin-bottom: .5rem; }
.empty-text { font-size: .88rem; }

.page-actions { display: flex; gap: .5rem; align-items: center; }

.filters {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters .field { margin: 0; }
.filters .field input, .filters .field select { min-width: 150px; }

.breadcrumb { font-size: .8rem; color: var(--text-muted); margin-bottom: .7rem; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb span { margin: 0 .35rem; }

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        inset: 0 0 0 auto;
        z-index: 60;
        transform: translateX(100%);
        transition: transform .2s;
    }
    .sidebar.open { transform: translateX(0); }
    .burger { display: block; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
