@font-face {
  font-family: "Inter var"; font-weight: 100 900; font-display: swap; font-style: normal;
  src: url("/static/fonts/inter-var.woff2") format("woff2");
}
:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f9fafb; --text: #0f172a; --muted: #64748b; --line: #e5e8ee;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-soft: #eef2ff; --accent-text: #ffffff;
  --ok: #059669; --ok-bg: #ecfdf5; --warn: #b45309; --warn-bg: #fffbeb; --bad: #dc2626; --bad-bg: #fef2f2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);
  --radius: 14px; --radius-sm: 9px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17; --panel: #131925; --panel-2: #182030; --text: #e8ecf3; --muted: #8b97ab; --line: #232c3d;
    --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: #1e2340; --accent-text: #0b0f17;
    --ok: #34d399; --ok-bg: #0c2a22; --warn: #fbbf24; --warn-bg: #2b2110; --bad: #f87171; --bad-bg: #2d1518;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.55 "Inter var", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: -.025em; margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h3 { font-size: .95rem; font-weight: 650; margin: 0; }
p { margin: 0; }
code { font: .86em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: .12rem .4rem; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 1.6rem; padding: .65rem 1.5rem;
  background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); font-size: 1rem; }
.brand:hover { color: var(--text); }
.brand svg { width: 28px; height: 28px; border-radius: 8px; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a { padding: .4rem .8rem; border-radius: 99px; color: var(--muted); font-weight: 550; }
.topbar nav a:hover { color: var(--text); background: var(--panel-2); }
.topbar nav a.active { color: var(--accent); background: var(--accent-soft); }
.who { display: flex; align-items: center; gap: .6rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem;
}
.who a { color: var(--text); font-weight: 550; display: flex; align-items: center; gap: .5rem; }
@media (max-width: 640px) { .who .name { display: none; } .topbar { gap: .6rem; padding: .6rem .9rem; } }

/* Layout */
main { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
@media (max-width: 640px) { main { padding: 1.2rem .9rem 3rem; } }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.page-header .sub { color: var(--muted); margin-top: .35rem; }
.crumbs { color: var(--muted); font-size: .86rem; margin-bottom: .7rem; display: flex; gap: .4rem; align-items: center; }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--text); }
.actions, .row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.grid-2 .wide { grid-column: 1 / -1; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem 1.4rem; margin-bottom: 1.1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.card.danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.stat .label { color: var(--muted); font-size: .8rem; font-weight: 550; }
.stat .value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.25; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: .85rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat .value.text { font-size: 1.05rem; letter-spacing: -.01em; padding: .35rem 0 .2rem; }

/* Buttons and inputs */
.btn, button {
  font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .52rem .95rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); color: var(--text);
  transition: background .12s, border-color .12s, box-shadow .12s, transform .05s; white-space: nowrap;
}
.btn:hover, button:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--muted) 45%, var(--line)); color: var(--text); }
.btn:active, button:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); border-color: transparent; }
.btn-sm { padding: .32rem .65rem; font-size: .84rem; border-radius: 7px; }
.btn svg { width: 16px; height: 16px; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; font-weight: 550; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .55rem; color: var(--text); font-size: .92rem; font-weight: 500; cursor: pointer; }
label.inline { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea {
  font: inherit; font-weight: 450; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .52rem .7rem; min-width: 0; transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus, select:focus, textarea:focus, button:focus-visible, .btn:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); padding: 0; }
input[type=file] { padding: .4rem; background: var(--panel-2); border-style: dashed; width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 7px; padding: .35rem .7rem; margin-right: .7rem; cursor: pointer; }
textarea { resize: vertical; width: 100%; }
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
form.inline .grow { flex: 1; min-width: 10rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem 1rem; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; }
legend { color: var(--muted); font-size: .82rem; font-weight: 550; padding: 0 .4rem; }
details > summary { cursor: pointer; color: var(--accent); font-weight: 550; list-style: none; display: inline-flex; align-items: center; gap: .35rem; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "+"; font-weight: 700; width: 1rem; text-align: center; }
details[open] > summary::before { content: "–"; }
details[open] > summary { margin-bottom: .8rem; }

/* Chips and status */
.chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; padding: .18rem .6rem; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.live { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip.live::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.phone { background: var(--panel); color: var(--text); font-weight: 550; }
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: color-mix(in srgb, var(--muted) 50%, transparent); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* Tabs */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.3rem; overflow-x: auto; }
.tabs button { border: 0; background: none; border-radius: 0; padding: .7rem .9rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; box-shadow: none; }
.tabs button:hover { color: var(--text); background: none; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-size: .74rem; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); padding: 0 .45rem; border-radius: 99px; font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -1.4rem -1.3rem; }
.card.flush .table-wrap { margin: 0; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .7rem 1.4rem; background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .8rem 1.4rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
td.strong a { font-weight: 600; color: var(--text); } td.strong a:hover { color: var(--accent); }

/* Building cards */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.1rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; color: var(--text); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); color: var(--text); }
.tile .cover { aspect-ratio: 16 / 8; background: linear-gradient(135deg, var(--accent-soft), var(--panel-2)); position: relative; display: grid; place-items: center; color: color-mix(in srgb, var(--accent) 55%, transparent); }
.tile .cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.tile .cover svg { width: 44px; height: 44px; }
.tile .cover .chip { position: absolute; top: .7rem; right: .7rem; }
.tile .body { padding: 1rem 1.15rem 1.1rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.tile .meta { display: flex; gap: 1rem; color: var(--muted); font-size: .82rem; margin-top: auto; padding-top: .5rem; }
.tile .meta b { color: var(--text); font-weight: 650; }

/* Maps */
.map { height: 340px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
.map.hero { height: 100%; min-height: 230px; border: 0; border-radius: 0; }
.leaflet-container { font: inherit; }

/* Empty states */
.empty { text-align: center; padding: 2.6rem 1rem; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .5; margin-bottom: .6rem; }
.empty h3 { color: var(--text); margin-bottom: .3rem; }
.empty .btn { margin-top: 1rem; }

/* Toasts */
.toasts { position: fixed; top: 4.2rem; right: 1.2rem; z-index: 100; display: flex; flex-direction: column; gap: .6rem; max-width: min(420px, calc(100vw - 2.4rem)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .75rem 1rem; cursor: pointer; animation: slidein .25s ease-out; }
.toast.error { border-left-color: var(--bad); }
.toast.leaving { opacity: 0; transform: translateX(12px); transition: all .3s; }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } }
.alert { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius-sm); padding: .65rem .9rem; font-weight: 500; }

/* Phone cards */
.phones { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.phone-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1rem; background: var(--panel-2); display: flex; flex-direction: column; gap: .75rem; }
.phone-card.left { opacity: .65; }
.phone-card .head { display: flex; align-items: center; gap: .6rem; }
.phone-card .head a { font-weight: 650; color: var(--text); font-size: 1rem; }
.phone-card .fields { display: grid; grid-template-columns: 5rem 1fr; gap: .5rem; }
.phone-card .fields .wide { grid-column: 1 / -1; }

/* Plots */
.plotbox { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem 1rem .4rem; margin-top: .9rem; background: var(--panel); }
.plothead { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .4rem; }
.plothead strong { font-weight: 650; }
.downloads { margin-left: auto; display: flex; gap: .4rem; }
.live-plot, .review-plot { width: 100%; min-height: 230px; }
.u-legend { font-size: .78rem; color: var(--muted); }
.u-legend .u-marker { border-radius: 3px; }
.toolbar { display: flex; gap: .7rem; align-items: flex-end; flex-wrap: wrap; }
.toolbar select, .toolbar input { padding: .4rem .6rem; }

/* Notes */
.note { display: flex; gap: .8rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.note:first-of-type { border-top: 0; }
.note .content { flex: 1; min-width: 0; }
.note .byline { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .2rem; }
.note .byline b { font-weight: 650; }
.composer { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem; margin-bottom: .6rem; }

/* Photos */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.photo { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); margin: 0; }
.photo .frame { display: block; position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--panel-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.photo .frame:hover img { transform: scale(1.04); }
.photo .frame .chip { position: absolute; left: .55rem; bottom: .55rem; backdrop-filter: blur(6px); }
.photo figcaption { padding: .7rem .8rem .8rem; display: flex; flex-direction: column; gap: .3rem; }
.photo .when { font-weight: 600; font-variant-numeric: tabular-nums; }
dialog { border: 0; border-radius: var(--radius); background: var(--panel); color: var(--text); max-width: 94vw; padding: .8rem; box-shadow: var(--shadow-lg); }
dialog img { max-width: 90vw; max-height: 78vh; display: block; border-radius: var(--radius-sm); }
dialog p { margin: .6rem .2rem; }
dialog::backdrop { background: rgba(8, 10, 16, .78); backdrop-filter: blur(3px); }

/* Facts and setup */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.4rem; margin: 0; align-items: baseline; }
.facts dt { color: var(--muted); font-size: .86rem; }
.facts dd { margin: 0; font-weight: 500; }
.hero { display: grid; grid-template-columns: 1.1fr 1fr; }
.hero .info { padding: 1.4rem; display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; } }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .7rem; }
.mini-stats div { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.mini-stats span { display: block; color: var(--muted); font-size: .76rem; font-weight: 550; }
.mini-stats b { font-weight: 650; font-size: 1rem; }
.active-rec { border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line)); background: color-mix(in srgb, var(--bad-bg) 45%, var(--panel)); border-radius: var(--radius-sm); padding: 1rem 1.1rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* Sign-in */
.auth { min-height: calc(100vh - 8rem); display: grid; place-items: center; }
.auth .card { width: min(400px, 100%); padding: 2rem; }
.auth .mark { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 1rem; }

/* View switch and stacked waveforms */
.segmented { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; padding: .34rem .8rem; border-radius: 7px; color: var(--muted); box-shadow: none; }
.segmented button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.display-bar { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; padding: .8rem 1.1rem; position: sticky; top: 3.6rem; z-index: 20; }
.display-bar .group { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
input[type=range] { padding: 0; border: 0; accent-color: var(--accent); width: 120px; box-shadow: none; }
.stack-plot { position: relative; width: 100%; }
.stack-handles { position: absolute; inset: 0; pointer-events: none; }
.stack-handle {
  position: absolute; left: 0; transform: translateY(-50%); pointer-events: auto; cursor: ns-resize; touch-action: none; user-select: none;
  width: 116px; padding: .22rem .4rem; border-radius: 7px; font-size: .76rem; font-weight: 650; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.stack-handle::before { content: "↕"; opacity: .6; margin-right: .3rem; }
.stack-handle:hover, .stack-handle.dragging { background: color-mix(in srgb, var(--c) 22%, var(--panel)); box-shadow: var(--shadow); }
.download-list { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.download-list .item { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .35rem .4rem .35rem .8rem; background: var(--panel-2); font-weight: 600; }
