/* Red Metal Ballistics – shared styles for the phone app and the dashboard */

:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --ink: #1b1f1c;
  --ink-2: #4a514c;
  --muted: #747b76;
  --line: #e2e0d8;
  --line-strong: #cfccc2;
  --accent: #f30306;          /* the logo's red */
  --accent-hover: #cc0205;
  --accent-ink: #ffffff;
  --accent-soft: #fde6e5;
  --accent-text: #c70205;     /* red text, dark enough to read on light backgrounds */
  --focus: #1b1f1c;           /* focus rings: not red, which would look like an error */
  --ok: #2b7a3d;
  --ok-soft: #e6f3e8;
  --danger: #a3195b;          /* delete and errors: wine, so it isn't mistaken for the brand red */
  --danger-soft: #fbe7ef;
  --danger-ink: #ffffff;
  --bar: #2f6f5e;             /* chart series */
  --grid: #ebe9e2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 21, .06), 0 2px 8px rgba(20, 24, 21, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513;
    --surface: #1b1f1c;
    --surface-2: #222724;
    --ink: #eef0ee;
    --ink-2: #c2c8c3;
    --muted: #8f9791;
    --line: #2d332f;
    --line-strong: #3d4540;
    --accent: #f30306;
    --accent-hover: #ff2d27;
    --accent-ink: #ffffff;
    --accent-soft: #3d1514;
    --accent-text: #ff6b63;
    --focus: #eef0ee;
    --ok: #63c27a;
    --ok-soft: #1c3322;
    --danger: #f27aa9;
    --danger-soft: #3b1a29;
    --danger-ink: #22070f;
    --bar: #5fb39b;
    --grid: #2a302c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 750; font-size: 1.1rem; letter-spacing: -.01em;
  text-decoration: none;
}
.brand .logo { flex: none; display: block; }
.brand .logo img { display: block; height: 30px; width: auto; }
.brand small { font-weight: 500; color: var(--muted); font-size: .85rem; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .875rem; color: var(--ink-2); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Layout ---------- */

.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 120px; }
.wrap-wide { max-width: 1200px; margin: 0 auto; padding: 20px 16px 64px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.kpis > .card + .card { margin-top: 0; }
.card h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.step {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: .75rem; font-weight: 700;
}

/* ---------- Forms ---------- */

.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > .label { display: block; font-size: .875rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.req { color: var(--accent-text); margin-left: 2px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row > .field { margin-bottom: 14px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=date], input[type=search], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
}
select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23747b76' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: transparent;
}
.invalid input, .invalid select, .invalid .seg, .invalid .photo-tile {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px var(--danger);
}
.field .error-text { display: none; color: var(--danger); font-size: .8rem; margin-top: 4px; }
.invalid .error-text { display: block; }

.unit-input { position: relative; }
.unit-input input { padding-right: 44px; }
.unit-input .unit {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .9rem; pointer-events: none;
}

/* Yes / No segmented control */
.seg {
  display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  display: grid; place-items: center; min-height: 44px;
  font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none;
}
.seg label + input + label, .seg input + label ~ label { border-left: 1px solid var(--line-strong); }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: -3px; }

/* ---------- Photos ---------- */

.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  aspect-ratio: 4 / 3;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  overflow: hidden;
  text-align: center;
  padding: 8px;
}
.photo-tile input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-tile svg { width: 28px; height: 28px; color: var(--muted); }
.photo-tile .t { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.photo-tile .s { font-size: .75rem; color: var(--muted); }
.photo-tile.has-photo { border-style: solid; padding: 0; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .badge {
  position: absolute; left: 6px; bottom: 6px;
  background: rgba(0,0,0,.62); color: #fff;
  font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.photo-tile .remove {
  position: absolute; right: 6px; top: 6px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.62); color: #fff; font-size: 18px; line-height: 1;
  cursor: pointer;
}
.extra-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.extra-thumbs .x { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; }
.extra-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.extra-thumbs .remove {
  position: absolute; right: 2px; top: 2px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.62); color: #fff; font-size: 14px; line-height: 1; cursor: pointer;
}
.processing { opacity: .55; pointer-events: none; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  font: inherit; font-weight: 650;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.btn-danger:hover { background: var(--danger); filter: brightness(.92); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }

.sticky-submit {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.sticky-submit .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.sticky-submit .inner .btn-primary, .form-actions-sticky .inner .btn-primary { flex: 1; }

/* Same action bar, but pinned to the bottom of a scrolling panel instead of the screen */
.form-actions-sticky {
  position: sticky; bottom: 0; z-index: 3;
  margin: 16px -16px -24px; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.form-actions-sticky .inner { display: flex; gap: 10px; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Messages ---------- */

.alert {
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: .9rem; margin-bottom: 12px;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-bin {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-strong);
}

.toast {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%);
  z-index: 50; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}

/* ---------- Login ---------- */

.login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px 16px;
}
.login .card { width: 100%; max-width: 380px; padding: 24px; }
.login .brand { flex-direction: column; gap: 2px; font-size: 1.5rem; margin-bottom: 4px; }
.login .brand .logo img { height: 64px; }
.login p.sub { text-align: center; margin: 0 0 20px; }

/* ---------- Shot list (field app) ---------- */

.list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 24px 0 12px; }
.shot-list { display: grid; gap: 10px; }
.shot-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.shot-item:hover { border-color: var(--line-strong); }
.shot-item .thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.shot-item .title { font-weight: 650; }
.shot-item .meta { font-size: .85rem; color: var(--muted); }
.shot-item .chev { color: var(--muted); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.bin-link { display: block; margin-top: 20px; text-align: center; color: var(--ink-2); font-size: .9rem; }
.privacy h1 { margin-bottom: 8px; }
.privacy h2 { font-size: 1rem; margin: 18px 0 4px; }
.privacy p { margin: 0 0 12px; line-height: 1.5; }
.privacy ul { margin: 0 0 12px; padding-left: 20px; line-height: 1.5; }
.privacy li { margin-bottom: 6px; }
.privacy .btn { margin-top: 12px; }
.shot-item.binned { grid-template-columns: 64px 1fr auto; }
.shot-item.binned .thumb { opacity: .55; }
.subnav .count { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .75rem; }

/* ---------- Detail ---------- */

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin: 0; }
.facts div { padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.facts dt { font-size: .78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; }
.gallery a { display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery figcaption { font-size: .8rem; color: var(--muted); margin-top: 4px; }

.lightbox {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column;
  background: rgba(8, 9, 8, .97);
}
.lightbox-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  color: #fff; font-weight: 600;
}
.lightbox-bar { flex-wrap: wrap; }
.lightbox-bar span:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
.lightbox.no-marks .mark-overlay { display: none; }
.lightbox-bar .zoom-btns { display: inline-flex; gap: 4px; margin-right: 8px; }
.lightbox-bar .zoom-btns [data-zoom="in"], .lightbox-bar .zoom-btns [data-zoom="out"] { min-width: 40px; font-size: 1.1rem; }
/* Zoomable photo: the layer is sized and moved by zoomViewer() in shared.js */
.lightbox-img {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.lightbox-img.zoomed { cursor: grab; }
.lightbox-img.dragging { cursor: grabbing; }
.zoom-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.lightbox-img.loading .zoom-layer { visibility: hidden; }
.zoom-layer.animate { transition: width .2s ease, height .2s ease, transform .2s ease; }
.zoom-layer > img, .zoom-layer > .marked { display: block; width: 100%; height: 100%; max-width: none; }
.zoom-layer img { -webkit-user-drag: none; }
.lightbox-img .spinner { position: absolute; left: 50%; top: 50%; margin: -9px; color: #fff; display: none; }
.lightbox-img.loading .spinner { display: block; }
.zoom-hint {
  margin: 0; padding: 6px 16px max(10px, env(safe-area-inset-bottom));
  color: rgba(255, 255, 255, .55); font-size: .8rem; text-align: center;
}

.photo-grid .field { margin: 0; }

/* ---------- Dialogs ---------- */

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 16px;
  background: rgba(10, 12, 11, .5);
}
.dialog {
  width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 20px; border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.dialog.dialog-wide { max-width: 720px; }
.dialog h2 { margin-bottom: 8px; }
.map-pick { position: relative; height: min(60dvh, 480px); border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
.map-pick-map { position: absolute; inset: 0; }
.map-pick-cross { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; z-index: 500; pointer-events: none; }
.loc-late { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.loc-late p { margin: 0 0 8px; font-weight: 600; color: var(--ink); }
.loc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.dialog > p, .dialog form > p { margin: 0 0 16px; color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.copy-box {
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font: .9rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; user-select: all;
}

.detail-actions { display: flex; gap: 8px; margin: -4px 0 14px; }

/* ---------- Dashboard ---------- */

.subnav { background: var(--surface); border-bottom: 1px solid var(--line); }
.subnav .inner { max-width: 1200px; margin: 0 auto; padding: 0 8px; display: flex; gap: 2px; overflow-x: auto; }
.subnav a {
  padding: 11px 10px 9px; border-bottom: 2px solid transparent;
  color: var(--ink-2); font-size: .9rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.subnav a:hover { color: var(--ink); }
.subnav a.active { color: var(--ink); border-bottom-color: var(--accent); }
.modal-head .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
table.data.static tbody tr { cursor: default; }
table.data.static tbody tr:hover { background: transparent; }

.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
  margin-bottom: 16px;
}
.filters .field { margin: 0; }
.filters .field > .label { font-size: .78rem; margin-bottom: 4px; }
.filters select, .filters input { min-height: 40px; padding-top: 6px; padding-bottom: 6px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi .k-label { font-size: .85rem; color: var(--muted); }
.kpi .k-value { font-size: 2rem; font-weight: 650; letter-spacing: -.01em; line-height: 1.15; margin-top: 4px; }
.kpi .k-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

.chart-card h2 { margin-bottom: 2px; }
.chart-card .sub { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
.bars { display: grid; gap: 2px; position: relative; }
.bar-row {
  display: grid; grid-template-columns: minmax(90px, 140px) 1fr; align-items: center; gap: 12px;
  min-height: 30px; padding: 3px 0; border-radius: 6px; cursor: default;
}
.bar-row:hover { background: var(--surface-2); cursor: pointer; }
.chart-card .bars { max-width: 860px; }
.bar-label { font-size: .875rem; color: var(--ink-2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { position: relative; display: flex; align-items: center; gap: 8px; height: 20px; }
.bar-fill { flex: none; width: calc((100% - 48px) * var(--w, 0)); min-width: 2px; height: 20px; background: var(--bar); border-radius: 0 4px 4px 0; }
.bar-value { font-size: .85rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar-row:hover .bar-fill { filter: brightness(1.12); }
.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--ink); color: var(--bg);
  padding: 6px 10px; border-radius: 8px; font-size: .8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.tooltip b { font-weight: 650; }

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem;
  padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
table.data td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 650; border-top: 2px solid var(--line-strong); border-bottom: 0; }
table.data.results tbody tr.selected { background: var(--accent-soft); }
.table-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.table-head h2 { margin: 0; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 12, 11, .5);
  display: flex; justify-content: flex-end;
}
.modal {
  width: min(760px, 100%); height: 100%; overflow-y: auto;
  background: var(--bg); padding: 0;
  box-shadow: -8px 0 32px rgba(0,0,0,.2);
}
.modal-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.modal-body { padding: 16px 16px 24px; }

@media (min-width: 900px) {
  .dash-grid { grid-template-columns: minmax(320px, 2fr) 3fr; align-items: start; }
}

@media (max-width: 640px) {
  .admin .topbar .who { display: none; }
  .kpi .k-value { font-size: 1.4rem; }
  .bar-row { grid-template-columns: minmax(80px, 110px) 1fr; }
}

@media (max-width: 420px) {
  .row { grid-template-columns: 1fr; gap: 0; }
  .facts { grid-template-columns: 1fr; }
}

/* ---------- Red Metal Ballistics additions ---------- */

/* Status bar under the phone app's top bar: all shooters' totals, each with a symbol */
.statusbar {
  position: relative; z-index: 5;
  display: flex; justify-content: center; flex-wrap: wrap; gap: 2px 20px;
  padding: 5px 16px; font-size: .9rem; min-height: 36px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--ink-2);
}
.statusbar .stat {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: none; padding: 2px 4px; border-radius: 6px;
  font: inherit; color: inherit; cursor: help;
}
.statusbar .stat:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.statusbar .stat-icon { width: 20px; height: 20px; flex: none; color: var(--accent); }
.statusbar .stat-icon-wide { width: 27px; }
.statusbar b { color: var(--ink); font-weight: 650; }
/* What a symbol means: on hover, or for a moment after a tap */
.statusbar .stat::after {
  content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%);
  white-space: nowrap; padding: 5px 9px; border-radius: 6px; font-size: .78rem; font-weight: 600;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.statusbar .stat:first-child::after { left: 0; transform: none; }
.statusbar .stat:last-child::after { left: auto; right: 0; transform: none; }
@media (hover: hover) { .statusbar .stat:hover::after { opacity: 1; } }
.statusbar .stat.show-tip::after, .statusbar .stat:focus-visible::after { opacity: 1; }

.pill-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.pill-wait { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.subnav .count-alert { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.profile-summary { margin: -4px 0 14px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.profile-summary dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 0; }
.profile-summary dt { font-size: .75rem; color: var(--muted); }
.profile-summary dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.vterm-value { font-weight: 650; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.zone-checks, .check-list { display: grid; gap: 6px; }
.zone-check { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }
.zone-check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.invalid .zone-checks { outline: 2px solid var(--danger); outline-offset: 3px; border-radius: var(--radius-sm); }

.seg-sm label { min-height: 32px; font-size: .82rem; padding: 0 10px; }
.wrap-cell { white-space: normal !important; min-width: 160px; }
.row-actions { display: inline-flex; gap: 6px; }
.table-summary { font-size: .85rem; color: var(--ink-2); margin: -6px 0 12px; }
.table-summary:empty { display: none; }

/* Review card: zone map + approval */
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 700px) { .review-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.review-map p { margin: 6px 0 0; }
.zone-map { width: 100%; height: auto; display: block; }

/* Photos with the bullet-hole marker drawn on top */
.marked { position: relative; max-width: 100%; }
.marked img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: fill; }
.marked .mark-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gallery a.has-mark { display: flex; align-items: center; justify-content: center; background: #111; }
.marked.fit-width { width: 100%; }
.marked.fit-height { height: 100%; }

.photo-tile .tile-open {
  position: absolute; inset: 0; border: 0; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; background: #111;
}
.photo-tile .tile-open > img { width: 100%; height: 100%; object-fit: cover; }
button.photo-tile { font: inherit; width: 100%; }
.photo-tile .mark-state {
  position: absolute; left: 6px; top: 6px; z-index: 1;
  font-size: .72rem; font-weight: 650; padding: 2px 8px; border-radius: 999px;
}
.photo-tile .mark-state.ok { background: var(--ok); color: #fff; }
.photo-tile .mark-state.todo { background: var(--danger); color: var(--danger-ink); }

/* ---------- Full-screen camera with outline, and bullet-hole marking ---------- */

.capture {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column;
  background: #000; color: #fff;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.cap-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.cap-title { font-weight: 650; }
.cap-close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 18px; cursor: pointer; }
.cap-view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #111; }
.cap-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cap-guide { position: absolute; pointer-events: none; transform-origin: center; }
.cap-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 80%; text-align: center; padding: 10px 14px; border-radius: 10px; background: rgba(0,0,0,.6); font-size: .9rem; }
.cap-msg.is-error { background: rgba(163, 25, 91, .88); }
.cap-hint { padding: 8px 16px 0; text-align: center; font-size: .85rem; color: rgba(255,255,255,.85); }
.cap-portrait { display: none; }
.capture.is-portrait .cap-portrait { display: inline; }
.cap-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 16px; }
.cap-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.1); color: #fff;
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.cap-shutter {
  width: 72px; height: 72px; border-radius: 50%; flex: none; cursor: pointer;
  border: 4px solid #fff; background: var(--accent); box-shadow: inset 0 0 0 4px #000;
}
.cap-shutter[disabled] { opacity: .4; cursor: default; }

.mk-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.mk-photo { position: relative; touch-action: none; cursor: crosshair; }
.mk-photo img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; pointer-events: none; }
.mk-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.mk-loupe {
  position: absolute; width: 130px; height: 130px; border-radius: 50%; pointer-events: none;
  border: 3px solid #fff; box-shadow: 0 6px 20px rgba(0,0,0,.5); background-repeat: no-repeat; background-color: #000;
}
.mk-loupe::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%);
  border: 2px solid #d62828; border-radius: 50%;
}
.mk-tools { padding: 10px 16px 0; display: grid; gap: 8px; }
.mk-modes { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid rgba(255,255,255,.3); border-radius: 10px; overflow: hidden; }
.mk-modes button { min-height: 40px; border: 0; background: transparent; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.mk-modes button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.mk-outline-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
/* Offline note under the status bar, and shots waiting on the phone to be sent (phone app) */
.offline-note { padding: 8px 16px; text-align: center; font-size: .85rem; background: var(--surface-2); color: var(--ink-2); border-bottom: 1px solid var(--line); }
.offline-note[hidden] { display: none; }
.outbox { margin-top: 12px; }
.outbox-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.outbox-head h2 { margin: 0; font-size: 1rem; }
.outbox-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.outbox-item .title { font-weight: 650; }
.outbox-item .meta { font-size: .85rem; color: var(--muted); }
.outbox-error { color: var(--danger); }

/* Hidden while marking, but keeps its space so the photo doesn't move when switching modes */
.mk-outline-tools[hidden] { display: flex; visibility: hidden; }
.mk-size { display: flex; align-items: center; gap: 10px; font-size: .85rem; flex: 1; min-width: 180px; }
.mk-size input { flex: 1; accent-color: var(--accent); }
.mk-hint { margin: 0; text-align: center; font-size: .85rem; color: rgba(255,255,255,.85); }

/* Keep the app name on one line in the top bar on small phones */
.brand span { white-space: nowrap; }
@media (max-width: 440px) {
  .topbar .who { display: none; }
  .topbar .brand { font-size: 1rem; }
}
.photo-tile .mark-state { max-width: calc(100% - 48px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Inactive caliber profile in the Shooters table */
.pill-off { opacity: .55; text-decoration: line-through; }

/* Progress of the export with photos */
.progress { height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.wrap-cell .pill { white-space: nowrap; margin: 1px 0; }

/* Files of a shot (dashboard) */
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-list a { overflow-wrap: anywhere; }
