/* 407 · Trips — "instrument cluster" desktop theme.
   Chakra Petch (technical display + data) + IBM Plex Sans (body), amber backlight accent,
   near-black cockpit with a faint blueprint grid. */

:root {
  --bg: #0b0d11;
  --bg-2: #0e1116;
  --panel: #13171e;
  --panel-2: #181d26;
  --line: #262d39;
  --line-soft: #1d232d;
  --text: #e7eaf0;
  --muted: #8a93a3;
  --faint: #59626f;
  --accent: #f5b942;
  --accent-2: #ffce6b;
  --accent-dim: rgba(245, 185, 66, 0.14);
  --good: #4ec98a;
  --bad: #ec6a5e;
  --display: "Chakra Petch", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  --r: 14px;
  --r-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 520px at 72% -12%, rgba(245, 185, 66, 0.07), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(78, 130, 180, 0.06), transparent 55%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 42px);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }

h1, .wordmark, .side-title, .trip-title, .stat .v, .detail-head .trip-title, table.cmp th {
  font-family: var(--display);
  letter-spacing: 0.01em;
}

button { font-family: var(--display); cursor: pointer; }
input { font-family: var(--body); }

/* ---- buttons + inputs ---- */
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font-size: 13px;
  transition: all 0.15s ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }

input {
  padding: 11px 13px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: var(--faint); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.primary, #loginBtn, #nameSave, .compare-btn, .name-edit button {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #221a05;
  border: 0;
  border-radius: var(--r-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px rgba(245, 185, 66, 0.18);
}
.primary:hover, #loginBtn:hover, #nameSave:hover, .compare-btn:not(:disabled):hover, .name-edit button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 6px 20px rgba(245, 185, 66, 0.28);
}
button:disabled { opacity: 0.5; cursor: default; box-shadow: none; transform: none; }

/* ---- login ---- */
.login { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; height: 100%; }
.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 340px;
  padding: 36px 32px 30px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.login-logo { width: 64px; height: 64px; border-radius: 16px; align-self: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.login-card h1 { font-size: 30px; font-weight: 700; margin: 6px 0 0; text-align: center; }
.login-card h1 span { color: var(--accent); margin: 0 6px; }
.login-card p { margin: 0 0 10px; text-align: center; }

/* ---- app shell ---- */
.app { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  flex: 0 0 60px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 22, 0.7);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: 0.04em; }
.wordmark em { color: var(--accent); font-style: normal; font-weight: 500; margin-left: 8px; font-size: 16px; letter-spacing: 0.18em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { color: var(--muted); font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workspace { display: flex; flex: 1; min-height: 0; }

/* ---- sidebar ---- */
.sidebar {
  width: 330px;
  flex: 0 0 330px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 29, 38, 0.5), rgba(19, 23, 30, 0.5));
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; }
.side-title { font-size: 13px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.compare-btn { font-size: 13px; padding: 7px 14px; }
.compare-btn:disabled { background: var(--panel-2); color: var(--faint); box-shadow: none; }
.trip-list { overflow-y: auto; flex: 1; padding: 0 10px 14px; }

.trip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  margin-bottom: 6px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  position: relative;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}
.trip-item:hover { background: var(--panel-2); transform: translateX(2px); }
.trip-item.active { background: var(--panel-2); border-color: var(--line); }
.trip-item.active::before {
  content: ""; position: absolute; left: -10px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.trip-item .cb { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; cursor: pointer; }
.trip-item .body { flex: 1; cursor: pointer; min-width: 0; }
.trip-item .when {
  font-family: var(--display); font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.trip-item .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.trip-item .pill {
  font-size: 11px; font-family: var(--display); color: var(--accent-2);
  background: var(--accent-dim); border-radius: 999px; padding: 2px 8px; letter-spacing: 0.02em;
}
.trip-item .date { font-size: 12px; color: var(--faint); }

.placeholder { color: var(--muted); padding: 40px 20px; text-align: center; line-height: 1.6; }

/* ---- detail / compare panels ---- */
.detail {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px;
  padding: 22px 26px; overflow-y: auto;
}
.detail-head .trip-title { font-size: 26px; font-weight: 700; line-height: 1.1; }
.detail-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.name-edit { display: flex; gap: 10px; margin-top: 12px; max-width: 520px; }
.name-edit input { flex: 1; }

/* chips (metric toggles) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; font-size: 13px; font-family: var(--display); color: var(--muted);
  cursor: pointer; transition: all 0.14s ease;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #221a05; font-weight: 600; }

/* map */
.map-wrap { position: relative; flex: 1; min-height: 380px; }
#map, #cmpMap { position: absolute; inset: 0; border-radius: var(--r); border: 1px solid var(--line); }
.leaflet-container { background: #0c0f14; border-radius: var(--r); font-family: var(--body); }
.leaflet-tile { filter: saturate(0.9) brightness(0.93) contrast(1.02); }

.legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 500; width: 210px;
  background: rgba(14, 17, 22, 0.92); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12px;
}
.legend .bar { height: 10px; border-radius: 5px; margin: 7px 0 5px; background: linear-gradient(to right, #2e7d32, #ffc107, #e53935); }
.legend .ends { display: flex; justify-content: space-between; color: var(--muted); font-family: var(--display); }

.map-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); background: var(--panel); border-radius: var(--r); line-height: 1.6;
}

/* stats — instrument tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; }
.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px;
  position: relative; overflow: hidden; transition: border-color 0.15s ease, transform 0.15s ease;
}
.stat::after { content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 100%; background: linear-gradient(90deg, var(--accent), transparent 70%); opacity: 0; transition: opacity 0.2s ease; }
.stat:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat:hover::after { opacity: 1; }
.stat .k { color: var(--muted); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* chart card */
.chart-wrap { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.chart-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; font-family: var(--display); letter-spacing: 0.02em; }
#chart, #cmpChart { width: 100%; height: 200px; display: block; }
#cmpChart { height: 220px; }

.back { align-self: flex-start; }

/* ---- comparison ---- */
.cmp-legend { display: flex; flex-wrap: wrap; gap: 16px; }
.cmp-legend .item { display: flex; align-items: center; gap: 8px; font-size: 14px; font-family: var(--display); }
.cmp-legend .dot { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 10px currentColor; }

.cmp-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
table.cmp { border-collapse: collapse; width: 100%; font-size: 14px; }
table.cmp th, table.cmp td { padding: 11px 16px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); color: var(--muted); }
table.cmp thead th { font-weight: 600; font-size: 13px; background: var(--panel-2); }
table.cmp thead th:first-child { background: var(--panel-2); }
table.cmp tbody tr:hover td { background: var(--panel-2); }
table.cmp td { font-variant-numeric: tabular-nums; }
table.cmp .delta { display: block; font-size: 12px; margin-top: 3px; color: var(--faint); font-family: var(--display); }
table.cmp .delta.up { color: var(--good); }
table.cmp .delta.down { color: var(--bad); }

/* ---- scrollbars ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #333c49; }

/* ---- entrance animation ---- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.topbar { animation: rise 0.4s ease both; }
.sidebar { animation: rise 0.45s ease 0.05s both; }
.detail { animation: rise 0.5s ease 0.1s both; }
.login-card { animation: rise 0.5s ease both; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
