/* HPI Assist dashboard. Same palette as the Android app (lib/theme.dart). */
:root {
  --brand: #1b78b8;          /* HPI blue, dark enough for white text */
  --brand-dark: #0b1620;     /* top bar: the artwork's navy-black */
  --brand-soft: #e7f3fb;
  --brand-green: #7fa81c;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --line: #d5dbe3;
  --ok: #1e7b3a;
  --ok-soft: #e5f4ea;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-size: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
small, .muted { color: var(--muted); }
code { background: #eef1f5; padding: 0 .3em; border-radius: 4px; font-size: .9em; }

/* Layout */
.topbar { background: var(--brand-dark); color: #fff; }
.topbar .inner { max-width: 1200px; margin: 0 auto; padding: .6rem 1rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.2rem; color: #fff; text-decoration: none; display: flex; align-items: center; gap: .5rem; }
.brand .mark { background: #fff; color: var(--brand-dark); border-radius: 8px; padding: 0 .45rem; font-weight: 800; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: #dbe8f3; text-decoration: none; padding: .45rem .75rem; border-radius: 8px; font-weight: 600; }
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active { background: #fff; color: var(--brand-dark); }
.userbox { display: flex; gap: .6rem; align-items: center; color: #dbe8f3; font-size: .9rem; }
.userbox form { margin: 0; }
.userbox button { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; min-height: 36px; padding: .2rem .8rem; }
main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Cards and grid */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow); }
.stat .value { font-size: 2rem; font-weight: 750; line-height: 1.1; }
.stat .label { color: var(--muted); font-weight: 600; }
.stat.bad .value { color: var(--bad); }
.stat.ok .value { color: var(--ok); }

/* Forms */
label { font-weight: 600; display: block; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff;
  border: 1.5px solid #9aa7b6; border-radius: 8px; padding: .55rem .7rem; min-height: 48px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #7cb7e0; outline-offset: 1px; }
select:disabled { background: #eef1f5; color: var(--muted); }
.field { margin-bottom: .9rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 200px; }
button, .btn {
  font: inherit; font-weight: 650; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--brand); color: #fff; padding: .55rem 1.1rem; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button.secondary, .btn.secondary { background: #fff; color: var(--brand-dark); border: 1.5px solid var(--brand); }
button.secondary:hover { background: var(--brand-soft); }
button.danger { background: var(--bad); }
button.danger:hover { background: #8c1b12; }
button.small, .btn.small { min-height: 38px; padding: .3rem .75rem; font-size: .9rem; }
button.big, .btn.big { min-height: 56px; font-size: 1.1rem; padding: .6rem 1.6rem; }
button[disabled] { opacity: .55; cursor: not-allowed; }
.inline { display: inline; margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Messages */
.msg { border-radius: 8px; padding: .7rem 1rem; margin-bottom: .75rem; font-weight: 600; border: 1px solid; }
.msg.success { background: var(--ok-soft); color: var(--ok); border-color: #a8d5b5; }
.msg.error { background: var(--bad-soft); color: var(--bad); border-color: #f2b8b2; }
.msg.info { background: var(--brand-soft); color: var(--brand-dark); border-color: #b3cfe3; }
.msg.warning { background: var(--warn-soft); color: var(--warn); border-color: #f0d38a; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; }
tr.highlight td { background: #fff7f6; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.num { text-align: right; white-space: nowrap; }

/* Badges */
.badge { display: inline-block; border-radius: 999px; padding: .1rem .6rem; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.badge-indexed { background: var(--ok-soft); color: var(--ok); }
.badge-failed { background: var(--bad-soft); color: var(--bad); }
.badge-pending, .badge-processing { background: var(--warn-soft); color: var(--warn); }
.badge-retired, .badge-duplicate { background: #eceff3; color: var(--muted); }
.badge-up { background: var(--ok-soft); color: var(--ok); }
.badge-down { background: var(--bad-soft); color: var(--bad); }
.badge-role { background: var(--brand-soft); color: var(--brand-dark); }

/* Library tree */
details.mfr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; box-shadow: var(--shadow); }
details.mfr > summary, details.model > summary { cursor: pointer; list-style: none; padding: .8rem 1rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
details.mfr > summary::-webkit-details-marker, details.model > summary::-webkit-details-marker { display: none; }
details.mfr > summary { font-size: 1.15rem; font-weight: 700; }
details.mfr > summary::before, details.model > summary::before { content: "▸"; color: var(--brand); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details.mfr .body { padding: 0 1rem 1rem; }
details.model { border: 1px solid var(--line); border-radius: 8px; margin: .5rem 0; background: #fbfcfd; }
details.model > summary { font-weight: 650; }
details.model .body { padding: 0 .75rem .75rem; }
.summary-tools { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; font-size: .9rem; font-weight: 400; }
.doc-title { font-weight: 600; }
.err { color: var(--bad); font-size: .9rem; white-space: pre-wrap; }

/* Ask */
.ask-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; }
@media (max-width: 900px) { .ask-layout { grid-template-columns: 1fr; } }
.answer { font-size: 1.05rem; }
.answer p { margin: .5rem 0; }
.answer p.step { padding-left: .25rem; }
.answer p.warn { background: var(--warn-soft); border-left: 5px solid #e0a100; color: #5c3d00; padding: .6rem .8rem; border-radius: 6px; font-weight: 600; }
a.cite { display: inline-block; background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #b3cfe3; border-radius: 999px; padding: 0 .55rem; margin: .1rem .1rem; font-size: .85rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
a.cite:hover { background: #d4e6f2; }
.filter-line { background: var(--brand-soft); color: var(--brand-dark); border-radius: 8px; padding: .35rem .75rem; font-weight: 600; display: inline-block; margin-bottom: .5rem; }
.meta { color: var(--muted); font-size: .85rem; }
.feedback { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .75rem; }
.thumbs { display: flex; gap: .5rem; }
.thumbs button { font-size: 1.3rem; min-width: 64px; }
.thumbs button.picked { outline: 3px solid var(--brand); }
.excerpt { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0; background: #fbfcfd; }
.excerpt pre { white-space: pre-wrap; font-family: inherit; font-size: .9rem; margin: .4rem 0 0; max-height: 18rem; overflow: auto; }

/* Loading */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.htmx-request .hide-while-loading { display: none; }
.spinner { width: 1.2rem; height: 1.2rem; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: rgba(14,90,138,.25); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Upload */
.dropzone { border: 3px dashed #9aa7b6; border-radius: var(--radius); background: #fff; padding: 2rem 1rem; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone.over { background: var(--brand-soft); border-color: var(--brand); }
.dropzone strong { font-size: 1.15rem; }
.filelist { list-style: none; padding: 0; margin: .75rem 0 0; }
.filelist li { padding: .3rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(ellipse at 70% 30%, #12304a 0%, #0b1620 60%, #070d14 100%); }
.login-stack { width: 100%; max-width: 760px; display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
.login-hero { display: block; width: 100%; max-width: 720px; height: auto; }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; padding: 2rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-card .brand { color: var(--brand-dark); font-size: 1.5rem; margin-bottom: 1.25rem; }
.login-card .brand .mark { background: var(--brand-dark); color: #fff; }

.pagination { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.password-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.3rem; background: #fff; border: 2px solid var(--ok); border-radius: 8px; padding: .3rem .8rem; display: inline-block; letter-spacing: .05em; }

/* Logo, phone app setup */
.brand img { display: block; height: 112px; width: auto; border-radius: 14px; background: none; padding: 0; border: 0; box-shadow: none; }
.login-logo { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 1.25rem; }
.setup-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 760px) { .setup-grid { grid-template-columns: 1fr; } }
.setup-qr { display: flex; justify-content: center; }
.setup-qr svg { width: 100%; max-width: 320px; height: auto; }
.setup-qr.expired svg { opacity: .12; }
.setup-steps { padding-left: 1.25rem; line-height: 1.6; }
.setup-steps li { margin-bottom: .75rem; }

/* Streaming chat (chat.js) */
.live-status { display: flex; align-items: center; gap: .5rem; color: var(--brand-dark); font-weight: 600; margin: .25rem 0 .5rem; }
.live-notes { list-style: none; padding: 0; margin: 0 0 .5rem; color: var(--muted); font-size: .92rem; }
.live-notes li::before { content: "› "; }
.live-answer { white-space: pre-wrap; font-size: 1.05rem; }
.turn-photo { max-width: 260px; max-height: 200px; border-radius: 8px; border: 1px solid var(--line); display: block; margin: 0 0 .6rem; }
.photo-pick { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.photo-pick input[type=file] { max-width: 100%; }
.photo-preview { max-height: 90px; border-radius: 6px; border: 1px solid var(--line); }
details.steps { margin: .5rem 0 0; }
details.steps summary { cursor: pointer; }
details.steps ol { margin: .4rem 0 0; padding-left: 1.4rem; font-size: .92rem; }

/* --- HPI Assist (2026-10-16): modes, source labels, page images, bulk upload --- */
.mode-banner { color: #fff; }
.mode-banner .inner { max-width: 1200px; margin: 0 auto; padding: .45rem 1rem; display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.mode-banner .mode-name { font-weight: 800; font-size: 1.05rem; letter-spacing: .02em; text-transform: uppercase; }
.mode-banner .mode-desc { opacity: .9; font-size: .9rem; flex: 1; min-width: 12rem; }
.mode-switch { display: inline-flex; border: 2px solid rgba(255,255,255,.8); border-radius: 999px; overflow: hidden; }
.mode-switch button { background: transparent; color: #fff; border: 0; border-radius: 0; min-height: 40px; padding: .2rem 1rem; font-weight: 700; box-shadow: none; }
.mode-switch button.on { background: #fff; color: var(--text); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; margin: .4rem 0; }
.check input { width: 22px; height: 22px; flex: none; }

.answer .src { padding: .35rem .6rem; border-left: 5px solid var(--line); background: #f8fafc; border-radius: 4px; }
.answer .src-label { font-weight: 800; margin-right: .3rem; }
.answer .src-manual { border-left-color: var(--brand); }
.answer .src-web { border-left-color: #6b4fbb; }
.answer .src-fix { border-left-color: var(--ok); background: var(--ok-soft); }
.answer .src-experience { border-left-color: #8a96a6; background: #f1f3f6; }
.cite.web { background: #f0ecfb; border-color: #cfc3f0; }
.web-sources { margin: .2rem 0 .8rem 1.2rem; padding: 0; }
.web-sources li { margin: .2rem 0; }

.operator-answer { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 1rem; align-items: start; }
.operator-answer .answer .step { font-size: 1.1rem; font-weight: 600; margin: .45rem 0; }
.page-thumbs { display: flex; flex-direction: column; gap: .6rem; }
.page-thumbs a { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; text-decoration: none; color: var(--muted); font-size: .8rem; }
.page-thumbs img { display: block; width: 100%; height: auto; background: #eee; min-height: 120px; }
.page-thumbs span { display: block; padding: .25rem .4rem; }
@media (max-width: 760px) {
  .operator-answer { grid-template-columns: 1fr; }
  .page-thumbs { flex-direction: row; overflow-x: auto; }
  .page-thumbs a { flex: 0 0 150px; }
}
.operator-form label { font-size: 1.05rem; }
.operator-form select, .operator-form textarea { font-size: 1.1rem; }
.contact-card { border-left: 6px solid var(--ok); }
.fixed-card { border-left: 6px solid var(--ok); }

.type-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.type-tabs a { border: 1.5px solid var(--line); border-radius: 999px; padding: .3rem .8rem; text-decoration: none; background: var(--surface); color: var(--text); font-weight: 600; }
.type-tabs a.on { border-color: var(--brand); background: var(--brand-soft); }
.badge-type { background: #eef1f5; color: var(--text); }
.badge-type.type-service_manual { background: #e6f0f7; color: #0a4166; }
.badge-type.type-operator_manual { background: var(--ok-soft); color: var(--ok); }
.badge-type.type-service_bulletin { background: var(--warn-soft); color: var(--warn); }
.badge-type.type-sop { background: #efe9fb; color: #5b3fa8; }
.badge-pending { background: var(--warn-soft); color: var(--warn); }

.upload-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .8rem; padding: .5rem .2rem; border-bottom: 1px solid var(--line); }
.upload-list .bar { grid-column: 1 / -1; height: 8px; background: #e7ebf0; border-radius: 4px; overflow: hidden; }
.upload-list .fill { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.upload-list li.good .fill { background: var(--ok); width: 100%; }
.upload-list li.bad .fill { background: var(--bad); width: 100%; }
.upload-list .msg-line { grid-column: 1 / -1; font-size: .9rem; color: var(--muted); }
.upload-list .zip-results { grid-column: 1 / -1; font-size: .85rem; margin: .2rem 0 0 1rem; max-height: 14rem; overflow: auto; }
.queue-now { margin: .4rem 0; }
.card.fix.pending { border-left: 6px solid #e0a100; }
.mode-card h3 { font-size: 1.15rem; }

/* Phones: the logo gets its own row, the menu wraps underneath it across the full width. */
@media (max-width: 760px) {
  .topbar .brand { flex: 1 0 100%; justify-content: center; }
  .brand img { height: 96px; }
  .nav { flex: 1 0 100%; justify-content: center; }
}
