/* ============================================================
   Admin dashboard — Sulaiman AlRajhi Real Estate
   Brand primary from the logo (#667882). Chart series: #2f7fb5
   (validated: lightness, chroma, contrast ≥ 3:1 on white).
   ============================================================ */

:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --ink: #1f2427;
  --ink-2: #4f5559;
  --muted: #7b8083;
  --line: #e6e7e5;
  --line-2: #d6d9db;

  --primary: #667882;
  --primary-600: #55666f;
  --primary-50: #eef1f3;
  --primary-100: #dfe5e8;

  --series: #2f7fb5;
  --series-wash: rgba(47, 127, 181, 0.10);
  --series-track: #e7eff6;

  --good: #0ca30c;
  --good-text: #006300;
  --good-bg: #e8f6e8;
  --warning: #fab219;
  --warning-text: #7a5200;
  --warning-bg: #fff5dd;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-text: #a52a2a;
  --critical-bg: #fdeceb;
  --info-text: #3d4d56;
  --info-bg: #eef1f3;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(31, 36, 39, 0.04), 0 4px 16px -8px rgba(31, 36, 39, 0.10);
  --font: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 256px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body.admin {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-600); text-decoration: none; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.nowrap { white-space: nowrap; }
.d-block { display: block; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 16px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
}
.sidebar__brand { display: block; padding: 4px 8px 12px; border-bottom: 1px solid var(--line); }
.sidebar__brand img { display: block; width: 150px; height: auto; }

.sidebar__nav { display: flex; flex-direction: column; gap: 4px; }
.navlink {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 600;
  transition: background .15s, color .15s;
}
.navlink svg { flex: none; color: var(--muted); }
.navlink:hover { background: var(--surface-2); color: var(--ink); }
.navlink.is-active { background: var(--primary-50); color: var(--ink); }
.navlink.is-active svg { color: var(--primary); }
.navlink__badge {
  margin-inline-start: auto;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me__avatar {
  flex: none;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary-600);
  font-weight: 700;
}
.me__text { display: flex; flex-direction: column; min-width: 0; }
.me__text strong { font-size: 13px; }
.me__text small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: end; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 32px 10px;
}
.topbar__titles { min-width: 0; flex: 1; }
.topbar__title { margin: 0; font-size: 22px; line-height: 1.35; font-weight: 700; }
.topbar__sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar__menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.topbar__menu span { width: 18px; height: 2px; background: var(--ink); display: block; }

.content { padding: 12px 32px 40px; display: flex; flex-direction: column; gap: 20px; }

.flash {
  margin: 8px 32px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--good-bg);
  color: var(--good-text);
  font-weight: 600;
}

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--primary); border-color: var(--primary-600); color: #fff; }
.btn--primary:hover { background: var(--primary-600); color: #fff; }
.btn--ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn--ghost:hover { border-color: var(--primary); color: var(--ink); background: var(--surface-2); }
.btn--danger { background: var(--surface); border-color: var(--critical); color: var(--critical-text); }
.btn--danger:hover { background: var(--critical); color: #fff; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--icon { width: 34px; padding: 0; font-size: 18px; }

.ctl {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.ctl:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102, 120, 130, 0.18); }
.ctl--sm { min-height: 34px; padding: 4px 10px; font-size: 13px; width: auto; }
select.ctl { cursor: pointer; }
textarea.ctl { resize: vertical; min-height: 96px; line-height: 1.6; }

.fld { display: flex; flex-direction: column; gap: 6px; }
.fld__label { font-size: 12px; font-weight: 700; color: var(--ink-2); padding: 0; }
.fld--inline { flex-direction: row; align-items: center; gap: 8px; }
.fld--inline .ctl { width: auto; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.field-error { margin: 0; color: var(--critical-text); font-size: 13px; }

.link { font-weight: 700; font-size: 13px; color: var(--primary-600); }
.link:hover { color: var(--ink); text-decoration: underline; }
.link--muted { color: var(--muted); font-weight: 600; }
.strong-link { color: var(--ink); font-weight: 700; }
.strong-link:hover { color: var(--series); }

/* ---------- Cards & layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card--flush { padding: 0; overflow: hidden; }
.card--flush .table th:first-child, .card--flush .table td:first-child { padding-inline-start: 22px; }
.card--warn { border-color: #f3d9a4; background: #fffcf4; }
.card--danger { border-color: #f2c9c6; }
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card__head--sub { margin-top: 26px; }
.card__title { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card__meta { color: var(--muted); font-size: 12px; }
.card__foot { padding: 14px 22px; border-top: 1px solid var(--line); }
.subhead { margin: 24px 0 10px; font-size: 14px; font-weight: 700; }

.grid { display: grid; gap: 20px; }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.empty { margin: 0; padding: 18px 0; color: var(--muted); text-align: center; }
.empty--big { padding: 56px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty--big svg { color: var(--line-2); }

.num-tag {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 22px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
}

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.seg__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.seg__btn::-webkit-details-marker { display: none; }
.seg__btn:hover { background: var(--surface-2); color: var(--ink); }
.seg__btn.is-active { background: var(--primary); color: #fff; }
.custom-range { position: relative; }
.custom-range__panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px -12px rgba(31, 36, 39, 0.25);
  min-width: 300px;
}
.filters__selects { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.filter-panel { display: flex; flex-direction: column; gap: 14px; }
.filter-panel__search { position: relative; }
.filter-panel__search svg { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 12px; color: var(--muted); pointer-events: none; }
.filter-panel__search .ctl { padding-inline-start: 38px; min-height: 44px; }
.filter-panel__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.filter-panel__actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.filter-panel__count { margin-inline-start: auto; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs__tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-weight: 600;
}
.tabs__tab:hover { color: var(--ink); }
.tabs__tab.is-active { color: var(--ink); border-bottom-color: var(--primary); }
.tabs__count {
  min-width: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}
.tabs__tab.is-active .tabs__count { background: var(--primary); color: #fff; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.kpi__label { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.kpi__value { font-size: 28px; font-weight: 700; line-height: 1.2; color: var(--ink); }
.kpi--hero .kpi__value { font-size: 40px; }
.kpi--hero { border-top: 3px solid var(--primary); }
.kpi__delta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; font-size: 12px; font-weight: 700; }
.kpi__delta--up { color: var(--good-text); }
.kpi__delta--down { color: var(--critical-text); }
.kpi__delta--flat { color: var(--muted); }
.kpi__vs { color: var(--muted); font-weight: 400; }

/* ---------- Charts ---------- */
.charts-stack { display: flex; flex-direction: column; gap: 22px; }
.chart { position: relative; margin: 0; }
.chart__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.chart__title { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.chart__total { font-size: 12px; color: var(--muted); }
.chart__total strong { color: var(--ink); font-size: 14px; }
.chart__plot { width: 100%; outline: none; border-radius: 4px; }
.chart__plot:focus-visible { box-shadow: 0 0 0 2px var(--series); }
.chart__svg { display: block; overflow: visible; font-family: var(--font); }
.chart__gridline { stroke: #ecedeb; stroke-width: 1; shape-rendering: crispEdges; }
.chart__baseline { stroke: #c9ccc6; stroke-width: 1; shape-rendering: crispEdges; }
.chart__tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart__line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__area { fill: var(--series-wash); stroke: none; }
.chart__dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart__bar { fill: var(--series); transition: opacity .12s; }
.chart__bar.is-active { fill: #256a99; }
.chart__cross { stroke: var(--ink-2); stroke-width: 1; stroke-opacity: .35; shape-rendering: crispEdges; }
.chart__tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 11px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .4);
}
.chart__tip strong { font-size: 14px; }
.chart__tip span { color: #c9cfd2; }
.chart__table { margin-top: 6px; }
.chart__table summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; width: max-content; padding: 8px 0; }
.chart__table summary:hover { color: var(--ink); }
.chart__table .table-wrap { max-height: 260px; overflow: auto; margin-top: 8px; }

/* Ranked bar lists */
.barlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.barlist__row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto; align-items: center; gap: 10px; }
.barlist__label { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist__label a { color: var(--ink); }
.barlist__label a:hover { color: var(--series); }
.barlist__track { height: 10px; background: var(--series-track); border-radius: 0 4px 4px 0; overflow: hidden; display: flex; justify-content: flex-start; }
[dir="rtl"] .barlist__track { border-radius: 4px 0 0 4px; }
.barlist__bar { height: 100%; background: var(--series); border-radius: 0 4px 4px 0; }
[dir="rtl"] .barlist__bar { border-radius: 4px 0 0 4px; }
.barlist__value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 72px; text-align: end; }
.barlist__value small { color: var(--muted); font-weight: 400; font-size: 12px; margin-inline-start: 4px; }

.cellbar { display: inline-block; width: 60px; height: 6px; margin-inline-end: 8px; background: var(--series-track); border-radius: 3px; vertical-align: middle; overflow: hidden; }
.cellbar__bar { display: block; height: 100%; background: var(--series); border-radius: 3px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  padding: 10px 12px;
  text-align: start;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table--compact td { padding: 9px 12px; }
.table--rows tbody tr { cursor: pointer; transition: background .12s; }
.table--rows tbody tr:hover { background: #f8f9f9; }
.actions-cell { text-align: end; }

.person { display: flex; align-items: center; gap: 10px; }
.person__avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--primary-50); }
.person__avatar--empty { display: grid; place-items: center; color: var(--primary-600); font-weight: 700; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip--soft { background: #f1f0ec; }
.chips-line { display: flex; flex-wrap: wrap; gap: 6px; }

/* Visitor location & identity */
.flag {
  display: inline-block;
  width: 18px;
  height: 13px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(31, 36, 39, 0.12);
  background: var(--line);
  vertical-align: -2px;
  margin-inline-end: 7px;
}
.geo { display: inline-flex; align-items: center; font-weight: 600; }
.ip {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, 'SFMono-Regular', monospace;
  font-size: 11.5px;
  direction: ltr;
  unicode-bidi: isolate;
}
.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-stack .small { line-height: 1.45; }

/* Status badges — status colours never carry meaning alone (icon + label) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ink);
}
.badge svg { flex: none; }
.badge--new { background: var(--info-bg); }
.badge--new svg { color: var(--primary); }
.badge--reviewing { background: var(--warning-bg); }
.badge--reviewing svg { color: #b47a00; }
.badge--approved { background: var(--good-bg); }
.badge--approved svg { color: var(--good); }
.badge--rejected { background: var(--critical-bg); }
.badge--rejected svg { color: var(--critical); }

.flag { display: inline-block; width: auto; height: auto; padding: 0 8px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; box-shadow: none; vertical-align: baseline; }
.flag--critical { background: var(--critical-bg); color: var(--critical-text); }
.flag--warning { background: var(--warning-bg); color: var(--warning-text); }
.flag--good { background: var(--good-bg); color: var(--good-text); }

.files-count { display: inline-flex; align-items: center; gap: 4px; color: var(--critical-text); font-weight: 700; font-size: 12px; }
.files-count.is-complete { color: var(--ink-2); }

.status-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.status-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.status-tile:hover { border-color: var(--primary); background: var(--surface-2); color: var(--ink); }
.status-tile__value { font-size: 26px; font-weight: 700; line-height: 1.1; }

/* ---------- Pagination ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; }
.card__foot .pager { padding-top: 0; }
.pager__info { color: var(--muted); font-size: 12px; }
.pager__links { display: flex; flex-wrap: wrap; gap: 4px; }
.pager__btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.pager__btn:hover { border-color: var(--primary); color: var(--ink); }
.pager__btn.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager__btn.is-disabled { opacity: .45; pointer-events: none; }
.pager__dots { padding: 0 4px; color: var(--muted); align-self: center; }

/* ---------- Submission detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.detail__main, .detail__side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.detail__side { position: sticky; top: 16px; }

.profile { display: flex; gap: 20px; align-items: center; }
.profile__photo { flex: none; }
.profile__photo img { display: block; width: 112px; height: 112px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.profile__body { min-width: 0; flex: 1; }
.profile__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.profile__name { margin: 0; font-size: 20px; }
.profile__meta { margin: 4px 0 12px; color: var(--ink-2); }
.profile__links { display: flex; flex-wrap: wrap; gap: 8px; }

.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
.dl > div { min-width: 0; }
.dl__wide { grid-column: 1 / -1; }
.dl dt { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.dl dd { margin: 0; font-weight: 600; word-break: break-word; }
.dl--stack { grid-template-columns: 1fr; gap: 10px; }
.dl--stack > div { display: flex; justify-content: space-between; gap: 12px; }
.dl--stack dd { text-align: end; }
.prose { margin: 0; line-height: 1.8; color: var(--ink-2); }

.checklist { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 10px; color: var(--critical-text); }
.checklist li::before { content: "✕"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--critical-bg); font-size: 11px; font-weight: 700; }
.checklist li.is-ok { color: var(--ink); }
.checklist li.is-ok::before { content: "✓"; background: var(--good-bg); color: var(--good-text); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.status-pick { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-pick legend { margin-bottom: 8px; }
.status-pick__opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.status-pick__opt:hover { border-color: var(--primary); }
.status-pick__opt:has(input:checked) { border-color: var(--primary); background: var(--primary-50); box-shadow: inset 0 0 0 1px var(--primary); }
.status-pick__opt input { accent-color: var(--primary); margin: 0; }

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.files__item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.files__item:last-child { border-bottom: 0; }
.files__icon {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.files__icon--img { background: var(--series); }
.files__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.files__meta strong { font-size: 13px; }
.files__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.mini-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mini-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }
.alert--danger { background: var(--critical-bg); color: var(--critical-text); }

/* ---------- Auth ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, #f2f1f0, #e9ecee); padding: 24px 16px; }
.auth__wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.auth__card {
  width: 100%;
  padding: 32px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 48px -24px rgba(31, 36, 39, 0.25);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth__card::before { content: ""; display: block; height: 3px; width: 64px; background: var(--primary); margin: -32px auto 10px; }
.auth__logo { display: block; width: 170px; height: auto; margin: 4px auto 6px; }
.auth__title { margin: 0; text-align: center; font-size: 18px; }
.auth__sub { margin: -8px 0 4px; text-align: center; color: var(--muted); font-size: 13px; }
.auth__form { display: flex; flex-direction: column; gap: 14px; }
.auth__foot { color: var(--muted); font-size: 12px; margin: 0; }

.sidebar-backdrop { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi--hero { grid-column: span 1; }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .grid--main { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
  .detail__side { position: static; }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 50;
    width: min(86vw, var(--sidebar-w));
    transform: translateX(100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .15);
  }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: none; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(31, 36, 39, .35); }
  .topbar__menu { display: inline-flex; }
  .topbar { padding: 16px 16px 6px; flex-wrap: wrap; }
  .content { padding: 10px 16px 32px; }
  .flash { margin: 8px 16px 0; }
}

@media (max-width: 700px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi--hero { grid-column: 1 / -1; }
  .grid--3 { grid-template-columns: 1fr; }
  .status-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl { grid-template-columns: 1fr; }
  .profile { flex-direction: column; align-items: flex-start; }
  .card { padding: 16px; }
  .topbar__title { font-size: 19px; }
  .custom-range__panel { min-width: 0; width: calc(100vw - 48px); }
  .filter-panel__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Tables on small screens ---------- */
.ref { white-space: nowrap; }
.person__text { min-width: 0; }
.person__status { display: none; }
.filter-panel__toggle {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
}
.filter-panel__toggle::-webkit-details-marker { display: none; }

@media (max-width: 700px) {
  /* Data tables keep a readable width and scroll sideways inside their card */
  .table-wrap > .table { min-width: 620px; }
  .table-wrap > .table--compact { min-width: 560px; }

  /* Application lists become stacked cards (label ⟷ value) */
  .table-wrap > .table--cards { min-width: 0; }
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table--cards tbody tr:last-child { border-bottom: 0; }
  .table--cards td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
    border: 0;
    text-align: start;
  }
  .card--flush .table--cards td:first-child { padding-inline-start: 0; }
  .table--cards td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding-top: 1px;
  }
  .table--cards .td-val { text-align: end; min-width: 0; overflow-wrap: anywhere; }
  .table--cards td.num { text-align: start; }
  .table--cards td.td-main { padding-bottom: 10px; }
  .table--cards td.td-main::before, .table--cards td.td-status { display: none; }
  .table--cards .person { width: 100%; }
  .table--cards .person__status { display: inline-flex; margin-inline-start: auto; }

  /* Advanced filters collapse behind a toggle */
  .filter-panel__toggle { display: inline-flex; }
  .filter-panel__more[open] > .filter-panel__grid { margin-top: 10px; }
  .filter-panel__count { margin-inline-start: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Unit statuses (icon dot + label, never colour alone) */
.badge--available { background: var(--good-bg); }
.badge--available svg { color: var(--good); }
.badge--negotiating { background: var(--info-bg); }
.badge--negotiating svg { color: var(--series); }
.badge--reserved_pending { background: var(--warning-bg); }
.badge--reserved_pending svg { color: #b47a00; }
.badge--reserved_confirmed { background: var(--primary-100); }
.badge--reserved_confirmed svg { color: var(--primary-600); }
.badge--sold { background: #e9e4f5; }
.badge--sold svg { color: #5b3fa0; }
.badge--unavailable { background: var(--line); }
.badge--unavailable svg { color: var(--muted); }

.unit-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-actions form { margin: 0; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-tile { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat-tile__label { color: var(--ink-2); font-size: 12px; font-weight: 600; }
.stat-tile__value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-tile__sub { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { padding-inline-start: 14px; border-inline-start: 3px solid var(--line-2); }

/* Marketer units: action buttons stay compact on desktop and become a tap-friendly grid on phones */
.unit-actions .btn { white-space: nowrap; }
@media (max-width: 700px) {
  .table--cards td.td-actions { display: block; padding-top: 10px; }
  .table--cards td.td-actions::before { display: none; }
  .unit-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .unit-actions .btn { width: 100%; min-height: 42px; justify-content: center; }
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs { flex-wrap: nowrap; gap: 0; }
  .tabs__tab { flex: 1; justify-content: center; padding-inline: 6px; font-size: 13px; white-space: nowrap; }
  .table--cards td.td-main { flex-direction: column; align-items: flex-start; gap: 2px; }
}

/* Notification bell */
.bell { position: relative; }
.bell > summary { list-style: none; cursor: pointer; position: relative; }
.bell > summary::-webkit-details-marker { display: none; }
.bell__count { position: absolute; top: -6px; inset-inline-start: -6px; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--critical); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.bell__panel { position: absolute; z-index: 60; top: calc(100% + 8px); inset-inline-end: 0; width: min(340px, 86vw); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.15); }
.bell__head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.bell__head form { margin: 0; }
.bell__head .link { background: none; border: 0; cursor: pointer; font: inherit; font-size: 12px; color: var(--primary-600); }
.bell__item { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--ink); border-inline-start: 3px solid transparent; }
.bell__item:last-child { border-bottom: 0; }
.bell__item span { font-size: 12px; color: var(--ink-2); }
.bell__item.is-unread { background: var(--primary-50); }
.bell__item--good { border-inline-start-color: var(--good); }
.bell__item--warning { border-inline-start-color: var(--warning); }
.bell__item--critical { border-inline-start-color: var(--critical); }
.bell__empty { padding: 16px; margin: 0; }

/* Marketer profile: account details and password side by side, stacked on small screens */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 700px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-grid .dl dd[dir="ltr"] { text-align: end; }


/* ============================================================
   Vibrant statistics — colourful tiles, charts and bars
   (colour is never the only signal: every tile keeps its label/value)
   ============================================================ */
:root {
  --c-blue: #2f7fb5;   --c-blue-bg: #e6f1fa;
  --c-teal: #14a38b;   --c-teal-bg: #e1f6f1;
  --c-violet: #7c5cd6; --c-violet-bg: #efeafb;
  --c-amber: #e8a317;  --c-amber-bg: #fff3d6;
  --c-rose: #e0527a;   --c-rose-bg: #fde8ee;
  --c-green: #2fa24a;  --c-green-bg: #e5f6e8;
  --c-red: #d9473f;    --c-red-bg: #fdeceb;
}

/* KPI tiles */
.kpi { --accent: var(--c-blue); --accent-bg: var(--c-blue-bg); position: relative; overflow: hidden; border: 0; background: linear-gradient(160deg, var(--accent-bg) 0%, #fff 62%); box-shadow: 0 1px 2px rgba(31,36,39,.05), 0 8px 22px -12px color-mix(in srgb, var(--accent) 55%, transparent); }
.kpi::before { content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 4px; background: var(--accent); }
.kpi::after { content: ""; position: absolute; inset-block-end: -28px; inset-inline-end: -28px; width: 96px; height: 96px; border-radius: 50%; background: var(--accent); opacity: .08; }
.kpi:nth-child(2) { --accent: var(--c-teal); --accent-bg: var(--c-teal-bg); }
.kpi:nth-child(3) { --accent: var(--c-violet); --accent-bg: var(--c-violet-bg); }
.kpi:nth-child(4) { --accent: var(--c-amber); --accent-bg: var(--c-amber-bg); }
.kpi:nth-child(5) { --accent: var(--c-rose); --accent-bg: var(--c-rose-bg); }
.kpi--hero { border-top: 0; }
.kpi__value { color: color-mix(in srgb, var(--accent) 72%, #1f2427); }

/* Stat tiles (units overview, marketer dashboard, marketer stats) */
.stat-tile { --accent: var(--c-blue); --accent-bg: var(--c-blue-bg); position: relative; overflow: hidden; border: 0; background: linear-gradient(160deg, var(--accent-bg) 0%, #fff 70%); box-shadow: 0 1px 2px rgba(31,36,39,.05), 0 8px 20px -14px color-mix(in srgb, var(--accent) 60%, transparent); padding-inline-start: 20px; transition: transform .15s, box-shadow .15s; }
.stat-tile::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 5px; background: var(--accent); }
a.stat-tile:hover { transform: translateY(-2px); }
.stat-tile:nth-child(5n+2) { --accent: var(--c-teal); --accent-bg: var(--c-teal-bg); }
.stat-tile:nth-child(5n+3) { --accent: var(--c-violet); --accent-bg: var(--c-violet-bg); }
.stat-tile:nth-child(5n+4) { --accent: var(--c-amber); --accent-bg: var(--c-amber-bg); }
.stat-tile:nth-child(5n+5) { --accent: var(--c-rose); --accent-bg: var(--c-rose-bg); }
.stat-tile__value { color: color-mix(in srgb, var(--accent) 70%, #1f2427); }

/* Request status tiles */
.status-tile { border: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); border-inline-start: 5px solid var(--c-blue); }
.status-tile:nth-child(2) { border-inline-start-color: var(--c-amber); background: var(--c-amber-bg); }
.status-tile:nth-child(3) { border-inline-start-color: var(--c-green); background: var(--c-green-bg); }
.status-tile:nth-child(4) { border-inline-start-color: var(--c-red); background: var(--c-red-bg); }
.status-tile:first-child { background: var(--c-blue-bg); }
.status-tile:hover { background: #fff; }

/* Stacked bar per project (available / in progress / won / other) */
.stack-bar { display: flex; height: 9px; border-radius: 99px; overflow: hidden; background: rgba(31,36,39,.08); margin-top: 8px; }
.stack-bar span { display: block; height: 100%; min-width: 0; }
.stack-bar .sb-avail { background: var(--c-green); }
.stack-bar .sb-prog { background: var(--c-amber); }
.stack-bar .sb-won { background: var(--c-violet); }
.stack-legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 11px; color: var(--muted); }
.stack-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 4px; }

/* Charts */
.chart[data-chart="line"] { --series: var(--c-blue); --series-wash: rgba(47,127,181,.16); }
.chart[data-chart="bar"] { --series: var(--c-teal); --series-wash: rgba(20,163,139,.16); }
.chart__line { stroke-width: 2.6; }
.chart__bar { rx: 3; }
.chart[data-chart="bar"] .chart__bar.is-active { fill: #0e7f6b; }
.chart[data-chart="line"] .chart__bar.is-active { fill: #256a99; }
.chart__head { padding-inline-start: 10px; border-inline-start: 4px solid var(--series); }

/* Ranked bars: rotating colours */
.barlist__row { --bar: var(--c-blue); --bar-bg: var(--c-blue-bg); }
.barlist__row:nth-child(5n+2) { --bar: var(--c-teal); --bar-bg: var(--c-teal-bg); }
.barlist__row:nth-child(5n+3) { --bar: var(--c-violet); --bar-bg: var(--c-violet-bg); }
.barlist__row:nth-child(5n+4) { --bar: var(--c-amber); --bar-bg: var(--c-amber-bg); }
.barlist__row:nth-child(5n+5) { --bar: var(--c-rose); --bar-bg: var(--c-rose-bg); }
.barlist__track { background: var(--bar-bg); height: 12px; }
.barlist__bar { background: linear-gradient(90deg, var(--bar), color-mix(in srgb, var(--bar) 70%, #fff)); }
[dir="rtl"] .barlist__bar { background: linear-gradient(270deg, var(--bar), color-mix(in srgb, var(--bar) 70%, #fff)); }
.barlist__label a:hover { color: var(--bar); }

/* Card titles get a colour dot */
.card__head .card__title::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c-blue); flex: none; }
