:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #fff;
  --panel2: #edf2ef;
  --line: #dee6e1;
  --text: #172821;
  --muted: #566b61;
  --accent: #17634e;
  --accent-hover: #0d4c3a;
  --ok: #16724e;
  --alert: #a83238;
  --warn: #825713;
  --pending: #55675e;
  --r: 14px;
  --field-radius: 8px;
  --field-border: #ccd8d1;
  --field-height: 42px;
  --compact-height: 34px;
  --select-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23435b50' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --select-caret-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 10 4-4 4 4' fill='none' stroke='%23435b50' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --sidebar-width: 230px;
  --topbar-height: 68px;
  --gutter: clamp(20px, 3vw, 40px);
  --shadow: 0 1px 2px #162d2110;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", system-ui, sans-serif;
}
button, select, input, textarea { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #26896d; outline-offset: 3px; }
main:focus, h1[tabindex="-1"]:focus { outline: none; }
img, video { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
p { margin: 0 0 14px; }
h1, h2, h3 { line-height: 1.2; }
h1 {
  margin: 0;
  font-size: clamp(30px, 3.1vw, 44px);
  font-weight: 720;
  letter-spacing: -.044em;
  overflow-wrap: anywhere;
}
h2 { font-size: 17px; font-weight: 680; letter-spacing: -.02em; margin: 0 0 14px; }
h3 { font-size: 14px; margin: 0 0 10px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; margin: 20px 0; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row > * { min-width: 0; }
.gap { gap: 10px; }
.icon {
  display: block;
  flex: none;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Workspace frame */
#view-app { min-height: 100dvh; }
.skip-link {
  position: fixed;
  z-index: 40;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 10px 16px;
  background: white;
  border-radius: 8px;
}
.skip-link:focus { transform: none; }
.sidebar {
  position: fixed;
  z-index: 12;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: 0 15px 20px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.sidebar-top {
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 720; letter-spacing: -.035em; }
.brand-mark {
  width: 35px;
  height: 35px;
  display: grid;
  flex: none;
  place-items: center;
  color: white;
  background: #175541;
  border-radius: 10px;
}
.brand-mark .icon { width: 21px; height: 21px; }
#nav { padding-top: 18px; }
.nav-group { display: grid; gap: 3px; }
.nav-group + .nav-group { margin-top: 24px; }
.nav-heading {
  padding: 0 11px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .105em;
  text-transform: uppercase;
}
#nav button {
  width: 100%;
  justify-content: flex-start;
  min-height: 42px;
  gap: 11px;
  padding: 8px 11px;
  color: #435b50;
  background: transparent;
  border-color: transparent;
  font-weight: 580;
}
#nav button:hover { background: #f0f4f1; color: var(--text); }
#nav button.active { color: #12513e; background: #e4f0e8; font-weight: 700; }
#nav button .icon { width: 18px; height: 18px; }
#nav-toggle, #nav-close, .nav-backdrop { display: none; }

.workspace { margin-left: var(--sidebar-width); min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-height);
  padding: 8px var(--gutter);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar-title, .who, .site-context { display: flex; align-items: center; min-width: 0; }
.topbar-title { gap: 9px; white-space: nowrap; }
.breadcrumb-root { color: var(--muted); }
.breadcrumb-divider.icon { width: 14px; height: 14px; color: #75877d; }
#current-page { font-weight: 680; }
.who { gap: 14px; }
.site-context { position: relative; gap: 7px; color: var(--muted); font-weight: 600; }
.site-context .icon { width: 17px; height: 17px; }
.site-context:has(#site-picker:not(.hidden)) > .icon {
  position: absolute;
  inset-inline-start: 10px;
  pointer-events: none;
  z-index: 1;
}
#site-picker { width: clamp(121px, 14vw, 196px); padding-inline-start: 34px; }
#site-label { max-width: clamp(90px, 20vw, 225px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-context:has(select.hidden):has(#site-label:empty) { display: none; }
.menu { position: relative; }
.account-button {
  padding: 3px 6px;
  color: var(--text);
  background: transparent;
  max-width: 230px;
}
.account-button:hover, .account-button[aria-expanded="true"] { background: var(--panel2); }
.account-button .icon { width: 15px; height: 15px; color: var(--muted); }
.account-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e4f0e8;
  color: #195740;
  font-size: 12px;
  font-weight: 750;
}
.menu-pop {
  position: absolute;
  z-index: 10;
  right: 0;
  top: calc(100% + 12px);
  display: grid;
  gap: 5px;
  width: max-content;
  min-width: 190px;
  max-width: min(290px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 28px #162d2124;
}
#me-role { padding: 7px 8px; overflow-wrap: anywhere; }
.menu-pop button { justify-content: flex-start; }

main { width: min(100%, 1660px); margin: 0 auto; padding: 28px var(--gutter) 48px; }
.tab { display: none; }
.tab.active { display: block; }
.page-heading { margin-bottom: 24px; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 15px; max-width: 64ch; }
.heading-with-action { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.subsection-heading { margin-top: 26px; }

/* Shared controls and surfaces */
button, a.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: var(--field-height);
  padding: 8px 14px;
  color: white;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--field-radius);
  font-weight: 650;
  line-height: 1.35;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
button:hover, a.btn:hover { background: var(--accent-hover); }
button.ghost, a.btn.ghost {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
button.ghost:hover, a.btn.ghost:hover { background: #edf3ef; border-color: #c7d5cd; }
button.danger { color: var(--alert); background: #fff; border-color: #e8c9cb; }
button.danger:hover { background: #fbecef; }
button.sm, a.btn { min-height: var(--compact-height); padding: 6px 10px; font-size: 12px; }
button:disabled { opacity: .55; cursor: wait; }
button .icon, a.btn .icon { width: 16px; height: 16px; }
button.icon-button {
  flex: none;
  width: 40px;
  min-height: 40px;
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
}
button.icon-button:hover { background: var(--panel2); }
button.icon-button .icon { width: 20px; height: 20px; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: var(--field-height);
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  scroll-margin-block: calc(var(--topbar-height) + 12px) 18px;
}
input::placeholder, textarea::placeholder { color: #61766a; }
input[type="checkbox"], input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"] { width: 16px; min-height: 0; height: 16px; padding: 0; flex: none; margin: 0; }
input[type="file"] { padding: 4px; }
input::file-selector-button {
  margin-right: 8px;
  padding: 5px 8px;
  color: var(--text);
  background: var(--panel2);
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font: inherit;
  line-height: 1.35;
}
label { display: block; margin-bottom: 13px; color: #40564a; font-size: 13px; font-weight: 600; }
label > input:not([type="checkbox"]), label > select, label > textarea { display: block; margin-top: 5px; font-size: 14px; font-weight: 400; }
label.row { display: flex; }
label .muted { font-weight: 400; }
select:where(:not([multiple], [size])) {
  appearance: none;
  padding-inline-end: 34px;
  background-image: var(--select-caret);
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  text-overflow: ellipsis;
}
select:enabled:hover { border-color: #a2b7a9; }
select:disabled { --select-surface: #f0f4f1; color: var(--muted); background-color: var(--select-surface); cursor: default; }
select.sm { width: auto; min-height: var(--compact-height); padding-block: 5px; font-size: 12px; }
select[multiple], select[size] { padding: 5px; }
select[multiple] option, select[size] option { padding: 4px 6px; }

/* Browsers that support styled pickers can wrap long option names. */
@media (pointer: fine) and (forced-colors: none) {
  @supports (appearance: base-select) and selector(::picker(select)) {
    select:where(:not([multiple], [size])), select:where(:not([multiple], [size]))::picker(select) {
      appearance: base-select;
    }
    select:not([multiple], [size]) {
      display: block;
      position: relative;
      overflow: hidden;
      background-image: none;
      white-space: nowrap;
    }
    select:open { border-color: var(--accent); }
    select::picker-icon {
      content: "";
      position: absolute;
      inset-block: 0;
      inset-inline-end: 0;
      width: 34px;
      pointer-events: none;
      background: var(--picker-caret, var(--select-caret)) right 10px center no-repeat,
        linear-gradient(to right, transparent, var(--select-surface, var(--panel)) 7px);
    }
    select:open::picker-icon { --picker-caret: var(--select-caret-up); }
    select::picker(select) {
      max-width: min(34rem, calc(100vw - 32px));
      max-height: min(22rem, 50dvh);
      margin-block: 5px;
      padding: 5px;
      color: var(--text);
      background: var(--panel);
      border: 1px solid var(--field-border);
      border-radius: 10px;
      box-shadow: 0 10px 26px #162d2126;
    }
    select:where(:not([multiple], [size])) option {
      gap: 8px;
      min-height: 34px;
      padding: 7px 9px;
      border-radius: 6px;
      white-space: normal;
      overflow-wrap: anywhere;
    }
    select:where(:not([multiple], [size])) option:checked { color: var(--accent-hover); background: #e4f0e8; }
    select:where(:not([multiple], [size])) option:enabled:hover { background: #edf3ef; }
    select:where(:not([multiple], [size])) option:disabled { color: var(--muted); opacity: .75; }
    select:where(:not([multiple], [size])) option:focus-visible { outline-width: 2px; outline-offset: -2px; }
  }
}
@media (forced-colors: active) {
  select:where(:not([multiple], [size])) { appearance: auto; background-image: none; padding-inline-end: 10px; }
}
.card, .surface {
  min-width: 0;
  padding: 19px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.split, .test-wrap, .dashboard-panels, .modal-grid { display: grid; align-items: start; gap: 18px; }
.split { grid-template-columns: minmax(0, 1fr) minmax(280px, 350px); }
.test-wrap { grid-template-columns: minmax(280px, .85fr) minmax(0, 1.3fr); }
.table-section { margin-top: 18px; }
#channel-status:not(:empty) { margin-bottom: 10px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  align-items: end;
  gap: 12px;
  margin-bottom: 13px;
}
.form-grid label { min-width: 0; margin-bottom: 0; }
.form-actions, .input-action { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.input-action > input, .input-action > select { width: auto; flex: 1 1 170px; }
.action-hint { margin-top: 8px; }
.card > p:last-child { margin-bottom: 0; }
.filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}
.filters label { margin: 0; flex: 0 1 176px; min-width: 0; }
#tab-accuracy .filters label:first-child { flex-basis: 240px; }
.filters select { width: 100%; }
.filters > button { flex: none; }
.tbl-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.tbl { width: 100%; border-collapse: collapse; text-align: left; background: var(--panel); }
.tbl th, .tbl td { padding: 12px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.tbl th { color: #465e51; font-weight: 700; background: #f0f4f1; white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background-color: #f8faf8; }
.tbl td.row { display: table-cell; white-space: nowrap; }
.tbl td.row > * + * { margin-left: 4px; }
.tbl td.url { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
td.nowrap { white-space: nowrap; }
td.detail { color: var(--muted); font-size: 12px; max-width: 420px; overflow-wrap: anywhere; }
.tbl .small { overflow-wrap: anywhere; }
.badge, .pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ecf1ee;
  color: #41584c;
  font-size: 11px;
  font-weight: 680;
  line-height: 1.4;
  white-space: nowrap;
}
.badge::first-letter { text-transform: uppercase; }
.b-ok, .b-online, .b-done, .b-confirmed { background: #e1f2e8; color: #155c3d; }
.b-alert, .b-offline, .b-failed, .b-rejected, .b-blocked { background: #fae9ea; color: #912d34; }
.b-error, .b-connecting, .b-uncertain, .b-candidate { background: #fbefda; color: #785013; }
.b-queued, .b-running { background: #e4effa; color: #225682; }
.role-superadmin { background: #efeafa; color: #604895; }
.role-site_admin { background: #e4effa; color: #225682; }
.pill { border: 1px solid var(--line); }
.err { color: #8c2d35; background: #fbefef; border-radius: 8px; padding: 9px 11px; margin: 9px 0; overflow-wrap: anywhere; }
span.err { display: block; }
.empty-state {
  grid-column: 1 / -1;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  min-height: 176px;
  padding: 22px 12px;
  border: 1px dashed #d5e2da;
  border-radius: 11px;
  background: #f8faf9;
  text-align: center;
}
.empty-state strong { font-size: 14px; font-weight: 700; }
.empty-state p { color: var(--muted); margin: 0; font-size: 13px; }
.empty-state button { margin-top: 7px; }
.empty-icon, .heading-icon, .metric-icon { display: grid; flex: none; place-items: center; color: #226149; background: #e9f2ed; }
.empty-icon { width: 42px; height: 42px; border-radius: 11px; margin-bottom: 3px; }
.empty-icon .icon { width: 22px; height: 22px; }

/* Dashboard */
.dashboard-hero {
  display: flex;
  align-items: center;
  min-height: 224px;
  padding: clamp(22px, 3.4vw, 44px);
  margin-bottom: 27px;
  border: 1px solid #143b31;
  border-radius: 19px;
  background: linear-gradient(90deg, #102c25 4%, #102c25f5 26%, #102c25a0 51%, #102c2520 88%),
    #102c25 url("/static/pipe-inspection.webp") right 59% / cover no-repeat;
  color: #fff;
  box-shadow: var(--shadow);
}
.hero-content { min-width: 0; }
.dashboard-hero h1 { font-size: clamp(31px, 3.65vw, 51px); }
.dashboard-hero p { margin: 9px 0 20px; color: #d2e2db; max-width: 42ch; font-size: 15px; }
.hero-actions { gap: 9px; flex-wrap: wrap; }
.hero-actions button { color: #153b2d; background: #cef1dd; }
.hero-actions button:hover { background: #b8e7cc; }
.hero-actions button.hero-secondary { color: #fff; background: #173b31; border-color: #738f81; }
.hero-actions button.hero-secondary:hover { background: #275246; }
.hero-actions button:focus-visible { outline-color: #bcebd2; }
.section-heading, .panel-heading, .panel-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.section-heading, .panel-heading { justify-content: space-between; flex-wrap: wrap; }
.section-heading { margin: 0 0 12px; }
.section-heading h2, .panel-title h2 { margin: 0; }
.update-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.update-note .icon { width: 14px; height: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); gap: 12px; margin-bottom: 19px; }
#kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 124px), 1fr)); margin-bottom: 22px; }
.kpi {
  min-width: 0;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.kpi .v { font-size: 26px; line-height: 1.25; font-weight: 720; letter-spacing: -.048em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kpi .l { color: #4d6457; font-size: 12px; font-weight: 650; }
.kpi .t, .metric-detail { color: var(--muted); font-size: 11px; }
.kpi.good .v { color: var(--ok); }
.kpi.bad .v, .kpi.alert .v { color: var(--alert); }
.dashboard-kpi { display: grid; grid-template-rows: auto auto 1fr auto; padding: 14px 15px; }
.dashboard-kpi .v { margin: 2px 0 1px; font-size: clamp(23px, 2.5vw, 32px); }
.dashboard-kpi .metric-text { font-size: clamp(19px, 2vw, 26px); text-transform: capitalize; min-height: 1.28em; }
.metric-icon, .heading-icon { width: 34px; height: 34px; border-radius: 9px; }
.metric-icon { margin-bottom: 10px; }
.metric-icon .icon, .heading-icon .icon { width: 18px; height: 18px; }
.dashboard-kpi.blue .metric-icon { background: #e8f0fa; color: #265987; }
.dashboard-kpi.orange .metric-icon, .heading-icon.warm { background: #faeee1; color: #89521e; }
.dashboard-kpi.violet .metric-icon { background: #f0eafa; color: #644497; }
.dashboard-kpi.slate .metric-icon { background: #eaf0f2; color: #405c68; }
.dashboard-panels { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: stretch; }
.dashboard-panels .surface { display: flex; flex-direction: column; }
.panel-heading { margin-bottom: 13px; }
.dashboard-panels .empty-state { flex: 1; }
.cam-grid { display: grid; flex: 1; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px; align-content: start; }
.cam-grid:has(.empty-state) { align-content: stretch; }
.cam { min-width: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.cam.is-alert { border-color: #ce7376; }
.cam button.view {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 250px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #172922;
}
.cam .view:focus-visible { outline-offset: -4px; outline-color: #bdf1d5; }
.cam .view img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam .view img:not([src]) { visibility: hidden; }
.cam .placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; color: #d1e0d7; overflow-wrap: anywhere; }
.cam .meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; min-width: 0; padding: 10px 12px; overflow-wrap: anywhere; }
.cam .name { font-weight: 700; }
.cam .sub { color: var(--muted); font-size: 12px; }
.live-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border-radius: 5px;
  color: #fff;
  background: #12251fe8;
  font-size: 10px;
}
.live-tag i { width: 7px; height: 7px; border-radius: 50%; background: #87e8aa; }
.feed { display: flex; flex: 1; flex-direction: column; gap: 7px; max-height: 520px; overflow: auto; }
button.feed-item {
  width: 100%;
  justify-content: flex-start;
  gap: 11px;
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
  padding: 7px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
button.feed-item:hover { background: #f0f5f1; }
.feed-item img { width: 76px; height: 51px; object-fit: cover; border-radius: 5px; background: #182a21; flex: none; }
.feed-item .t, .feed-item .s { display: block; }
.feed-item .t { font-weight: 700; }
.feed-item .s { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }

/* Capture and image review */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 14px; }
button.thumb {
  display: block;
  padding: 0;
  min-width: 0;
  align-self: stretch;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  text-align: left;
  box-shadow: var(--shadow);
}
button.thumb:hover { background: #f2f7f3; border-color: #9ebbae; }
.thumb img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: #182a21; }
.thumb .cap { display: flex; justify-content: space-between; align-items: start; gap: 7px; padding: 10px; font-size: 12px; overflow-wrap: anywhere; }
.thumb .cap > * { min-width: 0; }
.thumb .cap .muted { font-weight: 400; }
.capture-status { text-align: right; }
.drop {
  position: relative;
  display: grid;
  min-height: 124px;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 16px;
  background: #f7faf8;
  border: 1px dashed #a5bfb0;
  border-radius: 10px;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.drop.over, .drop:hover { border-color: var(--accent); background: #edf6f0; }
.drop:focus-within { outline: 3px solid #26896d; outline-offset: 3px; }
.drop input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; opacity: 0; }
.result-img { display: block; width: 100%; border-radius: 9px; background: #14221c; }
.scores { margin-top: 12px; }
.score { display: grid; grid-template-columns: minmax(0, 1fr) minmax(35px, 1.1fr) auto; gap: 8px; align-items: center; margin: 5px 0; font-size: 12px; overflow-wrap: anywhere; }
.bar, .progress { background: var(--panel2); overflow: hidden; border-radius: 999px; }
.bar { margin: 5px 0; height: 6px; }
.bar span, .bar > div, .progress span { display: block; height: 100%; background: var(--accent); }
.bar span.al { background: var(--alert); }

.modal-open { overflow: hidden; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 14px;
  background: #10251eb3;
}
.modal-body {
  position: relative;
  width: min(100%, 1080px);
  max-height: calc(100dvh - 28px);
  overflow: auto;
  padding: 20px;
  background: var(--panel);
  border-radius: 15px;
  box-shadow: 0 25px 65px #10251e52;
}
.modal .close { position: absolute; right: 12px; top: 11px; }
.modal-body h2:first-child { padding-right: 44px; min-height: 30px; overflow-wrap: anywhere; }
.modal-grid { grid-template-columns: minmax(0, 1fr) minmax(245px, 300px); }
.toggle { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 9px; }
dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; margin: 10px 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.toast {
  position: fixed;
  z-index: 30;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 10px 15px;
  background: #17392e;
  color: #fff;
  border-radius: 9px;
  box-shadow: 0 6px 20px #162d2140;
  overflow-wrap: anywhere;
}
.secret { font: 16px/1.5 ui-monospace, monospace; background: var(--bg); padding: 10px; border: 1px solid var(--line); border-radius: 8px; user-select: all; margin: 10px 0; overflow-wrap: anywhere; }

/* Authentication */
.auth-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.16fr);
  min-height: 100dvh;
  background: var(--panel);
}
.auth-art {
  grid-area: 1 / 2;
  margin: 14px 14px 14px 0;
  min-height: 260px;
  border-radius: 20px;
  background: #102c25 url("/static/pipe-inspection.webp") 76% center / cover no-repeat;
}
.auth-card { grid-area: 1 / 1; align-self: center; justify-self: center; width: min(100% - 48px, 380px); padding: 35px 0; }
.auth-card .brand { margin-bottom: 32px; }
.auth-card h1 { margin-bottom: 8px; }
.auth-card h1 + p { margin-bottom: 21px; }
.auth-card label { margin-bottom: 15px; }
.auth-card button[type="submit"] { width: 100%; margin-top: 4px; }
.auth-card .row button { width: auto; flex: 1; margin-top: 0; }
.auth-card > p:last-child { margin: 15px 0 0; }

/* Alerts, training and inspections */
.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: -3px 0 13px; }
.checks label { display: flex; align-items: center; gap: 6px; margin: 0; }
.verdict { padding: 14px 16px; margin: 10px 0 16px; border-radius: 10px; border: 1px solid var(--line); }
.verdict.pass { background: #edf7f0; border-color: #9cc9aa; }
.verdict.fail { background: #faeff0; border-color: #dfb0b3; }
.verdict.wait { background: #fbf5e9; border-color: #e6d3ab; }
.verdict b { font-size: 15px; }
.verdict ul { margin: 7px 0 0; padding-left: 19px; }
.review-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.review-box .row { flex-wrap: wrap; }
.btn-ok { background: var(--ok); }
.btn-bad { background: var(--alert); }
.btn-bad:hover { background: #882730; }
table.conf td, table.conf th { text-align: center; padding: 8px; }
table.conf td.diag { background: #e1f2e8; font-weight: 650; }
table.conf td.off { background: #fae9ea; }
.cards2, .steps { display: grid; gap: 15px; align-items: start; }
.cards2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); margin-top: 14px; }
.steps { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.step { display: flow-root; }
.step-n { float: left; display: grid; place-items: center; height: 25px; width: 25px; margin: -2px 8px 0 0; background: #e4f0e8; color: #15563f; border-radius: 7px; font-weight: 750; }
.step > h2 { min-height: 23px; }
details { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; margin-bottom: 8px; }
details summary { cursor: pointer; font-size: 13px; font-weight: 650; }
details[open] summary { margin-bottom: 9px; }
.indent { margin: 0 0 10px 18px; }
.progress { height: 8px; margin: 6px 0; }
.progress span { transition: width .35s; }
.job { margin-bottom: 12px; }
.job-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
pre.log {
  padding: 10px;
  border-radius: 8px;
  max-height: 220px;
  background: #182a22;
  color: #deebe3;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11px;
}
.map-row { display: grid; grid-template-columns: minmax(65px, 1fr) repeat(3, minmax(26px, .36fr)) minmax(55px, 1fr); gap: 4px; align-items: center; font-size: 12px; margin: 4px 0; overflow-wrap: anywhere; }
.map-row input { padding: 5px; min-height: 34px; }
.map-head { color: var(--muted); font-size: 10px; }
.warn { color: var(--warn); font-size: 12px; }
svg.chart { display: block; width: 100%; height: 140px; background: var(--bg); border-radius: 8px; }
.training-settings { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.inspection-add { margin-top: 18px; scroll-margin-top: calc(var(--topbar-height) + 16px); }
.inspection-add select { scroll-margin-top: calc(var(--topbar-height) + 25px); }
.inspection-setup { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.inspection-setup, .inspection-upload { max-width: 820px; }
.inspection-add h3 { margin-top: 18px; }
.server-actions { margin-top: 10px; }
#ins-uploads:not(:empty), #ins-sources { margin-top: 10px; }
#ins-sources .tbl, #ins-list .tbl { min-width: 590px; }
.mobile-table-label { display: none; }
.inspection-heading { margin-bottom: 15px; }
.inspection-heading .row { flex-wrap: wrap; }
.inspection-title { margin: 10px 0; }
.inspection-title p { overflow-wrap: anywhere; }
.inspection-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.inspection-options .input-action { max-width: 690px; }
.inspection-options .section-heading p { margin: 0; overflow-wrap: anywhere; }
.pipe-fields { margin-top: 12px; }
.finding-controls { margin-bottom: 10px; }
.finding-controls .form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 116px), 1fr)); margin-bottom: 0; }
.timeline-heading h2 { margin-bottom: 4px; }
.timeline-heading p { margin: 0; }
#ins-body .split { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
#ins-tl { display: block; width: 100%; margin: 9px 0; border-radius: 8px; cursor: crosshair; }
#ins-legend { display: flex; flex-wrap: wrap; gap: 3px 10px; overflow-wrap: anywhere; }
#ins-legend span { color: var(--muted); }
#ins-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--swatch); }
.ev { display: flex; gap: 10px; padding: 8px; margin-bottom: 8px; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.event-image { display: block; width: clamp(100px, 16vw, 168px); align-self: flex-start; margin: 0; padding: 0; border: 0; flex: none; overflow: hidden; background: #182a21; }
.event-image img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.ev.confirmed { border-color: #a4c8ad; }
.ev.rejected { background: #fbf4f4; }
.ev.uncertain { border-color: #ddc697; }
.ev-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pill.flag-high { background: #fde2e1; color: #9b1c1c; border-color: #f5b5b2; }
.pill.flag-medium { background: #fef0d9; color: #8a4b08; border-color: #f3cf96; }
.pill.flag-low { background: #e8f0ec; color: #3b5a4a; }
.pill.conf-high { background: #dcf2e3; color: #17603a; border-color: #a6d8b8; }
.pill.conf-low { color: #6b7280; }
/* inspection viewer: stays in view while the findings list scrolls; bigger view = full screen */
#ins-body .split { align-items: start; }
.ins-side { position: sticky; top: calc(var(--topbar-height) + 12px); max-height: calc(100vh - var(--topbar-height) - 24px); overflow-y: auto; overscroll-behavior: contain; }
.ins-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 12px; margin-top: 12px; align-items: start; }
.ann-stage { position: relative; }
.ann-stage img, .ann-stage video { display: block; width: 100%; border-radius: 8px; background: #0e1116; }
.ann-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.ann-expand { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px;
  background: #0e1116b3; color: #fff; font-size: 18px; line-height: 34px; cursor: pointer; }
.ann-expand:hover { background: #0e1116e6; }
.ann-bar { display: none; }
.ann-wrap.expanded { position: fixed; inset: 0; z-index: 3000; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 12px; background: #060a08f2; }
.ann-wrap.expanded .ann-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; color: #fff; }
.ann-wrap.expanded .ann-bar .ghost { color: #fff; border-color: #ffffff55; background: transparent; }
.ann-wrap.expanded .ann-hint { color: #c9d1cc; }
.ann-wrap.expanded .ann-stage { display: inline-block; }
.ann-wrap.expanded .ann-stage img, .ann-wrap.expanded .ann-stage video { width: auto; max-width: calc(100vw - 24px); max-height: calc(100vh - 90px); }
.ann-wrap.expanded .ann-expand { display: none; }
body.ins-fullscreen { overflow: hidden; }
@media (max-width: 720px) {
  .ins-side { position: static; max-height: none; overflow: visible; }
}
.hits { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 120px), 1fr)); gap: 8px; margin-top: 8px; }
.hit { cursor: pointer; overflow-wrap: anywhere; }
.hit img { width: 100%; border-radius: 6px; }

@media (max-width: 1180px) {
  .dashboard-panels { grid-template-columns: minmax(0, 1.42fr) minmax(0, 1fr); }
}
@media (max-width: 960px) {
  :root { --topbar-height: 60px; }
  .workspace { margin-left: 0; }
  .sidebar {
    width: min(290px, calc(100% - 48px));
    transform: translateX(-100%);
    visibility: hidden;
  }
  .nav-open .sidebar { transform: translateX(0); visibility: visible; transition: transform .2s ease; }
  body:has(.nav-open) { overflow: hidden; }
  .nav-open .nav-backdrop { display: block; position: fixed; z-index: 11; inset: 0; background: #10251e82; }
  #nav-toggle, #nav-close { display: inline-flex; }
  .breadcrumb-root, .breadcrumb-divider.icon { display: none; }
  .sidebar-top { padding-inline: 4px 0; }
  .split { grid-template-columns: minmax(0, 1fr) minmax(245px, 315px); }
}
@media (max-width: 720px) {
  :root { --gutter: 16px; }
  main { padding-top: 19px; }
  .split, .test-wrap, .dashboard-panels, .modal-grid, #ins-body .split { grid-template-columns: minmax(0, 1fr); }
  .dashboard-hero {
    min-height: 210px;
    padding: 22px;
    margin-bottom: 21px;
    background-image: linear-gradient(90deg, #102c25f5 0%, #102c25d1 40%, #102c2566 100%), url("/static/pipe-inspection.webp");
    background-position: right center;
  }
  .dashboard-hero p { font-size: 14px; }
  #kpis { grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr)); gap: 9px; }
  .dashboard-kpi { padding: 11px 12px; }
  .dashboard-kpi .metric-icon { width: 28px; height: 28px; margin-bottom: 6px; }
  .dashboard-kpi .metric-icon .icon { width: 16px; height: 16px; }
  .dashboard-panels { gap: 12px; }
  .empty-state { min-height: 144px; }
  .auth-screen { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .auth-art { grid-area: 1 / 1; min-height: clamp(125px, 27vh, 205px); margin: 10px 10px 0; border-radius: 13px; background-position: right 59%; }
  .auth-card { grid-area: 2 / 1; align-self: start; padding: 24px 0; }
  .auth-card .brand { margin-bottom: 23px; }
  .account-name { display: none; }
  .account-button { gap: 3px; padding-inline: 4px; }
  .who { gap: 5px; }
  .modal-body { padding: 14px; }
  .panel-heading { margin-bottom: 10px; }
  main input, main select, .modal-body input, .modal-body select, .auth-card input,
  label > input:not([type="checkbox"]), label > select, label > textarea { font-size: 16px; }
}
@media (max-width: 580px) {
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tab-accuracy .filters > button { align-self: stretch; }
  .inspection-setup { grid-template-columns: minmax(0, 1fr); }
  #ins-list .tbl-wrap { border: 0; background: transparent; box-shadow: none; }
  #ins-list .inspection-table { display: block; min-width: 0; background: transparent; }
  .inspection-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .inspection-table tbody { display: grid; gap: 10px; }
  .inspection-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
  }
  .inspection-table tbody td { display: block; padding: 0; border: 0; overflow-wrap: anywhere; }
  .inspection-table tbody tr:hover td { background: transparent; }
  .inspection-table td:first-child, .inspection-table td:last-child { grid-column: 1 / -1; }
  .inspection-table td:last-child { display: flex; flex-wrap: wrap; }
  .inspection-table td.row > * + * { margin-left: 0; }
  .mobile-table-label { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 650; color: var(--muted); }
  .inspection-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .inspection-kpis .kpi { padding: 8px 9px; }
  .inspection-kpis .v { font-size: 19px; }
  .inspection-kpis .l { font-size: 11px; }
}
@media (max-width: 440px) {
  .topbar { gap: 5px; }
  .topbar-title { gap: 6px; }
  #current-page { max-width: 28vw; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
  .site-context { gap: 3px; }
  .site-context > .icon, .account-button > .icon { display: none; }
  #site-picker { width: clamp(100px, 36vw, 142px); padding-inline-start: 10px; font-size: 14px; }
  #site-label { font-size: 12px; max-width: 27vw; }
  .card, .surface { padding: 13px; }
  .filters { padding: 10px; gap: 8px; }
  .finding-controls .form-grid > label:last-child { grid-column: 1 / -1; }
  .section-heading { gap: 5px; }
  .update-note { font-size: 11px; }
  .hero-actions button { padding-inline: 10px; font-size: 13px; }
  #kpis > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .dashboard-kpi { grid-template-columns: 28px minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: 8px; align-content: start; }
  .dashboard-kpi .metric-icon { grid-row: 1 / 4; }
  .dashboard-kpi .l, .dashboard-kpi .v, .dashboard-kpi .metric-detail { grid-column: 2; }
  .dashboard-kpi .metric-text { min-height: 0; font-size: 17px; }
  .inspection-upload > input, .inspection-upload > button { flex-basis: 100%; }
  .ev { flex-wrap: wrap; }
}
@media (pointer: coarse) {
  :root { --field-height: 44px; --compact-height: 44px; }
  #nav button { min-height: 44px; }
}
.spinner {
  flex: none; width: 13px; height: 13px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .sidebar, .nav-open .sidebar, .progress span { transition: none; }
  .spinner { animation-duration: 2.4s; }
}
