/* =====================================================================
   RealtyCRM — Main Stylesheet
   Aesthetic: emerald + terracotta + gold (continuation of Estatery brand)
   ===================================================================== */

/* ------------------------------ TOKENS ------------------------------ */
:root {
  /* Brand palette */
  --accent: #0E4D3C;
  --accent-soft: #DCE9E1;
  --accent-dark: #0A3528;
  --secondary: #C2592C;
  --secondary-soft: #FBE5D6;
  --gold: #B8975C;
  --gold-soft: #F5EBD8;
  --lavender: #6B5BB8;
  --lavender-soft: #E8E5F5;
  --rose: #C25E7A;
  --rose-soft: #FBE0E7;
  --teal: #2E7D8C;
  --teal-soft: #DBEEF1;
  --terra: #7A5B3D;
  --green: #16A34A;
  --green-soft: #DCFCE7;
  --amber: #D97706;
  --amber-soft: #FEF3C7;
  --red: #DC2626;
  --red-soft: #FEE2E2;
  --blue: #2563EB;
  --blue-soft: #DBEAFE;
  --info: #0891B2;
  --info-soft: #CFFAFE;
  --purple: #9333EA;
  --purple-soft: #F3E8FF;
  --orange: #EA580C;
  --orange-soft: #FFEDD5;
  --gray: #6B7280;
  --gray-soft: #F3F4F6;

  /* Surfaces (light theme defaults) */
  --bg: #F4EFE6;
  --bg-soft: #FBF8F2;
  --surface: #FFFFFF;
  --surface-2: #FAFAF8;
  --surface-3: #F4F1EC;
  --border: #E8E2D5;
  --border-strong: #D6CFBF;
  --text: #1C1917;
  --text-soft: #57534E;
  --text-muted: #8A8275;
  --text-inv: #FFFFFF;

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(28,25,23,.04), 0 1px 3px rgba(28,25,23,.06);
  --shadow-md: 0 4px 12px rgba(28,25,23,.08);
  --shadow-lg: 0 12px 32px rgba(28,25,23,.12);

  /* Type */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

/* Dark theme overrides */
[data-theme="dark"] {
  --bg: #0E0D0B;
  --bg-soft: #16140F;
  --surface: #1F1C17;
  --surface-2: #26221C;
  --surface-3: #2E2920;
  --border: #36312A;
  --border-strong: #4A4338;
  --text: #F4EFE6;
  --text-soft: #C8C0AC;
  --text-muted: #8B8475;
  --accent-soft: rgba(14,77,60,.25);
  --secondary-soft: rgba(194,89,44,.2);
  --gold-soft: rgba(184,151,92,.2);
  --lavender-soft: rgba(107,91,184,.2);
  --rose-soft: rgba(194,94,122,.2);
  --teal-soft: rgba(46,125,140,.2);
  --green-soft: rgba(22,163,74,.18);
  --amber-soft: rgba(217,119,6,.2);
  --red-soft: rgba(220,38,38,.2);
  --blue-soft: rgba(37,99,235,.2);
  --info-soft: rgba(8,145,178,.2);
  --purple-soft: rgba(147,51,234,.2);
  --orange-soft: rgba(234,88,12,.2);
  --gray-soft: rgba(107,114,128,.2);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}

/* ------------------------------ RESET ------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 22px; }
h3 { font-size: 17px; line-height: 1.3; }
h4 { font-size: 14px; font-weight: 700; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
p  { margin: 0 0 8px; color: var(--text-soft); }
a  { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
code { font-family: 'SFMono-Regular', Menlo, monospace; background: var(--surface-3); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong-link { font-weight: 600; color: var(--text); }
.strong-link:hover { color: var(--accent); }
.muted-link { color: var(--text-muted); font-size: 13px; }
.muted-link:hover { color: var(--accent); }

/* ------------------------------ LAYOUT ------------------------------ */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 60;
  transition: transform .22s ease;
}
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
}
.content {
  flex: 1;
  padding: 24px;
  max-width: 1600px;
  width: 100%;
}
.appfoot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.appfoot-inner {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--text-muted);
}

/* ------------------------------ SIDEBAR ------------------------------ */
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  border-radius: 8px;
  position: relative;
  flex-shrink: 0;
}
.brand-logo::before {
  content: ''; position: absolute; inset: 6px 6px auto auto;
  width: 8px; height: 8px; background: var(--gold); border-radius: 2px;
}
.brand-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 600; color: var(--text);
  line-height: 1.1;
}
.brand-tag { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-close {
  display: none;
  background: none; border: none;
  color: var(--text-muted);
  padding: 6px;
}

.sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: 12px 12px;
}
.nav-section { margin-bottom: 16px; }
.nav-section-label {
  font-size: 10.5px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 6px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text-soft);
  font-weight: 500; font-size: 13.5px;
  margin-bottom: 1px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
}
[data-theme="dark"] .nav-item.active { color: var(--text); }
.nav-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  flex-shrink: 0;
}
.nav-label { flex: 1; }

.icon-green    { background: var(--green-soft);    color: var(--green); }
.icon-blue     { background: var(--blue-soft);     color: var(--blue); }
.icon-amber    { background: var(--amber-soft);    color: var(--amber); }
.icon-gold     { background: var(--gold-soft);     color: var(--gold); }
.icon-lavender { background: var(--lavender-soft); color: var(--lavender); }
.icon-rose     { background: var(--rose-soft);     color: var(--rose); }
.icon-teal     { background: var(--teal-soft);     color: var(--teal); }
.icon-terra    { background: var(--secondary-soft); color: var(--secondary); }
.icon-gray     { background: var(--gray-soft);     color: var(--gray); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.upgrade-card {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--text-inv);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 12.5px;
}
.upgrade-title { font-weight: 600; margin-bottom: 2px; }
.upgrade-text { opacity: .85; font-size: 11.5px; }

/* ------------------------------ TOPBAR ------------------------------ */
.hamburger {
  display: none;
  background: none; border: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  align-items: center; justify-content: center;
  color: var(--text-soft);
}
.hamburger:hover { background: var(--surface-2); }

.topbar-search {
  flex: 1;
  max-width: 480px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  position: relative;
}
.topbar-search:focus-within { border-color: var(--accent); }
.topbar-search input {
  flex: 1;
  border: none; background: transparent; outline: none;
  color: var(--text); font-size: 13.5px;
}
.search-icon { color: var(--text-muted); display: flex; }
.search-kbd {
  font-size: 10.5px;
  background: var(--surface);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-family: var(--font-sans);
}

.topbar-actions {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
}
.icon-btn {
  background: none; border: none;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-soft);
  position: relative;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.disabled { opacity: .4; pointer-events: none; }
.notif-dot {
  position: absolute; top: 4px; right: 4px;
  background: var(--rose); color: white;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}

/* Theme toggle: hide opposite icon */
.theme-light, .theme-dark { display: inline-flex; }
[data-theme="light"] .theme-dark { display: none; }
[data-theme="dark"]  .theme-light { display: none; }

.user-menu {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  outline: none;
}
.user-menu:hover { background: var(--surface-2); }
.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-role { font-size: 11.5px; color: var(--text-muted); }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 6px;
  display: none;
  z-index: 50;
}
.user-menu:hover .user-dropdown,
.user-menu:focus-within .user-dropdown { display: block; }
.user-dropdown a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 13px;
  text-decoration: none;
}
.user-dropdown a:hover { background: var(--surface-2); color: var(--text); }
.user-dropdown hr { margin: 6px 4px; }
.logout-link { color: var(--rose) !important; }

/* ------------------------------ AVATAR ------------------------------ */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--accent); color: white;
  border-radius: 50%;
  font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.avatar-xs { width: 22px; height: 22px; font-size: 10px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.user-cell { display: flex; align-items: center; gap: 10px; }

/* ------------------------------ BUTTONS ------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
  text-decoration: none;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform .08s, box-shadow .12s, background .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-dark); color: white; text-decoration: none; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn-full { width: 100%; justify-content: center; padding: 11px; }
.btn.disabled { opacity: .4; pointer-events: none; }
.btn-mini {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-soft);
  border: 1px solid var(--border);
  text-decoration: none;
}
.btn-mini:hover { background: var(--accent-soft); color: var(--accent-dark); text-decoration: none; }
.btn-mini.disabled { opacity: .4; pointer-events: none; }

/* ------------------------------ PAGE HEAD ------------------------------ */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title { font-size: 26px; margin: 0 0 2px; }
.page-sub { color: var(--text-muted); margin: 0; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------ CARDS ------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
  margin: -4px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0 0 2px; }
.card-head p { margin: 0; font-size: 12.5px; }
.pad-xl { padding: 40px; }

/* ------------------------------ KPI GRID ------------------------------ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; gap: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.kpi-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
}
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-meta { flex: 1; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.1; color: var(--text); }
.kpi-value .kpi-of { color: var(--text-muted); font-size: 16px; font-weight: 400; }
.kpi-foot { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.kpi-green   .kpi-icon { background: var(--green-soft);    color: var(--green); }
.kpi-green::before   { background: var(--green); }
.kpi-rose    .kpi-icon { background: var(--rose-soft);     color: var(--rose); }
.kpi-rose::before    { background: var(--rose); }
.kpi-gold    .kpi-icon { background: var(--gold-soft);     color: var(--gold); }
.kpi-gold::before    { background: var(--gold); }
.kpi-teal    .kpi-icon { background: var(--teal-soft);     color: var(--teal); }
.kpi-teal::before    { background: var(--teal); }
.kpi-blue    .kpi-icon { background: var(--blue-soft);     color: var(--blue); }
.kpi-blue::before    { background: var(--blue); }
.kpi-lavender .kpi-icon { background: var(--lavender-soft); color: var(--lavender); }
.kpi-lavender::before { background: var(--lavender); }

.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.trend.up   { color: var(--green); }
.trend.down { color: var(--rose); }

/* ------------------------------ DASH ROWS ------------------------------ */
/*.dash-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}*/
.dash-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  align-items: start;
}
.dash-row-3 { grid-template-columns: repeat(3, 1fr); }
/*.chart-card { min-height: 320px; }*/
.chart-card { 
  min-height: 320px; 
  max-height: 380px; 
  height: 380px;
  display: flex; 
  flex-direction: column; 
  overflow: hidden;
}
.chart-card .card-head { flex-shrink: 0; }
.chart-card canvas { 
  max-height: 260px !important; 
  height: 260px !important;
  width: 100% !important;
  flex-shrink: 0;
}
.chart-card .funnel,
.chart-card .src-list,
.chart-card .proj-inv-list { 
  flex: 1; 
  overflow-y: auto; 
  min-height: 0;
}

.dash-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  align-items: stretch;
}
.dash-row > * {
  min-height: 0;
  min-width: 0;
}
.chart-card canvas { max-height: 280px !important; flex: 1; min-height: 0; }

.chart-legend {
  display: flex; gap: 16px; align-items: center;
  font-size: 12px; color: var(--text-muted);
}
.legend-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px; vertical-align: middle;
}

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-label { width: 100px; font-size: 12.5px; font-weight: 500; color: var(--text-soft); flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; position: relative; height: 32px; background: var(--surface-3); border-radius: 8px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 8px; transition: width .4s ease; }
.funnel-count {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-weight: 600; font-size: 12.5px; color: var(--text);
}

/* Source list */
.src-list { display: flex; flex-direction: column; gap: 10px; }
.src-row { display: grid; grid-template-columns: 140px 1fr 90px; align-items: center; gap: 12px; }
.src-label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.src-dot { width: 10px; height: 10px; border-radius: 50%; }
.src-bar-wrap { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.src-bar { height: 100%; border-radius: 4px; transition: width .4s ease; }
.src-val { font-size: 12.5px; text-align: right; }

/* Project inventory list */
.proj-inv-list { display: flex; flex-direction: column; gap: 14px; }
.proj-inv-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.proj-inv-bar { display: flex; height: 18px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.proj-inv-bar .seg { transition: width .3s ease; }
.seg-green { background: var(--green); }
.seg-amber { background: var(--amber); }
.seg-red   { background: var(--rose); }
.seg-blue  { background: var(--blue); }
.proj-inv-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-muted);
  margin-top: 6px;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* List soft (compact item lists) */
.list-soft { display: flex; flex-direction: column; gap: 1px; }
.list-soft-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.list-soft-item:last-child { border-bottom: none; }
.task-prio {
  width: 4px; height: 36px; border-radius: 2px;
  background: var(--gray);
}
.prio-low { background: var(--gray); }
.prio-medium { background: var(--blue); }
.prio-high { background: var(--amber); }
.prio-urgent, .prio-hot { background: var(--rose); }
.task-meta { flex: 1; min-width: 0; }

.visit-date {
  width: 44px; text-align: center;
  background: var(--surface-3);
  border-radius: 8px;
  padding: 4px;
  flex-shrink: 0;
}
.visit-day { display: block; font-weight: 600; color: var(--text); font-size: 16px; }
.visit-mon { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}
.dot-create, .dot-status_change { background: var(--green); }
.dot-update { background: var(--blue); }
.dot-delete { background: var(--rose); }
.dot-login, .dot-logout { background: var(--lavender); }
.dot-view { background: var(--gray); }
.activity-body { flex: 1; min-width: 0; }

/* ------------------------------ TABLES ------------------------------ */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th, .table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-weight: 600; font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--surface-2);
  position: sticky; top: 0;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table-compact th, .table-compact td { padding: 8px 10px; }

/* ------------------------------ FORMS ------------------------------ */
/*.form-grid { display: flex; flex-direction: column; gap: 16px; }
.form-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 8px;
}
.span-2 { grid-column: span 2; }

label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-soft);
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="search"],
input[type="date"], input[type="datetime-local"], input[type="time"],
select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 60px; }
.check { display: flex; align-items: center; gap: 6px; flex-direction: row; font-size: 13px; }
.check-row { flex-direction: row; align-items: center; }*/

/* ------------------------------ FORMS ------------------------------ */
.form-grid { display: flex; flex-direction: column; gap: 16px; }
.form-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 8px;
}
.span-2 { grid-column: span 2; }

label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 0;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="search"],
input[type="date"], input[type="datetime-local"], input[type="time"],
input[type="url"], input[type="color"],
select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
  display: block;
  margin-top: 4px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="color"] {
  padding: 4px;
  height: 40px;
  cursor: pointer;
}

textarea { 
  resize: vertical; 
  min-height: 80px; 
  font-family: inherit;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A8275' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.check { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  flex-direction: row; 
  font-size: 13px; 
  cursor: pointer;
}
.check input[type="checkbox"], .check input[type="radio"] {
  width: auto;
  margin: 0;
}
.check-row { flex-direction: row; align-items: center; }

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* ------------------------------ FILTER BAR ------------------------------ */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: -4px 0 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.filter-bar select { width: auto; min-width: 140px; }
.filter-search {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
}
.filter-search:focus-within { border-color: var(--accent); }
.filter-search input {
  flex: 1; border: none; background: transparent; outline: none;
  padding: 9px 0;
}

/* ------------------------------ FLASH ------------------------------ */
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.flash-success { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.flash-error   { background: var(--red-soft);   color: var(--red);   border-color: var(--red); }
.flash-warning { background: var(--amber-soft); color: var(--amber); border-color: var(--amber); }
.flash-info    { background: var(--blue-soft);  color: var(--blue);  border-color: var(--blue); }

/* ------------------------------ STATUS PILLS ------------------------------ */
.pill {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
  letter-spacing: .01em;
}
.pill-green   { background: var(--green-soft);   color: var(--green); }
.pill-red     { background: var(--red-soft);     color: var(--red); }
.pill-amber   { background: var(--amber-soft);   color: var(--amber); }
.pill-blue    { background: var(--blue-soft);    color: var(--blue); }
.pill-purple  { background: var(--purple-soft);  color: var(--purple); }
.pill-orange  { background: var(--orange-soft);  color: var(--orange); }
.pill-info    { background: var(--info-soft);    color: var(--info); }
.pill-gray    { background: var(--gray-soft);    color: var(--gray); }

.source-pill {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
}
.hot-flag {
  display: inline-block;
  font-size: 11px;
  margin-left: 6px;
}

/* ------------------------------ EMPTY STATE ------------------------------ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}
.empty-state-full { padding: 60px 20px; }
.empty-state-mini {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-illustration {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .85;
}

/* ------------------------------ PAGINATION ------------------------------ */
.pagination {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0 0;
  font-size: 12.5px;
  flex-wrap: wrap;
  gap: 12px;
}
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.pagination-info { color: var(--text-muted); }

/* ------------------------------ PROJECT CARDS ------------------------------ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--text);
}
.project-cover {
  height: 120px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.6);
}
.project-cover-icon { display: flex; }
.project-status { position: absolute; top: 12px; left: 12px; }
.project-body { padding: 16px; }
.project-code { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.project-name { font-size: 17px; margin: 4px 0; }
.project-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; margin-bottom: 12px; }
.project-stats { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.project-stat { display: flex; flex-direction: column; }
.project-stat strong { font-size: 16px; }
.project-stat span { font-size: 11px; color: var(--text-muted); }
.project-progress {
  height: 6px; background: var(--surface-3); border-radius: 3px;
  margin-top: 12px; overflow: hidden;
}
.project-progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }

/* ------------------------------ INVENTORY GRID ------------------------------ */
.legend-bar {
  display: flex; gap: 16px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 12px;
}
.legend { display: flex; align-items: center; }

.inventory-grid {
  display: flex; flex-direction: column; gap: 4px;
  margin: -8px 0;
}
.floor-row { display: flex; gap: 12px; align-items: center; padding: 4px 0; }
.floor-label {
  width: 64px; flex-shrink: 0;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}
.unit-row { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.unit-cell {
  width: 78px;
  padding: 8px 6px;
  border-radius: 6px;
  text-align: center;
  cursor: pointer;
  transition: transform .08s, box-shadow .12s;
  border: 1px solid transparent;
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 2px;
}
.unit-cell:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.unit-no { font-weight: 600; font-size: 12px; }
.unit-type { font-size: 10px; color: var(--text-muted); }
.unit-available { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.unit-blocked   { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.unit-booked    { background: var(--blue-soft);  border-color: var(--blue);  color: var(--blue); }
.unit-sold      { background: var(--rose-soft);  border-color: var(--rose);  color: var(--rose); }
.unit-registered{ background: var(--lavender-soft); border-color: var(--lavender); color: var(--lavender); }
.unit-possession{ background: var(--gold-soft);  border-color: var(--gold);  color: var(--gold); }
.unit-not_for_sale { background: var(--gray-soft); border-color: var(--gray); color: var(--gray); }
.unit-cell .unit-no, .unit-cell .unit-type { color: inherit; }

/* ------------------------------ MODAL ------------------------------ */
.modal {
  position: fixed; inset: 0;
  background: rgba(28,25,23,.45);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 90vh;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.modal-foot select, .modal-foot input { width: auto; flex: 1; min-width: 120px; }

/* ------------------------------ KV LIST ------------------------------ */
.kv-list {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 16px;
  margin: 0;
  font-size: 13px;
}
.kv-list dt { color: var(--text-muted); font-weight: 500; }
.kv-list dd { margin: 0; color: var(--text); font-weight: 500; }

/* ------------------------------ LEAD DETAIL ------------------------------ */
.lead-detail-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
}
.lead-summary { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.lead-summary-meta h2 { font-size: 22px; margin: 0 0 6px; }
.lead-req {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}
.lead-req h4 { margin-bottom: 6px; }

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.tab {
  background: none; border: none;
  padding: 10px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Status form (inline) */
.status-form { display: flex; gap: 8px; align-items: center; }
.status-form select { flex: 1; }

/* Note form */
.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.note-form textarea { font-size: 13px; }
.note-form button { align-self: flex-start; }
.note-list { display: flex; flex-direction: column; gap: 14px; }
.note-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: none; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}
.dot-status_change { background: var(--blue); }
.dot-created { background: var(--green); }
.dot-converted { background: var(--gold); }
.dot-note, .dot-call, .dot-email, .dot-sms { background: var(--lavender); }

/* ------------------------------ BACKDROP ------------------------------ */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 55;
}

/* ------------------------------ RESPONSIVE ------------------------------ */
@media (max-width: 1100px) {
  .dash-row, .dash-row-3 { grid-template-columns: 1fr; }
  .lead-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); width: 280px; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-wrap { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .sidebar-close { display: inline-flex; margin-left: auto; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .topbar { padding: 0 16px; gap: 8px; }
  .content { padding: 16px; }
  .topbar-search { display: none; }
  .form-2col { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .user-info { display: none; }
  .kv-list { grid-template-columns: 1fr; gap: 4px 0; }
  .kv-list dt { color: var(--text-muted); margin-top: 8px; }
  .kpi-value { font-size: 22px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }
}
@media (max-width: 480px) {
  .table th, .table td { padding: 8px 8px; font-size: 12.5px; }
  .src-row { grid-template-columns: 1fr; gap: 4px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select { width: 100%; }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
