:root {
  /* Market Pulse brand: primary #012AF6. */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #17202c;
  --muted: #637083;
  --line: #e2e7ee;
  --brand: #012af6;
  --brand-ink: #ffffff;
  --brand-soft: #e8edff;
  --ok: #157f4c;      --ok-bg: #e5f5ec;
  --crit: #b42318;    --crit-bg: #fde8e6;
  --major: #b54708;   --major-bg: #fdf0e1;
  --minor: #8a6a00;   --minor-bg: #fdf6d8;
  --info: #475467;    --info-bg: #eef1f5;
  --blue: #175cd3;    --blue-bg: #e6efff;
  --purple: #6941c6;  --purple-bg: #f0ebfd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}

/* Dark theme: set on <html data-theme> by base.html (saved choice or system setting). */
:root[data-theme="dark"] {
    --bg: #0d1017; --surface: #151a24; --text: #e7ecf3; --muted: #95a0b4; --line: #252d3d;
    --brand: #8ea2ff; --brand-ink: #020a33; --brand-soft: #0f1a4a;
    --ok: #6fd3a0; --ok-bg: #12301f; --crit: #ff8f86; --crit-bg: #3a1714;
    --major: #ffb470; --major-bg: #3a2410; --minor: #f0d062; --minor-bg: #332a0b;
    --info: #b5c0cf; --info-bg: #1f2833; --blue: #8ab4ff; --blue-bg: #13233f;
    --purple: #c3a8ff; --purple-bg: #251b3d;
    --shadow: none;
    color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", "Geeza Pro", Tahoma, sans-serif;
  transition: background-color .2s, color .2s;
}
button, input, select, textarea { font-family: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-block-size: 64px; padding: 10px 24px; background: var(--surface); border-block-end: 1px solid var(--line);
  position: sticky; inset-block-start: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; color: var(--text); flex-shrink: 0; }
.logo { display: inline-flex; }
.logo img { block-size: 34px; inline-size: auto; display: block; }
.logo.big img { block-size: 60px; }
.brand-sep { inline-size: 1px; block-size: 22px; background: var(--line); }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .01em;
  background: linear-gradient(135deg, var(--ai1), var(--ai2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-head .product-name { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 700; color: var(--text); }
.login-head .product-name span[lang="ar"] { background: linear-gradient(135deg, var(--ai1), var(--ai2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dot-sep { inline-size: 5px; block-size: 5px; border-radius: 999px; background: var(--line); }
.visually-hidden { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
.mainnav { display: flex; gap: 4px; margin-inline-end: auto; margin-inline-start: 18px; }
.mainnav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 14px; }
.mainnav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.mainnav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.theme-toggle {
  display: inline-grid; place-items: center; inline-size: 34px; block-size: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer;
  transition: transform .2s, border-color .2s;
}
.theme-toggle:hover { border-color: var(--brand); transform: rotate(-15deg); }
.theme-toggle svg { inline-size: 17px; block-size: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
.avatar {
  display: inline-grid; place-items: center; inline-size: 28px; block-size: 28px; border-radius: 999px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ai1), var(--ai2)); color: #fff; font-weight: 600; font-size: 13px;
}
.role-tag { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; inline-size: 26px; block-size: 26px;
  border-radius: 7px; background: var(--brand); color: var(--brand-ink); font-size: 14px;
}
.brand-mark.big { inline-size: 40px; block-size: 40px; font-size: 22px; border-radius: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-actions form { margin: 0; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; }

.page { max-inline-size: 1280px; margin: 0 auto; padding: 20px 24px 48px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}

/* buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: transparent; }
.wide { inline-size: 100%; justify-content: center; }
input, select {
  font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--text); min-inline-size: 0;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; }


/* badges */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px;
  font-weight: 600; white-space: nowrap; background: var(--info-bg); color: var(--info);
}
.badge.big { font-size: 14px; padding: 4px 12px; }
.status-ok { background: var(--ok-bg); color: var(--ok); }
.status-partial { background: var(--minor-bg); color: var(--minor); }
.status-failed { background: var(--crit-bg); color: var(--crit); }
.status-running { background: var(--blue-bg); color: var(--blue); display: inline-flex; align-items: center; gap: 6px; }
.pulse { inline-size: 7px; block-size: 7px; border-radius: 50%; background: currentColor; }
@media (prefers-reduced-motion: no-preference) { .pulse { animation: pulse 1.2s ease-in-out infinite; } }
@keyframes pulse { 50% { opacity: .25; } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-block-end: 14px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-wide { grid-column: span 2; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; }

/* filters */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-block-end: 14px; }
.filter-actions { display: flex; gap: 8px; margin-inline-start: auto; }

/* tables */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { inline-size: 100%; border-collapse: collapse; }
.reports th, .reports td { padding: 11px 14px; text-align: start; vertical-align: top; border-block-end: 1px solid var(--line); }
.reports th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--bg); }
.reports tbody tr:hover { background: var(--bg); }
.reports td > .badge + .badge { margin-inline-start: 4px; }
.booking { white-space: nowrap; }
.booking-id { font-weight: 700; font-size: 15px; }
.ext { margin-inline-start: 6px; color: var(--muted); }
.issues { min-inline-size: 280px; max-inline-size: 520px; }
.preview { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; }
.preview li { display: flex; align-items: flex-start; }
.empty { padding: 28px; text-align: center; color: var(--muted); margin: 0; }
.empty.ok { color: var(--ok); padding: 16px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 12px; }

/* login */
.login-wrap { min-block-size: 80vh; display: grid; place-items: center; }
.login { inline-size: min(400px, 100%); display: grid; gap: 14px; padding: 24px 30px 30px; position: relative; overflow: hidden; }
.login::before { content: ""; position: absolute; inset: 0 0 auto 0; block-size: 3px; background: linear-gradient(90deg, var(--ai1), var(--ai2), var(--ai3)); }
.login-tools { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.login-head { display: grid; justify-items: center; gap: 10px; margin-block-end: 8px; text-align: center; }
.login-head h1 { font-size: 17px; font-weight: 500; color: var(--muted); }
.tagline { margin: -4px 0 0; font-size: 13.5px; color: var(--muted); }
.alert { background: var(--crit-bg); color: var(--crit); padding: 9px 12px; border-radius: 8px; margin: 8px 0 0; }
.notice { background: var(--blue-bg); color: var(--blue); padding: 9px 12px; border-radius: 8px; margin: 8px 0 0; }

/* detail */
.back { display: inline-block; margin-block-end: 12px; font-size: 14px; }
.summary { display: grid; gap: 12px; margin-block-end: 14px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.side { display: grid; gap: 14px; }

/* accent gradient (brand name, avatar, sync button) */
:root { --ai1: #2b97dc; --ai2: #012af6; --ai3: #12b5a6; }
:root[data-theme="dark"] { --ai1: #5bb8f0; --ai2: #a08bff; --ai3: #3fd5c4; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .stat-wide { grid-column: auto; }
}
@media (max-width: 600px) {
  .page { padding: 14px 16px 40px; }
  .topbar { padding: 10px 16px; }
  .who { display: none; }
  .filter-actions { margin-inline-start: 0; }
}

/* page heading */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; margin-block-end: 16px; }
.page-head p { margin: 4px 0 0; }
/* vehicle photo + name */
.car-cell { display: flex; align-items: center; gap: 12px; min-inline-size: 220px; }
.car-cell > div { text-align: start; }  /* title, make and id line up (also in RTL) */
.car-photo { inline-size: 76px; block-size: 52px; border-radius: 8px; object-fit: cover; display: block; flex-shrink: 0;
  background: var(--bg); border: 1px solid var(--line); }
/* No photo: the brand placeholder car, fitted inside the same frame. */
.car-photo.placeholder { object-fit: contain; padding: 6px 4px; background: linear-gradient(180deg, var(--surface), var(--bg)); }
.car-photo.big { inline-size: 168px; block-size: 112px; border-radius: 12px; }
.car-photo.big.placeholder { padding: 14px 10px; }
.car-name { font-weight: 600; font-size: 13.5px; line-height: 1.35; margin-block-start: 2px; }
.car-name.big { font-size: 16px; font-weight: 500; }
.car-trim { line-height: 1.3; }
.summary-title { display: grid; gap: 2px; }
@media (max-width: 600px) { .car-photo.big { inline-size: 100%; block-size: 180px; } }
.page-head h1 { font-size: 22px; }
.btn-ai { border: 0; color: #fff; background: linear-gradient(135deg, var(--ai1), var(--ai2)); font-weight: 600; }
.btn-ai:hover { filter: brightness(1.08); }

/* listing summary card */
.summary { gap: 18px; padding: 20px; }
.sum-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.sum-photo { display: block; }
.sum-id { display: grid; gap: 8px; min-inline-size: 0; }
.sum-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sum-title h1 { font-size: 28px; line-height: 1.1; letter-spacing: -.01em; }
.sum-id .car-name.big { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; margin: 0; }
.car-trim-tag { font-size: 13px; font-weight: 500; color: var(--muted); padding: 1px 9px; border: 1px solid var(--line); border-radius: 999px; }
.sum-id .src-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); }
.sum-id .src-line .by { margin-inline-start: 4px; }
.sum-actions { display: flex; flex-direction: column; gap: 8px; align-self: start; }
.sum-actions form { margin: 0; display: grid; }
.sum-actions .btn { justify-content: center; text-align: center; white-space: nowrap; }
.sum-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); overflow: hidden;
}
.sum-stats .tile { padding: 12px 16px; border-inline-start: 1px solid var(--line); min-inline-size: 0; }
.sum-stats .tile:first-child { border-inline-start: 0; }
.sum-stats .tile-findings { grid-column: span 2; }
.sum-stats dt { font-size: 12px; color: var(--muted); margin-block-end: 4px; }
.sum-stats dd { margin: 0; font-size: 15.5px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sum-stats .count { font-size: 12.5px; padding: 2px 9px; }
.ok-text { color: var(--ok); }
.sum-note { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--muted); }
.sum-note svg { inline-size: 16px; block-size: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (max-width: 900px) {
  .sum-hero { grid-template-columns: auto minmax(0, 1fr); }
  .sum-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .sum-stats .tile-findings { grid-column: 1 / -1; border-block-end: 1px solid var(--line); }
}
@media (max-width: 600px) {
  .sum-hero { grid-template-columns: 1fr; }
  .sum-title h1 { font-size: 24px; }
  .sum-stats .tile { border-inline-start: 0; border-block-start: 1px solid var(--line); }
  .sum-stats .tile:first-child { border-block-start: 0; }
}

/* footer */
body { display: flex; flex-direction: column; min-block-size: 100vh; }
.page { flex: 1; inline-size: 100%; }
.site-foot { border-block-start: 1px solid var(--line); background: var(--surface); }
.site-foot-inner {
  max-inline-size: 1280px; margin: 0 auto; padding: 14px 24px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
  font-size: 13px; color: var(--muted);
}
.provided { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); }
.provided:hover { text-decoration: none; color: var(--text); }
.provided img { block-size: 26px; inline-size: auto; display: block; transition: transform .18s; }
.provided:hover img { transform: translateY(-1px); }
.site-foot .logo-dark { display: none; }
:root[data-theme="dark"] .site-foot .logo-light { display: none; }
:root[data-theme="dark"] .site-foot .logo-dark { display: block; }
@media (max-width: 600px) { .site-foot-inner { padding: 12px 16px; justify-content: center; text-align: center; } }

/* Table cells holding dates/numbers are dir="ltr" (keeps "2026-10-15 14:28", "10.5 s", "155,000"
   in order) - but in Arabic they must still line up with their right-aligned headings. */
[dir="rtl"] td[dir="ltr"], [dir="rtl"] th[dir="ltr"] { text-align: right; }

/* ---------------------------------------------------------------------------------------
   Market Pulse additions
   --------------------------------------------------------------------------------------- */
.lang { font-size: 14px; font-weight: 500; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
/* dir="ltr" cells (years, dates, numbers) in an Arabic table still line up with their header. */
[dir="rtl"] td[dir="ltr"] { text-align: right; }
.unit { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.head-sub { font-weight: 400; font-size: 18px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.head-actions form { margin: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px 4px; }
.card-head h2 { margin: 0; }
.notice { margin: 0 0 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.i-sync, .i-dl { inline-size: 16px; block-size: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ok-text { color: var(--ok); }

/* stat tiles: the one hero figure per view */
.stat-value { line-height: 1.15; }
.stat-value.hero { font-size: 48px; font-weight: 600; letter-spacing: -.02em; }
.stat-hero { justify-content: space-between; }
.stat-hero .stat-value.hero { background: linear-gradient(135deg, var(--ai1), var(--ai2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* platform cards (overview) */
.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; margin-block-end: 14px; }
.platform-card { display: grid; gap: 14px; position: relative; overflow: hidden; }
.platform-card::before { content: ""; position: absolute; inset: 0 0 auto 0; block-size: 3px; background: linear-gradient(90deg, var(--ai1), var(--ai2), var(--ai3)); }
.platform-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.platform-head h2 { margin: 0; font-size: 18px; }
.platform-head code { font-size: 12px; }
.platform-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; }
.platform-facts > div { padding: 8px 12px; border-inline-start: 1px solid var(--line); min-inline-size: 0; }
.platform-facts > div:first-child { border-inline-start: 0; }
.platform-facts dt { font-size: 12px; color: var(--muted); }
.platform-facts dd { margin: 0; font-weight: 600; font-size: 15px; text-align: start; }
.platform-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.platform-actions form { margin: 0; }
.run-error { margin: 0; color: var(--crit); background: var(--crit-bg); padding: 6px 10px; border-radius: 8px; word-break: break-word; }
.runs-table td { vertical-align: middle; }
.reason-cell { min-inline-size: 200px; max-inline-size: 380px; }
.reason-cell .run-error { margin-block-start: 4px; }

/* column chart (single series, per day) */
.chart { margin: 0 0 14px; display: grid; gap: 10px; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 12px; }
.chart-head h2 { margin: 0; }
.cols-wrap { position: relative; padding-inline-start: 40px; }
.cols-grid { position: absolute; inset: 0 0 22px 40px; pointer-events: none; }
.cols-tick { position: absolute; inset-inline: 0; border-block-start: 1px solid var(--line); }
.cols-tick i { position: absolute; inset-inline-end: calc(100% + 8px); transform: translateY(-50%); font-style: normal; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cols { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; block-size: 200px; }
.col { display: flex; align-items: flex-end; justify-content: center; block-size: 100%; outline: none; cursor: default; }
.col-bar { display: block; inline-size: min(100%, 24px); min-block-size: 0; background: var(--brand); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.cols:hover .col-bar { opacity: .55; }
.cols .col:hover .col-bar, .col:focus-visible .col-bar { opacity: 1; }
.col:focus-visible { box-shadow: inset 0 0 0 2px var(--ai2); border-radius: 4px; }
.cols-x { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; block-size: 22px; padding-block-start: 6px; }
.cols-x span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: visible; text-align: center; }
.chart-table summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.chart-table table { margin-block-start: 8px; max-inline-size: 320px; }
.chart-tip { position: absolute; z-index: 50; display: none; gap: 0; padding: 6px 10px; border-radius: 8px; pointer-events: none;
  background: var(--text); color: var(--surface); font-size: 12.5px; line-height: 1.35; box-shadow: 0 4px 14px rgba(16, 24, 40, .18); }
.chart-tip b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* horizontal "top N" bars */
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(70px, 120px) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13.5px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
a.hbar-label:hover { color: var(--brand); }
.hbar-track { display: block; block-size: 10px; }
.hbar { display: block; block-size: 100%; min-inline-size: 2px; background: var(--brand); border-radius: 0 4px 4px 0; }
[dir="rtl"] .hbar { border-radius: 4px 0 0 4px; }
.hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; min-inline-size: 3ch; text-align: end; }

/* listings page */
.insights { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 14px; margin-block-end: 14px; align-items: start; }
.insights .chart { margin: 0; }
.filters label.grow { flex: 1 1 220px; }
.filters label.short input { inline-size: 110px; }
.listings td { vertical-align: middle; }
.car-title { font-weight: 600; color: var(--text); }
.car-title:hover { color: var(--brand); }
.price { font-weight: 600; }
@media (max-width: 1400px) { .insights { grid-template-columns: repeat(3, minmax(0, 1fr)); } .insights .chart { grid-column: 1 / -1; } }
@media (max-width: 1100px) { .insights { grid-template-columns: 1fr 1fr; } .insights .chart { grid-column: 1 / -1; } }
@media (max-width: 700px) { .insights { grid-template-columns: 1fr; } .platform-grid { grid-template-columns: 1fr; } }

/* listing detail */
.detail-price { font-size: 26px; font-weight: 700; color: var(--brand); }
.detail-grid { grid-template-columns: minmax(0, 1fr) 380px; margin-block-end: 14px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gallery img { inline-size: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); display: block; }
.gallery a:hover img { border-color: var(--brand); }
.description { margin: 0; white-space: pre-line; }
.facts { margin: 0; display: grid; }
.facts > div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-block-start: 1px solid var(--line); font-size: 14px; }
.facts > div:first-child { border-block-start: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; word-break: break-word; text-align: start; }
.raw summary { cursor: pointer; font-weight: 600; }
.raw pre { margin: 12px 0 0; max-block-size: 520px; overflow: auto; font-size: 12px; line-height: 1.5; background: var(--bg); border-radius: 8px; padding: 12px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* narrow screens: the nav moves to its own row and scrolls sideways instead of the page */
.topbar { flex-wrap: wrap; row-gap: 6px; }
@media (max-width: 760px) {
  .mainnav { order: 3; inline-size: 100%; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .mainnav a { white-space: nowrap; }
  .brand-sep, .brand-name { display: none; }
  .topbar-actions { gap: 8px; }
  .stat-value.hero { font-size: 40px; }
  .cols-x span { font-size: 10px; }
}

/* listing page: head, photo viewer, car boxes, seller card */

.viewer { padding: 0; overflow: hidden; }
.viewer-stage { position: relative; background: #0b0d12; block-size: clamp(260px, 58vh, 600px); inline-size: 100%; display: grid; place-items: center; overflow: hidden; }
.viewer-main { max-inline-size: 100%; max-block-size: 100%; inline-size: 100%; block-size: 100%; object-fit: contain; display: block; cursor: zoom-in; }
.viewer-nav {
  position: absolute; inset-block-start: 50%; transform: translateY(-50%); inline-size: 44px; block-size: 44px; border-radius: 999px;
  border: 0; background: rgba(255, 255, 255, .85); color: #17202c; font-size: 28px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.viewer-nav:hover { background: #fff; }
.viewer-nav.prev { inset-inline-start: 14px; }
.viewer-nav.next { inset-inline-end: 14px; }
.viewer-nav svg { inline-size: 22px; block-size: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* Icons, not text: mirrored once here for Arabic (prev on the right points right). */
[dir="rtl"] .viewer-nav svg { transform: scaleX(-1); }
.viewer-count, .viewer-source { position: absolute; inset-block-end: 12px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: rgba(0, 0, 0, .6); color: #fff; }
.viewer-count { inset-inline-end: 12px; font-variant-numeric: tabular-nums; }
.viewer-source { inset-inline-start: 12px; }
.viewer-source.is-offline::before { content: "● "; color: #6fd3a0; }
.viewer-strip { display: flex; gap: 8px; padding: 10px; overflow-x: auto; scrollbar-width: thin; }
.viewer-thumb { flex: none; padding: 0; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; opacity: .7; transition: opacity .15s, border-color .15s; }
.viewer-thumb img { display: block; inline-size: 112px; block-size: 76px; object-fit: cover; border-radius: 6px; }
.viewer-thumb:hover { opacity: 1; }
.viewer-thumb.is-active { border-color: var(--brand); opacity: 1; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: 14px; align-items: start; margin-block-end: 14px; }
.detail-main { display: grid; gap: 14px; min-inline-size: 0; }
.detail-side { position: sticky; inset-block-start: 80px; display: grid; gap: 14px; min-inline-size: 0; }
.box { padding: 0; overflow: hidden; }
.box-title { margin: 0; padding: 16px 18px; font-size: 17px; border-block-end: 1px solid var(--line); }
.car-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; }
.car-cell-box { position: relative; padding: 14px 18px; border-block-end: 1px solid var(--line); border-inline-end: 1px solid var(--line); min-inline-size: 0; }
.car-grid .car-cell-box:nth-child(5n) { border-inline-end: 0; }
.car-cell-box dt { font-size: 13px; color: var(--muted); }
.car-cell-box dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.car-ico { position: absolute; inset-inline-end: 14px; inset-block-end: 12px; color: var(--muted); }
.car-ico .ico { inline-size: 34px; block-size: 34px; }
.ico { inline-size: 18px; block-size: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spec-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.spec { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 18px; border-block-end: 1px solid var(--line); border-inline-end: 1px solid var(--line); min-inline-size: 0; }
.spec-grid .spec:nth-child(3n) { border-inline-end: 0; }
.spec dt { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; min-inline-size: 0; }
.spec dt .ico { color: var(--muted); }
.spec dd { margin: 0; font-weight: 600; font-size: 14.5px; text-align: end; overflow-wrap: anywhere; }

.seller { display: grid; gap: 14px; }
.seller-head { display: flex; gap: 12px; align-items: center; }
.seller-head h2 { margin: 0 0 4px; font-size: 18px; line-height: 1.25; }
.seller-avatar { inline-size: 56px; block-size: 56px; border-radius: 14px; object-fit: cover; flex: none; font-size: 22px; border: 1px solid var(--line); }
.seller-facts { margin: 0; display: grid; }
.seller-facts > div { display: grid; gap: 2px; padding: 9px 0; border-block-start: 1px solid var(--line); }
.seller-facts dt { font-size: 12.5px; color: var(--muted); }
.seller-facts dd { margin: 0; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.chip { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--blue-bg); color: var(--blue); white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.seller-actions { display: grid; gap: 8px; }
.seller-actions .btn { white-space: normal; text-align: center; }
.filter-chip { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; padding: 6px 8px 6px 14px; border-radius: 999px; background: var(--brand-soft); color: var(--text); font-size: 14px; }
.filter-chip a { display: inline-grid; place-items: center; inline-size: 24px; block-size: 24px; border-radius: 999px; color: var(--brand); }
.filter-chip a:hover { background: var(--surface); text-decoration: none; }

@media (max-width: 1100px) { .car-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .car-grid .car-cell-box:nth-child(5n) { border-inline-end: 1px solid var(--line); } .car-grid .car-cell-box:nth-child(3n) { border-inline-end: 0; } }
@media (max-width: 1000px) {
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .spec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec-grid .spec:nth-child(3n) { border-inline-end: 1px solid var(--line); }
  .spec-grid .spec:nth-child(2n) { border-inline-end: 0; }
}
@media (max-width: 600px) {
  .car-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .car-grid .car-cell-box:nth-child(3n) { border-inline-end: 1px solid var(--line); }
  .car-grid .car-cell-box:nth-child(2n) { border-inline-end: 0; }
  .spec-grid { grid-template-columns: 1fr; }
  .spec-grid .spec { border-inline-end: 0 !important; }
  .viewer-stage { block-size: 62vw; min-block-size: 220px; }
  .viewer-thumb img { inline-size: 84px; block-size: 58px; }
}

/* listing page: summary + seller box (right column) */
.summary-box { display: grid; gap: 14px; padding: 20px; }
.summary-box .sum-title h1 { font-size: 22px; line-height: 1.2; }
.seller-pill { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--brand-soft); }
.seller-pill .seller-avatar { inline-size: 44px; block-size: 44px; border-radius: 12px; font-size: 18px; border: 0; }
.seller-id { display: grid; min-inline-size: 0; flex: 1; }
.seller-id b { color: var(--brand); font-size: 15.5px; line-height: 1.3; overflow-wrap: anywhere; }
.seller-type { font-size: 12.5px; color: var(--muted); }
.seller-since { display: grid; text-align: end; line-height: 1.3; }
.listing-no { margin: 0; }
.quick-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 0; padding-block-end: 14px; border-block-end: 1px solid var(--line); }
.quick-facts > div { display: flex; gap: 6px; }
.quick-facts dt { color: var(--muted); }
.quick-facts dd { margin: 0; font-weight: 600; }
.price-block { display: grid; gap: 2px; }
.price-block .detail-price { font-size: 30px; line-height: 1.15; }
.contact-actions { display: grid; gap: 8px; }
.contact-actions .btn { justify-content: center; padding-block: 10px; font-weight: 600; white-space: normal; text-align: center; }
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #0b2e1a; }
.seller-facts .address dt { display: flex; align-items: center; gap: 6px; }
.side-box { display: grid; gap: 10px; }
.side-box-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.side-box-head h2 { margin: 0; }
.engagement { display: inline-flex; gap: 12px; font-weight: 600; }
.engagement span { display: inline-flex; align-items: center; gap: 4px; }
.copy-link { display: flex; gap: 6px; }
.copy-link input { flex: 1; min-inline-size: 0; font-size: 13px; color: var(--muted); }
.side-box .btn { justify-content: center; white-space: normal; text-align: center; }
/* narrow screens: photos, then the summary/seller box, then the car boxes */
@media (max-width: 1000px) {
  .detail-layout { display: flex; flex-direction: column; align-items: stretch; }
  .detail-main { display: contents; }
  .detail-layout > *, .detail-main > * { min-inline-size: 0; max-inline-size: 100%; }
  .viewer { order: -2; }
  .detail-side { order: -1; }
}

/* ---- Analytics page ------------------------------------------------------------------------
   Platform / category colours: 7 slots validated (scripts/validate_palette.js) on #fff and
   #14151f; only light slot 3 (sky) is at 3:1, so every chart also shows labels or a table view. */
:root { --s1: #4f55c4; --s2: #e0662c; --s3: #1f9fd8; --s4: #cf4f8c; --s5: #b98100; --s6: #14875a; --s7: #6e3a96; --s0: #a3acba; }
:root[data-theme="dark"] { --s1: #6e74e0; --s2: #d8692f; --s3: #2f9fd6; --s4: #cc5a92; --s5: #b98a14; --s6: #22966a; --s7: #9a6fd0; --s0: #5d6878; }
.s0 { --c: var(--s0); } .s1 { --c: var(--s1); } .s2 { --c: var(--s2); } .s3 { --c: var(--s3); }
.s4 { --c: var(--s4); } .s5 { --c: var(--s5); } .s6 { --c: var(--s6); } .s7 { --c: var(--s7); }
/* paint swatches for the colour feature: the car's own colour */
.paint-white { --c: #f4f4f2; } .paint-black { --c: #1f2023; } .paint-gray { --c: #8a8f98; } .paint-silver { --c: #c4c8ce; }
.paint-blue { --c: #2f5fb3; } .paint-red { --c: #b8322c; } .paint-brown { --c: #7a5236; } .paint-gold { --c: #c9a13b; }
.paint-beige { --c: #d9c8a4; } .paint-green { --c: #3f7d4a; } .paint-other { --c: var(--s0); }

.an-head .note { margin: 6px 0 0; }
.an-filters select, .an-filters input { min-inline-size: 0; }
.an-filters label.short input { inline-size: 96px; }
.an-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-block-end: 14px; align-items: start; }
.an-grid > * { margin: 0; min-inline-size: 0; }
.an-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.an-grid .span-2 { grid-column: span 2; }
.an-grid .span-all { grid-column: 1 / -1; }
.an-section { font-size: 15px; font-weight: 700; margin: 22px 0 10px; color: var(--text); }
.an-section small { font-weight: 400; color: var(--muted); margin-inline-start: 8px; font-size: 13px; }
.stats.an-kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; inline-size: fit-content; }
.delta.up { background: var(--ok-bg); color: var(--ok); }
.delta.down { background: var(--crit-bg); color: var(--crit); }
.stat .stat-sub { font-size: 12.5px; color: var(--muted); }

.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; inline-size: 10px; block-size: 10px; border-radius: 3px; background: var(--c); flex-shrink: 0; }
.paint-white.sw, .comp-bar .paint-white { box-shadow: inset 0 0 0 1px var(--line); }

/* stacked columns: segments bottom-up, 2px surface line between them */
.cols.stack .col { flex-direction: column-reverse; justify-content: flex-start; align-items: center; }
.cols.stack .seg { display: block; inline-size: min(100%, 24px); background: var(--c); min-block-size: 0; transition: opacity .15s; }
.cols.stack .seg + .seg { border-block-end: 2px solid var(--surface); }
.cols.stack .seg:last-child { border-radius: 4px 4px 0 0; }
.cols.stack:hover .seg { opacity: .55; }
.cols.stack .col:hover .seg, .cols.stack .col:focus-visible .seg { opacity: 1; }

/* donut */
.donut-wrap { display: grid; grid-template-columns: minmax(120px, 170px) minmax(0, 1fr); gap: 18px; align-items: center; }
.donut { inline-size: 100%; block-size: auto; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: var(--bg); stroke-width: 5; }
.donut-arc { fill: none; stroke: var(--c); stroke-width: 5; outline: none; transition: stroke-width .15s; }
.donut-arc:hover, .donut-arc:focus-visible { stroke-width: 6.5; }
.donut text { transform: rotate(90deg); transform-origin: 21px 21px; text-anchor: middle; fill: var(--text); }
.donut-total { font-size: 6.5px; font-weight: 700; }
.donut-sub { font-size: 3.2px; fill: var(--muted) !important; }
.legend-list, .comp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13.5px; }
.legend-list li, .comp-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; }
.lg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list b, .comp-list b { font-variant-numeric: tabular-nums; }
.legend-list .muted, .comp-list .muted { font-size: 12.5px; font-variant-numeric: tabular-nums; min-inline-size: 5ch; text-align: end; }

/* line chart: SVG line + HTML dots */
.line-wrap { position: relative; padding-inline-start: 44px; }
.line-grid { inset: 0 0 24px 44px; }
.line-plot { position: relative; block-size: 200px; }
.line-plot svg { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; overflow: visible; }
.line-plot polyline { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { position: absolute; inline-size: 9px; block-size: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 999px; background: var(--brand);
  box-shadow: 0 0 0 2px var(--surface); outline: none; cursor: default; }
.dot::before { content: ""; position: absolute; inset: -8px; }
.dot:hover, .dot:focus-visible { transform: scale(1.4); }
.line-x { position: relative; block-size: 24px; }
.line-x span { position: absolute; inset-block-start: 6px; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }

/* features: 100% bar + rows */
.comp .chart-head { margin-block-end: 8px; }
.comp-hint { margin: -4px 0 8px; }
.comp-bar { display: flex; gap: 2px; block-size: 12px; margin-block-end: 12px; border-radius: 4px; overflow: hidden; }
.comp-bar span { display: block; flex-basis: 0; min-inline-size: 2px; background: var(--c); outline: none; }
.comp-bar span:hover, .comp-bar span:focus-visible { filter: brightness(1.12); }

/* weekday x hour heatmap */
.heat { display: grid; grid-template-columns: auto repeat(24, minmax(0, 1fr)); gap: 2px; align-items: center; font-size: 11px; color: var(--muted); }
.heat .hc { block-size: 18px; border-radius: 3px; background: color-mix(in oklab, var(--brand) calc(var(--l) * 100%), var(--bg)); outline: none; }
.heat .hc:hover, .heat .hc:focus-visible { box-shadow: 0 0 0 2px var(--text); }
.heat .hd { padding-inline-end: 8px; white-space: nowrap; }
.heat .hh { text-align: center; }
.heat-scale { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-block-start: 10px; }
.heat-scale i { inline-size: 120px; block-size: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--bg), var(--brand)); }
[dir="rtl"] .heat-scale i { background: linear-gradient(-90deg, var(--bg), var(--brand)); }
.heat-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; margin-block-start: 8px; }

/* tables */
.an-table td, .an-table th { white-space: nowrap; }
.an-table td.num, .an-table th.num { text-align: end; font-variant-numeric: tabular-nums; }
[dir="rtl"] .an-table td.num[dir="ltr"] { text-align: left; } /* the header's "end" side */
/* dir="ltr" cells (years, dates, numbers) in an Arabic table still line up with their header. */
[dir="rtl"] td[dir="ltr"] { text-align: right; }
.an-table .plat { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.cell-low { color: var(--ok); font-weight: 700; }
.cell-high { color: var(--crit); font-weight: 700; }
.cell-tag { font-size: 11px; font-weight: 600; margin-inline-start: 4px; }

@media (max-width: 1100px) {
  .an-grid, .an-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-grid .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .an-grid, .an-grid.four { grid-template-columns: minmax(0, 1fr); }
  .donut-wrap { grid-template-columns: 120px minmax(0, 1fr); gap: 12px; }
  .heat { font-size: 9.5px; gap: 1px; }
  .heat .hc { block-size: 13px; }
}

/* ---- Settings pages ---- */
.settings-form { display: grid; gap: 14px; }
.settings-group { display: grid; gap: 16px; }
.settings-group h2 { margin: 0; }
.settings-group h2 + p { margin: -10px 0 0; }
.setting { display: grid; gap: 6px; padding-block-end: 14px; border-block-end: 1px solid var(--line); }
.setting:last-child { border-block-end: 0; padding-block-end: 0; }
.setting-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.setting-head label { font-size: 14px; font-weight: 600; color: var(--text); }
.setting-head code { font-size: 11.5px; }
.setting input:not(.short, [type=color]), .setting select, .setting textarea { inline-size: 100%; }
.setting input.short { inline-size: 160px; }
/* Brand colour: native picker + a live preview of the menu badge + the hex value */
.color-field { display: flex; align-items: center; gap: 12px; }
.times-field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.time-pill { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.time-pill input[type=time] { border: 0; background: transparent; padding: 6px 10px; font: inherit; font-variant-numeric: tabular-nums; color: inherit; direction: ltr; }
.time-x { border: 0; background: none; color: var(--muted); cursor: pointer; inline-size: 26px; block-size: 26px; border-radius: 999px; }
.time-x:hover { background: var(--danger-bg, #fde8e8); color: var(--danger, #c0392b); }
.color-field input[type=color] { inline-size: 56px; block-size: 36px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.sw-lg { display: inline-grid; place-items: center; inline-size: 28px; block-size: 28px; border-radius: 8px; background: var(--c); color: var(--on, #fff); font-weight: 700; font-size: 13px; }
.setting textarea, textarea.mono { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); resize: vertical; }
.setting.has-error input, .setting.has-error textarea { border-color: var(--crit); }
.field-error { margin: 0; color: var(--crit); font-size: 12.5px; }
.setting-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); cursor: pointer; font: inherit; }
.link-btn:hover { text-decoration: underline; }
.settings-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; position: sticky; inset-block-end: 12px; z-index: 4; }
.test-result { display: grid; gap: 10px; margin-block-end: 14px; border-inline-start: 4px solid var(--ok); }
.test-result.is-failed { border-inline-start-color: var(--crit); }
.test-result pre { max-block-size: 420px; }


/* ---- App shell: sidebar menu (grows with any number of pages) + slim top bar ------------
   Groups of links on the inline-start side (right in Arabic). Desktop: collapsible to icons
   (remembered in localStorage). Phones: a drawer opened with the ☰ button. */
:root { --side-w: 248px; --side-w-mini: 68px; }
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-block-size: 100vh; }
.nav-collapsed .shell { grid-template-columns: var(--side-w-mini) minmax(0, 1fr); }
.main-col { display: flex; flex-direction: column; min-inline-size: 0; }
.main-col .page { flex: 1; inline-size: 100%; }

.sidebar { position: sticky; inset-block-start: 0; block-size: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 14px 12px; background: var(--surface); border-inline-end: 1px solid var(--line); overflow: hidden; z-index: 20; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; border-block-end: 1px solid var(--line); margin-block-end: 6px; }
.side-brand:hover { text-decoration: none; }
.side-brand .logo img { block-size: 32px; }
.side-nav { flex: 1; overflow-y: auto; overflow-x: hidden; display: grid; align-content: start; gap: 14px; scrollbar-width: thin; }
.side-group { display: grid; gap: 2px; }
.side-title { margin: 0 0 4px; padding: 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap; }
.side-nav a { display: flex; align-items: center; gap: 10px; block-size: 38px; padding: 0 10px; border-radius: 9px;
  color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; position: relative; }
.side-nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-nav a[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -12px; inset-block: 8px;
  inline-size: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
[dir="rtl"] .side-nav a[aria-current="page"]::before { border-radius: 3px 0 0 3px; }
.side-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-ico { inline-size: 20px; block-size: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.side-dot { display: inline-grid; place-items: center; inline-size: 20px; block-size: 20px; flex-shrink: 0; border-radius: 6px;
  background: var(--c); color: var(--on, #fff); font-size: 11px; font-weight: 700;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); }
.side-collapse { display: flex; align-items: center; gap: 10px; block-size: 38px; padding: 0 10px; border: 0; border-radius: 9px;
  background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.side-collapse:hover { background: var(--bg); color: var(--text); }
.side-collapse svg, .nav-toggle svg { inline-size: 20px; block-size: 20px; flex-shrink: 0; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
[dir="rtl"] .side-collapse svg { transform: scaleX(-1); }
.nav-collapsed .side-collapse svg { transform: rotate(180deg); }
[dir="rtl"].nav-collapsed .side-collapse svg, .nav-collapsed [dir="rtl"] .side-collapse svg { transform: scaleX(-1) rotate(180deg); }
/* collapsed: icons only, labels in the tooltip (title) */
.nav-collapsed .side-label, .nav-collapsed .side-title, .nav-collapsed .side-nav .menu-tag,
.nav-collapsed .side-brand .brand-name { display: none; }
.nav-collapsed .side-nav a, .nav-collapsed .side-collapse { justify-content: center; padding: 0; }
.nav-collapsed .side-group { padding-block-start: 6px; border-block-start: 1px solid var(--line); }
.nav-collapsed .side-group:first-child { border: 0; padding: 0; }
.nav-collapsed .side-brand { justify-content: center; padding-inline: 0; }
.side-mark { display: none; inline-size: 32px; block-size: 32px; border-radius: 8px; }
.nav-collapsed .side-brand .logo { display: none; }
.nav-collapsed .side-mark { display: block; }

.topbar { position: sticky; inset-block-start: 0; z-index: 10; display: flex; align-items: center; gap: 12px; flex-wrap: nowrap;
  min-block-size: 58px; padding: 8px 24px; border-block-end: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 90%, transparent); backdrop-filter: saturate(1.4) blur(8px); }
.top-title { font-weight: 600; font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; flex-shrink: 0; }
.nav-toggle { display: none; place-items: center; inline-size: 38px; block-size: 38px; padding: 0; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.lang-pill { display: inline-grid; place-items: center; block-size: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.lang-pill:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.side-backdrop { display: none; }

/* menus: <details class="menu"> (user menu) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:focus-visible { outline: 2px solid var(--ai2); outline-offset: 2px; }
.chev { inline-size: 14px; block-size: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.menu[open] > summary .chev { transform: rotate(180deg); }
.menu-panel { position: absolute; inset-block-start: calc(100% + 6px); inset-inline-end: 0; z-index: 30; min-inline-size: 260px;
  display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .14); }
.menu-tag { font-size: 10.5px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.menu-item { display: flex; align-items: center; gap: 10px; inline-size: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 14px; text-align: start; cursor: pointer; }
.menu-item:hover { background: var(--bg); }
.menu-item svg { inline-size: 16px; block-size: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-item.danger { color: var(--crit); }
.menu-panel form { margin: 4px 0 0; border-block-start: 1px solid var(--line); padding-block-start: 4px; }
.user-menu > summary { display: inline-flex; align-items: center; gap: 8px; block-size: 38px; padding: 0 10px 0 3px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--text); font-size: 13.5px; font-weight: 500; cursor: pointer; }
[dir="rtl"] .user-menu > summary { padding: 0 3px 0 10px; }
.user-menu > summary:hover { border-color: var(--brand); }
.user-name { max-inline-size: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-user { display: flex; gap: 12px; align-items: center; padding: 8px 10px 10px; }
.menu-user > div { display: grid; gap: 2px; min-inline-size: 0; }
.menu-user b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-user .role-tag { inline-size: fit-content; margin-block-start: 2px; }
.avatar.big { inline-size: 40px; block-size: 40px; font-size: 17px; }

/* tablets: start collapsed width is up to the user; phones: drawer */
@media (max-width: 900px) {
  .shell, .nav-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; inline-size: min(84vw, 290px); transform: translateX(-105%);
    transition: transform .22s ease; box-shadow: 0 0 40px rgba(16, 24, 40, .25); z-index: 60; }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .nav-open .sidebar { transform: none !important; }
  .nav-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(10, 14, 22, .45); }
  .side-collapse { display: none; }
  .nav-collapsed .side-label, .nav-collapsed .side-title, .nav-collapsed .side-nav .menu-tag, .nav-collapsed .side-brand .brand-name { display: revert; }
  .nav-collapsed .side-nav a { justify-content: flex-start; padding: 0 10px; }
  .nav-toggle { display: inline-grid; }
  .topbar { padding: 8px 16px; }
  .user-name { display: none; }
}


/* ---- One button system: every button 38px (32px .btn-sm), same radius / weight ---------- */
.btn, .btn-ai, .btn-primary { box-sizing: border-box; block-size: 38px; padding: 0 16px; border-radius: 9px;
  border: 1px solid var(--line); justify-content: center; gap: 8px; font-size: 14px; font-weight: 600; line-height: 1;
  transition: filter .15s, background-color .15s, border-color .15s, box-shadow .15s; }
.btn-primary { border-color: var(--brand); }
.btn-ai { border-color: transparent; }
.btn:focus-visible { outline: 2px solid var(--ai2); outline-offset: 2px; }
.btn:not(.btn-primary):not(.btn-ai):hover { border-color: var(--brand); color: var(--brand); filter: none; }
.btn-sm { block-size: 32px; padding: 0 12px; font-size: 13px; }
.btn .i-sync, .btn .i-dl, .btn svg { inline-size: 16px; block-size: 16px; flex-shrink: 0; }
form > .btn, td .btn { vertical-align: middle; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select { block-size: 38px; border-radius: 9px; }
.filters .form-actions, .form-actions { display: flex; align-items: center; gap: 8px; }

/* platform cards: same height row, buttons at the bottom, equal widths */
.platform-card { display: flex; flex-direction: column; gap: 14px; }
.platform-facts { align-items: stretch; }
.platform-facts dd { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-note { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.platform-actions { margin-block-start: auto; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.platform-actions form { display: grid; }
.platform-actions .btn { inline-size: 100%; }

.crumbs { display: flex; align-items: center; gap: 8px; min-inline-size: 0; font-size: 14px; white-space: nowrap; overflow: hidden; }
.crumbs b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { color: var(--muted); }
[dir="rtl"] .crumb-sep { transform: scaleX(-1); }
.platform-facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); }
.platform-facts dd { font-size: 14.5px; }
.side-collapse { justify-content: flex-start; }

.sidebar .brand-name { display: inline !important; }
.nav-collapsed .sidebar .brand-name { display: none !important; }
@media (max-width: 900px) {
  .nav-collapsed .sidebar .brand-name { display: inline !important; }
  .nav-collapsed .side-brand .logo { display: inline-flex; }
  .nav-collapsed .side-mark { display: none; }
}


/* ---- Users page (ported from inspection_agent_ai) ---- */
.users-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.users tr.is-inactive { opacity: .55; }
.person { display: flex; align-items: center; gap: 10px; }
.person-name { font-weight: 600; }
.person.big .avatar { inline-size: 48px; block-size: 48px; font-size: 20px; }
.person.big h1 { font-size: 20px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--blue-bg); color: var(--blue); white-space: nowrap; }
.chip-admin { background: var(--purple-bg); color: var(--purple); white-space: normal; }
.chip-muted { background: var(--info-bg); color: var(--info); }
.role-superadmin { background: var(--purple); color: #fff; }
.role-admin { background: var(--purple-bg); color: var(--purple); }
.role-staff { background: var(--blue-bg); color: var(--blue); }
.user-form { display: grid; gap: 14px; }
.user-form h2 { margin: 0; }
.user-form.narrow { max-inline-size: 560px; }
.user-form > label { display: grid; gap: 4px; font-size: 13.5px; font-weight: 500; }
.user-form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.user-form legend { font-size: 13.5px; font-weight: 500; margin-block-end: 6px; padding: 0; }
.user-form b { display: block; font-weight: 600; color: var(--text); }
.user-form small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.role-pick { grid-template-columns: 1fr 1fr; }
.user-form .role-option { display: flex; flex-direction: row; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.role-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.role-option input { margin-block-start: 4px; accent-color: var(--brand); }
.user-form .switch { display: flex; flex-direction: row; gap: 12px; align-items: flex-start; cursor: pointer; padding: 8px 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; flex-shrink: 0; inline-size: 38px; block-size: 22px; border-radius: 999px; background: var(--line); transition: background .2s; margin-block-start: 1px; }
.switch .track::after { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; inline-size: 16px; block-size: 16px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: inset-inline-start .2s; }
.switch input:checked + .track { background: linear-gradient(90deg, var(--ai1), var(--ai2)); }
.switch input:checked + .track::after { inset-inline-start: 19px; }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.user-form:has(input[name="role"][value="superadmin"]:checked) .perm-pick { opacity: .4; pointer-events: none; }
@media (max-width: 1000px) { .users-grid { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .role-pick { grid-template-columns: 1fr; } }
.users td { vertical-align: middle; }
.role-option input { block-size: auto !important; }
.user-form .switch { position: relative; }
@media (max-width: 1000px) { .users-grid { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .role-pick { grid-template-columns: 1fr; } }

/* Photo viewer: the photo fills the stage exactly and is shown whole, centred (no cropping).
   (As a grid item its 100% height fell back to auto, so tall photos overflowed and showed
   only their top part.) */
.viewer-stage { position: relative; }
.viewer-main { position: absolute; inset: 0; inline-size: 100%; block-size: 100%;
  max-inline-size: none; max-block-size: none; object-fit: contain; object-position: center; }

/* Analytics: more charts */
.line-plot polyline.ml { stroke: var(--c); stroke-width: 2; }
.dot.ml-dot { background: var(--c); inline-size: 8px; block-size: 8px; margin: -4px 0 0 -4px; }
.legend-note { font-weight: 600; color: var(--text); font-size: 12px; }
.cols.stack.share .seg + .seg { border-block-end-width: 1px; }
.cols.stack.share .seg:last-child { border-radius: 3px 3px 0 0; }
.matrix { display: grid; grid-template-columns: auto repeat(var(--cols), minmax(52px, 1fr)); gap: 2px; font-size: 11.5px; min-inline-size: 520px; }
.mx-corner { font-size: 10.5px; color: var(--muted); align-self: end; padding: 0 8px 4px 0; white-space: nowrap; }
.mx-col { text-align: center; color: var(--muted); padding-block-end: 4px; white-space: nowrap; }
.mx-row { color: var(--muted); padding-inline-end: 8px; white-space: nowrap; align-self: center; }
.mx-cell { block-size: 34px; display: grid; place-items: center; border-radius: 4px; font-variant-numeric: tabular-nums; color: var(--text);
  background: color-mix(in oklab, var(--brand) calc(var(--l) * 100%), var(--bg)); outline: none; }
.mx-cell.dark { color: var(--brand-ink); font-weight: 600; }
.mx-cell:hover, .mx-cell:focus-visible { box-shadow: 0 0 0 2px var(--text); }
.insight-note { margin: 0 0 14px; font-size: 13.5px; color: var(--muted); }
.insight-note b { color: var(--text); }

/* ---------- Analytics: KSA heat map (one-hue sequential ramp, own steps per theme) ---------- */
.kmap { margin-block-end: 14px; padding: 16px; --k0: #eceef3; --k1: #d6defe; --k2: #a9baff; --k3: #7390ff; --k4: #2f55f7; --k5: #0120b8; --ring: #0120b8; }
:root[data-theme="dark"] .kmap { --k0: #20283a; --k1: #18234d; --k2: #1f358f; --k3: #2f55f7; --k4: #6f8bff; --k5: #c3cfff; --ring: #c3cfff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kmap { --k0: #20283a; --k1: #18234d; --k2: #1f358f; --k3: #2f55f7; --k4: #6f8bff; --k5: #c3cfff; --ring: #c3cfff; } }
.kmap-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.seg-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); }
.seg-tabs button { padding: 6px 12px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.seg-tabs button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.kmap-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 20px; align-items: center; margin-block-start: 8px; }
.kmap-svg { display: block; inline-size: 100%; block-size: auto; overflow: visible; }
.km-shape { fill: none; stroke: var(--line); stroke-width: 2; }
.km-dots circle { stroke: none; transform-box: fill-box; transform-origin: center; }
.kh0 { fill: var(--k0); background: var(--k0); } .kh1 { fill: var(--k1); background: var(--k1); } .kh2 { fill: var(--k2); background: var(--k2); }
.kh3 { fill: var(--k3); background: var(--k3); } .kh4 { fill: var(--k4); background: var(--k4); } .kh5 { fill: var(--k5); background: var(--k5); }
.kmap.play .km-dots circle { animation: km-in .6s cubic-bezier(.2,.9,.3,1.3) both; animation-delay: calc(var(--d) * 18ms); }
@keyframes km-in { from { opacity: 0; transform: scale(.2); } }
.km-city { cursor: pointer; outline: none; }
.km-hit { fill: transparent; stroke: none; }
.km-core { fill: var(--surface); stroke: var(--ring); stroke-width: 3; transition: r .2s; }
.km-pulse { fill: none; stroke: var(--ring); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: km-ring 2.6s ease-out infinite; animation-delay: calc(var(--k) * .25s); }
.km-city:not(.big) .km-pulse { opacity: .5; animation: none; }
@keyframes km-ring { 0% { opacity: .9; transform: scale(.7); } 100% { opacity: 0; transform: scale(3); } }
.km-city:hover .km-core, .km-city:focus-visible .km-core, .km-city.sel .km-core { fill: var(--ring); }
.km-labels text { pointer-events: none; fill: var(--text); font-size: 17px; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.kmap-legend { display: flex; align-items: center; justify-content: center; gap: 4px; margin-block-start: 8px; font-size: 12px; color: var(--muted); }
.kmap-legend i { inline-size: 22px; block-size: 8px; border-radius: 3px; }
.kmap-legend span { margin-inline: 6px; }
.kmap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.kmap-list a { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; grid-template-areas: "rank name val" "rank bar bar"; gap: 3px 10px; align-items: center;
  padding: 7px 10px; border-radius: 8px; color: var(--text); }
.kmap-list a:hover, .kmap-list li.sel a { background: var(--brand-soft); }
.kl-rank { grid-area: rank; font-size: 12px; color: var(--muted); }
.kl-name { grid-area: name; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kl-v { grid-area: val; display: none; font-variant-numeric: tabular-nums; font-weight: 600; }
.kl-v small { color: var(--muted); font-weight: 400; }
.kmap[data-metric="ads"] .v-ads, .kmap[data-metric="price"] .v-price, .kmap[data-metric="fresh"] .v-fresh { display: inline; }
.kl-bar { grid-area: bar; block-size: 5px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.kl-bar i { display: block; block-size: 100%; inline-size: var(--wa); border-radius: inherit; background: var(--k4); transition: inline-size .6s cubic-bezier(.2,.8,.2,1); }
.kmap[data-metric="price"] .kl-bar i { inline-size: var(--wp); } .kmap[data-metric="fresh"] .kl-bar i { inline-size: var(--wf); }
.kmap-note { margin: 10px 0 0; }
@media (max-width: 900px) { .kmap-body { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .km-labels text { font-size: 28px; stroke-width: 7px; } .kmap-head .seg-tabs { inline-size: 100%; } .seg-tabs button { flex: 1; padding-inline: 6px; } }
@media (prefers-reduced-motion: reduce) { .kmap.play .km-dots circle, .km-pulse { animation: none; } }

/* =====================================================================================
   Design v2 (2026-10-22): the dashboard system (as in next-gen): canvas + white
   cards with hairline borders, Geist / Geist Mono, uppercase mono micro-labels, big tabular
   numbers, delta pills, gradient bars, pill filters. Light and dark, LTR and RTL.
   ===================================================================================== */
:root {
  --bg: #f7f8fc; --surface: #ffffff; --surface-2: #f3f4fb; --text: #11121a; --ink-2: #464a61; --muted: #6e7289;
  --line: rgba(17, 18, 26, .08); --line-2: rgba(17, 18, 26, .05);
  --brand: #012af6; --brand-ink: #ffffff; --brand-soft: rgba(1, 42, 246, .08); --violet: #3d63ff; --sky: #3aace2; --bar: #2f55f7;
  --ok: #13784a; --ok-bg: #e3f4ea; --crit: #b83232; --crit-bg: #fbe3e3; --minor: #9a5b00; --minor-bg: #fbf0d9;
  --blue: #2f64c4; --blue-bg: #e7eefb;
  --grad-brand: linear-gradient(120deg, #012af6 0%, #4d7cff 100%);
  --grad-ai: linear-gradient(120deg, #012af6 0%, #3aace2 100%);
  --shadow: none;
  --shadow-sm: 0 1px 2px rgba(17, 18, 26, .04), 0 2px 8px rgba(17, 18, 26, .03);
  --shadow-lg: 0 24px 60px -24px rgba(1, 20, 120, .22), 0 8px 24px -12px rgba(17, 18, 26, .08);
  --r-card: 20px; --radius: 20px;
  --sans: "Geist", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --side-w: 260px; --side-w-mini: 76px;
}
:root[data-theme="dark"] {
  --bg: #0b0c13; --surface: #14151f; --surface-2: #1c1e2b; --text: #eceefa; --ink-2: #c3c6dc; --muted: #8b8fab;
  --line: rgba(236, 238, 250, .09); --line-2: rgba(236, 238, 250, .06);
  --brand: #8ea2ff; --brand-ink: #020a33; --brand-soft: rgba(1, 42, 246, .22); --bar: #6f8bff;
  --ok: #6fd3a0; --ok-bg: rgba(19, 120, 74, .22); --crit: #ff9a92; --crit-bg: rgba(184, 50, 50, .22); --minor: #f0c062; --minor-bg: rgba(154, 91, 0, .24);
  --blue: #8ab4ff; --blue-bg: rgba(47, 100, 196, .2);
  --grad-brand: linear-gradient(120deg, #2f55f7 0%, #7f97ff 100%);
  --shadow-sm: none; --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .7);
}
html[lang="ar"] { --sans: "IBM Plex Sans Arabic", "Geist", ui-sans-serif, system-ui, sans-serif; }
body { font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: rgba(1, 42, 246, .22); }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; border-radius: 6px; }
a:hover { text-decoration: none; }
code, .mono { font-family: var(--mono); }
h1 { font-weight: 560; letter-spacing: -.03em; }
h2 { font-size: 15.5px; font-weight: 570; letter-spacing: -.015em; }
html[lang="ar"] h1, html[lang="ar"] h2 { letter-spacing: 0; }
.page { max-inline-size: 1480px; padding: clamp(20px, 2.6vw, 34px) clamp(16px, 2.4vw, 32px) 64px; }

/* micro-label: mono, uppercase, wide */
.micro, .stat-label, .side-title, .reports th, .an-section small { font-family: var(--mono); }
html[lang="ar"] .micro, html[lang="ar"] .stat-label, html[lang="ar"] .side-title, html[lang="ar"] .reports th { font-family: var(--sans); letter-spacing: 0 !important; text-transform: none !important; }

/* cards */
.card { border-radius: var(--r-card); border: 1px solid var(--line); box-shadow: none; padding: 18px 20px 20px;
  transition: box-shadow .35s var(--ease), border-color .35s var(--ease), transform .35s var(--ease); }
.card.chart:hover, .an-grid > .card:hover, .an-grid > * > .card:hover, .insights > .card:hover, .panel:hover { box-shadow: var(--shadow-lg); border-color: rgba(1, 42, 246, .22); }
.card h2 { margin-block-end: 14px; }
.table-card { padding: 0; }
.card-head { padding: 18px 20px 6px; }

/* KPI tiles */
.stats { gap: 16px; margin-block-end: 22px; }
.stat { gap: 10px; padding: 18px 20px; position: relative; overflow: hidden; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: rgba(1, 42, 246, .25); }
.stat-label { font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat-label .unit { text-transform: none; letter-spacing: 0; }
.stat-value, .stat-value.hero { font-size: clamp(26px, 2.4vw, 32px); font-weight: 520; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-hero .stat-value.hero { background: none; color: var(--text); -webkit-text-fill-color: currentColor; }
.stat .stat-sub, .stat .muted.small { font-size: 12.5px; color: var(--muted); }
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; min-block-size: 26px; }
.delta, .stat .delta { display: inline-flex; align-items: center; gap: 4px; inline-size: fit-content; padding: 3px 8px; border-radius: 99px;
  font-size: 12.5px; font-weight: 540; font-variant-numeric: tabular-nums; }
.delta svg { inline-size: 13px; block-size: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.delta.up { background: var(--ok-bg); color: var(--ok); } .delta.down { background: var(--crit-bg); color: var(--crit); }
.delta.flat { background: var(--surface-2); color: var(--ink-2); }
.spark { inline-size: 96px; block-size: 30px; overflow: visible; flex-shrink: 0; }
.spark polyline { fill: none; stroke: var(--bar); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: spark-draw 1.4s var(--ease) .2s forwards; }
.spark.good polyline { stroke: #1baf7a; }
@keyframes spark-draw { to { stroke-dashoffset: 0; } }
[dir="rtl"] .spark { transform: scaleX(-1); }

/* buttons */
.btn, .btn-ai, .btn-primary { block-size: 40px; padding: 0 16px; border-radius: 11px; font-size: 14px; font-weight: 520; letter-spacing: -.01em; gap: 8px;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background-color .25s, color .25s, border-color .25s; }
.btn { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--text); }
.btn:not(.btn-primary):not(.btn-ai):hover { border-color: rgba(1, 42, 246, .3); color: var(--text); transform: translateY(-1px); }
.btn-primary { background: var(--brand); border-color: transparent; color: var(--brand-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 8px 24px -10px rgba(1, 42, 246, .7); }
.btn-primary:hover { filter: none; background: #33378a; transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 14px 30px -12px rgba(1, 42, 246, .8); }
:root[data-theme="dark"] .btn-primary:hover { background: #b9bcff; }
.btn-ai { background: var(--grad-ai); color: #fff; border: 0; box-shadow: 0 8px 24px -12px rgba(1, 42, 246, .8); }
.btn-ai:hover { filter: none; transform: translateY(-1px); }
.btn-ghost { box-shadow: none; }
.btn-sm { block-size: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.icon-btn { display: inline-grid; place-items: center; inline-size: 34px; block-size: 34px; padding: 0; border: 0; border-radius: 10px;
  background: none; color: var(--ink-2); cursor: pointer; transition: background .2s, color .2s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { inline-size: 16px; block-size: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[disabled] { opacity: .45; cursor: not-allowed; }

/* tags / badges */
.badge, .tag { display: inline-flex; align-items: center; gap: 6px; block-size: 24px; padding: 0 9px; border-radius: 99px;
  font: 500 11px/1 var(--mono); letter-spacing: .04em; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
html[lang="ar"] .badge, html[lang="ar"] .tag { font-family: var(--sans); font-size: 12px; letter-spacing: 0; }
.badge.big { block-size: 28px; font-size: 12px; padding: 0 12px; }
.tag svg { inline-size: 12px; block-size: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tag.live, .status-ok { background: var(--ok-bg); color: var(--ok); }
.status-partial, .tag.warn { background: var(--minor-bg); color: var(--minor); }
.status-failed { background: var(--crit-bg); color: var(--crit); }
.status-running, .tag.brand { background: var(--brand-soft); color: var(--brand); }
.live-badge { display: inline-flex; align-items: center; gap: 8px; block-size: 28px; padding: 0 12px; border-radius: 99px;
  background: var(--ok-bg); color: var(--ok); font-size: 12.5px; font-weight: 560; white-space: nowrap; }
.live-badge i { inline-size: 7px; block-size: 7px; border-radius: 50%; background: currentColor; animation: live-pulse 2s infinite; }
.live-badge small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(19, 120, 74, .45); } 70% { box-shadow: 0 0 0 7px rgba(19, 120, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(19, 120, 74, 0); } }

/* tables */
.reports th { padding: 10px; font-size: 10.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  background: none; border-block-end: 1px solid var(--line); white-space: nowrap; }
.reports td { padding: 11px 10px; border-block-end: 1px solid var(--line-2); color: var(--ink-2); font-size: 13.5px; }
.reports th:first-child, .reports td:first-child { padding-inline-start: 20px; }
.reports th:last-child, .reports td:last-child { padding-inline-end: 20px; }
.reports td:first-child { color: var(--text); }
.reports tbody tr { transition: background .2s; }
.reports tbody tr:hover { background: var(--surface-2); }
.reports tbody tr:last-child td { border-block-end: 0; }
.reports td.num, .reports .num { font-family: var(--mono); font-size: 12.5px; }
.reports td.price { color: var(--text); font-weight: 560; }

/* inputs */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]), select { block-size: 40px; border-radius: 11px; border-color: var(--line);
  background: var(--surface); transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px rgba(1, 42, 246, .14); }

/* sidebar + top bar */
.sidebar { padding: 16px 12px; gap: 6px; }
.side-brand { block-size: 44px; padding: 0 6px 0 8px; border: 0; margin-block-end: 10px; }
.side-title { padding: 14px 12px 6px; margin: 0; font-size: 10.5px; font-weight: 500; letter-spacing: .12em; }
.side-nav { gap: 0; }
.side-nav a { block-size: 40px; padding: 0 12px; gap: 12px; border-radius: 11px; font-size: 14.5px; font-weight: 450; color: var(--ink-2);
  transition: background .2s, color .2s; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 560; }
.side-nav a[aria-current="page"]::before { inset-block: 10px; background: var(--grad-brand); }
.nav-ico { inline-size: 18px; block-size: 18px; stroke-width: 2; }
.side-collapse { block-size: 40px; border-radius: 11px; }
.topbar { min-block-size: 64px; padding: 0 clamp(16px, 2.4vw, 32px); background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px); border-block-end: 1px solid var(--line); }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs b { color: var(--text); font-weight: 560; }
.theme-toggle, .lang-pill { border-color: var(--line); }
.user-menu > summary { border-color: transparent; padding-block: 3px; }
.user-menu > summary:hover { background: var(--surface-2); border-color: transparent; }
.avatar { inline-size: 32px; block-size: 32px; background: var(--grad-brand); }
.menu-panel { border-radius: 18px; padding: 8px; box-shadow: 0 30px 80px -30px rgba(17, 18, 26, .35), var(--shadow-sm); animation: pop-in .22s var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

/* ---- page header (product style) ---- */
.p-hero { display: grid; gap: 18px; margin-block-end: 22px; }
.p-hero-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; }
.p-hero-id { display: flex; gap: 16px; align-items: flex-start; min-inline-size: 0; }
.p-tile { flex-shrink: 0; display: grid; place-items: center; inline-size: 52px; block-size: 52px; border-radius: 15px; background: var(--grad-brand); color: #fff;
  font-size: 20px; font-weight: 600; box-shadow: 0 10px 24px -12px rgba(1, 42, 246, .7); }
.p-tile svg { inline-size: 22px; block-size: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.p-tile.plat { background: var(--c); color: var(--on, #fff); }
.p-eyebrow { display: block; font: 500 12px var(--mono); letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
html[lang="ar"] .p-eyebrow { font-family: var(--sans); letter-spacing: 0; }
.p-hero h1 { margin-block-start: 4px; font-size: clamp(26px, 2.8vw, 36px); line-height: 1.08; letter-spacing: -.035em; font-weight: 560; }
html[lang="ar"] .p-hero h1 { line-height: 1.3; }
.p-hero .tagline { margin: 8px 0 0; max-inline-size: 72ch; font-size: 15.5px; color: var(--ink-2); }
.p-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.p-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.p-actions form { margin: 0; }

/* ---- filter bar: white rounded bar, pill selects with a prefix ---- */
.fbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; margin-block-end: 22px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); }
.fbar-label { padding: 0 6px; font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
html[lang="ar"] .fbar-label { font-family: var(--sans); letter-spacing: 0; font-size: 12px; }
.fpill { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; min-block-size: 38px; padding: 0 8px 0 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent; font-size: 13.5px; color: var(--text); cursor: pointer; transition: background .2s, border-color .2s, box-shadow .2s; }
[dir="rtl"] .fpill { padding: 0 12px 0 8px; }
.fpill:hover { background: color-mix(in oklab, var(--surface-2) 70%, var(--brand-soft)); }
.fpill:focus-within { background: var(--surface); border-color: var(--violet); box-shadow: 0 0 0 4px rgba(1, 42, 246, .14); }
.fpill > span { flex-shrink: 0; font-size: 12.5px; color: var(--muted); }
.fpill > span::after { content: ":"; }
.fpill select, .fpill input { block-size: 36px !important; min-inline-size: 0; padding: 0 4px; border: 0 !important; border-radius: 0 !important; background: transparent !important;
  box-shadow: none !important; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; }
.fpill select { max-inline-size: 190px; }
.fpill input[type="number"] { inline-size: 84px; cursor: text; }
.fpill.search { flex: 1 1 240px; cursor: text; }
.fpill.search input { flex: 1; inline-size: 100%; cursor: text; }
.fpill.search svg { inline-size: 15px; block-size: 15px; color: var(--violet); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fbar .spacer { flex: 1; }
.fbar .btn { block-size: 38px; }
@media (max-width: 760px) { .fbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .fbar::-webkit-scrollbar { display: none; } .fpill.search { flex: 0 0 220px; } }

/* ---- horizontal bars ("top N"): track, brand bar, first one a gradient, grow in ---- */
.hbars { gap: 4px; }
.hbars li { grid-template-columns: minmax(80px, 38%) minmax(0, 1fr) 64px; gap: 12px; padding: 5px 6px; border-radius: 9px; font-size: 13px; transition: background .2s; }
.hbars li:hover { background: var(--surface-2); }
.hbar-label { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); min-inline-size: 0; }
.hbar-label > b, .hbar-label > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 450; }
a.hbar-label:hover { color: var(--brand); }
.hbar-track { block-size: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.hbar { border-radius: 99px; background: var(--bar); transform-origin: left; animation: bar-in 1s var(--ease) both; }
[dir="rtl"] .hbar { border-radius: 99px; transform-origin: right; }
.hbars li:first-child .hbar { background: linear-gradient(90deg, var(--bar), var(--violet)); }
[dir="rtl"] .hbars li:first-child .hbar { background: linear-gradient(-90deg, var(--bar), var(--violet)); }
.hbars li:nth-child(2) .hbar { animation-delay: 50ms; } .hbars li:nth-child(3) .hbar { animation-delay: 100ms; } .hbars li:nth-child(4) .hbar { animation-delay: 150ms; }
.hbars li:nth-child(5) .hbar { animation-delay: 200ms; } .hbars li:nth-child(n+6) .hbar { animation-delay: 250ms; }
@keyframes bar-in { from { transform: scaleX(0); } }
.hbar-value { font: 560 12.5px var(--mono); color: var(--text); }

/* make logo tile (white, contained; a letter when there is no logo) */
.mlogo { flex-shrink: 0; display: inline-grid; place-items: center; inline-size: 22px; block-size: 22px; border-radius: 6px; background: #fff; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line-2); font: 600 11px var(--sans); color: var(--brand); }
.mlogo img { inline-size: 100%; block-size: 100%; object-fit: contain; padding: 1px; }
.mlogo.md { inline-size: 26px; block-size: 26px; border-radius: 7px; }
.mlogo.lg { inline-size: 40px; block-size: 40px; border-radius: 11px; padding: 4px; }
:root[data-theme="dark"] .mlogo { background: #f4f5fa; }
.mlogo.letter { background: var(--brand-soft); }

/* ranked list (01, 02 …) */
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: rk; }
.rank li { counter-increment: rk; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: 9px; font-size: 13px; color: var(--ink-2); transition: background .2s; }
.rank li::before { content: counter(rk, decimal-leading-zero); font: 500 10.5px var(--mono); color: var(--muted); }
.rank li:hover { background: var(--surface-2); color: var(--text); }
.rank a { color: inherit; display: inline-flex; align-items: center; gap: 8px; min-inline-size: 0; }
.rank a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank b { font: 560 12.5px var(--mono); color: var(--text); }
.rank small { font: 500 11px var(--mono); color: var(--muted); margin-inline-start: 6px; }
.scale { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-block-end: 10px; font: 500 10.5px var(--mono); color: var(--muted); }
.scale i { block-size: 8px; border-radius: 9px; background: linear-gradient(90deg, #e8edff, #7390ff, #0120b8); }
[dir="rtl"] .scale i { background: linear-gradient(-90deg, #e8edff, #7390ff, #0120b8); }

/* panels grid */
.panels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-block-end: 16px; align-items: stretch; }
.panels > * { margin: 0; min-inline-size: 0; }
.panels .span-2 { grid-column: span 2; } .panels .span-3 { grid-column: 1 / -1; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-block-end: 14px; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
@media (max-width: 1180px) { .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); } .panels .span-2 { grid-column: 1 / -1; } }
@media (max-width: 760px) { .panels { grid-template-columns: minmax(0, 1fr); } }

/* column chart: brand gradient bars, grow up */
.col-bar { background: linear-gradient(180deg, var(--violet), var(--bar)); border-radius: 4px 4px 1px 1px; transform-origin: bottom; animation: col-in .9s var(--ease) both; }
.col.is-today .col-bar { background: linear-gradient(180deg, var(--sky), var(--bar)); }
@keyframes col-in { from { transform: scaleY(0); } }
.cols-tick { border-color: var(--line-2); }
.cols-tick i, .cols-x span { font: 500 10.5px var(--mono); color: var(--muted); }
.chart-head h2 { margin: 0; }
.chart-tip { background: rgba(17, 18, 26, .94); color: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: 0 16px 40px -12px rgba(17, 18, 26, .5); }

/* platforms table (overview) */
.plat-cell { display: flex; align-items: center; gap: 12px; min-inline-size: 0; }
.plat-cell .side-dot { inline-size: 30px; block-size: 30px; border-radius: 9px; font-size: 13px; }
.plat-cell b { display: block; color: var(--text); font-weight: 560; font-size: 14px; }
.plat-cell code { font-size: 11px; color: var(--muted); }
.plat-table td { vertical-align: middle; }
.plat-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
.plat-actions form { margin: 0; display: inline-flex; }
.plat-error { display: block; margin-block-start: 4px; max-inline-size: 360px; font-size: 12px; color: var(--crit); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* runs table: long errors folded */
.err-details { margin-block-start: 4px; }
.err-details summary { cursor: pointer; list-style: none; display: flex; gap: 6px; align-items: baseline; color: var(--crit); font-size: 12.5px; }
.err-details summary::-webkit-details-marker { display: none; }
.err-details summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 340px; }
.err-details summary b { flex-shrink: 0; font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
.err-details[open] summary b { display: none; }
.err-details pre { margin: 6px 0 0; max-block-size: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 11.5px/1.5 var(--mono);
  color: var(--crit); background: var(--crit-bg); padding: 10px 12px; border-radius: 10px; }

/* listings: make logo next to the make line */
.car-cell .make-line { display: flex; align-items: center; gap: 6px; margin-block-start: 2px; }
.car-photo { border-radius: 10px; border-color: var(--line); }

/* entrance for page content */
@media (prefers-reduced-motion: no-preference) {
  .page > * { animation: rise .5s var(--ease) both; }
  .page > *:nth-child(2) { animation-delay: 40ms; } .page > *:nth-child(3) { animation-delay: 80ms; } .page > *:nth-child(n+4) { animation-delay: 120ms; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .hbar, .col-bar, .spark polyline, .page > * { animation: none !important; } .spark polyline { stroke-dashoffset: 0; } }

.ov-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .ov-kpis { grid-template-columns: minmax(0, 1fr); } }
.ov-platforms { margin-block-end: 16px; }
.ov-platforms .card-head, section.table-card > .card-head { padding: 18px 20px 4px; }
.card-head > .panel-head { inline-size: 100%; margin: 0; align-items: center; }
.ov-panels .card { block-size: 100%; }
.ov-panels .chart { margin: 0; block-size: 100%; }
.ov-links { display: flex; flex-wrap: wrap; gap: 8px; }

.pl-facts .rank li { grid-template-columns: 22px minmax(0, 1fr) auto; }
.panels > section.card, .panels > .span-2 > .card { block-size: 100%; }
.panels .chart { margin: 0; }

/* analytics: section titles with a hairline rule */
.an-section { display: flex; align-items: center; gap: 12px; margin: 34px 0 14px; font-size: 18px; font-weight: 570; letter-spacing: -.02em; }
.an-section::after { content: ""; flex: 1; block-size: 1px; background: var(--line); }
.an-section small { order: 3; font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
html[lang="ar"] .an-section small { font-family: var(--sans); letter-spacing: 0; text-transform: none; font-size: 12px; }
.an-grid { gap: 16px; margin-block-end: 16px; }
.stats.an-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .stats.an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .stats.an-kpis { grid-template-columns: minmax(0, 1fr); } }
.kmap { padding: 18px 20px 20px; }
.seg-tabs { padding: 3px; border-radius: 12px; background: var(--surface-2); border: 0; }
.seg-tabs button { block-size: 32px; padding: 0 12px; border-radius: 9px; font-weight: 500; color: var(--ink-2); }
.seg-tabs button.on { background: var(--surface); color: var(--text); font-weight: 560; box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .seg-tabs button.on { background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); }

/* sidebar: fits 16 links + 3 groups on a 900px screen */
.side-title { padding: 10px 12px 4px; }
.side-nav a { block-size: 36px; }
.side-brand { margin-block-end: 4px; }
/* donut: smaller ring, legend gets the room (names not cut) */
.donut-wrap { grid-template-columns: minmax(110px, 140px) minmax(0, 1fr); gap: 14px; }
.legend-list li { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 6px; font-size: 12.5px; }
.legend-list .lg-label { min-inline-size: 60px; }

/* sync runs: one compact button per platform */
.run-panel { margin-block-end: 16px; }
.run-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.run-grid form { margin: 0; display: grid; }
.run-btn { display: flex; align-items: center; gap: 10px; block-size: 46px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 520; cursor: pointer; text-align: start;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s; }
.run-btn:hover { transform: translateY(-1px); border-color: rgba(1, 42, 246, .35); box-shadow: var(--shadow-lg); color: var(--text); }
.run-btn > span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-btn svg { inline-size: 16px; block-size: 16px; color: var(--violet); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.run-btn small { font-size: 11.5px; color: var(--muted); }
.run-btn:active svg { transform: rotate(180deg); transition: transform .4s var(--ease); }

/* --- MMYT pages (catalog: makes, models, years, needs linking) ------------------------------ */
.page-head .cat-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cat-export { position: relative; }
.cat-export > summary { list-style: none; cursor: pointer; }
.cat-export > summary::-webkit-details-marker { display: none; }
.cat-export-menu { position: absolute; inset-inline-end: 0; inset-block-start: calc(100% + 6px); z-index: 20; min-inline-size: 260px; display: grid; gap: 6px; padding: 12px; }
.cat-export-menu a { font-family: var(--mono); font-size: 13px; }
.cat-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-block: 4px 14px; border-block-end: 1px solid var(--line); }
.cat-tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-block-end: 2px solid transparent; margin-block-end: -1px; font-weight: 600; }
.cat-tabs a.on { color: var(--text); border-color: var(--brand, #012af6); }
.cat-tabs.sub { border: 0; margin-block: 18px 6px; }
.cat-tabs.sub a { border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; margin: 0; }
.cat-tabs.sub a.on { background: var(--surface); border-color: var(--brand, #012af6); }
.cat-tabs .count { font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.cat-name { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.cat-name:hover b { text-decoration: underline; }
.cat-table td { vertical-align: middle; }
.chip-ours { background: var(--purple-bg); color: var(--purple); }
.cat-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-block-end: 16px; }
@media (max-width: 900px) { .cat-grid { grid-template-columns: 1fr; } }
.cat-form { display: grid; gap: 14px; }
.cat-form.narrow { max-inline-size: 720px; }
.cat-form h2 { margin: 0; }
.cat-form label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.cat-form textarea { font-family: inherit; }
.cat-title { display: flex; align-items: center; gap: 14px; }
.mlogo.big { inline-size: 48px; block-size: 48px; }
.link-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.link-form input { inline-size: 150px; }
.link-form select { max-inline-size: 220px; }
.unlinked .examples a { display: block; max-inline-size: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.unlinked .chip .side-dot { inline-size: 8px; block-size: 8px; font-size: 0; margin-inline-end: 4px; }
.btn.danger { color: var(--crit); }

/* Ad types (app.ad_rules): one colour per type, text in ink */
.chip.type-new { background: var(--blue-bg); color: var(--blue); }
.chip.kind-new { background: var(--blue-bg); color: var(--blue); }
.chip.kind-used { background: var(--info-bg); color: var(--info); }
.chip.type-installment, .chip.type-finance { background: var(--purple-bg); color: var(--purple); }
.chip.type-showroom { background: var(--surface-2, #f3f4fb); color: var(--ink-2, #464a61); }
.chip.type-bidding { background: #fff4e5; color: #8a5300; }
:root[data-theme="dark"] .chip.type-bidding { background: #3a2a10; color: #f0b866; }
.chip-row.ad-types { margin-block: 6px 2px; }
.chip-row.ad-types a.chip { text-decoration: none; }
.feat-chips { margin-block-start: 12px; }
.chip.chip-good { background: var(--ok-bg); color: var(--ok); }  /* condition notes on the ad page */
/* VIN chip (every platform) and Safqa Auction listing states (list rows and the ad page) */
.chip.chip-vin { background: var(--ok-bg); color: var(--ok); font-weight: 700; letter-spacing: .04em; }
.vin-line { margin: 4px 0 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vin-line .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.chip.state-live { background: var(--crit-bg); color: var(--crit); }
.chip.state-online { background: var(--blue-bg); color: var(--blue); }
.chip.state-buynow { background: #fff4cc; color: #7a5b00; }
.chip.state-sold { background: var(--ok-bg); color: var(--ok); }
.chip.state-ended { background: var(--line, #eee); color: var(--muted, #666); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.state-buynow { background: #3a2f05; color: #ffd84d; } }
:root[data-theme="dark"] .chip.state-buynow { background: #3a2f05; color: #ffd84d; }
/* Full API data: one block per API answer (list / details / inspection) */
.raw .raw-part { margin: 8px 0 0; border-top: 1px solid var(--line); padding-top: 8px; }
.raw .raw-part > summary { cursor: pointer; font-weight: 600; font-size: 13px; }
/* Damage tags (every platform): red for damage, green for a normal working car */
.chip[class*="damage-"] { background: var(--crit-bg); color: var(--crit); text-decoration: none; }
.chip.damage-no_damage { background: var(--ok-bg); color: var(--ok); }
.chip.damage-not_working, .chip.damage-damaged { background: #fff1e0; color: #8a4b00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.damage-not_working, :root:not([data-theme="light"]) .chip.damage-damaged { background: #3a2410; color: #ffb366; } }
:root[data-theme="dark"] .chip.damage-not_working, :root[data-theme="dark"] .chip.damage-damaged { background: #3a2410; color: #ffb366; }
.chip.damage-minor_accident { background: #fff4cc; color: #7a5b00; }
:root[data-theme="dark"] .chip.damage-minor_accident { background: #3a2f05; color: #ffd84d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.damage-minor_accident { background: #3a2f05; color: #ffd84d; } }
/* Imported car tag (every platform) */
.chip.chip-imported { background: var(--blue-bg); color: var(--blue); text-decoration: none; font-weight: 600; }

/* Overview: "Download all ads CSV" (app.exports): its own row under Analytics / Sync runs, at the
   row's end, the last file's date · ads · size under the button */
.p-actions:has(.export-all) { display: grid; grid-template-columns: auto auto; justify-content: end; align-items: center; }
.export-all { grid-column: 1 / -1; justify-self: end; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.export-meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
a.export-meta:hover { color: var(--text); text-decoration: underline; }
.export-meta.crit { color: var(--crit); }
.export-earlier { display: flex; flex-direction: column; align-items: flex-end; }
.export-earlier summary { cursor: pointer; list-style: none; }
.export-earlier summary::-webkit-details-marker { display: none; }
.export-earlier[open] { gap: 4px; }
.export-earlier[open] summary { margin-block-end: 2px; }
.btn.is-busy { cursor: progress; gap: 8px; font-variant-numeric: tabular-nums; }
.btn.is-failed { border-color: var(--crit); color: var(--crit); }
.btn .spin { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; animation: export-spin .9s linear infinite; }
@keyframes export-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn .spin { animation-duration: 2.4s; } }
/* header buttons' icons are line drawings (the Analytics icon had no stroke: it did not show) */
.p-actions .btn svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
