:root {
  color-scheme: light;
  --paper: #f5f4ef;
  --white: #fff;
  --ink: #202a2d;
  --muted: #586669;
  --line: #dce2de;
  --accent: #9c2635;
  --accent-dark: #741a27;
  --soft: #f7e9e9;
  --green: #23574f;
  --green-soft: #e7f1eb;
  --blue: #1766a3;
  --radius: 16px;
  --bar: 64px;
  font: 15px/1.48 "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
#main:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.75rem, 4.6vw, 2.45rem); line-height: 1.12; letter-spacing: -.045em; }
h2 { font-size: 1.2rem; letter-spacing: -.024em; }
h3 { font-size: 1rem; }
small { color: var(--muted); }
.muted { color: var(--muted); }
.topbar {
  min-height: var(--bar); position: sticky; top: 0; z-index: 3; display: flex;
  justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px max(16px, calc((100vw - 1260px)/2)); background: var(--white);
  border-bottom: 1px solid var(--line);
}
.brand, .top-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  display: grid; place-items: center; background: var(--ink); color: #fff;
  width: 37px; height: 37px; border-radius: 11px; font-size: .83rem; font-weight: 800;
  letter-spacing: -.055em; flex-shrink: 0;
}
.page-title {
  padding: 4px 0; color: var(--accent); background: transparent; border: 0;
  box-shadow: none; font-weight: 750; text-align: left; line-height: 1.17;
}
.page-title:hover { text-decoration: underline; text-underline-offset: 4px; }
.role-link {
  display: inline-flex; align-items: center; gap: 5px; color: var(--green); font-weight: 650;
  text-decoration: none; font-size: .84rem; text-align: right; line-height: 1.15;
}
.role-link:hover { text-decoration: underline; }
.icon-button {
  display: inline-grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px;
  padding: 0; color: var(--ink); background: var(--white);
  border: 1px solid var(--line); border-radius: 10px; font-weight: 750;
}
.account { border-radius: 50%; background: var(--green-soft); color: var(--green); }
.app-layout {
  max-width: 1280px; margin: auto; padding: 24px 16px 34px; display: grid;
  grid-template-columns: 198px minmax(0, 1fr); gap: 26px;
}
.app-layout.guest { display: block; padding: 32px 16px; }
main { min-width: 0; }
.loading { margin: 6vh auto; text-align: center; color: var(--muted); }
.navigation {
  display: flex; flex-direction: column; gap: 5px; position: sticky;
  top: calc(var(--bar) + 24px); align-self: start;
}
.navigation button {
  border: 0; background: transparent; color: var(--muted); font-weight: 650;
  display: flex; align-items: center; gap: 12px; border-radius: 10px;
  min-height: 43px; padding: 8px 11px; text-align: left;
}
.navigation button:hover { background: #e9ece6; color: var(--ink); }
.navigation button[aria-current="page"] { background: var(--soft); color: var(--accent-dark); }
.nav-icon { width: 23px; font-size: 1.18rem; line-height: 1; text-align: center; }
.screen { display: grid; gap: 13px; }
.screen-head, .toolbar, .block-head, .dialog-head, .dialog-foot, .actions {
  display: flex; align-items: center; justify-content: space-between; gap: 9px;
}
.screen-head { min-height: 48px; }
.screen-head p { margin-top: 3px; }
.toolbar { justify-content: start; flex-wrap: nowrap; }
.toolbar > * { min-width: 0; }
.toolbar-label { flex: 1 1 auto; }
.toolbar .date-filter { flex: 0 1 155px; }
.hero {
  position: relative; isolation: isolate; border-radius: 20px; overflow: hidden; min-height: 185px;
  padding: clamp(20px, 4vw, 30px); display: grid; gap: 13px; align-content: center;
  color: white; background: #193a39;
}
.hero::after {
  content: ""; position: absolute; z-index: -1; inset: 0 0 0 50%; opacity: .34; pointer-events: none;
  background: repeating-radial-gradient(ellipse at 86% 66%, transparent 0 15px, #85ae9e 16px 17px, transparent 18px 28px);
  mask-image: linear-gradient(90deg, transparent, black 55%);
}
.hero h1 { max-width: 20ch; overflow-wrap: anywhere; }
.hero p { color: #d8e9df; max-width: 44ch; }
.hero .button { justify-self: start; }
.guest-wrap {
  max-width: 940px; display: grid; grid-template-columns: minmax(0,1.2fr) minmax(300px,1fr);
  margin: min(6vh, 48px) auto; gap: 16px; align-items: stretch;
}
.guest-wrap .hero { min-height: 350px; }
.guest-wrap .hero h1 { font-size: clamp(2.25rem, 5vw, 3.6rem); }
.guest-wrap .hero p { max-width: 31ch; }
.guest-wrap .hero::after { inset: 15% -35% -40% 16%; }
.auth { align-self: stretch; display: grid; align-content: center; gap: 14px; padding: 24px; }
.block, .metric {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0;
}
.block { padding: 14px; }
.block-head { margin-bottom: 9px; }
.block-head > * { min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.metric { padding: 12px; display: grid; align-content: space-between; gap: 6px; }
.metric strong { font-size: clamp(1.15rem, 4vw, 1.75rem); letter-spacing: -.045em; line-height: 1.12; overflow-wrap: anywhere; }
.metric small { line-height: 1.25; }
.section-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-align: center; white-space: nowrap; border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; font-weight: 700; min-height: 39px; padding: 7px 12px;
  color: var(--ink); background: var(--white);
}
.button:hover { background: #f0f3ef; }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.inverse { background: #f9ece9; color: var(--accent-dark); border-color: #f9ece9; }
.button.danger { color: var(--accent-dark); border-color: #e6bdc0; }
.button.small { min-height: 32px; font-size: .84rem; padding: 4px 8px; }
.text-button { color: var(--accent); background: none; border: 0; padding: 4px 1px; font-weight: 650; }
.text-button:hover { text-decoration: underline; }
.tabs { display: flex; gap: 5px; overflow-x: auto; padding: 2px; }
.tabs button {
  min-height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--white);
  color: var(--muted); padding: 5px 9px; font-weight: 650; white-space: nowrap;
}
.tabs button[aria-selected="true"], .tabs button[aria-pressed="true"] {
  color: var(--green); border-color: #afc8bb; background: var(--green-soft);
}
.list { max-height: min(58dvh, 610px); overflow: auto; padding: 1px 3px; }
.rows { padding: 0; margin: 0; list-style: none; }
.row {
  width: 100%; display: grid; grid-template-columns: minmax(118px, 1.8fr) minmax(77px, 1fr) minmax(70px, .8fr) 15px;
  align-items: center; gap: 8px; border: 0; border-bottom: 1px solid var(--line);
  padding: 10px 5px; text-align: left; background: none; color: var(--ink);
}
.row:hover { background: #f4f7f2; }
.row strong, .row small { display: block; }
.row .truncate, .row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .row-arrow { color: var(--muted); font-size: 1.1rem; }
.rows li:last-child .row { border-bottom: 0; }
.empty { padding: 26px 5px; color: var(--muted); text-align: center; }
.pill {
  display: inline-flex; align-items: center; padding: 2px 7px; min-height: 22px; border-radius: 999px;
  font-size: .77rem; font-weight: 720; background: var(--green-soft); color: var(--green);
}
.pill.alert { background: #ffeedc; color: #83401a; }
.pill.neutral { background: #edf0ec; color: var(--muted); }
.form { display: grid; gap: 11px; }
.grid-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.grid-fields.compact { grid-template-columns: repeat(3,minmax(0,1fr)); }
.field { display: grid; align-content: start; gap: 4px; font-size: .86rem; font-weight: 650; min-width: 0; }
.field.wide { grid-column: 1/-1; }
.field small { font-weight: 400; }
input, select, textarea {
  width: 100%; min-width: 0; padding: 7px 8px; background: white; color: var(--ink);
  border: 1px solid #c9d2cc; border-radius: 8px; min-height: 39px; font-weight: 450;
}
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
input[type=range] { padding: 0; min-height: 22px; accent-color: var(--accent); }
.error { font-size: .9rem; color: var(--accent-dark); font-weight: 650; overflow-wrap: anywhere; }
.notice { color: var(--green); background: var(--green-soft); padding: 9px; border-radius: 8px; }
.form-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; align-items: center; }
.form-footer .button { flex-shrink: 0; }
dialog {
  border: 1px solid var(--line); padding: 0; border-radius: 18px; width: min(790px, calc(100% - 24px));
  max-height: min(90dvh, 930px); color: var(--ink); background: var(--paper); box-shadow: 0 14px 58px #15202233;
}
dialog::backdrop { background: #17232188; }
#confirm { width: min(430px, calc(100% - 26px)); }
.dialog-head, .dialog-foot { padding: 10px 14px; background: var(--white); z-index: 1; }
.dialog-head { position: sticky; top: 0; border-bottom: 1px solid var(--line); }
.dialog-head h2, .dialog-head p { overflow-wrap: anywhere; }
.dialog-foot { position: sticky; bottom: 0; border-top: 1px solid var(--line); justify-content: end; flex-wrap: wrap; }
.dialog-body { padding: 12px 14px; display: grid; gap: 10px; }
details {
  background: var(--white); border: 1px solid var(--line); border-radius: 11px; min-width: 0;
}
summary { padding: 10px; font-weight: 750; cursor: pointer; }
details > .detail-content { padding: 0 10px 10px; display: grid; gap: 8px; }
.sub-card { border: 1px solid var(--line); padding: 8px; border-radius: 9px; display: grid; gap: 6px; }
.sub-card h3 { font-size: .88rem; }
.data-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 12px; margin: 0; }
.data-grid dt { font-size: .78rem; font-weight: 650; color: var(--muted); }
.data-grid dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.data-grid .wide { grid-column: 1/-1; }
.scroll-box { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .8rem; }
.chart { display: block; width: 100%; height: 158px; }
.map-section { display: grid; gap: 8px; }
.map-controls { padding: 7px; background: white; border: 1px solid var(--line); border-radius: 10px; display: flex; gap: 7px; flex-wrap: wrap; }
.map-controls select { width: auto; max-width: 100%; font-size: .85rem; }
.map-controls label { display: flex; gap: 4px; align-items: center; font-size: .82rem; }
.map-canvas { background: #f0f2ea; border: 1px solid #d4ddd2; width: 100%; height: 315px; border-radius: 11px; touch-action: pan-y; display: block; }
.map-canvas.measuring { touch-action: none; cursor: crosshair; }
.bearing { color: var(--accent-dark); font-weight: 650; min-height: 23px; }
.map-key { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; font-size: .77rem; }
.map-key > div { padding: 4px; border: 1px solid var(--line); border-radius: 5px; min-width: 0; }
.map-key button { display: block; color: var(--muted); border: 0; background: transparent; padding: 2px; font-size: inherit; text-align: left; }
.map-key button[aria-pressed="true"] { color: var(--accent); font-size: .88rem; font-weight: 800; }
.toast {
  position: fixed; z-index: 5; right: 14px; bottom: 14px; padding: 9px 13px; max-width: min(410px, calc(100% - 28px));
  background: var(--ink); color: white; border-radius: 9px; box-shadow: 0 6px 19px #0004;
}
@media (max-width: 750px) {
  :root { --bar: 55px; }
  .topbar { padding: 5px 11px; }
  .brand, .top-actions { gap: 6px; }
  .logo { width: 32px; height: 32px; border-radius: 8px; }
  .account { width: 34px; height: 34px; }
  .app-layout, .app-layout.guest { display: block; padding: 11px 10px 82px; }
  .navigation {
    z-index: 2; position: fixed; inset: auto 0 0; display: flex; flex-direction: row; justify-content: center;
    padding: 3px 3px max(4px, env(safe-area-inset-bottom)); gap: 1px; background: #fff; border-top: 1px solid var(--line);
  }
  .navigation button { flex: 1; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; font-size: .69rem; padding: 3px 1px; }
  .nav-icon { font-size: 1.11rem; }
  .screen { gap: 9px; }
  .hero { min-height: 144px; padding: 17px; }
  .hero::after { left: 38%; }
  .guest-wrap { grid-template-columns: 1fr; margin: 0 auto; max-width: 475px; gap: 10px; }
  .guest-wrap .hero { min-height: 185px; }
  .auth { padding: 16px; }
  .stats { gap: 5px; }
  .metric { padding: 7px 6px; }
  .metric small { font-size: .73rem; }
  .section-grid { grid-template-columns: 1fr; }
  .block { padding: 8px; }
  .row { grid-template-columns: minmax(95px,1.5fr) minmax(65px,1fr) minmax(60px,.8fr) 11px; font-size: .86rem; gap: 4px; padding: 8px 2px; }
  .row small { font-size: .75rem; }
  .button { padding-inline: 8px; }
  .toolbar { gap: 5px; }
  .toolbar .date-filter { flex-basis: 126px; }
  .toast { bottom: 67px; }
  .grid-fields.compact { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 385px) {
  .page-title { font-size: .84rem; }
  .role-link { max-width: 83px; font-size: .73rem; }
  .grid-fields { gap: 6px; }
  .toolbar .date-filter { flex-basis: 107px; }
  .dialog-head, .dialog-foot, .dialog-body { padding-inline: 8px; }
}
@media print {
  body { background: white; }
  .topbar, .navigation, .toast, .no-print, .dialog-foot, .dialog-head button { display: none !important; }
  body:has(#dialog[open]) .app-layout { display: none; }
  #dialog[open] {
    position: absolute; inset: 0 auto auto 0; max-height: none; overflow: visible;
    width: 100%; max-width: none; margin: 0; box-shadow: none; border: 0; border-radius: 0;
  }
  dialog::backdrop { display: none; }
  .dialog-head { position: static; }
  .block, .metric, details { break-inside: avoid; }
  .list { max-height: none; overflow: visible; }
  .map-canvas, .pill { print-color-adjust: exact; }
}
.chooser { max-width: 760px; margin: min(6vh, 48px) auto 0; display: grid; gap: 14px; }
.chooser-options { align-items: stretch; }
.chooser-card { display: grid; gap: 10px; padding: 17px; grid-template-rows: auto 1fr auto; }
.chooser-card .button { justify-self: start; }
.chooser-note { padding: 0 2px; }
.chooser-help { max-width: min(450px, calc(100% - 24px)); color: var(--ink); }
.chooser-help .button { margin-top: 10px; }
.chooser-help::backdrop { background: #17232144; }
