@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/vazirmatn-arabic-variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/vazirmatn-latin-variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #07111f;
    --surface: #0d1b2d;
    --surface-2: #12243a;
    --surface-3: #172c45;
    --text: #e7eef8;
    --muted: #9fb0c7;
    --line: #223a55;
    --accent: #2dd4bf;
    --accent-dark: #0f766e;
    --blue: #60a5fa;
    --warning: #f59e0b;
    --danger: #fb7185;
    --success: #34d399;
    --radius: 16px;
    --shadow: 0 18px 50px rgb(0 0 0 / 22%);
}

* { box-sizing: border-box; }
html { font-family: "Vazirmatn", Tahoma, sans-serif; background: var(--bg); color: var(--text); line-height: 1.7; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 85% -15%, #123d52 0, transparent 34rem), var(--bg); }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
code, .technical, .ltr { direction: ltr; text-align: left; unicode-bidi: plaintext; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; inset-block-start: -4rem; inset-inline-start: 1rem; z-index: 100; background: var(--accent); color: #02120f; padding: .65rem 1rem; border-radius: 8px; }
.skip-link:focus { inset-block-start: 1rem; }
:focus-visible { outline: 3px solid #fde047; outline-offset: 3px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { position: sticky; inset-block-start: 0; height: 100vh; overflow-y: auto; padding: 1.25rem 1rem; background: rgb(7 17 31 / 88%); border-inline-end: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: .75rem; margin-block-end: 1.4rem; }
.brand-centered { justify-content: center; }
.brand-mark { display: grid; place-items: center; inline-size: 44px; block-size: 44px; border-radius: 14px; background: linear-gradient(135deg, var(--accent), var(--blue)); color: #041018; font-size: 1.35rem; font-weight: 900; box-shadow: 0 10px 28px rgb(45 212 191 / 28%); }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: .78rem; }
.sidebar nav { display: grid; gap: .25rem; }
.nav-item { min-height: 44px; display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; text-decoration: none; border-radius: 11px; color: #b9c8da; }
.nav-item:hover { background: var(--surface-2); color: white; }
.nav-item.active { background: linear-gradient(90deg, rgb(45 212 191 / 18%), transparent); color: var(--accent); box-shadow: inset -3px 0 var(--accent); }
.nav-item > span { inline-size: 1.5rem; text-align: center; }
.nav-divider { block-size: 1px; background: var(--line); margin-block: .8rem; }
.main-area { min-width: 0; }
.topbar { min-height: 84px; display: flex; align-items: center; gap: 1rem; justify-content: space-between; padding: 1rem clamp(1rem, 3vw, 2rem); border-block-end: 1px solid var(--line); background: rgb(7 17 31 / 65%); backdrop-filter: blur(12px); position: sticky; inset-block-start: 0; z-index: 20; }
.topbar h1 { margin: 0; font-size: clamp(1.1rem, 2.2vw, 1.6rem); }
.topbar .eyebrow { margin: 0; }
.topbar-actions, .toolbar-actions, .form-actions, .row-actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.user-chip, .count-chip { color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .35rem .7rem; font-size: .82rem; }
.sidebar-toggle { display: none; }
.content { padding: clamp(1rem, 3vw, 2rem); max-width: 1680px; margin-inline: auto; }

.panel { background: linear-gradient(145deg, rgb(18 36 58 / 92%), rgb(11 26 43 / 95%)); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 2vw, 1.35rem); box-shadow: var(--shadow); min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-block-end: 1rem; }
.panel h2 { font-size: 1.05rem; margin: .15rem 0 0; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .09em; font-size: .72rem; font-weight: 800; margin-block: 0 .25rem; }
.muted, .help { color: var(--muted); }
.help { font-size: .85rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-block-end: 1rem; }
.kpi-card { padding: 1.1rem; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(145deg, var(--surface-2), var(--surface)); }
.kpi-card span, .kpi-card small { color: var(--muted); display: block; }
.kpi-card strong { display: block; font-size: clamp(1.45rem, 3vw, 2rem); margin-block: .2rem; font-variant-numeric: tabular-nums; }
.kpi-card.accent { border-color: rgb(45 212 191 / 50%); }
.kpi-card.warning { border-color: rgb(245 158 11 / 50%); }
.kpi-card.danger { border-color: rgb(251 113 133 / 45%); }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-block-end: 1rem; }
.span-2 { grid-column: span 2; }
.chart-wrap { position: relative; min-height: 320px; }
.chart-wrap.compact { min-height: 290px; }

.toolbar { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-block-end: 1rem; }
.filters { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; flex: 1; }
.grow { flex: 1 1 260px; }
label { display: grid; gap: .35rem; color: #d6e2f0; font-weight: 550; }
input, select, textarea { width: 100%; min-height: 44px; border: 1px solid #31506f; border-radius: 10px; color: var(--text); background: #081828; padding: .58rem .75rem; }
textarea { resize: vertical; min-height: 112px; }
input::file-selector-button { font: inherit; border: 0; border-radius: 7px; background: var(--surface-3); color: var(--text); padding: .35rem .65rem; margin-inline-end: .6rem; }
.button, .icon-button { min-height: 44px; border: 1px solid transparent; border-radius: 10px; padding: .55rem .9rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.button.primary { background: linear-gradient(135deg, var(--accent), #22c7df); color: #041116; }
.button.secondary { background: var(--surface-3); color: var(--text); border-color: #31506f; }
.button.ghost { background: transparent; color: #c6d5e7; border-color: var(--line); }
.button.danger-outline { background: transparent; color: #fecdd3; border-color: rgb(251 113 133 / 55%); }
.button.small { min-height: 36px; padding: .3rem .55rem; font-size: .8rem; }
.button.full { width: 100%; }
.button.disabled { pointer-events: none; opacity: .42; }
.icon-button { inline-size: 44px; padding: 0; background: var(--surface-2); color: var(--text); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .75rem .65rem; border-block-end: 1px solid var(--line); text-align: right; vertical-align: middle; }
th { color: #aebfd3; font-size: .78rem; white-space: nowrap; }
tbody tr:hover { background: rgb(255 255 255 / 2.5%); }
.sort-link { text-decoration: none; }
.empty-state { color: var(--muted); text-align: center; padding: 2.2rem; }
.pagination { display: flex; justify-content: center; align-items: center; gap: .7rem; margin-block-start: 1rem; }
.hash { display: inline-block; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

.badge { display: inline-flex; align-items: center; min-height: 28px; border-radius: 999px; padding: .18rem .55rem; background: #293b51; color: #dce7f3; white-space: nowrap; font-size: .78rem; }
.status-in_progress, .status-processing { color: #bfdbfe; background: rgb(37 99 235 / 25%); }
.status-approved, .status-published, .status-completed, .status-indexed, .status-created { color: #a7f3d0; background: rgb(5 150 105 / 24%); }
.status-blocked, .status-failed, .status-critical { color: #fecdd3; background: rgb(225 29 72 / 23%); }
.status-pending_review, .status-warning, .status-p1 { color: #fde68a; background: rgb(217 119 6 / 23%); }
.status-p0 { color: #fecaca; background: rgb(220 38 38 / 25%); }
.status-p2 { color: #bfdbfe; background: rgb(37 99 235 / 22%); }
.status-p3, .status-not_started, .status-skipped { color: #cbd5e1; background: rgb(100 116 139 / 23%); }
.alert { padding: .8rem 1rem; border-radius: 11px; margin-block-end: 1rem; border: 1px solid; }
.alert.success { color: #a7f3d0; border-color: rgb(52 211 153 / 40%); background: rgb(5 150 105 / 13%); }
.alert.danger { color: #fecdd3; border-color: rgb(251 113 133 / 44%); background: rgb(225 29 72 / 12%); }

.form-panel { max-width: 1100px; margin-inline: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { margin-block-start: 1rem; }
.sticky-actions { position: sticky; inset-block-end: 0; padding-block: .8rem; background: linear-gradient(transparent, var(--surface) 35%); }
.field-error { color: #fda4af; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; }
.summary-grid > div { border: 1px solid var(--line); border-radius: 10px; padding: .7rem; background: rgb(0 0 0 / 10%); }
.summary-grid dt { color: var(--muted); font-size: .78rem; }
.summary-grid dd { margin: .15rem 0 0; font-size: 1.15rem; font-weight: 800; }

.auth-page, .installer-page { display: grid; place-items: center; padding: 1rem; }
.auth-card, .installer-card { width: min(100%, 480px); padding: clamp(1.25rem, 4vw, 2rem); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.auth-card h1, .installer-card h1 { font-size: 1.4rem; }
.auth-card form, .installer-card form { display: grid; gap: 1rem; }
details { border: 1px solid var(--line); border-radius: 10px; padding: .7rem; margin-block: 1rem; }
summary { cursor: pointer; font-weight: 700; }

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; inline-size: min(86vw, 310px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
    [dir="rtl"] .sidebar { inset: 0 0 0 auto; transform: translateX(105%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: inline-flex; }
    .user-chip { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
    .kpi-grid, .form-grid, .summary-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .topbar { align-items: flex-start; }
    .topbar-actions { margin-inline-start: auto; }
    table.responsive, table { min-width: 0; }
    table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
    table, tbody, tr, td { display: block; width: 100%; }
    tbody tr { padding: .6rem; border-block-end: 1px solid var(--line); }
    td { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; gap: .6rem; border: 0; padding: .35rem; overflow-wrap: anywhere; }
    td::before { content: attr(data-label); color: var(--muted); font-size: .77rem; }
    .row-actions { display: flex; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
@media print {
    :root { color-scheme: light; --bg: white; --surface: white; --surface-2: white; --text: #111827; --muted: #4b5563; --line: #d1d5db; }
    body { background: white; }
    .sidebar, .topbar-actions, .sidebar-toggle, .toolbar-actions, .button, form { display: none !important; }
    .app-shell { display: block; }
    .topbar { position: static; background: white; }
    .panel, .kpi-card { box-shadow: none; break-inside: avoid; }
}
