/* ============================================================
   SignTrack — modern SaaS styling
   ============================================================ */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

.brand-dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: linear-gradient(135deg,#6366f1,#a855f7); vertical-align: middle;
  margin-right: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform .05s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-block { width: 100%; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page { background: radial-gradient(1200px 600px at 20% -10%, #312e81 0%, #0f172a 45%, #0b1120 100%); min-height: 100vh; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 420px; background: var(--card); border-radius: 20px;
  padding: 38px 34px; box-shadow: 0 30px 80px rgba(0,0,0,.4);
}
.brand-mark { font-weight: 800; font-size: 15px; letter-spacing: .01em; color: #1e293b; margin-bottom: 22px; }
.login-card h1 { font-size: 26px; }
.login-card .subtitle { color: var(--muted); margin: 8px 0 22px; font-size: 14.5px; line-height: 1.5; }
.login-form { display: grid; gap: 14px; }
.login-form label, .add-form label, .brand-filter label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #334155; }
.login-form input, .add-form input, .add-form select, .brand-filter select {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
.login-form input:focus, .add-form input:focus, .add-form select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.alert { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.divider { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 12px; margin: 22px 0 16px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.divider span { padding: 0 12px; }
.demo-buttons { display: grid; gap: 10px; }
.btn-demo { justify-content: flex-start; font-weight: 600; }
.btn-admin { border-color: #c7d2fe; }
.btn-admin::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #4f46e5; margin-right: 10px; }
.btn-burger::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #c2410c; margin-right: 10px; }
.btn-velocity::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #0e7490; margin-right: 10px; }
.fineprint { text-align: center; color: var(--muted); font-size: 12px; margin: 20px 0 0; }

/* ============================================================
   APP SHELL (admin dashboard)
   ============================================================ */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #cbd5e1; padding: 22px 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { color: #fff; font-weight: 800; font-size: 15px; margin-bottom: 26px; }
.sidebar-nav { display: grid; gap: 4px; }
.nav-item { padding: 10px 12px; border-radius: 9px; font-size: 14px; color: #cbd5e1; font-weight: 500; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(99,102,241,.22); color: #fff; }
.sidebar-foot { margin-top: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; background: rgba(255,255,255,.05); border-radius: 10px; }
.chip-avatar { width: 32px; height: 32px; border-radius: 8px; background: #4f46e5; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.chip-name { color: #fff; font-size: 13.5px; font-weight: 600; }
.chip-role { color: #94a3b8; font-size: 11.5px; }
.logout { display: block; margin-top: 12px; text-align: center; font-size: 13px; color: #94a3b8; padding: 9px; border-radius: 9px; border: 1px solid rgba(255,255,255,.08); }
.logout:hover { color: #fff; background: rgba(255,255,255,.06); }

.content { padding: 30px 34px 60px; max-width: 1300px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 20px; }
.page-head h1 { font-size: 24px; }
.page-head .muted { margin-top: 4px; font-size: 14px; }
.brand-filter select { min-width: 170px; cursor: pointer; }

/* KPIs */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.kpi-num { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-label { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 22px; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 16px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; }
.count, .brand-tag { font-size: 12px; }
.count { color: var(--muted); font-weight: 600; margin-left: 6px; }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .dot, .legend-item .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-below { padding: 14px 20px; border-top: 1px solid var(--line); }

/* Map */
.map { width: 100%; height: 420px; }
.hero-map { height: 460px; }
.pin-dot { display: block; width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pop-addr { color: #475569; font-size: 12.5px; }
.pop-badge { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 700; }
.pop-notes { display: block; margin-top: 6px; color: #475569; font-size: 12px; }
.pop-target { color: #64748b; font-size: 11.5px; }
.leaflet-popup-content { margin: 12px 14px; line-height: 1.45; }

/* Add form */
.add-form { padding: 20px; }
.add-form .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 12px; }
.add-form .wide { grid-column: 1 / -1; }
.add-form .hint, .hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 14px; }

/* Table */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; padding: 12px 16px; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); background: #f8fafc; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table td.small { max-width: 280px; }
.brand-tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 30%, white); }
.stage-wrap { display: inline-flex; align-items: center; gap: 8px; }
.stage-select {
  appearance: none; -webkit-appearance: none; padding: 6px 26px 6px 22px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; color: #fff; border: none;
  background:
    var(--c, #6b7280)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E")
    no-repeat right 9px center;
  position: relative;
}
.stage-select option { background: #fff; color: #0f172a; }
.saved { color: #16a34a; font-size: 12px; font-weight: 700; opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }

/* ============================================================
   CLIENT PORTAL
   ============================================================ */
.client-shell { background: var(--bg); }
.client-page { min-height: 100vh; }
.topnav { background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.topnav-inner { max-width: 1120px; margin: 0 auto; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topnav-brand { display: flex; align-items: baseline; gap: 8px; }
.tn-name { font-weight: 800; font-size: 17px; }
.tn-sub { color: var(--muted); font-size: 12.5px; }
.topnav-right { display: flex; align-items: center; gap: 14px; }
.user-chip.light { background: #f1f5f9; color: #334155; font-size: 13px; font-weight: 600; padding: 6px 12px 6px 6px; border-radius: 999px; }
.logout.light { border-color: var(--line); color: var(--muted); margin-top: 0; padding: 8px 14px; }
.client-main { max-width: 1120px; margin: 0 auto; padding: 30px 24px 60px; }
.client-head { margin-bottom: 20px; }
.client-head h1 { font-size: 26px; }
.client-head .muted { margin-top: 4px; }
.kpi-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi.big .kpi-num { font-size: 34px; }
.map-card { position: relative; }
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 26px; }
.loc-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.loc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.loc-top h3 { font-size: 15px; line-height: 1.3; }
.stage-badge { flex-shrink: 0; padding: 3px 10px; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 700; }
.loc-addr { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.loc-notes { font-size: 13px; color: #334155; margin: 0 0 10px; line-height: 1.5; }
.loc-target { font-size: 12.5px; color: var(--muted); margin: 0; }

/* How it works */
.app-foot { margin-top: 10px; }
.hiw { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 20px; box-shadow: var(--shadow); }
.hiw summary { cursor: pointer; padding: 14px 0; font-weight: 600; font-size: 14px; color: #334155; }
.hiw p { color: var(--muted); font-size: 13.5px; line-height: 1.65; margin: 0 0 16px; max-width: 760px; }

/* Responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px; }
  .sidebar-nav { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .add-form .grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .kpi-row, .kpi-strip { grid-template-columns: 1fr 1fr; }
  .add-form .grid { grid-template-columns: 1fr; }
}
