/* DriveTrace Tenant Portal — Shared Design System */

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

:root {
  --accent:       #6366f1;
  --accent-dark:  #4f46e5;
  --accent-light: #a5b4fc;
  --green:   #22c55e;
  --red:     #ef4444;
  --amber:   #f59e0b;
  --sky:     #0ea5e9;

  --bg:      #0f172a;
  --surface: #1e293b;
  --surface2:#243145;
  --border:  #1e293b;
  --border2: #334155;
  --text:    #f1f5f9;
  --text2:   #cbd5e1;
  --muted:   #64748b;

  --nav-h:   60px;
  --radius:  10px;
  --font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { min-height: 100vh; }
body { font-family: var(--font); background: var(--bg); color: var(--text); }

/* ── Top nav ── */
.top-nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: rgba(15,23,42,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border2);
  display: flex; align-items: center; padding: 0 24px; gap: 0;
}
.nav-logo { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -.4px; white-space: nowrap; }
.nav-logo span { color: var(--accent-light); }
.nav-links { display: flex; align-items: center; gap: 2px; margin-left: 28px; flex: 1; overflow-x: auto; }
.nav-link {
  padding: 6px 12px; border-radius: 7px; font-size: 14px; font-weight: 500;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  transition: all .15s; cursor: pointer;
}
.nav-link:hover  { color: var(--text2); background: var(--surface); }
.nav-link.active { color: var(--accent-light); background: rgba(99,102,241,.15); }
.nav-spacer { flex: 1; }
.nav-user {
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted);
  padding-left: 16px; border-left: 1px solid var(--border2); white-space: nowrap;
}
.nav-user strong { color: var(--text2); }
.nav-signout { font-size: 12px; color: var(--muted); cursor: pointer; text-decoration: underline; }
.nav-signout:hover { color: var(--text2); }

/* ── Page layout ── */
.page-wrap { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 20px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text2);
              text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.place-card { cursor: pointer; transition: border-color .15s, background .15s; }
.place-card:hover { border-color: var(--border2); background: var(--surface2); }

/* ── Stat cards ── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--border2);
             border-radius: var(--radius); padding: 16px 18px; }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase;
              letter-spacing: .07em; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); }
.stat-sub   { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-3, .grid-2, .grid-4 { grid-template-columns: 1fr; } .page-wrap { padding: 16px; } }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 8px 12px; text-align: left; font-size: 11px; font-weight: 700;
           text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
           border-bottom: 1px solid var(--border2); }
tbody td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px;
         font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.badge-green  { background: rgba(34,197,94,.15);   color: #4ade80; }
.badge-red    { background: rgba(239,68,68,.15);    color: #f87171; }
.badge-amber  { background: rgba(245,158,11,.15);   color: #fbbf24; }
.badge-blue   { background: rgba(99,102,241,.2);    color: #818cf8; }
.badge-gray   { background: rgba(100,116,139,.15);  color: #94a3b8; }

/* ── Buttons ── */
.btn {
  padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s; display: inline-flex;
  align-items: center; gap: 6px; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: none; border: 1px solid var(--border2); color: var(--text2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #4ade80; }
.btn-success:hover { background: rgba(34,197,94,.2); }
.btn-danger { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #f87171; }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #94a3b8;
              letter-spacing: .05em; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 9px 13px; border-radius: 8px; font-size: 14px;
  border: 1px solid var(--border2); background: var(--bg); color: var(--text);
  outline: none; transition: border-color .15s;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--muted); }
.form-select { appearance: none; cursor: pointer; }

/* ── Loading / empty ── */
.loading { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }
.empty   { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; font-style: italic; }
.error-msg { color: #f87171; font-size: 13px; }

/* ── Map container ── */
.map-container { height: 70vh; border-radius: var(--radius); overflow: hidden;
                 border: 1px solid var(--border2); }

/* ── Progress bar ── */
.pbar-wrap { display: flex; align-items: center; gap: 10px; }
.pbar { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.pbar-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.pbar-fill.green { background: var(--green); }
.pbar-fill.amber { background: var(--amber); }
.pbar-fill.red   { background: var(--red); }
.pbar-label { font-size: 12px; font-weight: 700; width: 34px; text-align: right; }

/* ── Login page ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border2);
              border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px; }
.login-logo { font-size: 22px; font-weight: 800; color: #fff; margin-bottom: 2px; }
.login-sub  { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.login-alert { display: none; color: #f87171; font-size: 13px; margin-bottom: 12px; }
.login-alert.show { display: block; }

/* ── Metric row ── */
.metric-row { display: flex; justify-content: space-between; align-items: center;
              padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.metric-row:last-child { border-bottom: none; }
.metric-key { color: var(--muted); }
.metric-val { font-weight: 600; }

/* ── Inline spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border2);
           border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }

/* ── Dot status ── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-red   { background: var(--red);   box-shadow: 0 0 6px var(--red); }
.dot-amber { background: var(--amber); }
.dot-gray  { background: var(--muted); }

/* ── Utility ── */
.mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.flex-row   { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mb-12 { margin-bottom: 12px; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
