/* VADD Field Report - web portal.
   Sized for gloved hands on a tablet: 44px minimum tap targets, high contrast,
   light-first because this gets used outdoors. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #14171c;
  --ink-soft: #5b6472;
  --line: #d4d9e0;
  --line-strong: #828282;
  --label-fill: #e9edf2;
  --accent: #12386b;
  --accent-ink: #ffffff;
  --danger: #bf0000;
  --warn-bg: #fff6e0;
  --warn-line: #e0b661;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 23, 28, .07), 0 4px 14px rgba(20, 23, 28, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1c2027; --ink: #eef1f5; --ink-soft: #9aa4b2;
    --line: #2c323b; --line-strong: #4a525e; --label-fill: #232932;
    --accent: #5b9dff; --accent-ink: #0d1117; --warn-bg: #2c2415; --warn-line: #6b5726;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------- masthead */
.masthead {
  background: var(--surface); border-bottom: 2px solid var(--accent);
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 20;
}
.masthead-inner {
  max-width: 1400px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.logo { height: 34px; width: auto; flex: none; }
.masthead-text { flex: 1 1 260px; min-width: 0; }
.masthead-project {
  font-size: 22px; font-weight: 700; letter-spacing: .01em;
  text-transform: uppercase; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.masthead-sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.masthead-actions { display: flex; gap: 8px; flex: none; flex-wrap: wrap; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* ---------------------------------------------------------------- atoms */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 16px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: var(--radius);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--line-strong); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.lg { min-height: 48px; padding: 0 24px; font-size: 16px; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; }
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
code { font: 13px/1 ui-monospace, "Cascadia Code", Consolas, monospace;
       background: var(--label-fill); padding: 2px 5px; border-radius: 4px; }
.hint { color: var(--ink-soft); font-size: 13px; }
.hint-inline { color: var(--ink-soft); font-weight: 400; font-size: 12px; }

/* -------------------------------------------------------------- reports */
table.reports {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.reports th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-soft); background: var(--label-fill);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.reports td { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.reports tbody tr { cursor: pointer; }
.reports tbody tr:hover { background: var(--label-fill); }
.reports .strong { font-weight: 600; }
.reports .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 56px 24px; text-align: center; box-shadow: var(--shadow);
}
.empty h2 { margin: 0 0 8px; }
.empty p { color: var(--ink-soft); max-width: 52ch; margin: 0 auto 22px; }

/* ----------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  min-height: 40px; padding: 0 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); border-radius: var(--radius);
  font: inherit; font-weight: 500; cursor: pointer;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* --------------------------------------------------------- observations */
.obs {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.obs-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.obs-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.obs-loc { flex: 1 1 180px; min-width: 0; }
input, textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); color: var(--ink);
  font: inherit; min-height: 40px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.enhanced {
  margin-top: 8px; padding: 10px 12px; background: var(--label-fill);
  border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; font-size: 14px;
}
.tag {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  background: var(--accent); color: var(--accent-ink);
  padding: 2px 6px; border-radius: 3px; margin-right: 8px; vertical-align: 1px;
}

.photo-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; align-items: flex-start; }
.thumb {
  position: relative; margin: 0; width: 132px; height: 100px;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--label-fill);
}
.thumb.is360 { width: 216px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge {
  position: absolute; left: 5px; bottom: 5px; font-size: 10px; font-weight: 700;
  background: rgba(0,0,0,.72); color: #fff; padding: 2px 6px; border-radius: 3px;
}
.thumb .x, .dwg-name .x {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  border: none; border-radius: 50%; background: rgba(0,0,0,.62); color: #fff;
  font-size: 16px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.dwg-name .x { position: static; width: 20px; height: 20px; font-size: 13px; background: transparent; color: var(--ink-soft); }

.dropzone {
  width: 132px; height: 100px; border: 2px dashed var(--line-strong); border-radius: 6px;
  display: grid; place-items: center; text-align: center; cursor: pointer;
  color: var(--ink-soft); font-size: 13px; padding: 6px;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--accent); }
.dropzone.pdf { width: 100%; height: 64px; margin-bottom: 12px; }

/* ------------------------------------------------------------- drawings */
.dwg-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .dwg-layout { grid-template-columns: 1fr; } }
.sheet-list {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; max-height: 74vh; overflow: auto; box-shadow: var(--shadow);
}
.dwg-name {
  font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: .04em; margin: 10px 0 6px; display: flex; align-items: center;
  justify-content: space-between; gap: 6px;
}
.sheet-item {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 6px; margin-bottom: 4px; border: 1px solid transparent; border-radius: 6px;
  background: none; color: var(--ink); font: inherit; cursor: pointer; min-height: 52px;
}
.sheet-item:hover { background: var(--label-fill); }
.sheet-item.active { border-color: var(--accent); background: var(--label-fill); }
.sheet-item img { width: 44px; height: 34px; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; flex: none; }
.sheet-label { min-width: 0; display: flex; flex-direction: column; }
.sheet-label strong { font-size: 13px; }
.sheet-label em {
  font-style: normal; font-size: 11px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.viewer {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.viewer-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); background: var(--label-fill); flex-wrap: wrap;
}
.sheet-name { font-weight: 600; font-size: 14px; }
.spacer { flex: 1; }
.zoom { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-soft); min-width: 46px; text-align: center; }
#pinMode.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.viewer-stage {
  position: relative; height: 68vh; overflow: hidden; background: #6b7280;
  display: grid; place-items: center; cursor: grab; touch-action: none;
}
.viewer-stage.pinning { cursor: crosshair; }
.viewer-stage.dragging { cursor: grabbing; }
#sheetImg { max-width: 100%; max-height: 100%; display: none; user-select: none; }
.viewer-empty { position: absolute; color: #fff; opacity: .85; font-size: 14px; }

/* --------------------------------------------------------------- panels */
.panel { animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.grid2 {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
label input, label textarea { margin-top: 5px; font-weight: 400; color: var(--ink); }
label.full {
  display: block; margin-top: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}

/* -------------------------------------------------------------- dialogs */
.dlg {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  background: var(--surface); color: var(--ink); max-width: 420px; width: calc(100% - 32px);
  box-shadow: 0 12px 48px rgba(0,0,0,.28);
}
.dlg.wide { max-width: 900px; }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg h3 { margin: 0 0 14px; }
.dlg label { margin-bottom: 12px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: 22px;
  font-size: 14px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 400px; box-shadow: var(--shadow); text-align: center;
}
.login-logo { height: 42px; width: auto; margin-bottom: 14px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .01em; }
.login-card form { text-align: left; margin-top: 18px; }
.login-card label { margin-bottom: 12px; }
.full-w { width: 100%; margin-top: 6px; }
.banner.error { background: color-mix(in srgb, var(--danger) 12%, var(--surface));
                border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line)); }
.small-banner { font-size: 13px; padding: 9px 12px; margin: 10px 0 0; }

/* --------------------------------------------------------------- masthead */
.logo-link { display: flex; flex: none; }
.whoami { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-soft); }

/* ------------------------------------------------------------- home cards */
.section-h { font-size: 14px; text-transform: uppercase; letter-spacing: .05em;
             color: var(--ink-soft); margin: 6px 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
         gap: 14px; margin-bottom: 30px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow);
}
.card:hover { border-color: var(--accent); }
.card-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.card-meta { color: var(--ink-soft); font-size: 13px; }
.card-stats { display: flex; gap: 14px; margin-top: 12px; font-size: 13px; }
.card-stats .ok { color: var(--accent); font-weight: 600; }
.card-stats .muted { color: var(--ink-soft); }

.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
        border-radius: 11px; background: var(--label-fill); color: var(--ink-soft); }
.chip.tablet { background: var(--accent); color: var(--accent-ink); }
.chip.cat { background: var(--label-fill); color: var(--ink); margin-right: 6px; }
.cat-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

/* ----------------------------------------------------------- project setup */
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.panel-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.panel-card.wide { grid-column: 1 / -1; }
.panel-card.highlight { border-color: var(--accent); }
.panel-card h3 { margin: 0 0 14px; font-size: 15px; }
.panel-card .grid2 { background: none; border: none; padding: 0; box-shadow: none; }
.centered-card { max-width: 540px; margin: 0 auto; text-align: center; }
.btn-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.btn-row.centered { justify-content: center; }
.grow { flex: 1 1 160px; min-width: 0; }

.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cat-num { flex: none; width: 24px; height: 24px; border-radius: 50%;
           background: var(--label-fill); color: var(--ink-soft);
           display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.cat-name { flex: 1; min-width: 0; }

.dwg-list { list-style: none; margin: 12px 0 0; padding: 0; }
.dwg-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0;
               border-bottom: 1px solid var(--line); font-size: 14px; }
.dwg-list li:last-child { border-bottom: none; }

.pair-out { text-align: center; margin: 14px 0; padding: 16px;
            background: var(--label-fill); border-radius: var(--radius); }
.pair-code { font: 700 38px/1.1 ui-monospace, "Cascadia Code", Consolas, monospace;
             letter-spacing: .12em; color: var(--accent); }
table.devices { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
.devices th { text-align: left; font-size: 11px; text-transform: uppercase;
              letter-spacing: .04em; color: var(--ink-soft); padding: 8px 6px;
              border-bottom: 1px solid var(--line); }
.devices td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
.devices tr:last-child td { border-bottom: none; }

/* ------------------------------------------------------------------ voice */
.voice-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.voice-row audio { height: 34px; max-width: 260px; }
.rec-btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; }
.rec-status { font-size: 12px; }
.enhanced.transcript { border-left-color: var(--ink-soft); }
.tag.alt { background: var(--ink-soft); }

/* ---------------------------------------------------------------- monthly */
.month-picker { display: flex; align-items: center; justify-content: center;
                gap: 16px; margin: 8px 0; }
.month-label { font-size: 20px; font-weight: 700; min-width: 200px; }
.month-stats { color: var(--ink-soft); font-size: 14px; margin: 4px 0 16px; }

/* --------------------------------------------------------------- offline */
.offline-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  background: var(--danger); color: #fff; text-align: center;
  padding: 9px 16px; font-size: 13px; font-weight: 600;
  box-shadow: 0 -2px 12px rgba(0,0,0,.22);
}
.offline-bar.syncing { background: var(--accent); color: var(--accent-ink); }

/* ------------------------------------------------------- tablet config */
.chip.pending { background: var(--warn-bg); color: var(--ink);
                border: 1px solid var(--warn-line); }
.dev-config td { background: var(--label-fill); padding: 0; }
.dev-config-body { padding: 16px; }
.dev-config-body .grid2 { background: none; border: none; padding: 0; box-shadow: none; }
.dev-config-body label { margin-top: 10px; }
.full-inline { display: flex; align-items: center; gap: 8px; margin-top: 12px;
               font-weight: 500; color: var(--ink); }
.full-inline input[type="checkbox"] { width: auto; min-height: 0; }

/* ------------------------------------------------------- credential box */
.cred-box {
  background: var(--label-fill); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin: 12px 0;
  text-align: center; word-break: break-all;
}
.cred-box code {
  background: none; padding: 0; font-size: 17px; font-weight: 600;
  letter-spacing: .02em; user-select: all;
}

/* --------------------------------------------------- provisioning guide */
.provision { max-width: 860px; margin: 0 auto; }
.steps { list-style: none; margin: 16px 0 0; padding: 0; counter-reset: step; }
.steps .step { margin-bottom: 16px; }
.step-n {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: 14px; margin-right: 10px; vertical-align: 2px;
}
.steps-plain { margin: 0; padding-left: 20px; color: var(--ink-soft); font-size: 14px; }
.steps-plain li { margin-bottom: 6px; }
.provision h3 { display: flex; align-items: center; }
.provision p { font-size: 14px; }
.provision pre {
  background: var(--label-fill); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; overflow-x: auto; font-size: 13px;
}
.shot { margin: 14px 0; }
.shot img {
  max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius);
  display: block;
}
.shot figcaption { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

.pair-qr {
  display: block; margin: 12px auto 8px; width: 190px; height: 190px;
  background: #fff;                 /* QR must stay dark-on-light in dark mode */
  border: 8px solid #fff; border-radius: 6px;
}

/* Account form: same rhythm as the login card, in a normal page panel. */
.stack { max-width: 420px; }
.stack label { margin-bottom: 12px; }
