:root {
  --brand: #1463e0;
  --brand-500: #2474ea;
  --brand-700: #0f4fb8;
  --brand-50: #eef4fe;
  --brand-100: #dce8fd;
  --navy: #0e2a5c;
  --teal-700: #0f5566;
  --teal-500: #1a7a8a;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--navy); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--navy); }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); font-size: 18px;
}
.brand-lg { font-size: 22px; margin-bottom: 24px; }

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(135deg, var(--teal-700), var(--teal-500));
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.login-card h1 { font-size: 22px; }
.login-card .muted { margin: 6px 0 20px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 0 8px 20px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #475569; font-weight: 500; text-decoration: none;
}
.sidebar nav a i { font-size: 17px; }
.sidebar nav a:hover { background: var(--surface-2); }
.sidebar nav a.active { background: var(--brand-50); color: var(--brand); }
.sidebar nav a .nav-count { margin-left: auto; padding: 1px 8px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar h2 { font-size: 18px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.admin-name { color: var(--muted); font-weight: 500; }
.menu-btn { display: none; }
.page { padding: 24px 28px 48px; }
.backdrop { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent;
  border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
.btn:hover { filter: brightness(0.97); text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.icon-btn {
  border: 0; background: transparent; width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  color: var(--muted); font-size: 16px; display: inline-grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-bg); color: var(--red); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: 13px; color: #334155; }
.field small { color: var(--muted); font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 9px 12px; width: 100%; outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.check { flex-direction: row; align-items: center; gap: 10px; }
.check input { width: 18px; height: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--red); background: var(--red-bg); padding: 10px 12px; border-radius: 10px; margin: 0 0 14px; }

/* ---------- cards / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.stat { padding: 18px; display: flex; gap: 14px; align-items: center; color: inherit; text-decoration: none; }
a.stat:hover { text-decoration: none; border-color: var(--brand-100); }
.stat .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: var(--brand-50); color: var(--brand); }
.stat .ico.teal { background: #e0f2f1; color: var(--teal-700); }
.stat .ico.green { background: var(--green-bg); color: var(--green); }
.stat .ico.amber { background: var(--amber-bg); color: var(--amber); }
.stat .ico.red { background: var(--red-bg); color: var(--red); }
.stat .num { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-weight: 500; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.hero-stats { grid-template-columns: repeat(3, 1fr); margin-bottom: 16px; }
.hero {
  padding: 22px; border-radius: var(--radius); color: #fff; display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, var(--teal-700), var(--teal-500)); text-decoration: none;
}
.hero:nth-child(2) { background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); }
.hero:nth-child(3) { background: linear-gradient(135deg, #0e2a5c, #1e4a8f); }
.hero:hover { text-decoration: none; filter: brightness(1.05); }
.hero i { font-size: 30px; opacity: 0.9; }
.hero .num { font-size: 32px; font-weight: 700; line-height: 1; }
.hero .lbl { opacity: 0.9; font-weight: 500; margin-top: 4px; }
.two-col { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 10px; }
.bar-row .track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar-row .fill { height: 100%; background: var(--brand); border-radius: 99px; }
.bar-row .fill.teal { background: var(--teal-500); }
.bar-row .val { text-align: right; font-weight: 600; }

/* ---------- toolbar / table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 36px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcff; }
td .title { font-weight: 600; color: var(--navy); }
td .sub { color: var(--muted); font-size: 12px; }
td.actions { white-space: nowrap; text-align: right; }
.thumb { width: 52px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: block; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty i { font-size: 32px; display: block; margin-bottom: 8px; color: #cbd5e1; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--brand-50); color: var(--brand); white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.gray { background: #f1f5f9; color: #475569; }
select.stage-select { width: auto; padding: 5px 8px; font-size: 13px; border-radius: 8px; }

/* ---------- detail ---------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 500; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; font-weight: 600; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--brand-100); }
.timeline .t { font-weight: 600; }
.timeline .m { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; font-weight: 600; color: #475569; }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab .count { margin-left: 6px; opacity: 0.8; }
.photo-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo-list .ph { position: relative; }
.photo-list img { width: 84px; height: 64px; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-2); }
.photo-list button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--red); color: #fff; cursor: pointer; font-size: 12px; display: grid; place-items: center; }

/* ---------- modal / toast ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.modal.wide { max-width: 760px; }
.modal-overlay.full { padding: 0; }
.modal.full { max-width: none; width: 100vw; height: 100vh; max-height: none; border-radius: 0; }
.modal.full .modal-body { flex: 1; }

/* ---------- buyer property picker ---------- */
.picked { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.picked .badge { font-weight: 500; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick-row { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.pick-row:hover { background: var(--surface-2); }
.pick-row.on { border-color: var(--brand); background: var(--brand-50); }
.pick-row input { width: 18px; height: 18px; margin: 0; }
.pick-row .title { font-weight: 600; }
.pick-row .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pick-row .price { font-weight: 600; white-space: nowrap; }
.pick-toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.pick-toggle input { width: auto; }

/* ---------- price range slider ---------- */
.range-head { font-size: 14px; color: var(--navy); }
.range { position: relative; height: 28px; }
.range-track { position: absolute; left: 10px; right: 10px; top: 12px; height: 4px; border-radius: 4px; background: var(--border); }
.range-fill { position: absolute; top: 0; bottom: 0; background: var(--brand); border-radius: 4px; }
.range input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 28px; margin: 0; padding: 0; border: 0; box-shadow: none;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.range input[type=range]::-webkit-slider-runnable-track { background: none; height: 28px; }
.range input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 20px; height: 20px; margin-top: 4px; border-radius: 50%;
  background: #fff; border: 2px solid var(--brand); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25); cursor: grab;
}
.range input[type=range]::-moz-range-track { background: none; }
.range input[type=range]::-moz-range-thumb {
  pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); cursor: grab;
}
.range input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--brand-100); }
.range-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; display: flex; gap: 8px; align-items: center; }
.toast.error { background: var(--red); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .two-col, .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform 0.2s; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); z-index: 30; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .page { padding: 16px 16px 40px; }
  .hero-stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-name, .topbar .btn span { display: none; }
  .kv { grid-template-columns: 110px 1fr; }
}

/* ---------- marketing kit ---------- */
.msg-card { margin-bottom: 14px; }
.msg-card:last-child { margin-bottom: 0; }
.msg-title { font-weight: 600; font-size: 13px; color: #334155; margin-bottom: 6px; }
.msg { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.msg-actions { display: flex; gap: 8px; margin-top: 8px; }
.tasks { margin: 0 0 14px; padding-left: 20px; line-height: 1.7; }
.kit-fields { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ---------- growth strategy ---------- */
.plan-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.plan-card.featured { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.plan-name { font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.plan-price { font-size: 26px; font-weight: 700; color: var(--navy); margin: 6px 0 2px; }
.plan-price .muted { font-size: 14px; font-weight: 500; }
.plan-card p { margin: 12px 0 0; line-height: 1.5; }
.calc-fields { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.week { margin-bottom: 14px; }
.week:last-child { margin-bottom: 0; }
.check-task { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; cursor: pointer; line-height: 1.5; }
.check-task input { width: auto; margin-top: 4px; flex-shrink: 0; }
.check-task.done span { text-decoration: line-through; color: var(--muted); }
