:root {
  --bg: #fafaf9;
  --card: #ffffff;
  --border: #e7e5e4;
  --text: #1c1917;
  --muted: #78716c;
  --navy: #1e40af;
  --navy-light: #eff6ff;
  --track: #dbe1ea;
  --red: #dc2626;
  --red-light: #fef2f2;
  --green: #15803d;
  --green-light: #f0fdf4;
  --gray-light: #f5f5f4;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }

/* ---- top bar ---- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 10px; height: 10px; border-radius: 2px; background: var(--navy); }
.brand .sub { font-weight: 400; color: var(--muted); }
.topbar .right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.topbar .right .name { color: var(--text); font-weight: 600; cursor: pointer; }
.topbar .right .name:hover { text-decoration: underline; }
.linkbtn { background: none; border: none; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.linkbtn:hover { color: var(--text); }

/* ---- layout ---- */
.container { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.container.narrow { max-width: 560px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
h2 { font-size: 16px; font-weight: 700; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.meta { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 10px; }
.meta .k { font-size: 11px; color: var(--muted); }
.meta .v { font-size: 13px; }
.ticker { color: var(--green); font-weight: 700; }

/* ---- forms ---- */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--navy); }
textarea { min-height: 88px; resize: vertical; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.error { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.btn {
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  transition: opacity 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-outline { border-color: var(--border); }
.btn-outline:hover { border-color: var(--text); }
.btn-danger { color: var(--red); border-color: var(--border); }
.btn-danger:hover { border-color: var(--red); }
.btn-block { width: 100%; padding: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* quick-pick pills */
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pill {
  padding: 4px 10px; font-size: 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); cursor: pointer; font-family: inherit; color: var(--text);
}
.pill:hover { border-color: var(--text); }
.pill.selected { background: var(--text); color: #fff; border-color: var(--text); }

/* radio-style choice boxes */
.choices { display: flex; gap: 10px; }
.choice {
  flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px;
  cursor: pointer; display: flex; align-items: center; gap: 8px; background: var(--card); font-size: 13px;
}
.choice.selected { border-color: var(--navy); background: var(--navy-light); }
.choice .radio { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--muted); flex-shrink: 0; }
.choice.selected .radio { border-color: var(--navy); background: radial-gradient(var(--navy) 45%, transparent 50%); }

/* ---- avatars & badges ---- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0; letter-spacing: 0.3px;
}
.avatars { display: flex; }
.avatars .avatar { margin-left: -6px; border: 2px solid var(--card); }
.avatars .avatar:first-child { margin-left: 0; }
.pct { display: inline-block; background: var(--gray-light); border-radius: 4px; padding: 1px 7px; font-weight: 700; font-size: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 4px; padding: 2px 8px; white-space: nowrap; }
.badge.open { background: var(--navy-light); color: var(--navy); }
.badge.yes  { background: var(--green-light); color: var(--green); }
.badge.no   { background: var(--red-light); color: var(--red); }
.badge.na   { background: var(--gray-light); color: var(--muted); }

/* ---- dashboard ---- */
.tabs { display: flex; gap: 4px; border: 1px solid var(--border); border-radius: 6px; padding: 3px; background: var(--card); }
.tab { padding: 5px 12px; font-size: 12px; font-weight: 600; border-radius: 4px; cursor: pointer; color: var(--muted); border: none; background: none; font-family: inherit; }
.tab.active { background: var(--text); color: #fff; }
.company { margin-bottom: 20px; }
.company-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.company-head .name { font-weight: 700; font-size: 15px; }
.driver-list { background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.driver-row {
  display: grid;
  grid-template-columns: 1fr 130px 70px 60px 100px 90px;
  gap: 12px; align-items: center;
  padding: 14px 16px; border-top: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
}
.driver-row:first-child { border-top: none; }
.driver-row:hover { background: var(--bg); }
.driver-row.header { cursor: default; background: var(--gray-light); padding: 8px 16px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
.driver-row.header:hover { background: var(--gray-light); }
.driver-row .statement { font-weight: 500; }
.driver-row .big { font-size: 18px; font-weight: 700; }
.driver-row .big.none { color: var(--muted); font-weight: 400; font-size: 13px; }
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
@media (max-width: 720px) {
  .driver-row { grid-template-columns: 1fr 70px 90px; }
  .driver-row .hide-sm { display: none; }
}

/* ---- slider ---- */
.slider-wrap { position: relative; padding-top: 48px; padding-bottom: 22px; --p: 0.5; }
.slider-wrap input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px; outline: none; margin: 0; display: block;
  background: linear-gradient(to right, var(--navy) calc(var(--p) * 100%), var(--track) calc(var(--p) * 100%));
}
.slider-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--navy); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--navy); cursor: pointer;
}
.slider-wrap input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--navy); border: 2px solid #fff; cursor: pointer;
}
.slider-wrap input[type=range]:disabled { opacity: 0.4; }
.slider-bubble {
  position: absolute; top: 2px;
  left: calc(8px + (100% - 16px) * var(--p));
  width: 36px; height: 36px; border-radius: 50% 50% 50% 0;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 12px;
  transform: translateX(-50%) rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.slider-bubble span { transform: rotate(45deg); }
.slider-ref {
  position: absolute; bottom: 0; font-size: 11px; color: var(--muted);
  transform: translateX(-50%); white-space: nowrap;
}
.slider-ref::before { content: ""; position: absolute; left: 50%; top: -14px; height: 10px; width: 1px; background: var(--muted); opacity: 0.5; }

/* ---- driver page ---- */
.stat-row { display: flex; gap: 32px; flex-wrap: wrap; margin: 4px 0 8px; }
.stat .k { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.2; }
.stat .v.none { font-size: 16px; color: var(--muted); font-weight: 400; padding-top: 6px; }
.analysts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0; }
.analyst { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; }
.history .item { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.history .item.first { border-top: none; padding-top: 0; }
.history .who { font-weight: 600; font-size: 13px; }
.history .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.history .note { margin-top: 3px; font-size: 13px; }
.history .note .pct { margin-right: 6px; }
.banner { border-radius: 8px; padding: 14px 16px; margin-bottom: 20px; display: flex; gap: 12px; align-items: flex-start; }
.banner.yes { background: var(--green-light); border: 1px solid #bbf7d0; }
.banner.no  { background: var(--red-light); border: 1px solid #fecaca; }
.banner.na  { background: var(--gray-light); border: 1px solid var(--border); }
.banner strong { display: block; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; margin-bottom: 24px; font-size: 18px; }

/* ---- demo mode banner (mock.js) ---- */
.demo-banner {
  background: #fffbeb; border-bottom: 1px solid #fde68a; color: #92400e;
  font-size: 12px; text-align: center; padding: 6px 12px;
}
.demo-banner code { background: #fef3c7; padding: 0 4px; border-radius: 3px; }
