/* =====================================================================
   Broker CRM — design system
   Logical properties throughout so Arabic (RTL) mirrors automatically.
   ===================================================================== */
:root {
  --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", "PingFang SC", "Microsoft YaHei", "Malgun Gothic", sans-serif;
  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #EEF2F6;
  --border: #E3E8EF;
  --border-strong: #CDD5DF;
  --text: #0F172A;
  --text-2: #475467;
  --muted: #6B7A90;

  --brand: #0E9AA7;
  --brand-600: #0A7F8A;
  --brand-700: #08646D;
  --brand-50: #E6F6F7;
  --brand-100: #C8EDF0;
  --accent: #E8833A;
  --accent-600: #C9682A;
  --accent-50: #FDF1E6;

  --green: #0E9F6E;  --green-bg: #E8F8F1;
  --amber: #C27803;  --amber-bg: #FFF6E0;
  --red: #E0352B;    --red-bg: #FDECEB;
  --blue: #2C7BE5;   --blue-bg: #EAF2FD;
  --slate: #5B6B82;  --slate-bg: #EEF1F5;
  --violet: #7A5AF8; --violet-bg: #F1EEFE;

  --sidebar: #0A101C;
  --sidebar-2: #121A2B;
  --sidebar-line: rgba(255,255,255,.07);
  --sidebar-text: #9AA6BA;
  --sidebar-text-strong: #F1F4F9;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 6px 16px -8px rgba(16,24,40,.12);
  --shadow-lg: 0 24px 48px -16px rgba(16,24,40,.25);
  --ring: 0 0 0 4px rgba(14,154,167,.18);
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0B111C;
  --surface: #111827;
  --surface-2: #0F1623;
  --surface-3: #1A2333;
  --border: #1F2A3C;
  --border-strong: #2B3850;
  --text: #E8EDF5;
  --text-2: #B2BDCF;
  --muted: #8291A8;
  --brand-50: rgba(14,154,167,.14);
  --brand-100: rgba(14,154,167,.28);
  --accent-50: rgba(232,131,58,.14);
  --green-bg: rgba(14,159,110,.15);
  --amber-bg: rgba(194,120,3,.18);
  --red-bg: rgba(224,53,43,.16);
  --blue-bg: rgba(44,123,229,.16);
  --slate-bg: rgba(91,107,130,.2);
  --violet-bg: rgba(122,90,248,.18);
  --sidebar: #070B13;
  --sidebar-2: #0E1522;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 24px 48px -16px rgba(0,0,0,.7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-ui); font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0 0 .75em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; flex: none; }
.icon-lg { width: 22px; height: 22px; flex: none; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: end; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 6px } .mt-2 { margin-top: 12px } .mt-3 { margin-top: 20px } .mt-4 { margin-top: 32px }
.mb-2 { margin-bottom: 12px } .mb-3 { margin-bottom: 20px }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ app shell */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--sidebar) 264px, transparent 264px); }
[dir="rtl"] .app { background: linear-gradient(270deg, var(--sidebar) 264px, transparent 264px); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: radial-gradient(120% 60% at 0% 0%, #13233A 0%, var(--sidebar) 55%) , var(--sidebar);
  color: var(--sidebar-text); display: flex; flex-direction: column; padding: 18px 14px;
  border-inline-end: 1px solid var(--sidebar-line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; color: var(--sidebar-text-strong); text-decoration: none !important; }
.brand img { width: 38px; height: 38px; filter: drop-shadow(0 6px 14px rgba(232,131,58,.35)); }
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--sidebar-text); letter-spacing: .08em; text-transform: uppercase; }
.agency-pill {
  display: flex; align-items: center; gap: 10px; padding: 10px; margin: 0 2px 14px;
  border: 1px solid var(--sidebar-line); border-radius: 12px; background: rgba(255,255,255,.03); color: var(--sidebar-text-strong);
}
.agency-pill .logo { width: 30px; height: 30px; border-radius: 8px; background: #fff; object-fit: contain; padding: 2px; }
.agency-pill .logo-fallback { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; color: #fff; }
.agency-pill .name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.agency-pill .sub { font-size: 11px; color: var(--sidebar-text); }
.nav-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #5D6A80; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 550; font-size: 13.5px; text-decoration: none !important;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: rgba(255,255,255,.05); color: var(--sidebar-text-strong); }
.nav-item.is-active { background: linear-gradient(90deg, rgba(14,154,167,.22), rgba(14,154,167,.06)); color: #fff; box-shadow: inset 2px 0 0 var(--brand); }
[dir="rtl"] .nav-item.is-active { box-shadow: inset -2px 0 0 var(--brand); }
.nav-item .count { margin-inline-start: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.sterling-card {
  display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 14px; text-decoration: none !important;
  background: linear-gradient(135deg, rgba(232,131,58,.16), rgba(14,154,167,.10)); border: 1px solid rgba(232,131,58,.25); color: var(--sidebar-text-strong);
}
.sterling-card img { width: 38px; height: 38px; }
.sterling-card strong { display: block; font-size: 13px; }
.sterling-card span { font-size: 11.5px; color: var(--sidebar-text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .search { position: relative; flex: 1; max-width: 420px; }
.topbar .search input { padding-inline-start: 38px; background: var(--surface); }
.topbar .search .icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .search kbd { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.menu-toggle { display: none; }
.content { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }
.banner { padding: 10px 28px; font-size: 13px; display: flex; gap: 10px; align-items: center; justify-content: center; text-align: center; }
.banner form { display: inline; }
.banner-impersonate { background: #2A1B48; color: #E7DDFF; }
.banner-trial { background: linear-gradient(90deg, var(--accent-50), var(--brand-50)); color: var(--text); border-bottom: 1px solid var(--border); }
.banner-warn { background: var(--amber-bg); color: var(--amber); }
.banner-info { background: var(--brand-ink, #063F45); color: #D5F3F5; }

kbd { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }

/* ------------------------------------------------------------------ page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.eyebrow { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--brand-600); font-weight: 700; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

.kpi { position: relative; padding: 18px 20px; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.kpi .value { font-size: 28px; font-weight: 780; letter-spacing: -.03em; margin-top: 6px; }
.kpi .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .kpi-icon { position: absolute; inset-inline-end: 16px; top: 16px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.tone-brand { background: var(--brand-50); color: var(--brand-600); }
.tone-accent { background: var(--accent-50); color: var(--accent-600); }
.tone-green { background: var(--green-bg); color: var(--green); }
.tone-violet { background: var(--violet-bg); color: var(--violet); }
.kpi-hero {
  color: #fff; border: 0;
  background: radial-gradient(120% 140% at 100% 0%, rgba(232,131,58,.55) 0%, rgba(232,131,58,0) 45%), linear-gradient(135deg, #0B6F79 0%, #0A2B3D 100%);
}
.kpi-hero .label, .kpi-hero .meta { color: rgba(255,255,255,.75); }
.kpi-hero .kpi-icon { background: rgba(255,255,255,.14); color: #fff; }

/* ------------------------------------------------------------------ buttons */
.btn {
  --b: var(--surface); --c: var(--text); --bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--bd); background: var(--b); color: var(--c);
  font: 600 13.5px/1 var(--font-ui); cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: transform .12s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease), border-color .15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary { --b: var(--brand); --c: #fff; --bd: var(--brand-600); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 6px 16px -8px rgba(14,154,167,.7); }
.btn-primary:hover { --b: var(--brand-600); border-color: var(--brand-700); }
.btn-accent { --b: var(--accent); --c: #fff; --bd: var(--accent-600); box-shadow: 0 6px 16px -8px rgba(232,131,58,.8); }
.btn-accent:hover { --b: var(--accent-600); }
.btn-dark { --b: #0F172A; --c: #fff; --bd: #0F172A; }
.btn-ghost { --b: transparent; --bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { --b: var(--surface-3); border-color: transparent; }
.btn-danger { --b: var(--surface); --c: var(--red); --bd: color-mix(in srgb, var(--red) 35%, var(--border)); }
.btn-danger:hover { --b: var(--red-bg); border-color: var(--red); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-ai { --b: linear-gradient(135deg, #FFF4EA, #E9F8F9); --bd: rgba(232,131,58,.4); --c: #8A4114; background: linear-gradient(135deg, #FFF4EA, #E9F8F9); }
:root[data-theme="dark"] .btn-ai { background: linear-gradient(135deg, rgba(232,131,58,.18), rgba(14,154,167,.16)); --c: #FFD3B0; }
.btn .spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ forms */
label, .label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.input, input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: 450 14px/1.4 var(--font-ui);
  transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none;
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
select { padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236B7A90' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
[dir="rtl"] select { background-position: left 12px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input[readonly], textarea[readonly], input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-2); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand); vertical-align: middle; }
input[type=file] { font: inherit; font-size: 13px; color: var(--text-2); }
input[type=file]::file-selector-button { font: 600 12.5px var(--font-ui); border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: 8px; padding: 7px 12px; margin-inline-end: 10px; cursor: pointer; color: var(--text); }
input[type=color] { width: 46px; height: 38px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); }
.field { min-width: 0; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field-row { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.field-row.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.field-row.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.input-group { display: flex; }
.input-group > .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted); font-weight: 600; border-start-start-radius: 10px; border-end-start-radius: 10px; border-inline-end: 0; }
.input-group > input { border-start-start-radius: 0; border-end-start-radius: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 550; color: var(--text); margin: 0; cursor: pointer; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; font-weight: 600; color: var(--text); }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* ------------------------------------------------------------------ badges / chips */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--slate-bg); color: var(--slate); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-slate { background: var(--slate-bg); color: var(--slate); }
.badge-violet { background: var(--violet-bg); color: var(--violet); }
.badge-brand { background: var(--brand-50); color: var(--brand-600); }
.badge-accent { background: var(--accent-50); color: var(--accent-600); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12.5px; font-weight: 600; text-decoration: none !important; }
.chip:hover { border-color: var(--brand); color: var(--brand-600); }
.chip.is-active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .n { color: var(--muted); font-weight: 600; }
.chip.is-active .n { color: inherit; opacity: .7; }

/* ------------------------------------------------------------------ alerts / toasts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid; font-size: 13.5px; margin-bottom: 16px; }
.alert-success { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 30%, transparent); color: var(--text); }
.alert-error { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 30%, transparent); color: var(--text); }
.alert-info { background: var(--brand-50); border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--text); }
.alert-warn { background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--text); }
.alert .icon { margin-top: 1px; }
.alert-success .icon { color: var(--green); } .alert-error .icon { color: var(--red); } .alert-info .icon { color: var(--brand); } .alert-warn .icon { color: var(--amber); }
.toasts { position: fixed; z-index: 100; inset-inline-end: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast { background: #0F172A; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; display: flex; gap: 10px; align-items: center; animation: toast-in .3s var(--ease); }
.toast.is-error { background: #7A1712; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; text-align: start; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.is-link { cursor: pointer; }
.table .ref { font-weight: 750; font-variant-numeric: tabular-nums; color: var(--text); }
.table .num { font-variant-numeric: tabular-nums; text-align: end; white-space: nowrap; }
.table-compact td { padding: 8px 12px; }
.thumb { width: 44px; height: 34px; border-radius: 7px; object-fit: cover; background: var(--surface-3); flex: none; }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { padding: 11px 14px; font-weight: 650; font-size: 13.5px; color: var(--muted); border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; text-decoration: none !important; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand-600); border-bottom-color: var(--brand); }
.tab .n { background: var(--surface-3); color: var(--text-2); font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; }
.seg a, .seg button { padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 650; color: var(--text-2); border: 0; background: none; cursor: pointer; text-decoration: none !important; }
.seg .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ dropdown / dialog */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; display: none; }
.dropdown.is-open .dropdown-menu { display: block; animation: fade .15s var(--ease); }
.dropdown-menu a, .dropdown-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font: 550 13.5px var(--font-ui); border: 0; background: none; cursor: pointer; text-align: start; text-decoration: none !important; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dropdown-menu .head { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); }
dialog.modal { border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(10,16,28,.55); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop .2s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

/* ------------------------------------------------------------------ misc components */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty img { width: 84px; opacity: .95; margin-bottom: 10px; }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 750; color: #fff; background: linear-gradient(135deg, var(--brand), #0A4B6E); flex: none; text-transform: uppercase; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; margin-top: 7px; }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.copy-field { display: flex; gap: 8px; }
.copy-field input, .copy-field textarea { font-family: var(--font-mono); font-size: 12.5px; }
pre.code { background: #0B1220; color: #D7E3F4; padding: 16px; border-radius: 12px; overflow-x: auto; font: 12.5px/1.6 var(--font-mono); margin: 0; white-space: pre-wrap; word-break: break-all; }
.divider-label { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider-label::before, .divider-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: inherit; }

/* quick-goto tiles */
.tiles { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.tile { scroll-snap-align: start; flex: none; min-width: 132px; max-width: 170px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); text-decoration: none !important; color: var(--text); transition: transform .15s var(--ease), border-color .15s, box-shadow .15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow); }
.tile strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.tile span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* charts */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 190px; padding-top: 10px; }
.bar { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar i { display: block; width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 55%, #0A2B3D) 100%); min-height: 3px; transition: height .6s var(--ease); }
.bar:last-child i { background: linear-gradient(180deg, var(--accent), var(--accent-600)); }
.bar b { font-size: 11px; color: var(--text-2); font-weight: 700; }
.bar span { font-size: 10.5px; color: var(--muted); }
.donut-wrap { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.legend { display: grid; gap: 8px; font-size: 13px; flex: 1; min-width: 170px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.hbar { display: grid; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.hbar-row .progress { height: 10px; }

/* ------------------------------------------------------------------ listing editor */
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.editor-title { display: flex; gap: 16px; align-items: center; min-width: 0; }
.editor-title .cover { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; box-shadow: var(--shadow); flex: none; }
.editor-title h1 { font-size: 24px; font-weight: 760; letter-spacing: -.02em; }
.editor-title .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 13px; }
.recnav { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.recnav a, .recnav span { display: grid; place-items: center; width: 34px; height: 34px; color: var(--text-2); border-inline-end: 1px solid var(--border); }
.recnav > :last-child { border-inline-end: 0; }
.recnav a:hover { background: var(--surface-3); color: var(--text); }
.recnav span { opacity: .35; }
.section-card { margin-bottom: 18px; scroll-margin-top: 140px; }
.section-card > .card-head h2 { display: flex; gap: 10px; align-items: center; }
.section-card > .card-head h2 .icon { color: var(--brand); }
.savebar {
  position: sticky; bottom: 0; z-index: 20; margin: 0 -28px -60px; padding: 14px 28px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.savebar .dirty { display: none; color: var(--amber); font-weight: 650; font-size: 13px; }
.savebar.is-dirty .dirty { display: inline-flex; gap: 6px; align-items: center; }
.history-banner { background: repeating-linear-gradient(-45deg, var(--amber-bg), var(--amber-bg) 12px, color-mix(in srgb, var(--amber-bg) 60%, var(--surface)) 12px, color-mix(in srgb, var(--amber-bg) 60%, var(--surface)) 24px); border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent); color: var(--text); padding: 12px 16px; border-radius: 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; font-weight: 600; }
.line-meter { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.line-meter.is-over { color: var(--red); font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 13px; }
[dir="rtl"] .timeline li { padding: 0 22px 16px 0; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .what { white-space: pre-line; color: var(--text-2); margin-top: 3px; font-size: 12.5px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); aspect-ratio: 4/3; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery figcaption { position: absolute; inset: auto 0 0 0; padding: 8px; display: flex; gap: 6px; justify-content: flex-end; background: linear-gradient(transparent, rgba(0,0,0,.55)); opacity: 0; transition: opacity .15s; }
.gallery figure:hover figcaption, .gallery figure:focus-within figcaption { opacity: 1; }
.gallery .is-cover { position: absolute; top: 8px; inset-inline-start: 8px; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); background: var(--surface-2); }
.dropzone.is-over { border-color: var(--brand); background: var(--brand-50); }

/* criteria builder */
.criteria { display: grid; gap: 8px; }
.criteria-row { display: grid; grid-template-columns: 90px 170px 150px 1fr 38px; gap: 8px; align-items: center; }
.criteria-row.is-or { margin-inline-start: 40px; padding-inline-start: 10px; border-inline-start: 3px solid var(--brand-100); }
.criteria-row .where { font-weight: 800; font-size: 12px; letter-spacing: .1em; color: var(--brand-600); text-align: center; }

/* ------------------------------------------------------------------ enquiries + SMS */
.thread { display: flex; flex-direction: column; gap: 10px; padding: 20px; max-height: 560px; overflow-y: auto; background: var(--surface-2); }
.bubble { max-width: 76%; padding: 10px 14px; border-radius: 16px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow-sm); }
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-end-start-radius: 4px; }
.bubble.out { align-self: flex-end; background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff; border-end-end-radius: 4px; }
.bubble.auto { background: linear-gradient(135deg, #3A4A63, #27344A); }
.bubble .meta { display: block; font-size: 11px; opacity: .7; margin-top: 4px; }
.composer { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { min-height: 46px; height: 46px; }
.counter { font-size: 11.5px; color: var(--muted); }

/* ------------------------------------------------------------------ AI assistant */
.assistant { display: grid; grid-template-columns: minmax(0,1fr); gap: 18px; max-width: 980px; }
.chat { display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg .who { width: 36px; height: 36px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--surface-3); }
.msg .who img { width: 30px; }
.msg .body { background: var(--surface); border: 1px solid var(--border); padding: 14px 16px; border-radius: 4px 16px 16px 16px; min-width: 0; flex: 1; box-shadow: var(--shadow-sm); }
.msg.user { flex-direction: row-reverse; }
.msg.user .body { background: var(--text); color: var(--surface); border-color: var(--text); border-radius: 16px 4px 16px 16px; flex: 0 1 auto; }
.ask-box { position: sticky; bottom: 0; padding: 14px 0 0; background: linear-gradient(transparent, var(--bg) 30%); }
.ask-box form { display: flex; gap: 10px; background: var(--surface); padding: 8px; border-radius: 16px; border: 1px solid var(--border-strong); box-shadow: var(--shadow); }
.ask-box input { border: 0; box-shadow: none !important; height: 44px; font-size: 15px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.sterling-hero { display: flex; gap: 18px; align-items: center; padding: 22px; border-radius: 18px; background: radial-gradient(120% 140% at 100% 0%, rgba(232,131,58,.22), transparent 50%), linear-gradient(135deg, #0B1A2C, #0A2B3D); color: #fff; }
.sterling-hero img { width: 84px; filter: drop-shadow(0 12px 24px rgba(232,131,58,.4)); }
.sterling-hero h2 { font-family: var(--font-display); font-weight: 400; font-size: 30px; letter-spacing: 0; }
.sterling-hero p { color: rgba(255,255,255,.75); margin: 4px 0 0; }

/* ------------------------------------------------------------------ auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-art { position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(70% 60% at 85% 15%, rgba(232,131,58,.45), transparent 60%), radial-gradient(70% 70% at 0% 100%, rgba(14,154,167,.55), transparent 60%), #08111F; }
.auth-art::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(80% 70% at 50% 50%, #000, transparent); pointer-events: none; }
.auth-art .mascot { width: min(300px, 60%); align-self: center; filter: drop-shadow(0 30px 60px rgba(232,131,58,.35)); animation: float 6s ease-in-out infinite; position: relative; z-index: 1; }
@keyframes float { 50% { transform: translateY(-10px) rotate(-1deg); } }
.auth-art blockquote { margin: 0; font-family: var(--font-display); font-size: 30px; line-height: 1.2; max-width: 460px; position: relative; z-index: 1; }
.auth-art .brand { padding: 0; position: relative; z-index: 1; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 28px; font-weight: 780; letter-spacing: -.02em; }
.auth-card .sub { color: var(--muted); margin: 6px 0 24px; }
.auth-card form { display: grid; gap: 14px; }
.auth-foot { margin-top: 20px; font-size: 13px; color: var(--muted); text-align: center; }
.lang-mini { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 26px; }
.lang-mini a { font-size: 12px; color: var(--muted); padding: 3px 8px; border-radius: 6px; }
.lang-mini a.is-active { background: var(--surface-3); color: var(--text); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-main { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 920px) {
  .app { grid-template-columns: minmax(0,1fr); background: none; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; z-index: 60; transform: translateX(-105%); transition: transform .25s var(--ease); }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
  .menu-toggle { display: inline-flex; }
  .topbar, .content { padding-inline: 16px; }
  .savebar { margin-inline: -16px; padding-inline: 16px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0,1fr); }
  .auth { grid-template-columns: minmax(0,1fr); }
  .auth-art { display: none; }
  .criteria-row { grid-template-columns: 1fr 1fr; }
  .field-row.cols-2, .field-row.cols-3 { grid-template-columns: minmax(0,1fr); }
  .span-2 { grid-column: auto; }
  .topbar .search kbd { display: none; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: minmax(0,1fr); }
  .page-head h1 { font-size: 22px; }
  .hide-sm { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .sidebar, .topbar, .savebar, .no-print { display: none !important; } .app { display: block; } }
