:root {
  color-scheme: light;
  --navy: #101f35;
  --ink: #172844;
  --muted: #546680;
  --surface: #fff;
  --canvas: #f2f5fa;
  --line: #e0e7f0;
  --teal: #087e6e;
  --green: #08ad89;
  --shadow: 0 11px 30px #152d4f0a;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 290px; }
h1, h2, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; }
:focus-visible { outline: 3px solid #1cae9a; outline-offset: 3px; }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.65rem); letter-spacing: -.055em; line-height: 1.12; }
h2 { font-size: 1.23rem; letter-spacing: -.027em; line-height: 1.25; }
.muted { color: var(--muted); line-height: 1.5; }

.brand { display: inline-flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; font-weight: 750; letter-spacing: -.045em; font-size: 1.55rem; }
.brand-icon { width: 2.4rem; height: 2.4rem; border-radius: .75rem; display: grid; place-items: center; background: #30dbb2; color: #123b38; }
.button, .icon-button { display: inline-flex; gap: .55rem; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: .65rem; font-weight: 650; }
.button { padding: .75rem 1rem; min-height: 2.7rem; }
.primary { color: #fff; background: var(--teal); }
.primary:not(:disabled):hover { background: #066657; }
.secondary { background: var(--surface); border-color: var(--line); color: var(--muted); }
.secondary:not(:disabled):hover, .icon-button:hover { background: #edf3fa; color: var(--ink); }
.icon-button { background: var(--surface); border-color: var(--line); color: var(--muted); width: 2.54rem; height: 2.54rem; flex: 0 0 auto; }
.message { border-radius: .55rem; background: #e9f6f3; color: #1e6258; line-height: 1.4; padding: .7rem .85rem; font-size: .92rem; }
.error { color: #923529; background: #fff0eb; }
.global-error { max-width: 78rem; margin: 1rem auto 0; }
.switch { display: flex; align-items: center; gap: .2rem; border-radius: .65rem; padding: .24rem; background: #edf2f8; }
.switch button { flex: 1; border: 0; border-radius: .48rem; min-height: 2.3rem; padding: .35rem .4rem; color: var(--muted); font-weight: 650; font-size: .875rem; background: transparent; }
.switch button[aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 2px 6px #17304414; }

.auth-layout { min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface); }
.auth-form-side { display: flex; flex-direction: column; align-items: flex-start; padding: clamp(1.4rem, 4.7vw, 4.8rem); }
.auth-content { width: min(100%, 25rem); margin: auto; padding: 2.5rem 0; }
.auth-content h1 { font-size: clamp(2.05rem, 4.35vw, 3.45rem); }
.auth-content > p { margin-top: .55rem; }
.auth-switch { margin: 1.65rem 0 1.25rem; }
.auth-switch button { font-size: .94rem; }
#auth-form { display: grid; gap: .9rem; }
#auth-form label { display: grid; gap: .38rem; font-size: .91rem; font-weight: 650; min-width: 0; }
#auth-form input, .route-toolbar input { width: 100%; padding: .64rem .8rem; min-height: 2.85rem; border: 1px solid #ccd8e5; background: #fff; border-radius: .6rem; color: var(--ink); font-weight: 400; font-size: 1rem; }
#auth-form input::placeholder { color: #65758a; }
#auth-form .primary { margin-top: .25rem; }
.name-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.auth-note { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-size: .88rem; }
.auth-note svg, .privacy-note svg { flex: 0 0 auto; color: var(--teal); }
.auth-art { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 34rem; padding: 2rem; color: #eef7ff; background: radial-gradient(ellipse at 50% 42%, #153c52 0, #132a43 41%, #101f35 77%); }
.auth-art::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, #9dc9eb0c 0 1px, transparent 1px 40px), repeating-linear-gradient(90deg, #9dc9eb0c 0 1px, transparent 1px 40px); mask-image: radial-gradient(ellipse at center, #000 20%, transparent 78%); }
.art-graphic { position: relative; width: min(100%, 24rem); aspect-ratio: 1; display: grid; place-items: center; }
.radar-ring, .radar-cross { position: absolute; }
.radar-ring { border: 1px solid #5adfc43e; border-radius: 50%; aspect-ratio: 1; }
.ring-one { width: 38%; background: #5adfc40b; }
.ring-two { width: 64%; }
.ring-three { width: 88%; border-color: #80d6ea31; }
.radar-cross { background: #80d6ea22; }
.cross-h { width: 100%; height: 1px; }
.cross-v { height: 100%; width: 1px; }
.art-pin { position: relative; display: grid; place-items: center; background: #36e1b9; color: #103c3a; width: 5.3rem; height: 5.3rem; border-radius: 1.45rem; box-shadow: 0 0 3rem #35dfa253; }
.art-dot { width: .62rem; height: .62rem; background: #64eccd; border-radius: 50%; position: absolute; box-shadow: 0 0 0 .35rem #64eccd20, 0 0 1.2rem #64eccd; }
.dot-one { left: 22%; top: 34%; }
.dot-two { right: 11%; bottom: 29%; background: #8ecbf9; }
.dot-three { left: 46%; bottom: 19%; width: .39rem; height: .39rem; }
.art-copy { text-align: center; position: relative; width: min(100%, 21rem); }
.art-copy p { letter-spacing: -.035em; font-weight: 720; font-size: 1.65rem; margin-bottom: .4rem; }
.art-copy span { line-height: 1.55; color: #adc6dc; }

.topbar { background: var(--navy); color: #f5f9fe; }
.topbar-inner, .shell { width: min(100% - 3rem, 82rem); margin: 0 auto; }
.topbar-inner { min-height: 4.5rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.account { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.avatar { width: 2.4rem; height: 2.4rem; flex: 0 0 auto; border-radius: .7rem; display: grid; place-items: center; font-size: .83rem; font-weight: 750; letter-spacing: .025em; background: #e6ecfa; color: #415d8a; text-transform: uppercase; }
.account-avatar { background: #29405c; color: #e9f4ff; }
.account-name { display: grid; min-width: 0; line-height: 1.22; }
.account-name strong, .account-name span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-name strong { font-size: .92rem; }
.account-name span { font-size: .8rem; color: #abc0d8; margin-top: .2rem; }
.logout { margin-inline-start: .35rem; background: #1d304a; border-color: #324761; color: #d3dfed; }
.logout:hover { color: #fff; background: #2f4864; }
.shell { padding: 2.1rem 0 2.5rem; }
.page-heading { display: flex; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.45rem; }
.page-heading p { margin-top: .45rem; }
.connection, .status-pill { display: inline-flex; align-items: center; gap: .45rem; border-radius: 2rem; font-size: .87rem; font-weight: 650; padding: .4rem .72rem; background: #e6edf6; color: #506484; flex: 0 0 auto; }
.connection > span:first-child, .status-pill > span:first-child { display: inline-block; width: .48rem; height: .48rem; border-radius: 50%; background: currentColor; }
.connection.live, .status-pill.live { color: #06745f; background: #ddf6ee; }
.connection.failed { color: #923529; background: #fce9e5; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.panel, .stat { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; box-shadow: var(--shadow); overflow: hidden; }
.stat { display: flex; align-items: center; gap: .8rem; min-height: 5.65rem; padding: .85rem 1rem; }
.stat-icon { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: 0 0 auto; border-radius: .75rem; }
.violet { background: #eeebfd; color: #6550a7; }
.mint { background: #ddf6ef; color: #087e6e; }
.sky { background: #e6f0ff; color: #335fa5; }
.stat p { color: var(--muted); font-size: .89rem; font-weight: 600; line-height: 1.25; }
.stat strong { display: block; font-size: 1.55rem; margin-top: .15rem; letter-spacing: -.035em; }
.dashboard { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(18rem, 1fr); align-items: start; gap: 1.25rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; min-height: 4.6rem; padding: .85rem 1.15rem; gap: .7rem; }
.panel-header p { font-size: .9rem; margin-top: .23rem; }
.panel-header h2 { overflow-wrap: anywhere; }
.map-actions { display: flex; gap: .4rem; }
.map-wrap { isolation: isolate; position: relative; }
#map { height: clamp(25rem, 54vh, 40rem); background: #e4eeec; }
.route-open #map { height: clamp(20rem, 43vh, 33rem); }
#map.leaflet-container { font-family: inherit; }
.leaflet-container .leaflet-control-attribution { color: #304d51; background: #fffffff0; }
.leaflet-container .leaflet-control-attribution a { color: #065b72; }
.leaflet-control-zoom a { color: var(--ink); }
.map-notice { background: #fffffff2; color: #284456; font-size: .9rem; padding: .45rem .65rem; border-radius: .45rem; position: absolute; left: 3.7rem; top: .75rem; right: .75rem; max-width: max-content; z-index: 700; }
.map-footer { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; min-height: 2.7rem; padding: .6rem 1.1rem; color: var(--muted); font-size: .85rem; }
.legend-dot { background: var(--green); width: .58rem; height: .58rem; border-radius: 50%; }
.footer-side { margin-left: auto; }
.route-detail { padding: .85rem 1.15rem; }
.route-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .65rem; padding: .1rem 1.15rem .75rem; }
.route-toolbar label { font-weight: 650; font-size: .9rem; }
.route-toolbar input { width: auto; min-height: 2.5rem; padding: .35rem .65rem; }
.route-toolbar input::-webkit-calendar-picker-indicator { cursor: pointer; }
#route-message { font-size: .9rem; }
.route-summary { display: flex; flex-wrap: wrap; gap: .65rem 1.7rem; }
.route-summary div { display: grid; gap: .2rem; }
.route-summary span { font-size: .85rem; color: var(--muted); }
.route-summary strong { font-size: 1.02rem; }
.people-panel { min-height: 23rem; }
.people-controls { display: grid; gap: .62rem; margin: 0 1rem .6rem; }
.search { display: flex; align-items: center; gap: .55rem; padding: 0 .7rem; border: 1px solid var(--line); min-height: 2.65rem; border-radius: .62rem; color: var(--muted); }
.search:focus-within { outline: 2px solid #1cae9a; }
.search svg { flex: 0 0 auto; }
.search input { min-width: 0; background: transparent; color: var(--ink); border: 0; outline: 0; width: 100%; font-size: .95rem; }
.search input::placeholder { color: var(--muted); }
.people-list { display: grid; padding: 0 .7rem; max-height: 28rem; overflow: auto; }
.person { text-align: left; display: flex; align-items: center; gap: .65rem; padding: .68rem .42rem; width: 100%; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.person:last-child { border-bottom: 0; }
.person:hover, .person[aria-pressed="true"] { background: #eaf7f4; }
.person:focus-visible { outline-offset: -3px; }
.person-main { flex: 1; min-width: 0; display: grid; gap: .2rem; }
.person-main strong, .person-main small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.person-main strong { font-size: .94rem; }
.person-main small, .person-state { font-size: .79rem; color: var(--muted); }
.person-state { font-weight: 650; max-width: 5.5rem; text-align: right; }
.person-state.live { color: #08705f; }
.empty { min-height: 14rem; padding: 1.5rem; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: .6rem; text-align: center; }
.empty-icon { background: #edf3fa; color: #546a8c; padding: .65rem; border-radius: .75rem; display: grid; }
.empty p { font-size: .9rem; color: var(--muted); }
.pages { padding: .7rem; display: flex; justify-content: space-between; align-items: center; gap: .45rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.pages .button { min-height: 2.2rem; padding: .35rem .67rem; }

.user-layout { display: grid; grid-template-columns: minmax(16rem, .82fr) minmax(0, 1.48fr); gap: 1.25rem; align-items: start; }
.user-shell { max-width: 72rem; }
.tracking-panel { padding: 1.35rem; }
.tracking-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.tracking-top .stat-icon { width: 3rem; height: 3rem; }
.tracking-panel h2 { margin: 1rem 0 .45rem; }
#tracking-button { margin-top: 1.25rem; width: 100%; }
#tracking-button.stop { color: #863a38; background: #fdeceb; border-color: #f6d5d2; }
#tracking-button.stop:hover { background: #f9dfdd; }
#tracking-message { margin-top: .7rem; }
.tracking-meta { display: grid; gap: .72rem; border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.2rem; }
.tracking-meta div { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.tracking-meta svg, .tracking-meta span { color: var(--muted); }
.tracking-meta strong { margin-inline-start: auto; white-space: nowrap; }
.user-map #map { height: clamp(20rem, 48vh, 32rem); }
.privacy-note { display: flex; align-items: flex-start; gap: .6rem; background: #e7f3f1; border: 1px solid #cfe7e2; margin-top: 1.25rem; border-radius: .8rem; padding: 1rem 1.1rem; }
.privacy-note p { color: #3b6263; line-height: 1.55; margin-top: .25rem; font-size: .93rem; }

@media (max-width: 830px) {
  .dashboard, .user-layout { grid-template-columns: 1fr; }
  .people-panel { grid-row: 1; min-height: 0; }
  .people-list { max-height: 13rem; }
  .empty { min-height: 8rem; }
  #map { height: clamp(19rem, 52vh, 28rem); }
}
@media (max-width: 650px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .topbar-inner, .shell { width: calc(100% - 1.6rem); }
  .shell { padding-top: 1.4rem; }
  .topbar-inner { min-height: 3.85rem; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
  .stats { gap: .4rem; margin-bottom: 1rem; }
  .stat { display: grid; align-items: start; align-content: start; gap: .36rem; min-height: 0; padding: .57rem .46rem; }
  .stat .stat-icon { height: 1.95rem; width: 1.95rem; border-radius: .5rem; }
  .stat .stat-icon svg { width: 1rem; height: 1rem; }
  .stat p { font-size: .79rem; }
  .stat strong { font-size: 1.3rem; }
  .dashboard, .user-layout { gap: .85rem; }
  .panel-header { padding: .75rem .85rem; }
  .account-avatar { display: none; }
  .account { max-width: 61%; }
  .global-error { margin-inline: .8rem; }
}
