/* ==========================================================================
   Realtor CRM — design system
   ========================================================================== */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f6;
  --border: #e6e8ec;
  --border-soft: #f0f1f4;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;

  --accent: #f97316;
  --accent-strong: #ea580c;
  --accent-soft: #fff4ec;
  --accent-soft-2: #ffe6d4;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --dark: #0f172a;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --danger: #e11d48;
  --danger-soft: #fde8ec;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .18);

  --sidebar-w: 212px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* stage / status palette: <name> = text, <name>-bg = soft fill */
  --slate: #64748b;   --slate-bg: #f1f5f9;
  --orange: #ea580c;  --orange-bg: #fff1e6;
  --blue: #2563eb;    --blue-bg: #eaf1ff;
  --purple: #9333ea;  --purple-bg: #f5edff;
  --cyan: #0891b2;    --cyan-bg: #e6f6fb;
  --teal: #0d9488;    --teal-bg: #e6f7f5;
  --amber: #d97706;   --amber-bg: #fef6d8;
  --green: #16a34a;   --green-bg: #e8f7ee;
  --red: #e11d48;     --red-bg: #fde8ec;
}

[data-theme="dark"] {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #161d2d;
  --surface-3: #1b2335;
  --border: #243049;
  --border-soft: #1e2840;
  --text: #f3f4f6;
  --text-2: #d1d5db;
  --muted: #9aa4b5;
  --faint: #6b7588;
  --accent-soft: #2a1a10;
  --accent-soft-2: #3a2415;
  --success-soft: #0f2a1b;
  --danger-soft: #2d121a;
  --slate-bg: #1e2638; --orange-bg: #2a1a10; --blue-bg: #122042; --purple-bg: #231537;
  --cyan-bg: #0e2830; --teal-bg: #0d2826; --amber-bg: #2a2110; --green-bg: #0f2a1b; --red-bg: #2d121a;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
[hidden] { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i-sm { width: 13px; height: 13px; }
svg.i-lg { width: 20px; height: 20px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 30;
}
.brand { display: flex; align-items: center; padding: 6px 10px 18px; }
.brand img { display: block; width: auto; height: 26px; }
.brand .logo-dark, [data-theme=dark] .brand .logo-light { display: none; }
[data-theme=dark] .brand .logo-dark { display: block; }

.sidebar-search { position: relative; margin: 0 2px 14px; }
.sidebar-search input {
  width: 100%; height: 34px; padding: 0 10px 0 32px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 12px;
}
.sidebar-search svg { position: absolute; left: 10px; top: 9px; color: var(--faint); }

.nav-group { margin-bottom: 10px; }
.nav-title { padding: 6px 10px; font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--faint); text-transform: uppercase; }
.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px; margin: 1px 0;
  border-radius: 8px; color: var(--text-2); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-3); }
.nav-link.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-link.active svg { color: var(--accent); }
.nav-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

.sidebar-user {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
}
.sidebar-user .meta { line-height: 1.2; min-width: 0; }
.sidebar-user .meta b { display: block; font-size: 12px; }
.sidebar-user .meta span { font-size: 11px; color: var(--muted); }
.sidebar-user form { margin-left: auto; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 0 20px; }
.panel {
  flex: 1;
  margin: 0 0 0 0;
  padding: 26px 28px 40px;
  background: var(--surface);
  border-top-left-radius: 18px;
  border: 1px solid var(--border);
  border-right: 0; border-bottom: 0;
}

.icon-btn {
  position: relative;
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn .dot { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 9px; font-weight: 700; display: grid; place-items: center; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-title { font-size: 24px; font-weight: 700; }
.page-sub { margin-top: 2px; color: var(--muted); font-size: 12px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 14px; font-weight: 700; }
.section-sub { font-size: 11px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 12px; font-weight: 600; white-space: nowrap;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn-dark:hover { background: #1e293b; }
[data-theme="dark"] .btn-dark { background: #f3f4f6; color: #0f172a; border-color: #f3f4f6; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-strong); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 11px; border-radius: 7px; }
.btn-block { width: 100%; height: 38px; }
.btn-icon { width: 28px; padding: 0; border-color: transparent; background: transparent; color: var(--faint); }
.btn-icon:hover { color: var(--danger); background: var(--danger-soft); }
.link { color: var(--accent-strong); font-weight: 600; font-size: 11px; }
.link:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 12.5px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; }
.select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m7 9 5-5 5 5M7 15l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input-sm, .select-sm { height: 30px; font-size: 12px; }
.checkbox { width: 15px; height: 15px; accent-color: var(--accent); }
.file-input { font: inherit; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 11px; font-weight: 500; color: var(--muted); }
.field .help { font-size: 10.5px; color: var(--faint); }
.field .errors { margin: 0; padding: 0; list-style: none; font-size: 11px; color: var(--danger); }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.form-section { padding: 18px 0; border-top: 1px solid var(--border-soft); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section h3 { font-size: 13px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.form-section h3 .num { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border-soft); }

.check-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.check-tile { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 12px; }
.check-tile:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-3); }
.segmented label, .segmented a { position: relative; padding: 5px 12px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked), .segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.lang-switch button { padding: 5px 9px; border: 0; border-radius: 7px; background: none; font: inherit; font-size: 11px; font-weight: 700; color: var(--muted); cursor: pointer; }
.lang-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Filters toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { width: auto; height: 30px; font-size: 12px; max-width: 190px; }
.toolbar .input { min-width: 170px; }
.toolbar .input[type="number"] { width: 100px; min-width: 0; }
.toolbar .input[type="date"] { min-width: 0; }
.toolbar .spacer { flex: 1; }
.chip-count { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--surface-3); font-size: 11px; font-weight: 700; color: var(--text-2); }
.filters-panel { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 16px; }
.filters-panel .toolbar { margin: 0; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab { padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); }

.pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-tab { height: 30px; padding: 0 12px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface); }
.pill-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Cards / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 0; }
.card-body { padding: 14px 16px 16px; }
.card-highlight { border: 2px solid var(--accent-soft-2); }

.grid { display: grid; gap: 12px; }
.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-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.mb-16 { margin-bottom: 16px; } .mb-12 { margin-bottom: 12px; } .mb-8 { margin-bottom: 8px; } .mt-16 { margin-top: 16px; } .mt-8 { margin-top: 8px; }

.stat { position: relative; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
a.stat:hover { border-color: var(--accent-soft-2); box-shadow: var(--shadow); }
.stat.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.stat-label.plain { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; }
.stat-value { margin-top: 4px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat-value.lg { font-size: 28px; }
.stat-delta { margin-top: 2px; font-size: 11px; font-weight: 600; color: var(--success); }
.stat-delta.down { color: var(--danger); }
.stat-foot { margin-top: 6px; }
.stat .spark { position: absolute; right: 14px; top: 14px; width: 60px; height: 22px; }
.stat .swatch { position: absolute; right: 14px; top: 12px; width: 34px; height: 20px; border-radius: 6px; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* palette helpers */
.c-slate  { color: var(--slate); }  .bg-slate  { background: var(--slate-bg); color: var(--slate); }
.c-orange { color: var(--orange); } .bg-orange { background: var(--orange-bg); color: var(--orange); }
.c-blue   { color: var(--blue); }   .bg-blue   { background: var(--blue-bg); color: var(--blue); }
.c-purple { color: var(--purple); } .bg-purple { background: var(--purple-bg); color: var(--purple); }
.c-cyan   { color: var(--cyan); }   .bg-cyan   { background: var(--cyan-bg); color: var(--cyan); }
.c-teal   { color: var(--teal); }   .bg-teal   { background: var(--teal-bg); color: var(--teal); }
.c-amber  { color: var(--amber); }  .bg-amber  { background: var(--amber-bg); color: var(--amber); }
.c-green  { color: var(--green); }  .bg-green  { background: var(--green-bg); color: var(--green); }
.c-red    { color: var(--red); }    .bg-red    { background: var(--red-bg); color: var(--red); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .strong { font-weight: 700; }
.text-sm { font-size: 11px; } .text-xs { font-size: 10.5px; } .nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; } .row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.accent { color: var(--accent-strong); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.badge-sold { background: var(--dark); color: #fff; }
.channel { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 10px; font-weight: 700; background: var(--surface-3); color: var(--faint); }
.channel.on { background: var(--blue-bg); color: var(--blue); }

/* ---------- Avatar ---------- */
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 14px; }
.avatar.xl { width: 56px; height: 56px; font-size: 18px; }
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.person { display: flex; align-items: center; gap: 9px; min-width: 0; }
.person b { display: block; font-size: 12.5px; font-weight: 600; }
.person small { display: block; font-size: 11px; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  height: 38px; padding: 0 14px; text-align: left; white-space: nowrap;
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { height: 48px; padding: 6px 14px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { font-variant-numeric: tabular-nums; }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; margin: 0 auto 10px; color: var(--faint); }
.empty b { display: block; color: var(--text); font-size: 13px; margin-bottom: 2px; }

.stage-select {
  height: 24px; padding: 0 22px 0 9px; border-radius: 6px; border: 0;
  font: inherit; font-size: 11px; font-weight: 600;
  background-color: var(--surface-3); color: var(--text-2);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m7 9 5-5 5 5M7 15l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
}

.direction { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; }
.direction.outgoing { background: var(--orange-bg); color: var(--orange); }
.direction.incoming { background: var(--green-bg); color: var(--green); }
.direction.missed { background: var(--red-bg); color: var(--red); }

.listen { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 6px; background: var(--orange-bg); color: var(--orange); font-size: 10.5px; font-weight: 700; border: 0; cursor: pointer; }

/* ---------- Pagination ---------- */
.pager-row { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 10px; font-size: 11.5px; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 4px; }
.pager a, .pager span { min-width: 28px; height: 28px; padding: 0 8px; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--border); font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface); }
.pager .current { border-color: var(--primary); color: var(--primary); background: var(--blue-bg); }
.pager .gap { border: 0; background: transparent; }

/* ---------- Drawer ---------- */
.drawer-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.drawer-root.open { pointer-events: auto; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(15, 23, 42, .28); backdrop-filter: blur(2px); opacity: 0; transition: opacity .2s; }
.drawer-root.open .drawer-overlay { opacity: 1; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.drawer-root.open .drawer { transform: translateX(0); }
.drawer.wide { width: min(640px, 100vw); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.drawer-kicker { font-size: 11px; font-weight: 600; color: var(--muted); }
.drawer-kicker.accent { color: var(--accent-strong); letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 20px 20px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.drawer-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.drawer-hero h2 { font-size: 18px; font-weight: 700; }
.drawer-hero .sub { font-size: 12px; color: var(--muted); }
.drawer-hero.tinted { margin: -14px -20px 16px; padding: 18px 20px; background: linear-gradient(180deg, var(--accent-soft), transparent); }
.drawer .field { margin-bottom: 10px; }
.drawer .field .input, .drawer .field .select { height: 34px; }
.drawer-section { padding: 14px 0; border-top: 1px solid var(--border-soft); }
.drawer-section h4 { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.kv .k { font-size: 11px; color: var(--muted); }
.kv .v { font-size: 12.5px; font-weight: 600; }

.stage-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-chip { height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 11px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.stage-chip:hover { border-color: var(--accent-soft-2); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 18px; font-size: 12px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 10.5px; color: var(--faint); }

.toast-saved { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--success); }

/* ---------- Phone privacy ---------- */
.phone-link { font-weight: 600; font-variant-numeric: tabular-nums; }
.phone-link:hover { color: var(--accent-strong); }
.phone-hidden { display: inline-flex; flex-direction: column; gap: 1px; }
.phone-hidden .masked { font-variant-numeric: tabular-nums; color: var(--muted); letter-spacing: .02em; }
.phone-hidden .hint { font-size: 10.5px; color: var(--accent-strong); font-weight: 600; }
.contact-lock { display: flex; gap: 10px; padding: 12px; border-radius: 10px; background: var(--accent-soft); border: 1px dashed var(--accent-soft-2); }
.contact-lock svg { color: var(--accent-strong); margin-top: 2px; }
.contact-lock b { display: block; font-size: 12.5px; }
.contact-lock span { font-size: 11.5px; color: var(--text-2); }

/* ---------- Kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.column { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 10px; min-height: 380px; transition: background .15s, border-color .15s; }
.column.drag-over { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.column-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.column-head .badge { height: 22px; }
.column-count { font-size: 11px; font-weight: 700; color: var(--muted); }
.column-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.column-tally { font-size: 12px; color: var(--muted); white-space: nowrap; }
.column-tally b, .stage-tally b { color: var(--text); font-weight: 700; }
.stage-tally { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.stage-tally .stat-value { margin-right: 2px; }
.column-body { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kcard { padding: 11px 12px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .15s, transform .15s; }
.kcard:hover { box-shadow: var(--shadow); }
.kcard.dragging { opacity: .5; transform: rotate(1.5deg); }
.kcard-title { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.kcard-meta { font-size: 11px; color: var(--muted); }
.kcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 8px; }
.kcard .select { height: 26px; font-size: 11px; margin-top: 8px; }
.due { display: inline-flex; align-items: center; height: 20px; white-space: nowrap; padding: 0 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.due.overdue { background: var(--red-bg); color: var(--red); }

/* ---------- Property cards ---------- */
.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.pcard { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); transition: box-shadow .2s, transform .2s; }
.pcard:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.pcard-media { position: relative; aspect-ratio: 16 / 10; background: linear-gradient(135deg, var(--accent-soft), var(--blue-bg)); overflow: hidden; }
.pcard-media img { width: 100%; height: 100%; object-fit: cover; }
.pcard-media .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent); opacity: .6; }
.pcard-media .ph svg { width: 42px; height: 42px; }
.pcard-media .tags { position: absolute; left: 10px; top: 10px; display: flex; gap: 5px; }
.pcard-media .tags .badge { background: rgba(255, 255, 255, .92); color: var(--text); backdrop-filter: blur(4px); }
.pcard-media .count { position: absolute; right: 10px; bottom: 10px; }
.pcard.sold .pcard-media img, .pcard.sold .pcard-media .ph { filter: grayscale(.9); opacity: .55; }
.sold-ribbon { position: absolute; inset: auto 0 0 0; padding: 7px 10px; background: rgba(15, 23, 42, .86); color: #fff; font-size: 11px; font-weight: 700; }
.pcard-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard-price { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.pcard-price small { font-size: 11px; font-weight: 600; color: var(--muted); }
.pcard-title { font-size: 12.5px; font-weight: 600; }
.pcard-addr { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.specs { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.specs span { display: inline-flex; align-items: center; gap: 4px; }
.specs svg { color: var(--faint); }
.pcard-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border-soft); }

.gallery { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; border-radius: 12px; overflow: hidden; }
.gallery .main-img { aspect-ratio: 16 / 10; background: linear-gradient(135deg, var(--accent-soft), var(--blue-bg)); position: relative; }
.gallery img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.gallery .thumbs { display: grid; grid-template-rows: repeat(2, 1fr); gap: 8px; }
.gallery .thumbs > div { background: var(--surface-3); position: relative; overflow: hidden; }
.gallery .more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 23, 42, .5); color: #fff; font-weight: 700; font-size: 15px; }
.image-manager { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.image-manager .thumb { position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.image-manager img { width: 100%; height: 100%; object-fit: cover; }
.image-manager .thumb-action { position: absolute; top: 5px; right: 5px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 22px; border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface-2); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 28px; height: 28px; color: var(--accent); }
.dropzone input { display: none; }
.preview-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.preview-strip img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.sticky { position: sticky; top: 16px; }
.spec-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.spec { padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border-soft); }
.spec .k { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.spec .v { font-size: 15px; font-weight: 800; margin-top: 2px; }
.price-box { padding: 16px; border-radius: 12px; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--accent-soft-2); }
.price-box .big { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- Dashboard widgets ---------- */
.dash-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr) 280px; gap: 12px; }
.portfolio { display: flex; flex-direction: column; gap: 10px; }
.portfolio .k { display: block; font-size: 12px; color: var(--muted); }
.pf-value { margin-top: 4px; }
.pf-value b { display: block; margin-top: 2px; font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.pf-income { padding: 12px 14px; border-radius: 12px; background: var(--green-bg); }
.pf-income .k { color: var(--green); font-weight: 600; }
.pf-income b { display: block; margin: 2px 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--green); }
.pf-income small { font-size: 11px; color: var(--muted); }
.pf-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; }
.pf-row b { white-space: nowrap; }
.pf-total { padding-top: 10px; border-top: 1px dashed var(--border); font-weight: 600; }
.pf-total b { font-size: 15px; color: var(--accent); }
.chart-box { position: relative; height: 230px; }
.chart-box.sm { height: 190px; }

.heatmap { display: grid; grid-template-columns: 44px repeat(7, 1fr); gap: 5px; font-size: 10.5px; }
.heatmap .h { color: var(--muted); display: flex; align-items: center; }
.heatmap .wd { text-align: center; color: var(--muted); font-weight: 600; }
.heatmap .cell { height: 24px; border-radius: 6px; background: var(--accent-soft); position: relative; }
.heatmap .l1 { background: #fed7b5; } .heatmap .l2 { background: #fdba74; } .heatmap .l3 { background: #fb923c; } .heatmap .l4 { background: #ea580c; }
[data-theme="dark"] .heatmap .l1 { background: #5a2e12; } [data-theme="dark"] .heatmap .l2 { background: #8a4216; }
.heat-legend { display: flex; align-items: center; gap: 3px; font-size: 10px; color: var(--muted); }
.heat-legend i { width: 14px; height: 8px; border-radius: 3px; display: inline-block; }

.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 10px; font-size: 11.5px; }
.funnel-row .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel-bar { grid-column: 1 / -1; height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.funnel-bar i { display: block; height: 100%; border-radius: 6px; min-width: 3px; }

.leader { display: grid; grid-template-columns: 26px minmax(0, 1.6fr) repeat(6, minmax(0, 1fr)) 110px; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); font-size: 12px; }
.leader.head { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.leader:last-child { border-bottom: 0; }
.leader.me { background: var(--accent-soft); }
.rank { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-weight: 800; font-size: 11px; background: var(--surface-3); color: var(--muted); }
.rank.r1 { background: #fef3c7; color: #b45309; } .rank.r2 { background: #e5e7eb; color: #4b5563; } .rank.r3 { background: #fde2cf; color: #c2410c; }
.score-bar { height: 6px; border-radius: 4px; background: var(--accent-soft-2); overflow: hidden; }
.score-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); border-radius: 4px; }
.score-num { font-weight: 800; color: var(--accent-strong); }

.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini { padding: 9px 11px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border-soft); }
.mini .k { font-size: 10.5px; color: var(--muted); }
.mini .v { font-size: 14px; font-weight: 800; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-item i { width: 9px; height: 9px; border-radius: 50%; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare .box { padding: 12px; border-radius: 10px; border: 1px solid var(--border); }
.compare .box.today { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.compare .box h5 { margin: 0 0 8px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.compare .line { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.compare .line b { font-weight: 800; }
.delta-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; background: var(--green-bg); color: var(--green); margin: 8px 6px 0 0; }
.delta-chip.down { background: var(--red-bg); color: var(--red); }
.rating-parts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.rating-parts .mini .v small { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.big-score { font-size: 42px; font-weight: 800; color: var(--accent-strong); letter-spacing: -.03em; line-height: 1; }
.progress { height: 10px; border-radius: 6px; background: var(--accent-soft-2); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }

.staff-card { padding: 14px; }
.staff-card .grid { margin-top: 10px; gap: 8px; }

.match-list { display: flex; flex-direction: column; gap: 8px; }
.match { display: flex; gap: 10px; align-items: center; padding: 9px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); transition: border-color .15s; }
.match:hover { border-color: var(--accent-soft-2); }
.match .thumb { width: 56px; height: 44px; border-radius: 7px; overflow: hidden; background: linear-gradient(135deg, var(--accent-soft), var(--blue-bg)); flex: none; }
.match .thumb img { width: 100%; height: 100%; object-fit: cover; }
.match-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; background: var(--green-bg); color: var(--green); }

/* ---------- Messages ---------- */
.messages { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.message { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; background: var(--dark); color: #fff; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toast-in .25s ease, toast-out .3s ease 4s forwards; }
.message.error { background: var(--danger); }
.message.success svg { color: #4ade80; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); visibility: hidden; } }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { position: relative; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; overflow: hidden; background: radial-gradient(1200px 600px at -10% -10%, #fb923c 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #2563eb 0%, transparent 55%), #0f172a; }
.auth-art h1 { font-size: 34px; line-height: 1.15; max-width: 440px; }
.auth-art p { max-width: 420px; color: rgba(255, 255, 255, .75); font-size: 14px; }
.auth-art .brand { padding: 0; }
.auth-art .brand img { height: 28px; }
.auth-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 460px; }
.auth-feats div { padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); font-size: 12px; }
.auth-feats b { display: block; font-size: 13px; margin-bottom: 2px; }
.auth-form { position: relative; display: grid; place-items: center; padding: 40px; background: var(--surface); }
.auth-lang { position: absolute; top: 20px; right: 24px; }
.auth-form > form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.auth-form .input { height: 42px; }

/* ---------- Code ---------- */
.code { display: block; padding: 10px 12px; border-radius: 9px; background: var(--surface-3); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; word-break: break-all; }
pre.code { white-space: pre-wrap; margin: 0; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgba(2, 6, 23, .88); padding: 30px; cursor: zoom-out; }
.lightbox img { max-height: 90vh; border-radius: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .dash-grid { grid-template-columns: 240px minmax(0, 1fr); }
  .dash-grid > :last-child { grid-column: 1 / -1; }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .leader { grid-template-columns: 26px minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)) 90px; }
  .leader .hide-md { display: none; }
}
@media (max-width: 1024px) {
  .detail-layout { grid-template-columns: 1fr; }
  .grid-5, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
}
@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); width: 240px; transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: grid !important; }
  .panel { padding: 18px 14px 30px; border-radius: 0; }
  .dash-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .spec-grid, .check-tiles { grid-template-columns: repeat(2, 1fr); }
}
.menu-btn { display: none !important; margin-right: auto; }
