/* Precision field app. Colors come from the logo: navy PRECISION, flame red, ice blue. */
:root {
  --navy: #223B73; --navy-2: #1a2e5a; --red: #E3262B; --ice: #2AA7DF;
  --bg: #f3f5f9; --card: #ffffff; --ink: #1b2233; --muted: #5d6679; --line: #dde2ec;
  --soft: #eef2f9; --ok: #1f8a4c; --warn: #b7791f; --bad: #c53030;
  --radius: 14px; --shadow: 0 1px 3px rgba(20, 30, 60, .08), 0 4px 14px rgba(20, 30, 60, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1522; --card: #182033; --ink: #e8ecf4; --muted: #9aa5bb; --line: #2a3550; --soft: #1f2940;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
  :root:not([data-theme="light"]) .logo { background: #fff; border-radius: 8px; padding: 3px 6px; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%; padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) a { color: #8fb4ff; } }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 3px solid var(--navy); box-shadow: var(--shadow);
}
.logo { height: 38px; width: auto; max-width: 52vw; object-fit: contain; }
.office-btn {
  margin-left: auto; border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 14px;
  background: var(--red); color: #fff; white-space: nowrap;
}
.icon-btn { border: 0; background: none; font-size: 24px; padding: 2px 6px; color: var(--navy); }
@media (max-width: 420px) { .office-btn { font-size: 12.5px; padding: 7px 10px; } .logo { height: 30px; } }

.menu {
  position: fixed; z-index: 30; top: 62px; left: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; min-width: 230px;
}
.menu button, .menu a { text-align: left; background: none; border: 0; padding: 11px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.menu button:hover, .menu a:hover { background: var(--soft); }
.menu-foot { margin: 6px 12px 4px; font-size: 12px; color: var(--muted); }

main { max-width: 860px; margin: 0 auto; padding: 14px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.narrow { max-width: 420px; margin: 30px auto; }
h1 { font-size: 22px; margin: 4px 0 14px; color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) h1 { color: #b9ccf5; } }
label { display: block; margin: 10px 0; font-weight: 600; font-size: 14px; }
input, textarea, select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: var(--card);
}
input:focus, textarea:focus { outline: none; border-color: var(--ice); box-shadow: 0 0 0 3px rgba(42, 167, 223, .2); }
.primary { background: var(--navy); color: #fff; border: 0; border-radius: 10px; padding: 11px 20px; font-weight: 700; }
.primary:disabled { opacity: .55; cursor: default; }
.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 8px; }
.link-btn { background: none; border: 0; color: var(--navy); font-weight: 600; padding: 6px 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .link-btn { color: #8fb4ff; } }
.back { margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--bad); font-weight: 600; }

.tagline {
  text-align: center; font-size: 18px; font-weight: 700; font-style: italic; margin: 22px 0 8px;
  background: linear-gradient(90deg, var(--red), var(--navy) 50%, var(--ice)); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* location + picker */
.where { margin-bottom: 12px; }
.gps { display: flex; align-items: flex-start; gap: 10px; }
.gps-dot { font-size: 20px; line-height: 1.3; }
.gps-text { flex: 1; }
.gps-text small { display: block; color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.picker { position: relative; margin-top: 10px; }
.picker-results {
  position: absolute; z-index: 15; left: 0; right: 0; top: 100%; margin-top: 4px; max-height: 50vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.picker-results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.picker-results button:hover, .picker-results button:focus { background: var(--soft); }
.picker-results .sub { display: block; color: var(--muted); font-size: 13px; }
.picker-results .kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ice); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 14px; font-weight: 600; }
.chip button { border: 0; background: var(--card); border-radius: 999px; width: 24px; height: 24px; line-height: 1; }
.chip .info { width: auto; padding: 0 8px; color: var(--navy); font-weight: 700; }

/* conversation */
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.empty-hint { color: var(--muted); padding: 4px 4px 0; }
.example { background: var(--card); border-left: 4px solid var(--ice); padding: 8px 12px; border-radius: 8px; font-style: italic; }
.bubble-tech { align-self: flex-end; max-width: 88%; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.answer { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.answer .status { padding: 12px 14px; color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.spinner { width: 16px; height: 16px; border: 2.5px solid var(--line); border-top-color: var(--ice); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.summary { background: linear-gradient(135deg, #eaf5fc, #eef2fa); border-bottom: 1px solid var(--line); padding: 14px 16px; font-size: 17px; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .summary { background: #1c2b47; } }
.summary h3, .details h3 { margin: 0 0 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ice); }
.details { padding: 14px 16px; }
.details h3 { color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .details h3 { color: #8fb4ff; } }
.md p { margin: 8px 0; }
.md ul, .md ol { padding-left: 22px; margin: 8px 0; }
.md li { margin: 4px 0; }
.md table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 14.5px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--soft); }
.md code { background: var(--soft); padding: 1px 5px; border-radius: 5px; font-size: 14px; }
.md pre { background: var(--soft); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md h4 { margin: 14px 0 4px; }
.chart-box { position: relative; margin: 12px 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); height: 260px; }
.answer-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.answer-actions button { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; }
.answer-actions .speak { border-color: var(--ice); color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .answer-actions .speak { color: #cfe3ff; } }
.answer-actions .speaking { background: var(--ice); color: #fff; }
.answer-actions .wrong { margin-left: auto; color: var(--red); border-color: #f3c3c4; }
.answer .fail { padding: 14px 16px; color: var(--bad); font-weight: 600; }

/* composer */
.composer { padding: 10px; margin-bottom: 12px; }
.composer textarea { resize: none; min-height: 52px; max-height: 40vh; border: 0; padding: 6px 4px; font-size: 17px; box-shadow: none; }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.composer-row .primary { margin-left: auto; padding: 11px 22px; font-size: 16px; }
.mic { border: 0; width: 46px; height: 46px; border-radius: 50%; background: var(--soft); font-size: 22px; flex: none; }
.mic.listening { background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(227, 38, 43, .15); } }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 7px 13px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--navy); color: #fff; }
.composer-foot { display: flex; justify-content: space-between; align-items: center; min-height: 20px; margin-top: 4px; font-size: 13px; }

/* photos on a question */
.photo-tray { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 2px 2px; }
.thumb { position: relative; width: 72px; height: 72px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.thumb button { position: absolute; top: -7px; right: -7px; width: 26px; height: 26px; border: 2px solid var(--card); border-radius: 50%;
  background: var(--ink); color: var(--card); font-size: 12px; font-weight: 700; line-height: 1; padding: 0; }
.bubble-photos { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal; }
.bubble-photos:not(:last-child) { margin-bottom: 8px; }
.bubble-photos img { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 10px; cursor: zoom-in; }
.photo-dlg { padding: 10px; width: min(900px, calc(100vw - 16px)); }
.photo-dlg img { display: block; max-width: 100%; max-height: 76vh; margin: 0 auto; border-radius: 8px; }
@media (max-width: 420px) {
  .composer-row { gap: 6px; }
  .mic { width: 42px; height: 42px; font-size: 20px; }
  .seg button { padding: 7px 10px; }
  .composer-row .primary { padding: 11px 16px; }
}

/* unit page */
.unit-head h1 { margin-bottom: 2px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.section { margin-top: 14px; }
.section h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.status-box { border-left: 5px solid var(--ice); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.kb { max-height: none; }
details > summary { cursor: pointer; font-weight: 700; color: var(--navy); padding: 4px 0; }
.unit-ask { margin-top: 14px; width: 100%; }

/* history */
.hist-item { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
.hist-item .when { color: var(--muted); font-size: 13px; }

/* dialog + toast */
dialog { border: 0; border-radius: 16px; padding: 18px; width: min(560px, calc(100vw - 24px)); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 20, 40, .5); }
dialog h2 { margin: 0 0 6px; color: var(--red); }
.context { background: var(--soft); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.dlg-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.dlg-row button:not(.mic):not(.primary) { border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 16px; }
.grow { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--card); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

/* admin */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat .v { font-size: 26px; font-weight: 800; color: var(--navy); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stat .v { color: #b9ccf5; } }
.stat .k { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
table.grid th { background: var(--soft); position: sticky; top: 0; }
table.grid td.text { max-width: 440px; white-space: pre-wrap; word-break: break-word; }
.kind { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.kind.question { background: #e3effd; color: #1c4f9c; } .kind.answer { background: #e3f6ea; color: var(--ok); }
.kind.refusal, .kind.not_found { background: #fde8e8; color: var(--bad); } .kind.error { background: #fde8e8; color: var(--bad); }
.kind.report { background: #fff1db; color: var(--warn); } .kind.login_failed { background: #fde8e8; color: var(--bad); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button, .small-btn { border: 1.5px solid var(--line); background: var(--card); border-radius: 8px; padding: 5px 10px; font-size: 13px; font-weight: 600; }
.on { color: var(--ok); font-weight: 700; } .off { color: var(--bad); font-weight: 700; }

/* one question + its answer, newest first */
.turn { display: flex; flex-direction: column; gap: 10px; }
.turn + .turn { padding-top: 12px; border-top: 1px dashed var(--line); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sec-head h3 { margin: 0 !important; }
.speak-top { border: 1.5px solid var(--ice); background: var(--card); color: var(--navy); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.speak-top.speaking { background: var(--ice); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .speak-top { color: #cfe3ff; } }
.kind.activity { background: #eef0f4; color: #5d6679; }

/* ✕ to clear the ask box */
.q-wrap { position: relative; }
.q-wrap textarea { padding-right: 40px; }
.clear-q { position: absolute; top: 4px; right: 2px; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: var(--soft); color: var(--muted); font-size: 16px; font-weight: 700; line-height: 1; }
.clear-q:hover, .clear-q:focus { background: var(--line); color: var(--ink); }
/* read-back voice dialog */
input[type="range"] { padding: 0; border: 0; box-shadow: none; accent-color: var(--navy); height: 32px; }
#voiceDlg select { margin-top: 4px; }
/* office reports + confirmed notes */
.report .rep-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.report .rep-msg { font-size: 16px; margin: 8px 0; white-space: pre-wrap; }
.report.focus { border: 2px solid var(--ice); box-shadow: 0 0 0 4px rgba(42, 167, 223, .15); }
.rep-approve { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.rep-approve .primary { padding: 8px 18px; }
.confirmed-note { margin: 6px 0; padding: 6px 10px; background: #e3f6ea; border-radius: 8px; font-size: 14px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .confirmed-note { background: #163a26; } }
/* Back Office side (office and admin logins) */
.mode-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 8px 14px;
  background: var(--navy); color: #fff; border-radius: var(--radius); }
.mode-bar .link-btn { color: #fff; text-decoration: underline; padding: 2px 0; }
.subjects-title { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 4px 8px; }
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.subject { display: flex; flex-direction: column; gap: 4px; text-align: left; border-left: 5px solid var(--ice); font-size: 17px; }
.subject:hover, .subject:focus { border-left-color: var(--navy); background: var(--soft); }
.plain { white-space: pre-wrap; word-break: break-word; }
.pdf-open { display: block; text-align: center; text-decoration: none; margin-top: 14px; }
td select { min-width: 150px; padding: 6px 8px; }
/* a Back Office document on screen: easier on the eye than a wall of text */
.sop { font-size: 16.5px; }
.sop h2 { font-size: 19px; color: var(--navy); margin: 26px -14px 10px; padding: 9px 14px; background: var(--soft); border-left: 6px solid var(--ice); scroll-margin-top: 76px; }
.sop h2:first-child { margin-top: 0; }
.sop h3, .sop h4 { color: var(--navy); margin: 18px 0 6px; scroll-margin-top: 76px; }
.sop ol { padding-left: 30px; }
.sop ol > li { margin: 12px 0; padding-left: 4px; scroll-margin-top: 76px; }
.sop ol > li::marker { color: var(--red); font-weight: 800; font-size: 18px; }
.sop ul > li::marker { color: var(--ice); }
.sop li > p { margin: 6px 0; }
.sop blockquote { margin: 14px 0; padding: 10px 14px; background: #eaf5fc; border: 1px solid #c9e4f5; border-left: 6px solid var(--ice); border-radius: 10px; }
.sop blockquote p { margin: 4px 0; }
.sop table { display: table; }
.sop th { color: var(--navy); }
.sop a { font-weight: 600; }
.sop em { color: var(--muted); }
/* a screenshot in a document, or one the assistant shows in an answer: fits the screen, tap to see it full size */
.sop img, .answer .md img { display: block; max-width: 100%; height: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; cursor: zoom-in; }
.sop .spot { animation: spot 2.4s ease-out; border-radius: 8px; }
@keyframes spot { 0%, 35% { background: #fff1b8; box-shadow: 0 0 0 6px #fff1b8; } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sop h2, :root:not([data-theme="light"]) .sop h3, :root:not([data-theme="light"]) .sop th { color: #b9ccf5; }
  :root:not([data-theme="light"]) .sop blockquote { background: #1c2b47; border-color: #2a3550; border-left-color: var(--ice); }
  :root:not([data-theme="light"]) .sop ol > li::marker { color: #ff8a8d; }
}
.empty-hint:empty { display: none; }
