/* ==========================================================================
   Design system — tokens, reset, layout, components.
   Every project overrides the token block in tokens.css; nothing else needs
   to change for a different brand.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* The UA [hidden] rule loses to .card/.grid/.stack display values, so any
   element toggled via the hidden property must win explicitly. */
[hidden] { display: none !important; }

:root {
  /* Colour — light theme. Override these five and the whole UI follows. */
  --accent: #4f46e5;
  --accent-hover: color-mix(in srgb, var(--accent) 88%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --accent-contrast: #ffffff;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f2f3f8;
  --surface-3: #e9ebf3;
  --border: #e3e6ef;
  --border-strong: #cfd4e2;
  --text: #101322;
  --text-soft: #45506b;
  --muted: #5f6a85;
  --success-ink: #0b7a50; --warning-ink: #8a5a12; --danger-ink: #a82822; --info-ink: #1d4ed8; --accent-ink: #0a6f66;

  --success: #0f9d68;
  --success-soft: #e4f7ee;
  --warning: #b7791f;
  --warning-soft: #fdf3e2;
  --danger: #d4443c;
  --danger-soft: #fdeceb;
  --info: #2563eb;
  --info-soft: #e8f0fe;

  /* Type */
  --font-sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.3125rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;
  --fs-3xl: 3rem;
  --lh-tight: 1.2;
  --lh-base: 1.6;

  /* Space — 4px scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --s-12: 48px; --s-16: 64px;

  /* Shape + depth */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;
  --shadow-sm: 0 1px 2px rgb(16 19 34 / 6%), 0 1px 3px rgb(16 19 34 / 4%);
  --shadow-md: 0 4px 12px rgb(16 19 34 / 8%), 0 2px 4px rgb(16 19 34 / 4%);
  --shadow-lg: 0 16px 40px rgb(16 19 34 / 12%), 0 4px 12px rgb(16 19 34 / 5%);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --ease: cubic-bezier(0.2, 0, 0.13, 1);
}

[data-theme="dark"] {
  --accent-soft: color-mix(in srgb, var(--accent) 22%, #0b0e17);
  --bg: #0b0e17;
  --surface: #121724;
  --surface-2: #171d2c;
  --surface-3: #1e2536;
  --border: #232b3d;
  --border-strong: #313a50;
  --text: #eef1f8;
  --text-soft: #c2c9da;
  --muted: #8b95ac;
  --success: #34d399; --success-soft: #10301f; --success-ink: #34d399; --warning-ink: #fbbf24; --danger-ink: #f87171; --info-ink: #60a5fa; --accent-ink: var(--accent);
  --warning: #fbbf24; --warning-soft: #33260c;
  --danger: #f87171; --danger-soft: #3a1618;
  --info: #60a5fa; --info-soft: #12233d;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 6px 18px rgb(0 0 0 / 45%);
  --shadow-lg: 0 20px 48px rgb(0 0 0 / 55%);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-soft: color-mix(in srgb, var(--accent) 22%, #0b0e17);
    --bg: #0b0e17; --surface: #121724; --surface-2: #171d2c; --surface-3: #1e2536;
    --border: #232b3d; --border-strong: #313a50;
    --text: #eef1f8; --text-soft: #c2c9da; --muted: #8b95ac;
    --success: #34d399; --success-soft: #10301f; --success-ink: #34d399; --warning-ink: #fbbf24; --danger-ink: #f87171; --info-ink: #60a5fa; --accent-ink: var(--accent);
    --warning: #fbbf24; --warning-soft: #33260c;
    --danger: #f87171; --danger-soft: #3a1618;
    --info: #60a5fa; --info-soft: #12233d;
    --success-ink: #34d399; --warning-ink: #fbbf24; --danger-ink: #f87171; --info-ink: #60a5fa; --accent-ink: var(--accent);
    color-scheme: dark;
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0 0 var(--s-3); line-height: var(--lh-tight); letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--s-4); color: var(--text-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
small { font-size: var(--fs-sm); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }
img, svg { max-width: 100%; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.875em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); overflow: auto; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-contrast); padding: var(--s-2) var(--s-4);
}
.skip-link:focus { left: var(--s-2); top: var(--s-2); }

/* ---------------------------------------------------------------- shell -- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: var(--s-4) var(--s-3);
  gap: var(--s-2);
}
.brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3) var(--s-4); font-weight: 700; font-size: var(--fs-md); color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; color: var(--accent-contrast); font-size: var(--fs-sm); font-weight: 800;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7c3aed));
  box-shadow: var(--shadow-sm);
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: var(--s-3) var(--s-3) var(--s-1); font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md); color: var(--text-soft); font-weight: 500; font-size: var(--fs-base);
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.sidebar-footer { margin-top: auto; padding-top: var(--s-4); border-top: 1px solid var(--border); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-6); border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.page { padding: var(--s-8) var(--s-6) var(--s-16); max-width: 1240px; width: 100%; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.page-header .grow { flex: 1; min-width: 240px; }
.page-header h1 { font-size: var(--fs-xl); margin-bottom: var(--s-1); }
.page-header p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, var(--sidebar-w)); z-index: 60;
    transform: translateX(-102%); transition: transform 220ms var(--ease); box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; inset: 0; background: rgb(6 9 16 / 48%); z-index: 55; opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease); }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .page { padding: var(--s-6) var(--s-4) var(--s-12); }
  .topbar { padding: 0 var(--s-4); }
}

/* --------------------------------------------------------------- pieces -- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: var(--s-5);
}
.card + .card { margin-top: var(--s-4); }
.card-header { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-header h3, .card-header h2 { margin: 0; font-size: var(--fs-md); }
.card-header .actions { margin-left: auto; display: flex; gap: var(--s-2); }
.card-flush { padding: 0; overflow: hidden; }

.grid { display: grid; gap: var(--s-4); }
.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-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); }
.muted { color: var(--muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* stats */
.stat { display: flex; flex-direction: column; gap: var(--s-1); }
.stat-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: var(--fs-xs); font-weight: 600; }
.stat-delta.up { color: var(--success-ink); }
.stat-delta.down { color: var(--danger-ink); }

/* -------------------------------------------------------------- buttons -- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 38px; padding: 0 var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-weight: 600; font-size: var(--fs-sm); cursor: pointer;
  transition: transform 100ms var(--ease), background 120ms var(--ease), border-color 120ms var(--ease), box-shadow 120ms var(--ease);
  text-decoration: none; white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: 0.55; pointer-events: none; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--accent-contrast); --btn-border: var(--accent); box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-soft { --btn-bg: var(--accent-soft); --btn-fg: var(--accent); --btn-border: transparent; }
.btn-soft:hover { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, black); }
.btn-sm { min-height: 30px; padding: 0 var(--s-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { min-height: 46px; padding: 0 var(--s-6); font-size: var(--fs-base); border-radius: var(--r-lg); }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* --------------------------------------------------------------- forms -- */
.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-soft); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .field-errors { margin: 0; padding-left: var(--s-4); color: var(--danger); font-size: var(--fs-xs); }

.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-base);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input.has-error, .textarea.has-error { border-color: var(--danger); }
.input-sm { min-height: 32px; font-size: var(--fs-sm); }

.input-group { display: flex; gap: var(--s-2); align-items: center; }
.input-group .input { flex: 1; }

.checkbox, .radio { display: flex; align-items: flex-start; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-soft); }
.checkbox input, .radio input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 38px; height: 22px; border-radius: var(--r-full); background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background 160ms var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform 160ms var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

.search-input { position: relative; }
.search-input .input { padding-left: 34px; }
.search-input svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }

/* --------------------------------------------------------------- table -- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.table-actions { display: flex; gap: var(--s-1); justify-content: flex-end; }

/* --------------------------------------------------------------- badges -- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.7; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text-soft); white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success-ink); }
.badge-warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge-danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge-info { background: var(--info-soft); color: var(--info-ink); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }

/* --------------------------------------------------------------- alerts -- */
.flash {
  display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface);
  font-size: var(--fs-sm); margin-bottom: var(--s-4); animation: slide-in 260ms var(--ease);
}
.flash-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, transparent); color: var(--success); }
.flash-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); color: var(--danger); }
.flash-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, transparent); color: var(--info); }

.alert { padding: var(--s-4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }

/* ---------------------------------------------------------------- empty -- */
.empty { text-align: center; padding: var(--s-12) var(--s-4); color: var(--muted); }
.empty-mark {
  width: 52px; height: 52px; border-radius: var(--r-lg); margin: 0 auto var(--s-4);
  display: grid; place-items: center; background: var(--surface-2); border: 1px dashed var(--border-strong); color: var(--muted);
}
.empty h3 { font-size: var(--fs-md); color: var(--text); margin-bottom: var(--s-1); }
.empty p { margin: 0 auto var(--s-4); max-width: 42ch; font-size: var(--fs-sm); }

/* ------------------------------------------------------------ pagination -- */
.pagination { display: flex; align-items: center; gap: var(--s-2); justify-content: space-between; flex-wrap: wrap; margin-top: var(--s-4); }
.pagination .pages { display: flex; gap: var(--s-1); }
.page-link {
  min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 var(--s-2);
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); font-size: var(--fs-sm); font-weight: 500;
}
.page-link:hover { background: var(--surface-2); text-decoration: none; }
.page-link.is-current { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 700; }

/* ---------------------------------------------------------------- modal -- */
.modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: var(--s-4); }
.modal.is-open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgb(6 9 16 / 52%); backdrop-filter: blur(2px); }
.modal-panel {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 88vh; overflow: auto;
  padding: var(--s-6); animation: pop-in 200ms var(--ease);
}
.modal-panel h2 { font-size: var(--fs-lg); }
.modal-close { position: absolute; top: var(--s-3); right: var(--s-3); }

/* -------------------------------------------------------------- dropdown -- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); padding: var(--s-1); display: none;
}
.dropdown.is-open .dropdown-menu { display: block; animation: pop-in 140ms var(--ease); }
.dropdown-item {
  display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm); color: var(--text-soft); font-size: var(--fs-sm); width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer; font-family: inherit;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.dropdown-sep { height: 1px; background: var(--border); margin: var(--s-1); }

/* ---------------------------------------------------------------- toast -- */
.toasts { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 90; display: flex; flex-direction: column; gap: var(--s-2); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm); min-width: 240px; animation: slide-in 200ms var(--ease);
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }

/* ---------------------------------------------------------------- tabs -- */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); margin-bottom: var(--s-5); overflow-x: auto; }
.tab {
  padding: var(--s-2) var(--s-4); border: 0; background: none; color: var(--muted);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------- progress -- */
.progress { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: inherit; transition: width 400ms var(--ease); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: var(--fs-sm); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-md); }

/* ---------------------------------------------------------------- auth -- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside {
  background:
    radial-gradient(1200px 600px at 10% 0%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%),
    linear-gradient(160deg, #0c1020, #131a2f 55%, #0a0d17);
  color: #fff; padding: var(--s-12); display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside h1 { font-size: var(--fs-3xl); letter-spacing: -0.03em; line-height: 1.1; max-width: 22ch; }
.auth-aside p { color: rgb(255 255 255 / 72%); max-width: 44ch; }
.auth-points { display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-8); }
.auth-point { display: flex; gap: var(--s-3); align-items: flex-start; font-size: var(--fs-sm); color: rgb(255 255 255 / 82%); }
.auth-point .dot { width: 22px; height: 22px; border-radius: 50%; background: rgb(255 255 255 / 12%); display: grid; place-items: center; flex: none; font-size: 11px; }
.auth-main { display: grid; place-items: center; padding: var(--s-8) var(--s-4); background: var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: var(--fs-xl); margin-bottom: var(--s-1); }
.auth-card .sub { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s-6); }
@media (max-width: 900px) { .auth-shell { grid-template-columns: 1fr; } .auth-aside { display: none; } }

/* ------------------------------------------------------------ installer -- */
.install-shell { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.install-panel { width: min(760px, 100%); }
.install-steps { display: flex; gap: var(--s-2); margin-bottom: var(--s-6); flex-wrap: wrap; }
.install-step {
  display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.install-step.is-done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.install-step.is-current { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.check-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.check-row:last-child { border-bottom: 0; }
.check-row .ok { color: var(--success); }
.check-row .bad { color: var(--danger); }
.check-row .detail { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }

/* ------------------------------------------------------------ animation -- */
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes skeleton { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skeleton {
  border-radius: var(--r-sm); height: 14px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: skeleton 1.4s ease infinite;
}
.reveal { animation: slide-in 320ms var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- print -- */
@media print {
  .sidebar, .topbar, .no-print, .toasts { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .page { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------- prose -- */
.prose { font-size: var(--fs-md); line-height: 1.7; color: var(--text-soft); }
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--text); margin: var(--s-8) 0 var(--s-3); }
.prose h2 { font-size: var(--fs-xl); padding-bottom: var(--s-2); border-bottom: 1px solid var(--border); }
.prose h3 { font-size: var(--fs-lg); }
.prose p { margin: 0 0 var(--s-4); }
.prose ul, .prose ol { margin: 0 0 var(--s-4); padding-left: var(--s-6); }
.prose li { margin-bottom: var(--s-1); }
.prose li::marker { color: var(--muted); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 5px; font-size: 0.875em; }
.prose pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); overflow-x: auto; margin: 0 0 var(--s-4); }
.prose pre code { background: none; border: 0; padding: 0; font-size: var(--fs-sm); }
.prose blockquote { margin: 0 0 var(--s-4); padding: var(--s-2) var(--s-4); border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--r-md) var(--r-md) 0; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { margin: var(--s-6) 0; }
.prose img { border-radius: var(--r-md); border: 1px solid var(--border); }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: var(--s-4); font-size: var(--fs-sm); }
.prose th, .prose td { border: 1px solid var(--border); padding: var(--s-2) var(--s-3); text-align: left; }
.prose th { background: var(--surface-2); }

/* ------------------------------------------------------------ team pages -- */
.team-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.team-card h2 { font-size: var(--fs-md); }
.team-avatar {
  width: 46px; height: 46px; flex: none; display: grid; place-items: center;
  border-radius: 14px; font-weight: 700; font-size: var(--fs-md);
  color: var(--accent-contrast); background: var(--brand-gradient);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 20px -14px rgba(0, 0, 0, 0.7);
}
.team-avatar-lg { width: 64px; height: 64px; border-radius: 18px; font-size: var(--fs-lg); }

/* ------------------------------------------------------- saved searches -- */
.alert-save {
  display: flex; gap: var(--s-4); align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: var(--s-4);
}
.alert-save-copy { flex: 1 1 260px; min-width: 0; }
.alert-save-copy h2 { font-size: var(--fs-md); margin-bottom: var(--s-1); }
.alert-save-form { display: flex; gap: var(--s-2); align-items: flex-end; flex-wrap: wrap; flex: 1 1 320px; }

/* ------------------------------------------------------------- mortgage -- */
.mortgage-form { display: flex; gap: var(--s-3); align-items: flex-end; flex-wrap: wrap; }
.mortgage-form .input { max-width: 110px; }

/* ------------------------------------------------------ narrow screens --- *
 * Long e-mails, addresses and hashes must not widen the page at 360px. */
.page, .card, .grid > *, .stack > *, .team-card, .listing-card { min-width: 0; }
pre, code, .table td, .table th { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .alert-save-form { flex-direction: column; align-items: stretch; }
  .mortgage-form .input { max-width: none; }
}

/* ==========================================================================
   PropertyDeck — agency board, calendar, listing site and detail screens.
   Everything below is brand-neutral: it only consumes the tokens above.
   ========================================================================== */

/* Content nav wrapper (the sidebar uses .nav as its list container). */
.nav { display: flex; flex-direction: column; gap: 2px; }
.text-danger { color: var(--danger); }
.nav-scrim { display: none; }

/* ------------------------------------------------------------- dashboard -- */
.dash-grid { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.dash-grid > .stack { gap: var(--s-4); }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 64px; padding: var(--s-2) 0; }
.spark-bar {
  flex: 1 1 0; min-width: 3px; border-radius: 3px 3px 1px 1px;
  background: linear-gradient(to top, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent));
  transition: filter 140ms var(--ease);
}
.spark-bar:hover { filter: brightness(1.15); }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.mini-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
}
.mini-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.mini-list li:first-child { padding-top: 0; }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-2) 0; border-bottom: 1px dashed var(--border); font-size: var(--fs-sm);
}
.history-list li:last-child { border-bottom: 0; }

.thumb {
  width: 56px; height: 42px; flex: none; border-radius: var(--r-sm);
  object-fit: cover; border: 1px solid var(--border); background: var(--surface-2);
}
.thumb-empty { display: grid; place-items: center; color: var(--muted); }

/* --------------------------------------------------------------- pipeline -- */
.pipeline {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr);
  gap: var(--s-4); overflow-x: auto; padding-bottom: var(--s-2);
  scroll-snap-type: x proximity;
}
.pipe-col {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  display: flex; flex-direction: column; min-height: 180px; scroll-snap-align: start;
}
.pipe-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border);
}
.pipe-count {
  font-size: var(--fs-xs); font-weight: 700; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-full);
  min-width: 24px; text-align: center; padding: 1px 6px;
}
.pipe-body { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); }
.pipe-empty { margin: 0; padding: var(--s-4); text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.lead-card {
  display: flex; flex-direction: column; gap: var(--s-1);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s-3); color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform 140ms var(--ease), box-shadow 140ms var(--ease), border-color 140ms var(--ease);
}
.lead-card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.lead-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.lead-card-top strong { font-size: var(--fs-sm); line-height: 1.35; }
.lead-card-property { font-size: var(--fs-xs); color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-card-meta { display: flex; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-xs); color: var(--muted); }
.lead-card-agent { font-size: var(--fs-xs); color: var(--muted); border-top: 1px dashed var(--border); padding-top: var(--s-1); margin-top: var(--s-1); }
.pipe-more { font-size: var(--fs-xs); text-align: center; padding: var(--s-2); color: var(--accent); border: 1px dashed var(--border-strong); border-radius: var(--r-md); }

/* ----------------------------------------------------------- filter + form -- */
.filter-bar {
  display: flex; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-4); border-radius: var(--r-lg);
}
.filter-bar.card { background: var(--surface); border: 1px solid var(--border); }
.filter-field { display: flex; flex-direction: column; gap: var(--s-1); min-width: 130px; }
.filter-field.grow { flex: 1 1 220px; }
.filter-field > label { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.filter-field .input, .filter-field .select { min-height: 38px; }
.filter-actions { display: flex; align-items: center; gap: var(--s-2); padding-bottom: 1px; }

.inline-form { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); padding: var(--s-4); }
.inline-form.card { border: 1px solid var(--border); }
.inline-form > summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: var(--fs-sm); }
.inline-form > summary::marker { color: var(--muted); }
.inline-form[open] > summary { margin-bottom: var(--s-2); }

/* --------------------------------------------------------------- calendar -- */
.cal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden;
}
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekdays { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-weekday {
  padding: var(--s-2) var(--s-3); font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.cal-day {
  min-height: 108px; padding: var(--s-2); border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s-1);
  min-width: 0;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.is-blank { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.cal-day.is-today { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.cal-date { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.cal-event {
  display: flex; flex-direction: column; gap: 1px; padding: 4px 6px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--text); font-size: var(--fs-xs); line-height: 1.3;
  overflow: hidden;
}
.cal-event:hover { text-decoration: none; filter: brightness(.98); }
.cal-time { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.cal-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-list { display: none; }

.viewing-list { display: flex; flex-direction: column; gap: var(--s-2); }
.viewing-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface);
}

/* ----------------------------------------------------------- detail + lead -- */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: var(--s-6); margin-top: var(--s-6); align-items: start; }
.detail-main, .detail-aside { min-width: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.detail-aside { position: sticky; top: calc(var(--topbar-h) + var(--s-4)); }

.kv { margin: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.kv > div { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline-item { position: relative; padding: 0 0 var(--s-5) var(--s-6); }
.timeline-item::before {
  content: ""; position: absolute; left: 6px; top: 14px; bottom: 0;
  width: 1px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  position: absolute; left: 0; top: 6px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.timeline-body { min-width: 0; }
.timeline-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-sm); }
.timeline-text { color: var(--text-soft); font-size: var(--fs-sm); }

/* --------------------------------------------------------------- editor -- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: var(--s-6); align-items: start; }
.editor-main, .editor-aside { min-width: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.editor-aside { position: sticky; top: calc(var(--topbar-h) + var(--s-4)); }
.feature-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-2); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.checklist li { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-soft); }
.checklist li.is-done { color: var(--muted); text-decoration: line-through; }
.checklist li.is-todo::before { content: "○"; color: var(--muted); }
.checklist li.is-done::before { content: "●"; color: var(--success); }
.feature-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s-2) var(--s-4); }
.feature-list li { display: flex; gap: var(--s-2); align-items: baseline; font-size: var(--fs-sm); color: var(--text-soft); }
.feature-list li span { color: var(--success); }

/* ------------------------------------------------------------------ media -- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s-4); }
.media-tile { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.media-tile-image { aspect-ratio: 16 / 10; background: var(--surface-2); }
.media-tile-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile-body { padding: var(--s-2) var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); font-size: var(--fs-xs); }
.media-actions { display: flex; gap: var(--s-1); flex-wrap: wrap; }
.media-cover-flag { color: var(--accent); font-weight: 700; }

/* ------------------------------------------------------------ public site -- */
.site { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.site-header {
  position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px); border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 var(--s-6); height: 66px;
  display: flex; align-items: center; gap: var(--s-6);
}
.site-nav { display: flex; align-items: center; gap: var(--s-5); font-size: var(--fs-sm); font-weight: 600; }
.site-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }
.lang-switch { display: flex; gap: var(--s-1); }
.site-main { flex: 1; }
.site-container { max-width: 1200px; margin: 0 auto; padding: var(--s-8) var(--s-6); width: 100%; }

.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 500px at 12% -10%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 60%),
    radial-gradient(900px 420px at 90% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 55%),
    linear-gradient(180deg, var(--surface), var(--bg));
  border-bottom: 1px solid var(--border);
}
.hero-inner { max-width: 1200px; margin: 0 auto; padding: var(--s-16) var(--s-6) var(--s-10); }
.eyebrow {
  margin: 0 0 var(--s-3); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent);
}
.hero h1 { font-size: clamp(2rem, 4.6vw, var(--fs-3xl)); line-height: 1.06; letter-spacing: -.035em; max-width: 20ch; margin: 0 0 var(--s-4); }
.hero-sub { color: var(--text-soft); font-size: var(--fs-md); max-width: 58ch; margin: 0 0 var(--s-8); }
.hero .filter-bar { background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--border); box-shadow: var(--shadow-md); backdrop-filter: blur(8px); }

.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.results-head h2 { font-size: var(--fs-xl); letter-spacing: -.02em; }
.sort-form { display: flex; align-items: center; gap: var(--s-2); }

.listing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-6); }
.listing-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.listing-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.listing-media { position: relative; display: block; aspect-ratio: 3 / 2; background: var(--surface-2); overflow: hidden; }
.listing-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 500ms var(--ease); }
.listing-card:hover .listing-media img { transform: scale(1.035); }
.listing-media-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: var(--fs-sm); }
.listing-flag {
  position: absolute; top: var(--s-3); left: var(--s-3);
  background: color-mix(in srgb, #0b1220 78%, transparent); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 8px; border-radius: var(--r-full); backdrop-filter: blur(6px);
}
.listing-flag.flag-warning { left: auto; right: var(--s-3); background: var(--warning); color: #241503; }
.listing-body { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-4); }
.listing-price { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.listing-price .muted { font-weight: 500; font-size: var(--fs-xs); }
.listing-title { font-size: var(--fs-md); margin: 0; line-height: 1.3; }
.listing-title a { color: var(--text); }
.listing-place { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.listing-specs { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); margin: var(--s-2) 0 0; padding: var(--s-2) 0 0; border-top: 1px solid var(--border); }
.listing-specs li { font-size: var(--fs-xs); color: var(--text-soft); background: var(--surface-2); border-radius: var(--r-full); padding: 3px 9px; }

.listing-page { padding-top: var(--s-6); }
.breadcrumb { display: flex; gap: var(--s-2); align-items: center; font-size: var(--fs-xs); color: var(--muted); margin-bottom: var(--s-4); }
.breadcrumb a { color: var(--muted); }
.listing-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-6); flex-wrap: wrap; margin-bottom: var(--s-5); }
.listing-head-main { min-width: 0; }
.listing-head h1 { font-size: clamp(1.6rem, 3vw, var(--fs-2xl)); letter-spacing: -.03em; margin: var(--s-2) 0 var(--s-1); }
.listing-address { color: var(--muted); margin: 0; font-size: var(--fs-sm); }
.listing-head-price { text-align: right; display: flex; flex-direction: column; }
.price-xl { font-size: clamp(1.6rem, 2.4vw, var(--fs-2xl)); font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

.gallery { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-2); border-radius: var(--r-xl); overflow: hidden; }
.gallery-main { display: block; aspect-ratio: 16 / 10; background: var(--surface-2); }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-grid { display: grid; grid-template-rows: 1fr 1fr; gap: var(--s-2); min-height: 0; }
.gallery-grid a { display: block; overflow: hidden; background: var(--surface-2); }
.gallery-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s-4); margin: 0; }
.spec-grid > div { border-left: 2px solid var(--accent-soft); padding-left: var(--s-3); }
.spec-grid dt { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.spec-grid dd { margin: 2px 0 0; font-size: var(--fs-md); font-weight: 650; }
.mortgage-form { display: flex; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap; }
.mortgage-form .field { min-width: 110px; }
.agent-card .avatar { flex: none; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: var(--s-12); }
.site-footer-inner {
  max-width: 1200px; margin: 0 auto; padding: var(--s-8) var(--s-6);
  display: flex; gap: var(--s-6); flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  font-size: var(--fs-sm); color: var(--muted);
}
.site-footer-links { display: flex; gap: var(--s-5); flex-wrap: wrap; }

/* ------------------------------------------------------------- team/demand -- */
.team-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.team-card { display: flex; flex-direction: column; gap: var(--s-2); }
.team-avatar {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: var(--fs-md);
}
.team-avatar-lg { width: 64px; height: 64px; border-radius: 18px; font-size: var(--fs-lg); }

.alert-save { display: flex; gap: var(--s-4); align-items: flex-end; flex-wrap: wrap; }
.alert-save-copy { flex: 1 1 260px; min-width: 0; }
.alert-save-copy h2 { font-size: var(--fs-md); margin-bottom: var(--s-1); }
.alert-save-form { display: flex; gap: var(--s-2); align-items: flex-end; flex-wrap: wrap; }

/* ----------------------------------------------------------- responsive -- */
@media (max-width: 1100px) {
  .dash-grid, .detail-layout, .editor-layout { grid-template-columns: 1fr; }
  .detail-aside, .editor-aside { position: static; }
  .gallery { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .site-header-inner { padding: 0 var(--s-4); gap: var(--s-3); }
  .site-nav { display: none; }
  .site-container, .hero-inner { padding-left: var(--s-4); padding-right: var(--s-4); }
  .hero-inner { padding-top: var(--s-10); }
  .listing-head-price { text-align: left; }
  .cal { display: none; }
  .cal-list { display: flex; }
  .table { display: block; width: 100%; overflow-x: auto; }
  .pipeline { grid-auto-columns: minmax(82vw, 1fr); }
  .filter-field { min-width: 0; flex: 1 1 140px; }
  .spark { height: 48px; }
  .timeline-item { padding-left: var(--s-5); }
}

/* ------------------------------------------------------------ charts ---- */
.chart-figure { margin: 0; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-sm { max-height: 96px; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-area { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }
.chart-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.chart-legend { display: flex; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-1); font-size: var(--fs-xs); color: var(--muted); }

/* --------------------------------------------------------- area trends -- */
.area-trends { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.area-trend {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.area-trend-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
.area-trend-head h3 { margin: 0; font-size: var(--fs-base); }
.area-median { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- page widths ---- */
.site-container.narrow { max-width: 860px; }

/* ----------------------------------------------------------- emphasis --- */
.table tr.is-active td { background: color-mix(in srgb, var(--accent) 8%, transparent); font-weight: 600; }
