/* ==========================================================================
   Contractor portal theme — RTL, token based (light / dark / auto),
   user-customisable: accent colour, font, size, density, radius, sidebar style.
   All preferences are applied by static/js/theme_boot.js as CSS variables / data-attributes.
   ========================================================================== */

@font-face { font-family: "Vazirmatn"; font-weight: 400; font-display: swap;
  src: local("Vazirmatn"), local("Vazirmatn Regular"), url("../fonts/Vazirmatn-Regular.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 500; font-display: swap;
  src: local("Vazirmatn Medium"), url("../fonts/Vazirmatn-Medium.woff2") format("woff2"); }
@font-face { font-family: "Vazirmatn"; font-weight: 700; font-display: swap;
  src: local("Vazirmatn Bold"), url("../fonts/Vazirmatn-Bold.woff2") format("woff2"); }

:root {
  --accent: #2f6fed;
  --accent-600: #2559c7;
  --accent-soft: rgba(47, 111, 237, .12);
  --accent-rgb: 47, 111, 237;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --text: #172033;
  --muted: #6b7686;
  --border: #e1e6ee;
  --shadow: 0 1px 2px rgba(15, 27, 51, .05), 0 6px 18px rgba(15, 27, 51, .05);

  --danger: #c0392b;
  --danger-soft: rgba(192, 57, 43, .10);
  --ok: #178a5b;
  --ok-soft: rgba(23, 138, 91, .12);
  --warn: #b7791f;
  --warn-soft: rgba(183, 121, 31, .14);

  --font: Vazirmatn, "Vazir", Tahoma, "Segoe UI", system-ui, Arial, sans-serif;
  --fs: 14px;
  --space: 1;          /* density multiplier: .8 compact, 1 normal, 1.25 comfortable */
  --radius: 12px;

  --sb-w: 252px;
  --sb-bg: linear-gradient(180deg, #0f1b33, #16264a);
  --sb-text: #dbe4f5;
  --sb-muted: #8ea3c9;
  --sb-hover: rgba(255, 255, 255, .08);
  --sb-border: rgba(255, 255, 255, .09);
  --sb-active-bg: var(--accent);
  --sb-active-text: #fff;

  --c1: var(--accent); --c2: #16a085; --c3: #f39c12; --c4: #8e44ad; --c5: #e74c3c; --c6: #00a8cc; --c7: #7f8c8d;
  color-scheme: light;
}

/* ---------- surface schemes ---------- */
:root[data-scheme="mint"] { --bg: #edf7f4; --surface: #ffffff; --surface-2: #f2faf7; --border: #d9ebe4; }
:root[data-scheme="sand"] { --bg: #f7f3ec; --surface: #fffefa; --surface-2: #f8f3e9; --border: #e9dfcf; }
:root[data-scheme="lavender"] { --bg: #f3f1fa; --surface: #ffffff; --surface-2: #f5f3fb; --border: #e2def0; }
:root[data-scheme="rose"] { --bg: #faf1f2; --surface: #ffffff; --surface-2: #fcf4f5; --border: #eedde0; }
:root[data-scheme="graphite"] { --bg: #eef1f4; --surface: #ffffff; --surface-2: #f4f6f8; --border: #dce2e8; }

/* ---------- dark ---------- */
:root[data-theme="dark"] {
  --bg: #0d1322; --surface: #151d33; --surface-2: #1b2542; --text: #e6ebf7; --muted: #94a1bf; --border: #26314f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
  --danger: #ff6b5e; --danger-soft: rgba(255, 107, 94, .14);
  --ok: #3ecf8e; --ok-soft: rgba(62, 207, 142, .14);
  --warn: #f5b84b; --warn-soft: rgba(245, 184, 75, .16);
  --sb-bg: linear-gradient(180deg, #0a0f1d, #0f1830);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0d1322; --surface: #151d33; --surface-2: #1b2542; --text: #e6ebf7; --muted: #94a1bf; --border: #26314f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
    --danger: #ff6b5e; --danger-soft: rgba(255, 107, 94, .14);
    --ok: #3ecf8e; --ok-soft: rgba(62, 207, 142, .14);
    --warn: #f5b84b; --warn-soft: rgba(245, 184, 75, .16);
    --sb-bg: linear-gradient(180deg, #0a0f1d, #0f1830);
    color-scheme: dark;
  }
}

/* ---------- sidebar styles ---------- */
:root[data-sidebar="light"] {
  --sb-bg: var(--surface); --sb-text: var(--text); --sb-muted: var(--muted);
  --sb-hover: var(--surface-2); --sb-border: var(--border);
  --sb-active-bg: var(--accent-soft); --sb-active-text: var(--accent);
}
:root[data-sidebar="accent"] {
  --sb-bg: linear-gradient(180deg, var(--accent), var(--accent-600));
  --sb-text: #fff; --sb-muted: rgba(255, 255, 255, .72);
  --sb-hover: rgba(255, 255, 255, .14); --sb-border: rgba(255, 255, 255, .2);
  --sb-active-bg: rgba(255, 255, 255, .24); --sb-active-text: #fff;
}

/* ---------- radius presets ---------- */
:root[data-radius="sharp"] { --radius: 4px; }
:root[data-radius="round"] { --radius: 20px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs); line-height: 1.75;
  background: var(--bg); color: var(--text);
  transition: background-color .2s ease, color .2s ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 calc(10px * var(--space)); line-height: 1.4; }
h3 { font-size: 1.2em; }
h4 { font-size: 1.05em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.muted { color: var(--muted); }
.error, .errorlist { color: var(--danger); }
.errorlist { list-style: none; padding: 0; margin: 4px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ic { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.content-wrap { min-height: 100vh; }
body.has-sidebar .content-wrap { margin-right: var(--sb-w); transition: margin .2s ease; }
body.sidebar-collapsed { --sb-w: 68px; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 calc(18px * var(--space));
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__spacer { flex: 1; }
.topbar__title { font-weight: 700; font-size: 1.05em; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 36px; height: 36px; padding: 0 10px; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: calc(var(--radius) * .75);
}
.icon-btn:hover { background: var(--surface-2); filter: none; text-decoration: none; }
.icon-btn .badge { position: absolute; top: -5px; left: -5px; }
.badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; line-height: 17px; min-width: 17px; text-align: center; }
.topbar__toggle { display: none; }
main.app-main { max-width: 1360px; margin: 0 auto; padding: calc(18px * var(--space)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: calc(16px * var(--space)); box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.col { flex: 1 1 220px; min-width: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 0 0 auto; z-index: 30; width: var(--sb-w);
  display: flex; flex-direction: column; background: var(--sb-bg); color: var(--sb-text);
  border-left: 1px solid var(--sb-border); transition: width .2s ease, transform .2s ease;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--sb-border); min-height: 64px; }
.sidebar__brand strong { display: block; font-size: 1em; }
.sidebar__brand small { color: var(--sb-muted); font-size: 11px; }
.sidebar__logo {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none;
  border-radius: calc(var(--radius) * .8); background: var(--accent); color: #fff; font-weight: 800;
}
:root[data-sidebar="accent"] .sidebar__logo { background: rgba(255, 255, 255, .25); }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 8px 8px 12px; }
.sidebar__nav a {
  display: flex; align-items: center; gap: 10px; padding: calc(7px * var(--space)) 12px; margin: 1px 0;
  border-radius: calc(var(--radius) * .7); color: var(--sb-text); font-size: .93em; white-space: nowrap;
}
.sidebar__nav a span.lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar__nav a:hover { background: var(--sb-hover); text-decoration: none; }
.sidebar__nav a.is-active { background: var(--sb-active-bg); color: var(--sb-active-text); font-weight: 600; }
.nav-group { margin: 14px 12px 4px; font-size: 11px; color: var(--sb-muted); letter-spacing: .02em; }
.sidebar__footer { padding: 12px; border-top: 1px solid var(--sb-border); display: flex; flex-direction: column; gap: 8px; }
.sidebar__user { color: var(--sb-text); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sidebar__user .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--sb-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
:root[data-sidebar="navy"] .sidebar__user .avatar { background: rgba(255, 255, 255, .14); }
.sidebar__collapse { background: transparent; color: var(--sb-muted); border: 1px solid var(--sb-border); width: 100%; }
.sidebar__collapse:hover { background: var(--sb-hover); }
.btn-logout { width: 100%; background: transparent; color: var(--sb-text); border: 1px solid var(--sb-border); }
.btn-logout:hover { background: var(--danger-soft); color: var(--danger); }
.sidebar-backdrop { display: none; }
body.sidebar-collapsed .sidebar__brand div:last-child,
body.sidebar-collapsed .nav-group,
body.sidebar-collapsed .sidebar__nav a span.lbl,
body.sidebar-collapsed .sidebar__nav a .pill,
body.sidebar-collapsed .sidebar__user .name,
body.sidebar-collapsed .btn-logout .lbl,
body.sidebar-collapsed .sidebar__collapse .lbl { display: none; }
body.sidebar-collapsed .sidebar__nav a { justify-content: center; }
.pill { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 11px; line-height: 18px; }

/* ---------- messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.messages .msg { background: var(--surface); border: 1px solid var(--border); border-right: 4px solid var(--ok); border-radius: calc(var(--radius) * .8); padding: 10px 12px; margin: 0 0 8px; }
.msg-error { border-right-color: var(--danger) !important; }
.msg-warning { border-right-color: var(--warn) !important; }
.msg-info { border-right-color: var(--accent) !important; }

/* ---------- forms & buttons ---------- */
label { display: block; margin: calc(10px * var(--space)) 0 4px; font-weight: 600; font-size: .93em; }
input, select, textarea {
  width: 100%; max-width: 720px; padding: calc(8px * var(--space)) 10px; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * .75);
}
input[type=checkbox], input[type=radio] { width: auto; max-width: none; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 36px; width: 56px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; }
button, .btn {
  display: inline-block; padding: calc(8px * var(--space)) 14px; cursor: pointer; font: inherit; text-align: center;
  border-radius: calc(var(--radius) * .75); border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
button:hover, .btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-block { display: block; width: 100%; margin-top: 16px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .93em; }
table th, table td { vertical-align: top; padding: calc(8px * var(--space)) 10px; border-bottom: 1px solid var(--border); }
table th { background: var(--surface-2); color: var(--text); font-weight: 700; white-space: nowrap; text-align: right; }
table tbody tr:hover { background: var(--surface-2); }
.table-wrap, .card > table { display: block; overflow-x: auto; }
.pagination { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- legacy inline colours (hundreds of templates use them) follow the theme ---------- */
[style*="solid #eee"], [style*="solid #ddd"], [style*="solid #f0f0f0"], [style*="solid #f3f3f3"],
[style*="dashed #eee"], [style*="dashed #ddd"] { border-color: var(--border) !important; }
[style*="color:#666"], [style*="color: #666"], [style*="color:#777"], [style*="color:#888"], [style*="color:#999"],
[style*="color:#555"], [style*="color:#444"] { color: var(--muted) !important; }
[style*="color:#b00"], [style*="color: #b00"], [style*="color:#c0392b"] { color: var(--danger) !important; }
[style*="color:#b45309"] { color: var(--warn) !important; }
[style*="background:#fafafa"], [style*="background:#f6f6f6"], [style*="background:#f5fbff"] { background: var(--surface-2) !important; }
[style*="background:#fff8e1"] { background: var(--warn-soft) !important; }
[style*="background:#fff5f5"], [style*="background:#fee"] { background: var(--danger-soft) !important; }
[style*="background:#fff;"], [style*="background:#fff\""], [style*="background: #fff"] { background: var(--surface) !important; }

/* ---------- login ---------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 390px; background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.3); padding: 28px 24px; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 14px; }
.auth-brand .sidebar__logo { width: 52px; height: 52px; font-size: 22px; }
.auth-brand h1 { font-size: 1.25em; margin: 10px 0 2px; }
.auth-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); border-radius: calc(var(--radius) * .75); padding: 8px 10px; margin-bottom: 8px; }
.auth-note { font-size: .85em; text-align: center; margin: 14px 0 0; }
.auth-card input { max-width: none; }

/* ---------- appearance panel ---------- */
.ap-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .2s; }
.ap-panel {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 61; width: min(360px, 92vw); overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(-102%); transition: transform .22s ease; padding: 16px;
}
body.ap-open .ap-backdrop { opacity: 1; pointer-events: auto; }
body.ap-open .ap-panel { transform: none; }
.ap-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ap-sec { margin: 14px 0; }
.ap-sec > .ap-title { font-weight: 700; margin-bottom: 6px; font-size: .95em; }
.ap-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.ap-seg button { flex: 1 1 auto; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 6px 10px; }
.ap-seg button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.ap-swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ap-swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); padding: 0; }
.ap-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.ap-panel select, .ap-panel input[type=range] { max-width: none; }
.ap-preview { margin-top: 6px; padding: 10px; border: 1px dashed var(--border); border-radius: calc(var(--radius) * .75); }

/* ---------- dashboard ---------- */
.dash-hero { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.dash-hero h2 { margin: 0; font-size: 1.5em; }
.dash-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-quick a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; }
.dash-quick a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 14px; }
.kpi { position: relative; overflow: hidden; display: flex; gap: 12px; align-items: flex-start; }
.kpi::after { content: ""; position: absolute; inset: auto auto -30px -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--kpi-c, var(--accent)); opacity: .08; }
.kpi__icon { width: 42px; height: 42px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: calc(var(--radius) * .8); background: color-mix(in srgb, var(--kpi-c, var(--accent)) 16%, transparent); color: var(--kpi-c, var(--accent)); }
.kpi__icon .ic { width: 22px; height: 22px; }
.kpi__label { color: var(--muted); font-size: .88em; }
.kpi__value { font-size: 1.55em; font-weight: 800; line-height: 1.3; }
.kpi__value small { font-size: .5em; font-weight: 500; color: var(--muted); }
.kpi__sub { font-size: .82em; color: var(--muted); }
.delta { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: .8em; font-weight: 700; }
.delta.up { background: var(--danger-soft); color: var(--danger); }     /* spending up = warning colour */
.delta.down { background: var(--ok-soft); color: var(--ok); }
.delta.flat { background: var(--surface-2); color: var(--muted); }
.dash-grid { display: grid; gap: 14px; margin-bottom: 14px; grid-template-columns: repeat(12, 1fr); }
.dash-grid > .card { margin: 0; min-width: 0; }
.span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; } .span-12 { grid-column: span 12; }
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.card__head h4 { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85em; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 5px; vertical-align: middle; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-family: var(--font); font-size: 11px; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .bar { transition: opacity .15s; } .chart .bar:hover { opacity: .75; }
.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; justify-content: center; }
.donut-wrap svg { width: 150px; height: 150px; flex: none; }
.donut-legend { list-style: none; padding: 0; margin: 0; font-size: .88em; flex: 1 1 140px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend .vl { color: var(--muted); }
.hbar { margin: 8px 0; }
.hbar__top { display: flex; justify-content: space-between; gap: 8px; font-size: .88em; }
.hbar__track { height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.hbar__fill { height: 100%; border-radius: 99px; background: var(--accent); }
.work-list { list-style: none; padding: 0; margin: 0; }
.work-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(8px * var(--space)) 0; border-bottom: 1px solid var(--border); }
.work-list li:last-child { border-bottom: 0; }
.tag { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .78em; background: var(--surface-2); color: var(--muted); }
.tag.late { background: var(--danger-soft); color: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }
details.card > summary { cursor: pointer; font-weight: 700; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) { .span-8, .span-6, .span-4 { grid-column: span 12; } }
@media (max-width: 900px) {
  body.has-sidebar .content-wrap { margin-right: 0; }
  .topbar__toggle { display: inline-flex; }
  .sidebar { transform: translateX(100%); width: var(--sb-w, 252px); }
  body.sidebar-collapsed { --sb-w: 252px; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .4); }
  body.sidebar-collapsed .sidebar__brand div:last-child, body.sidebar-collapsed .nav-group, body.sidebar-collapsed .sidebar__nav a span.lbl,
  body.sidebar-collapsed .sidebar__nav a .pill, body.sidebar-collapsed .sidebar__user .name, body.sidebar-collapsed .btn-logout .lbl { display: revert; }
  .sidebar__collapse { display: none; }
  main.app-main { padding: 12px; }
}

/* ---------- print ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --border: #bbb; --muted: #444; --shadow: none; }
  .no-print, .sidebar, .topbar, .sidebar-backdrop, .ap-panel, .ap-backdrop { display: none !important; }
  body.has-sidebar .content-wrap { margin: 0; }
  body { background: #fff; color: #000; }
  .card { border: 0; box-shadow: none; padding: 0; }
  main.app-main { max-width: none; padding: 0; }
}

/* ---------- help ---------- */
.help-layout { display: grid; grid-template-columns: 260px 1fr; gap: 14px; align-items: start; }
.help-toc { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }
.help-list { list-style: none; padding: 0; margin: 0; }
.help-list li { padding: 3px 0; }
.help-list a.is-current { font-weight: 700; color: var(--text); }
.help-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.help-cards .card + .card { margin-top: 0; }
.help-body { line-height: 2; }
.help-body h2 { font-size: 1.45em; border-bottom: 2px solid var(--accent); padding-bottom: 6px; margin-bottom: 14px; }
.help-body h3 { margin-top: 20px; font-size: 1.15em; }
.help-body h4 { margin-top: 14px; }
.help-body ol, .help-body ul { padding-right: 22px; }
.help-body table { margin: 10px 0; }
.help-note, .help-warn, .help-tip { margin: 12px 0; padding: 10px 14px; border-radius: calc(var(--radius) * .7); border-right: 4px solid var(--accent); background: var(--accent-soft); }
.help-warn { border-right-color: var(--danger); background: var(--danger-soft); }
.help-tip { border-right-color: var(--ok); background: var(--ok-soft); }
.help-note > strong:first-child, .help-warn > strong:first-child, .help-tip > strong:first-child { margin-left: 6px; }
.help-steps { counter-reset: s; list-style: none; padding-right: 0 !important; }
.help-steps > li { counter-increment: s; position: relative; padding: 4px 38px 4px 0; margin: 6px 0; }
.help-steps > li::before { content: counter(s, persian); position: absolute; right: 0; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: .85em; }
.help-body kbd, .help-body .btnlike { display: inline-block; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); font-size: .9em; font-family: inherit; }
.help-pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--border); }
@media (max-width: 900px) { .help-layout { grid-template-columns: 1fr; } .help-toc { position: static; max-height: none; } }

/* ---------- admin center ---------- */
.hub-layout { display: grid; grid-template-columns: 250px 1fr; gap: 14px; align-items: start; }
.hub-nav { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 2px; }
.hub-nav a { padding: 6px 10px; border-radius: calc(var(--radius) * .6); color: var(--text); }
.hub-nav a:hover { background: var(--surface-2); text-decoration: none; }
.hub-nav a.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.health-page > .dash-hero { align-items: center; }
.health-page > .dash-hero h2 { margin: 0 0 4px; }
.health-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.health-count { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.health-count strong { font-size: 1.45em; line-height: 1; }
.health-count--error strong { color: var(--danger); }
.health-count--warn strong { color: var(--warn); }
.health-count--info strong { color: var(--accent); }
.health-note { margin-bottom: 18px; }
.health-note p { margin: 6px 0 0; }
.health-group { margin: 18px 0 22px; }
.health-group > h3 { padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.health-list { display: grid; gap: 10px; }
.health-item { padding: 14px 16px; border: 1px solid var(--border); border-right: 4px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.health-item--error { border-right-color: var(--danger); }
.health-item--warn { border-right-color: var(--warn); }
.health-item--info { border-right-color: var(--accent); }
.health-item__head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.health-item__head h4 { margin: 0; }
.health-severity { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78em; font-weight: 700; white-space: nowrap; }
.health-severity--error { color: var(--danger); background: var(--danger-soft); }
.health-severity--warn { color: var(--warn); background: var(--warn-soft); }
.health-severity--info { color: var(--accent); background: var(--accent-soft); }
.health-details { margin: 12px 0 8px; }
.health-details > div { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 8px; padding: 7px 0; border-top: 1px solid var(--border); }
.health-details dt { color: var(--muted); font-weight: 700; }
.health-details dd { margin: 0; }
.health-details ol { margin: 0; padding-right: 20px; }
.health-details li + li { margin-top: 3px; }
.health-action { display: inline-block; margin-top: 4px; }
.health-clean { border-right: 4px solid var(--ok); }
.health-clean p { margin: 6px 0 0; color: var(--muted); }
.hub-group { margin: 12px 10px 2px; font-size: .8em; color: var(--muted); font-weight: 700; }
.hub-filter { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.hub-filter input, .hub-filter select { width: auto; flex: 1 1 160px; max-width: 280px; }
table.matrix th, table.matrix td { padding: 5px 8px; }
@media (max-width: 900px) { .hub-layout { grid-template-columns: 1fr; } .hub-nav { position: static; } }
@media (max-width: 640px) {
  .health-summary { grid-template-columns: 1fr; }
  .health-details > div { grid-template-columns: 1fr; gap: 2px; }
}
