@font-face {
  font-family: Outfit;
  src: url("Outfit.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --paper: #fff;
  --ink: #0a0a0a;
  --muted: #5d5d61;
  --border: #dedee0;
  --quiet: #ededee;
  --map: #e9e9e9;
  --sheen: rgba(255,255,255,.85);
  --glass: rgba(255,255,255,.82);
  --depth: rgba(25,25,27,.13);
  --tile-glow: #fff;
  --tile-shade: #f6f6f7;
  --brake: #a73733; --accel: #8a5a00; --corner: #3e56a2; --speeding: #a83c78; --idle: #28725c; --road: #0a0a0a;
  --rank: #fff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --paper: #161617;
  --ink: #fff;
  --muted: #b4b4b8;
  --border: #363638;
  --quiet: #252527;
  --map: #242424;
  --sheen: rgba(255,255,255,.09);
  --glass: rgba(19,19,21,.84);
  --depth: rgba(0,0,0,.52);
  --tile-glow: #232325;
  --tile-shade: #151517;
  --brake: #e9827e; --accel: #ddb359; --corner: #93a9ef; --speeding: #e88fbf; --idle: #78c2a6; --road: #eee;
  --rank: #0a0a0a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: radial-gradient(ellipse 70% 30rem at 62% 0,var(--sheen),transparent),var(--bg); color: var(--ink); font: 400 15px/1.45 Outfit, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { background: transparent; border: 0; cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.04em; line-height: 1.1; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
.muted { color: var(--muted); }
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--paper);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.logo { display: flex; align-items: baseline; gap: 7px; padding-inline: 8px; white-space: nowrap; }
.logo b { font-size: 22px; letter-spacing: -.04em; }
.logo span { color: var(--muted); }
.role { display: grid; gap: 6px; color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.role select, input {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  min-height: 40px;
}
nav { display: grid; gap: 4px; }
nav button, #logout { min-height: 40px; padding: 8px 12px; border-radius: 12px; text-align: left; }
nav button { color: var(--muted); }
nav button:hover, #logout:hover, .area:hover { background: var(--quiet); color: var(--ink); }
nav button[aria-current="page"], .primary {
  color: var(--paper);
  background: var(--ink);
  font-weight: 550;
}
.primary { border-radius: 999px; min-height: 42px; padding: 8px 18px; width: fit-content; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.seg { display: flex; border: 1px solid var(--border); background: linear-gradient(var(--sheen),transparent),var(--quiet); border-radius: 999px; padding: 3px; width: fit-content; }
.seg button { border-radius: 999px; padding: 6px 14px; min-height: 36px; white-space: nowrap; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.page { padding: 24px clamp(16px, 2.4vw, 34px); min-width: 0; }
#dashboard { display: grid; gap: 16px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
#range { margin-top: 6px; }
#status { color: var(--muted); margin-block: 12px; }
#status:empty { display: none; }
.sign-in { max-width: 420px; margin: 6vh auto 0; padding: 28px; }
.sign-in form, .sign-in label { display: grid; gap: 8px; }
.sign-in form { gap: 16px; margin-top: 20px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 10px; }
.card, .tile { background: var(--paper); border: 1px solid var(--border); border-radius: 18px; min-width: 0; }
.tile {
  background: linear-gradient(155deg,var(--tile-glow),var(--tile-shade));
  box-shadow: inset 0 1px var(--sheen),0 3px 9px var(--depth);
  display: grid; gap: 3px; padding: 12px 14px; text-align: left; color: var(--muted); }
.tile:hover, .tile[aria-pressed="true"] { border-color: var(--ink); }
@media (hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference) {
  .tile { transition: transform .18s ease-out, box-shadow .18s ease-out; }
  .tile:hover:not([aria-pressed="true"]) {
    transform: perspective(640px) translateY(-2px) rotateX(4deg);
    box-shadow: inset 0 1px var(--sheen),0 9px 16px var(--depth);
  }
}
.tile strong { color: var(--ink); font-size: 25px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile small { font-size: 12px; }

.board, .lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 32%); gap: 12px; }
.board { height: clamp(400px, 57vh, 610px); }
.mapcard { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--map); font-family: Outfit, sans-serif; }
.legend {
  position: absolute;
  bottom: 24px;
  left: 10px;
  max-width: calc(100% - 20px);
  z-index: 500;
  pointer-events: none;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}
.leaflet-container .leaflet-control-attribution, .leaflet-container .leaflet-bar a {
  background: var(--paper);
  color: var(--ink);
}
.leaflet-container .leaflet-control-attribution a { color: var(--ink); text-decoration: underline; }
.mapcard .leaflet-bar, .mapcard .legend {
  background: var(--paper);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px var(--sheen),0 4px 12px var(--depth);
}
.mapcard .leaflet-bar a {
  background: transparent;
  width: 36px; height: 36px; line-height: 36px;
  border-color: var(--border);
}
.mapcard .leaflet-bar a:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
@supports ((backdrop-filter:blur(12px)) or (-webkit-backdrop-filter:blur(12px))) {
  .mapcard .leaflet-bar, .mapcard .legend {
    background: linear-gradient(var(--sheen),transparent),var(--glass);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
}
@media (prefers-reduced-transparency:reduce) {
  .mapcard .leaflet-bar, .mapcard .legend {
    background: var(--paper);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
.panel { display: flex; flex-direction: column; overflow: hidden; }
.panel-head { border-bottom: 1px solid var(--border); padding: 14px 16px; }
#hotspots { overflow: auto; }
#hotspots > p { padding: 16px; color: var(--muted); }
.area {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  width: 100%;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  text-align: left;
}
.area[aria-pressed="true"] { background: var(--quiet); box-shadow: inset 3px 0 var(--ink); }
.area span:not(.hotspot-rank) { display: block; }
.hotspot-rank {
  display: grid; place-items: center; width: 21px; height: 21px;
  border-radius: 50%; color: var(--rank); font-size: 11px; font-weight: 650;
}
.hotspot-icon .hotspot-rank {
  width: 28px; height: 28px; font-size: 13px;
  border: 2px solid var(--paper); box-shadow: 0 2px 5px var(--depth);
}
.selected-marker .hotspot-rank { outline: 2px solid var(--ink); }
.layer-brake { background: var(--brake); } .layer-accel { background: var(--accel); }
.layer-corner { background: var(--corner); } .layer-speeding { background: var(--speeding); }
.layer-idle { background: var(--idle); } .layer-road { background: var(--road); }
.area small { color: var(--muted); }
.lower .card { padding: 14px 16px; }
.lower p, #trend { margin-top: 8px; }
.week {
  display: grid;
  grid-template-columns: minmax(80px, auto) 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 14px;
}
.week progress { width: 100%; accent-color: var(--ink); }

@media (max-width: 850px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; gap: 12px; border: 0; border-bottom: 1px solid var(--border); padding: 12px 16px; }
  .logo { padding: 0; }
  #navigation { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
  .role { margin: 0; }
  nav { display: flex; flex-wrap: wrap; }
  .side-foot { display: flex; justify-content: space-between; }
  .board, .lower { grid-template-columns: minmax(0, 1fr); height: auto; }
  .mapcard { height: clamp(320px, 52vh, 510px); }
  .panel { max-height: 360px; }
}
@media (max-width: 500px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:only-child { grid-column: 1 / -1; }
  .page { padding-top: 16px; }
}
