/* Tech Assist - the legacy app's look (Architecture/tech-assist-web-app-ui-spec.md §8). */
:root {
  /* Instrument Sans (sdate, 2026-10-24): easier to read than the legacy Open Sans. */
  --font: "Instrument Sans", "Segoe UI", system-ui, Arial, sans-serif;
  --red: #e01c24;
  --red-text: #db1a20;
  --blue: #1877f2;
  --electric: #0a5cff;  /* the First Look's "quick read" line (sdate, 2026-11-01) */
  --black: #000;
  --text: #000;
  --text-2: #333;
  --value: #3e414b;
  --muted: #6b7280;
  --border: #ccc;
  --border-2: #e0e0e0;
  --surface: #fff;
  --surface-2: #f5f5f5;
  --input: #f0f0f0;
  --selected: #e1ecfd;
  --context: #fff8e1;
  --bubble-user: rgb(245, 234, 234);
  --bubble-agent: rgb(224, 220, 220);
  --acc: rgb(239, 237, 237);
  --acc-nested: rgb(215, 209, 209);
  --shadow: 0 4px 12px #00000014;
  --shadow-modal: 0 4px 24px #0000002e;
  --base: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--base);
  color: var(--text);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
body.text-large { --base: 17px; }
button { font-family: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---- header ---- */
.app-header {
  display: flex;
  align-items: stretch;
  height: 56px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border-2);
}
.header-left { display: flex; align-items: center; gap: 10px; padding: 0 12px; flex: 0 0 auto; }
.brand-logo { height: 30px; width: auto; }
.brand-wordmark { height: 12px; width: auto; }
.header-banner {
  flex: 1 1 auto;
  background: url("/static/assets/header-banner.png") right center / auto 100% no-repeat;
}
.icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-size: 15px;
}

/* ---- drawer ---- */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 20;
  background: var(--surface); box-shadow: var(--shadow-modal);
  display: flex; flex-direction: column; padding: 12px; gap: 4px;
}
.drawer-user { display: flex; align-items: center; gap: 10px; padding: 8px 4px 16px; font-weight: 600; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.drawer-item {
  text-align: left; padding: 10px 8px; border: 0; border-radius: 4px; background: none;
  font-size: 14px; cursor: pointer;
}
.drawer-item:hover { background: var(--selected); }

/* ---- columns ---- */
.columns { flex: 1 1 auto; display: flex; min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border-2); }
.pane-orders { width: 310px; flex: 0 0 auto; }
.pane-similar { width: 290px; flex: 0 0 auto; }
.pane-chat { flex: 1 1 auto; min-width: 0; border-right: 0; }
body.panels-hidden .pane-orders, body.panels-hidden .pane-similar { display: none; }
.pane-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-2);
  padding: 10px 12px;
}
.pane-header h2 { margin: 0; font-size: 15px; font-weight: 700; text-align: center; }
.pane-search { padding: 8px; }
.pane-search input {
  width: 100%; height: 28px; padding: 2px 10px;
  border: 1px solid var(--border); border-radius: 4px; background: var(--input);
  font: inherit;
}
.pane-empty { color: var(--muted); padding: 16px 12px; text-align: center; margin: 0; }

/* ---- chat tabs ---- */
.chat-tabs {
  display: flex; align-items: center; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--border-2);
  overflow-x: auto; scrollbar-width: none; flex: 0 0 auto;
}
.chat-tabs > * { flex: 0 0 auto; white-space: nowrap; }
.chat-tab {
  border: 0; background: none; padding: 10px 11px; font-size: 15px; color: var(--muted);
  border-bottom: 3px solid transparent; cursor: pointer;
}
.chat-tab.active { color: var(--text-2); font-weight: 700; border-bottom-color: var(--red); }
.chat-tab:disabled { cursor: default; opacity: .6; }
.chat-tabs-spacer { flex: 1 1 auto; }
.text-size {
  border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
  padding: 4px 8px; cursor: pointer; font-size: 13px;
}
.text-size[aria-pressed="true"] { font-weight: 700; }

/* ---- buttons ---- */
.btn { border: 0; border-radius: 4px; padding: 6px 12px; font-size: 13px; cursor: pointer; color: #fff; }
.btn-blue { background: var(--blue); }
.btn-red { background: var(--red); }
.btn-pill { border-radius: 8px; font-weight: 600; }

/* ---- context bar ---- */
.context-bar { background: var(--context); padding: 6px 12px; font-size: 12px; border-bottom: 1px solid var(--border-2); }
.context-bar strong { display: block; font-size: 12px; }

/* ---- messages ---- */
.messages { flex: 1 1 auto; overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.chat-empty { margin: auto; color: #f0a07a; font-size: 20px; }
.msg { border-radius: 10px; padding: 8px 12px; font-size: var(--base); line-height: 1.55; max-width: 100%; }
.msg-user { background: var(--bubble-user); align-self: flex-end; max-width: 75%; white-space: pre-wrap; }
.msg-user .msg-label, .msg-agent .msg-label { font-weight: 700; display: block; margin-bottom: 4px; }
.msg-agent { background: var(--bubble-agent); }
.msg-head { display: flex; align-items: center; gap: 6px; }
.msg-head .msg-label { flex: 1 1 auto; margin: 0; }
.msg-tool {
  border: 1px solid #00000033; background: var(--surface); border-radius: 4px;
  font-size: 12px; padding: 2px 8px; cursor: pointer;
}
.msg-body { overflow-wrap: anywhere; }
/* A manual page shown in an answer (app.js manualPage): click opens the viewer. */
.msg-body img.kb-figure { display: block; max-width: 100%; max-height: 560px; margin: 8px 0; background: #fff;
  border: 1px solid var(--border-2); border-radius: 6px; cursor: zoom-in; }
.msg-body img.kb-figure:focus-visible { outline: 2px solid var(--electric); outline-offset: 2px; }
.msg-body table { border-collapse: collapse; margin: 6px 0; font-size: var(--base); display: block; overflow-x: auto; }
.msg-body th, .msg-body td { border: 1px solid #000; padding: 4px 8px; text-align: left; vertical-align: top; }
.msg-body th { font-weight: 700; }
.msg-body code { background: #ffffff99; padding: 0 3px; border-radius: 3px; }
.msg-body pre { background: #ffffffaa; padding: 8px; border-radius: 4px; overflow-x: auto; }
.msg-status { color: var(--muted); font-style: italic; }
/* The first look: a fast model's few lines while the full answer is written. */
.first-look {
  margin: 4px 0 8px; padding: 6px 10px; border-left: 3px solid #2b7a78;
  background: var(--surface); border-radius: 4px;
}
.first-look > summary { cursor: pointer; font-weight: 600; color: #2b7a78; }
.first-look-note { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--electric); font-weight: 600; margin: 2px 0 4px; }
.first-look-bolt { width: 14px; height: 14px; flex: none; fill: var(--electric); }
.msg-error { background: #fde8e8; color: #8a1116; }
.footer-line { font-size: 12px; color: var(--muted); }

/* A document the agent wrote (```document <file name>): shown as a page, downloaded as a PDF. */
.doc-card { border: 1px solid var(--border, #d0d5dd); border-radius: 6px; margin: 10px 0; background: var(--surface); overflow: hidden; }
.doc-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--bg, #f4f6f8); border-bottom: 1px solid var(--border, #d0d5dd); }
.doc-card-name { font-weight: 600; overflow-wrap: anywhere; }
.doc-download { border: 1px solid var(--blue); color: #fff; background: var(--blue); border-radius: 4px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.doc-download:disabled { opacity: 0.6; cursor: progress; }
.doc-card-body { padding: 10px 14px; overflow-x: auto; }
.doc-card-error { color: #b42318; font-size: 13px; padding: 0 10px 8px; }

/* The page html2pdf renders (it lays out its own copy off screen): a Letter-like width, plain colours. */
.doc-print { width: 760px; background: #fff; color: #111; font-family: "Instrument Sans", Arial, sans-serif; font-size: 12px; line-height: 1.45; }
/* The app header's look: logo + wordmark on the white left side of header-banner.png. */
.doc-print .doc-banner { position: relative; height: 64px; margin: 0 0 14px; overflow: hidden; }
.doc-print .doc-banner-image { position: absolute; right: 0; top: 0; height: 64px; width: auto; }
.doc-print .doc-banner-brand { position: absolute; left: 8px; top: 0; height: 64px; display: flex; align-items: center; gap: 10px; }
.doc-print .doc-banner-brand .brand-logo { height: 30px; width: auto; }
.doc-print .doc-banner-brand .brand-wordmark { height: 13px; width: auto; }
.doc-print .doc-content { padding: 0 6px; }
.doc-print h1 { font-size: 20px; margin: 0 0 8px; }
.doc-print h2 { font-size: 15px; margin: 14px 0 6px; }
.doc-print h3 { font-size: 13px; margin: 10px 0 4px; }
.doc-print table { border-collapse: collapse; width: 100%; margin: 6px 0; }
.doc-print th, .doc-print td { border: 1px solid #999; padding: 3px 6px; text-align: left; vertical-align: top; }
.doc-print tr { page-break-inside: avoid; }

/* Fold-out sections (legacy accordions). */
.acc { margin: 6px 0; border-radius: 4px; background: var(--surface); }
.acc > summary {
  list-style: none; cursor: pointer;
  background: var(--acc); border-radius: 4px;
  padding: 9.6px 12.8px; font-size: var(--base); font-weight: 600; color: #222;
  display: flex; justify-content: space-between; align-items: center;
}
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: "\25BA"; font-size: 11px; transition: transform .15s; }
.acc[open] > summary::after { transform: rotate(90deg); }
.acc-body { padding: 6px 12px; }
.acc .acc > summary { background: var(--acc-nested); font-size: calc(var(--base) * .96); padding: 8px 11.2px; color: var(--text-2); }

/* Next steps as buttons. */
.next-steps { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.next-steps-title { font-weight: 700; }
.next-step {
  text-align: left; border: 1px solid var(--blue); color: var(--blue); background: var(--surface);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: var(--base);
}
.next-step:hover { background: var(--selected); }

/* ---- composer ---- */
.composer { margin: 8px 12px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.composer textarea {
  width: 100%; border: 0; resize: none; font: inherit; font-size: 15px;
  padding: 6px 8px 2px; border-radius: 6px; min-height: 28px; max-height: 160px; overflow-y: hidden;
}
.composer textarea:focus { outline: none; }
.composer-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 6px; }
.composer-tools { position: relative; display: inline-flex; }
.attach-btn {
  width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; cursor: pointer;
  color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
}
.attach-btn:hover, .attach-btn[aria-expanded="true"] { background: var(--surface-2); }
.attach-btn .ico { width: 24px; height: 24px; }
.attach-menu {
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 25; display: flex; flex-direction: column;
  min-width: 170px; padding: 6px 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-modal);
}
.attach-menu button {
  border: 0; background: none; text-align: left; padding: 9px 16px; font: inherit; font-size: 15px; cursor: pointer;
}
.attach-menu button:hover, .attach-menu button:focus-visible { background: var(--selected); }
.composer-status { color: var(--muted); font-size: 12px; }
.send-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: var(--blue); color: #fff; font-size: 15px; cursor: pointer;
}
.send-btn:disabled { background: #9bbcf3; cursor: default; }

/* ---- footer ---- */
.app-footer {
  flex: 0 0 auto; display: flex; justify-content: space-between; gap: 8px;
  padding: 4px 12px; border-top: 1px solid var(--border-2); font-size: 12px; color: var(--muted);
}
.footer-warning { text-align: center; flex: 1 1 auto; }

/* ---- popover ---- */
.popover {
  position: fixed; right: 16px; bottom: 60px; z-index: 30; width: min(420px, calc(100vw - 32px));
  max-height: 50vh; overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: var(--shadow-modal); padding: 10px 12px; font-size: 13px;
}
.popover table { border-collapse: collapse; width: 100%; }
.popover td { padding: 2px 4px; border-bottom: 1px solid var(--border-2); }
.popover td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
/* The timings tree: wider, and the outer layers stand out. */
#timing-popover { width: min(620px, calc(100vw - 32px)); max-height: 70vh; }
.timing-tree td:first-child { color: var(--muted); white-space: nowrap; }
.timing-tree td:nth-child(2) { word-break: break-word; }
.timing-tree .timing-ms { white-space: nowrap; }
.timing-tree .timing-browser td, .timing-tree .timing-web-app td, .timing-tree .timing-service td { font-weight: 600; }
.msg-stopped { color: #8a1116; }
/* The composer's send button while an answer is written: Stop. */
.send-btn.stop { background: #8a1116; }
.attach-btn:disabled { opacity: 0.35; cursor: not-allowed; }
/* A Next step that needs the technician's input first: fills the message box. */
.next-step.next-step-edit { border-style: dashed; }
.next-step-pen { opacity: 0.7; }
/* The first look: a short summary, then a few short sections. */
.first-look p { margin: 4px 0; }
.first-look ul { margin: 2px 0 4px; padding-left: 20px; }

/* ---- phase 2: tab panels, side columns, cards, flyouts, machine row (UI spec §3) ---- */
.tab-panel { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.pane-header { display: flex; align-items: center; justify-content: center; position: relative; }
/* Line icons drawn like the legacy ones (stroke, no fill). */
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); }
.pane-icons { position: absolute; right: 6px; display: inline-flex; gap: 2px; }
.pane-icon {
  border: 0; background: none; cursor: pointer; color: var(--text-2); padding: 3px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.pane-icon:hover { background: var(--border-2); }
.search-row { display: flex; align-items: center; gap: 6px; }
.search-box { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
.search-row input {
  flex: 1 1 auto; min-width: 0; height: 30px; padding: 2px 30px 2px 10px;
  border: 1px solid var(--border); border-radius: 4px; background: var(--input); font: inherit;
}
.search-row input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; padding: 0;
  border: 0; background: none; cursor: pointer; display: inline-flex;
}
.search-clear svg { width: 20px; height: 20px; fill: #9ca3af; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.info-tip { display: inline-flex; flex: 0 0 auto; color: var(--blue); cursor: help; }
.info-tip .ico { width: 22px; height: 22px; stroke-width: 1.6; }
.funnel {
  position: relative; flex: 0 0 auto; border: 0; background: none; padding: 0;
  width: 26px; height: 30px; cursor: pointer; color: var(--black);
  display: inline-flex; align-items: center; justify-content: center;
}
.funnel .ico { width: 22px; height: 22px; stroke-width: 1.6; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--red); color: #fff; font-size: 11px; line-height: 16px;
}
.filter-panel {
  display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border-2); background: var(--surface-2);
}
.filter-panel label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 600; }
.filter-panel input, .filter-panel select {
  height: 28px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px; font: inherit; font-weight: 400;
}
.filter-pair { display: flex; gap: 8px; }
.filter-pair label { flex: 1 1 0; min-width: 0; }
.filter-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.pane-list { flex: 1 1 auto; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.list-note { color: var(--muted); font-size: 12px; margin: 0; text-align: center; }
.load-more { align-self: center; }
.btn-plain { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.btn-black { background: #000; }
.btn-red { background: var(--red); }
.btn-grey { background: #8a8f98; }
.btn-teal { background: #1f7a6d; }

.wo-card, .sim-card {
  border: 1px solid var(--border-2); border-radius: 6px; padding: 8px 10px; background: var(--surface);
  cursor: pointer;
}
.wo-card:hover, .sim-card:hover { border-color: var(--border); }
.wo-card.selected, .sim-card.selected { background: var(--selected); border-color: var(--blue); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 0; }
.wo-card .kv-grid { grid-template-columns: 1fr; gap: 3px; }  /* one column, as in the legacy card */
.kv { display: flex; flex-direction: column; min-width: 0; }
.kv-label { font-size: 11px; font-weight: 700; color: var(--black); }
.kv-value { font-size: 13px; color: var(--value); overflow-wrap: anywhere; }
.wo-buttons { display: flex; gap: 5px; margin-top: 8px; flex-wrap: nowrap; }
.wo-buttons .btn { padding: 6px 9px; white-space: nowrap; flex: 0 0 auto; }
.wo-buttons .btn-sq { width: 30px; padding: 6px 0; text-align: center; }

.similar-scope { margin: 0; padding: 0 10px; color: var(--muted); font-size: 12px; }
.sim-head { display: flex; justify-content: space-between; align-items: center; }
.sim-dot { width: 12px; height: 12px; border-radius: 50%; background: #c7c9cf; flex: 0 0 auto; }
.sim-dot.band-most_relevant { background: var(--blue); }
.sim-dot.band-relevant { background: #f0a020; }
.sim-dot.band-somewhat_relevant { background: #f6cf7a; }
.sim-date { font-size: 12px; color: var(--muted); }
.sim-complaint {
  color: var(--red-text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sim-complaint.open { white-space: normal; }
.sim-more { margin-top: 6px; }
.link-btn { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 4px 0 0; font: inherit; font-size: 12px; }

.context-bar strong { display: block; }
.context-complaint { display: block; color: var(--text-2); }

.machine-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 0; }
.combo { position: relative; flex: 1 1 100px; min-width: 90px; }
.combo-year { flex: 0 1 90px; min-width: 80px; }
.combo input {
  width: 100%; height: 28px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--input); font: inherit; font-size: 13px;
}
.combo.locked input { background: #e4e4e4; color: var(--text-2); cursor: default; }
.combo-list {
  position: absolute; left: 0; right: 0; bottom: 100%; z-index: 25; margin: 0 0 4px; padding: 4px 0;
  list-style: none; max-height: 240px; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow-modal); min-width: 220px;
}
.combo-item { display: flex; flex-direction: column; padding: 5px 10px; cursor: pointer; }
.combo-item[aria-selected="true"], .combo-item:hover { background: var(--selected); }
.combo-main { font-size: 13px; }
.combo-sub { font-size: 11px; color: var(--muted); }

.flyouts { position: fixed; top: 56px; bottom: 30px; left: 310px; z-index: 22; display: flex; gap: 0; }
body.panels-hidden .flyouts { left: 0; }
.flyout {
  width: 320px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-modal); display: flex; flex-direction: column; overflow: hidden;
}
.flyout-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-2); }
.flyout-head h3 { margin: 0; font-size: 14px; }
.flyout-body { flex: 1 1 auto; overflow-y: auto; margin: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.flyout > .btn { margin: 0 12px 12px; align-self: flex-start; }
.part-block { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--border-2); display: flex; flex-direction: column; gap: 4px; }
.popover-center {
  top: 50%; left: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px)); font-size: var(--base);
}
.popover-center h3 { margin: 0 0 8px; font-size: 15px; }

/* A work order cited in an answer: opens its 3Cs | Parts | Explain view. */
.wo-ref {
  border: 0; padding: 0; background: none; font: inherit; color: var(--blue); cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px;
}
.wo-ref:hover { text-decoration-style: solid; }

/* Reply in context (legacy "Respond"): the button over a selection, the quote bar in the
   composer, and the quote in the user's bubble. */
.respond-pop {
  position: fixed; z-index: 35; border: 0; border-radius: 10px; background: var(--surface);
  box-shadow: 0 2px 10px #0000003d; padding: 8px 20px; font: inherit; font-size: 15px; cursor: pointer;
}
.respond-pop:hover { background: var(--surface-2); }
.quote-bar {
  display: flex; align-items: center; gap: 8px; margin: 8px 8px 0; padding: 8px 10px 8px 14px;
  background: #e4e4e4; border-radius: 8px;
}
.quote-text {
  flex: 1 1 auto; min-width: 0; font-style: italic; color: var(--text-2); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quote-close {
  flex: 0 0 auto; border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px;
  display: inline-flex;
}
.quote-close .ico { width: 18px; height: 18px; }
.msg-quote {
  display: block; margin: 2px 0 6px; padding: 4px 10px; border-left: 3px solid #b9a9a9;
  font-style: italic; color: var(--text-2); white-space: pre-wrap;
  max-height: 7.5em; overflow-y: auto;
}

/* Diagnose's "resume a previous conversation?" dialog (legacy). */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: #00000066;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  width: min(1230px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-modal);
}
.modal-head { position: relative; padding: 16px 52px 12px 18px; border-bottom: 1px solid var(--border-2); }
.modal-head h3 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.modal-head .pane-icon { position: absolute; top: 14px; right: 14px; }
.modal-head .pane-icon .ico { width: 22px; height: 22px; }
.modal-machine { margin: 0 0 6px; font-size: 14px; color: var(--text-2); }
.modal-help { margin: 0; font-size: 16px; color: var(--text-2); }
.resume-search { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 18px 8px; align-items: stretch; }
.resume-text { flex: 1 1 320px; display: flex; min-width: 0; }
.resume-text input {
  flex: 1 1 auto; min-width: 0; height: 44px; padding: 4px 14px; font: inherit; font-size: 15px;
  border: 1px solid var(--border); border-right: 0; border-radius: 4px 0 0 4px;
}
.resume-find {
  width: 54px; border: 1px solid var(--border); border-radius: 0 4px 4px 0; background: #e9ecef;
  color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.resume-search input[type="date"] {
  height: 44px; padding: 4px 12px; font: inherit; font-size: 15px; border: 1px solid var(--border); border-radius: 4px;
}
.resume-search .btn { font-size: 16px; padding: 0 22px; min-height: 44px; }
.btn-red-outline { background: var(--surface); color: var(--red); border: 1px solid var(--red); }
.resume-list {
  margin: 8px 18px 0; border: 1px solid var(--border-2); border-radius: 4px; overflow-y: auto;
  flex: 1 1 auto; min-height: 120px; max-height: 380px;
}
.resume-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border-2); }
.resume-row:nth-child(even) { background: #f7f7f7; }
.resume-row-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.resume-row-text strong { font-size: 16px; font-weight: 600; text-transform: uppercase; overflow-wrap: anywhere; }
.resume-when { font-size: 14px; color: var(--text-2); }
.resume-go {
  border: 0; background: none; color: var(--red); cursor: pointer; font: inherit; font-size: 15px;
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px; flex: 0 0 auto;
}
.resume-go .ico { width: 30px; height: 30px; stroke-width: 1.5; }
.resume-go:disabled { opacity: .6; cursor: default; }
.modal-foot { display: flex; justify-content: center; gap: 16px; padding: 18px; }
.modal-foot .btn { font-size: 16px; padding: 10px 24px; }

/* A similar order's detail view, in place of the chat tabs (legacy 3Cs | Parts | Explain). */
.pane-chat.detail-open > .chat-tabs, .pane-chat.detail-open > .tab-panel { display: none !important; }
.sim-detail { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.detail-close { margin-left: auto; }
.detail-close .ico { width: 22px; height: 22px; }
.detail-panel:not(.messages) { flex: 1 1 auto; overflow-y: auto; padding: 14px 20px; }
.detail-head { margin: 10px 0 4px; font-size: 16px; font-weight: 600; }
.detail-head:first-child { margin-top: 0; }
.detail-text { margin: 0 0 10px; white-space: pre-wrap; font-size: 14px; }
.detail-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.detail-table th, .detail-table td { border: 1px solid var(--border-2); padding: 10px 12px; text-align: left; vertical-align: top; }
.detail-table th { background: var(--surface-2); font-weight: 600; }
.detail-table td.num { text-align: center; }
.popover-center p { white-space: pre-wrap; margin: 0 0 12px; }

/* ---- login: the legacy card (sizes and colours from its live CSS, 2026-10-25) - artwork on
   the left, the sign-in on the right; on a phone the artwork fills the screen behind it ---- */
.login-page { background: #f2f2f2; align-items: center; justify-content: center; position: relative; }
.login-card { display: flex; width: 80vw; height: 80vh; border-radius: 15px; overflow: hidden; }
.login-art { flex: 1; background: url("/static/assets/login-background.svg") center / cover no-repeat; }
.login-panel {
  flex: 1; background: var(--surface); display: flex; flex-direction: column; justify-content: center;
  align-items: flex-start; padding: 5% 3%; color: #333;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; }
.login-brand .brand-logo { height: 30px; width: auto; }
.login-brand .brand-wordmark { height: 15px; width: auto; }
.login-version { font-size: .95rem; color: #333; margin: 0 0 5vh; }
.login-form { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 300px; }
.login-form label { font-size: .875rem; font-weight: 700; }
.login-form input {
  height: 30px; padding: 2px 10px; border: 1px solid #ccc; border-radius: 5px; font: inherit; font-size: .95rem;
}
.login-note { font-size: .875rem; margin: 0 0 1.2rem; }
.login-button {
  background: #0078d4; color: #fff; border: none; border-radius: 5px; padding: .6rem 1rem; font: inherit;
  font-size: .95rem; cursor: pointer; text-decoration: none; display: inline-block; align-self: flex-start;
  transition: background-color .2s;
}
.login-button:hover { background: #005ea2; }
.login-error { color: #dc2626; font-size: .85rem; margin: 0 0 1rem; }
.login-copyright { position: absolute; left: 45%; bottom: 1svh; font-size: .525rem; color: #000; }
@media (min-width: 741px) and (max-width: 1024px) { .login-copyright { left: 40%; } }
@media (min-width: 741px) and (max-width: 1150px) { .login-copyright { bottom: 2svh; } }
@media (max-width: 740px), (orientation: landscape) and (max-height: 450px) {
  .login-card {
    width: 100vw; height: 100vh; border-radius: 0; justify-content: center; align-items: center;
    background: url("/static/assets/login-background.svg") center / cover no-repeat;
  }
  .login-art { display: none; }
  .login-panel { flex: 0 0 auto; max-width: 82vw; border-radius: 15px; padding: 10%; }
  .login-brand .brand-wordmark { height: 10px; }
  .login-copyright { color: #fff; left: 5%; bottom: .5%; }
}

/* ---- attachments (phase 4) ---- */
.composer-tools { display: inline-flex; gap: 2px; align-items: center; }
.composer-row .composer-status { flex: 1 1 auto; padding: 0 8px; }
.tool-btn { border: 1px solid transparent; background: none; border-radius: 4px; padding: 3px 7px; font: inherit; cursor: pointer; color: var(--text-2); }
.tool-btn:hover { background: var(--surface-2); }
.tool-btn.active { border-color: var(--blue); color: var(--blue); }
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 8px 0; }
.attach-chips[hidden] { display: none; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; border: 1px solid var(--border-2); border-radius: 6px; padding: 3px 4px 3px 3px; background: var(--surface-2); font-size: 13px; }
.attach-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; }
.attach-chip.has-error { border-color: var(--red); color: var(--red-text); }
.attach-icon { font-size: 18px; padding: 0 4px; }
.attach-note { flex: 1 1 100%; margin: 0; font-size: 12px; color: var(--muted); }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.chip-btn { border: 0; background: none; cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; color: var(--muted); }
.chip-btn:hover { color: var(--text); }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border-2); display: block; }
.msg-file { display: inline-block; font-size: 13px; padding: 4px 8px; border: 1px solid var(--border-2); border-radius: 6px; background: var(--surface); color: var(--text-2); text-decoration: none; }
.annotate { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .85); display: flex; flex-direction: column; }
.annotate[hidden] { display: none; }
.annotate-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; background: var(--surface); }
.annotate-stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px; }
.annotate-stage canvas { max-width: 100%; max-height: 100%; touch-action: none; cursor: crosshair; background: #fff; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: #222; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow-modal); max-width: calc(100vw - 32px); }

/* ---- camera popup (phase 4) ---- */
.combo-serial { position: relative; }
.combo-serial input { padding-right: 34px; }
.scan-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 16px; padding: 2px 4px; }
.scan { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.scan[hidden] { display: none; }
.scan-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.scan-stage video { max-width: 100%; max-height: 100%; }
.scan-guide { position: absolute; width: 80%; height: 50%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); pointer-events: none; }
.scan-title { align-self: center; }
.scan-foot { background: var(--surface); padding: 10px 12px; }
.scan-status { margin: 0 0 8px; }
.scan-hint { background: var(--context); border-radius: 6px; padding: 6px 10px; margin-bottom: 8px; font-size: 14px; }
.scan-hint[hidden] { display: none; }
.scan-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---- Conversation History (phase 3) ---- */
.history-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border-2); }
.history-search input[type="search"] { flex: 1 1 260px; min-width: 0; height: 32px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.history-search select, .history-search input[type="date"] { height: 32px; border: 1px solid var(--border); border-radius: 4px; font: inherit; padding: 2px 6px; background: var(--surface); }
.history-date, .history-all { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.history-custom { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history-list { gap: 8px; }
.history-row { border: 1px solid var(--border-2); border-radius: 6px; padding: 10px 12px; background: var(--surface); }
.history-row-head { display: flex; gap: 8px; align-items: baseline; }
.history-title { overflow-wrap: anywhere; }
.history-meta { color: var(--value); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.history-row-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.history-when { color: var(--muted); font-size: 13px; }
.kind-badge { flex: 0 0 auto; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.kind-estimate { background: #e3f2ef; color: #1f7a6d; }
.kind-explain { background: #e1ecfd; color: #1456b8; }
.kind-diagnose { background: #fde8e9; color: #b3161c; }
.history-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.history-view[hidden] { display: none; }
.history-view-head { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border-2); flex-wrap: wrap; }
.history-readonly { color: var(--muted); font-size: 13px; }

/* ---- admin page ---- */
.admin-page { display: flex; flex-direction: column; min-height: 100%; }
.admin-home { text-decoration: none; color: inherit; font-size: 20px; }
.admin-main { padding: 0 16px 24px; overflow-y: auto; flex: 1 1 auto; }
.admin-main h2 { font-size: 16px; margin: 18px 0 8px; }
.admin-note { color: var(--value); }
.admin-error { color: var(--red-text); }
.table-wrap { overflow-x: auto; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border-2); vertical-align: top; }
.admin-table th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }

/* ---- knowledge base page and viewer (phase 1A.4) ---- */
.kb-breadcrumb { margin: 10px 0 4px; font-size: 12px; color: var(--muted); }
.kb-page .combo-list { top: 100%; bottom: auto; margin: 4px 0 0; }  /* forms sit at the top here */
/* Text boxes here are white like the page's other inputs: the grey --input reads as disabled. */
.kb-page .combo input { background: var(--surface); height: 28px; }
.kb-req { color: var(--red-text); font-weight: 700; }
.kb-help { font-size: 12px; color: var(--muted); margin: 6px 0 0; max-width: 90ch; }
.kb-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kb-field-label { font-size: 12px; font-weight: 600; }
.kb-invalid { border-color: var(--red-text) !important; box-shadow: 0 0 0 1px var(--red-text); }
/* manufacturer and model pickers */
.kb-pick { flex: none; min-width: 150px; }
.kb-pick-list { max-height: 280px; min-width: 260px; overflow-x: hidden; }
.kb-pick-item { flex-direction: row; align-items: flex-start; gap: 8px; }
/* Outranks the forms' ".kb-queue input, .kb-applies input" (full width, 28px high). */
.kb-page .kb-pick-item input[type="checkbox"] {
  width: 14px; min-width: 0; height: 14px; padding: 0; margin: 2px 0 0; border: 0; flex: none; pointer-events: none;
}
.kb-pick-text .combo-main, .kb-pick-text .combo-sub { overflow-wrap: anywhere; }
.kb-pick-item.active { background: var(--selected); }
.kb-pick-text { display: flex; flex-direction: column; min-width: 0; }
.kb-pick-summary { display: block; margin-top: 3px; font-size: 12px; font-weight: 400; text-decoration: underline; max-width: 260px; text-align: left; }
.kb-applies-pickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 12px; margin: 6px 0; }
.kb-applies-edit .kb-help { margin: 2px 0 4px; }
/* library sorting and pages */
.kb-sort { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.kb-sort:hover { text-decoration: underline; }
.kb-sort-mark { font-size: 9px; color: var(--muted); }
.kb-pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin: 10px 0; font-variant-numeric: tabular-nums; }
/* "Are you sure?" */
.kb-confirm { width: min(460px, 100%); }
.kb-confirm-text { padding: 12px 18px; margin: 0; overflow-wrap: anywhere; }
.kb-page label > .combo { flex: none; }  /* .combo's 100px basis is a height inside these column labels */
.kb-sub { font-size: 12px; color: var(--muted); }
.kb-detail { color: var(--red-text); max-width: 360px; overflow-wrap: anywhere; }
.kb-link { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--blue); cursor: pointer; text-align: left; }
.kb-link:hover { text-decoration: underline; }
.kb-pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 10px; border-radius: 8px; white-space: nowrap; }
.kb-pill-ready { background: #e3f4e6; color: #1e7b34; }
.kb-pill-warn { background: #fff4d6; color: #8a5a00; }
.kb-pill-work { background: #e1ecfd; color: #1456b8; }
.kb-pill-bad { background: #fde8e9; color: #b3161c; }
.kb-pill-old { background: var(--surface-2); color: var(--muted); }
.kb-row-old td { color: var(--muted); }
.kb-row-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.kb-row-actions .btn { padding: 3px 8px; font-size: 12px; }
.kb-row-actions .btn:disabled { opacity: .45; cursor: default; }
.kb-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; margin: 12px 0;
  padding: 28px 16px; border: 2px dashed var(--border); border-radius: 6px; background: var(--surface-2);
  color: var(--text-2); cursor: pointer; text-align: center;
}
.kb-drop input { display: none; }
.kb-drop-over { border-color: var(--blue); background: var(--selected); }
.kb-apply-all { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 10px; border: 1px solid var(--border-2); border-radius: 6px; margin-bottom: 10px; }
.kb-apply-all > strong { width: 100%; font-size: 13px; }
.kb-queue input, .kb-queue select, .kb-applies input, .kb-applies select {
  width: 100%; min-width: 90px; height: 28px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; font: inherit; font-size: 13px;
}
.kb-queue .combo { min-width: 150px; }
.kb-queue progress { width: 110px; }
.kb-state-queued { color: #1e7b34; font-weight: 600; }
.kb-state-rejected, .kb-state-error, .kb-state-duplicate { color: var(--red-text); font-weight: 600; }
.kb-actions { display: flex; justify-content: flex-end; gap: 10px; margin: 12px 0; }
.kb-actions .btn { font-size: 14px; padding: 8px 18px; }
.kb-modal { width: min(1100px, 100%); }
.kb-modal-body { overflow-y: auto; padding: 12px 18px; display: flex; flex-direction: column; gap: 12px; }
.kb-quality { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--value); }
.kb-warning { color: #8a5a00; }
.kb-edit, .kb-search-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 12px; border: 1px solid var(--border-2); border-radius: 6px; }
.kb-edit textarea { padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font: inherit; font-weight: 400; resize: vertical; }
.kb-wide { grid-column: 1 / -1; }
.kb-edit .kb-wide > strong { display: block; font-size: 12px; margin-bottom: 4px; }
.kb-edit .kb-wide > .btn { margin-top: 6px; }
.kb-search-form { margin: 10px 0; }
.kb-search-form .filter-actions { grid-column: 1 / -1; }
.kb-results { display: flex; flex-direction: column; gap: 8px; }
.kb-excerpt { cursor: default; }
.kb-excerpt-head a { font-size: 12px; margin-left: 6px; }
.kb-fit { color: #1456b8; }
.kb-excerpt-text { margin-top: 6px; font-size: 13px; white-space: pre-wrap; color: var(--text-2); }
.kb-viewer-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 8px 16px; border-bottom: 1px solid var(--border-2); }
.kb-viewer-nav { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.kb-viewer-nav input { width: 64px; height: 28px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.kb-viewer-nav a.btn { text-decoration: none; }
.kb-viewer-main { flex: 1 1 auto; overflow: auto; padding: 12px; background: #e9e9e9; text-align: center; }
.kb-viewer-main img { max-width: 100%; height: auto; box-shadow: var(--shadow); background: #fff; }
body.kb-zoomed .kb-viewer-main img { max-width: none; width: 160%; }
@media (max-width: 740px) {
  .kb-row-actions .btn { padding: 6px 10px; }
  /* the library becomes one card per document */
  .kb-table thead { display: none; }
  .kb-table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--border-2); }
  .kb-table td { display: block; border: 0; padding: 2px 4px; }
  .kb-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: var(--muted); font-size: 12px; }
  .kb-table td:last-child { padding-top: 6px; }
  .kb-viewer-bar { padding: 8px; }
}

/* ---- PDF export: only the conversation being exported is printed ---- */
@media print {
  html:has(body.printing), body.printing, body.printing .columns, body.printing .pane, body.printing .tab-panel {
    height: auto !important; overflow: visible !important; display: block !important;
  }
  body.printing * { visibility: hidden; }
  body.printing .print-target, body.printing .print-target * { visibility: visible; }
  body.printing .print-target { position: absolute; left: 0; top: 0; width: 100%; overflow: visible; height: auto; }
  /* Cited work orders (.wo-ref) are buttons on screen but text on paper. */
  body.printing .print-target button:not(.wo-ref), body.printing .print-target .msg-tool { display: none; }
  body.printing .print-target .wo-ref { border: 0; background: none; padding: 0; color: inherit; text-decoration: none; }
  body.printing .print-hide { display: none !important; }
}

/* ---- phone layout (legacy: <=740px, or landscape <=450px tall) ---- */
.phone-tabs { display: none; }
@media (max-width: 740px), (orientation: landscape) and (max-height: 450px) {
  .header-banner { display: none; }
  #collapse-btn { display: none; }
  .phone-tabs { display: flex; border-bottom: 1px solid var(--border-2); }
  .phone-tabs button {
    flex: 1 1 0; border: 0; background: none; padding: 10px 4px; font-size: 14px;
    border-bottom: 3px solid transparent; color: var(--muted);
  }
  .phone-tabs button.active { color: var(--text-2); font-weight: 700; border-bottom-color: var(--red); }
  .pane { display: none; width: 100%; border-right: 0; }
  .pane.active { display: flex; }
  .pane-similar[hidden] { display: none; }
  .chat-tabs { overflow-x: auto; }
  .chat-tab { padding: 10px 12px; white-space: nowrap; }
  .messages { padding: 12px; }
  .msg-user { max-width: 90%; }
  .flyouts { left: 0; right: 0; top: 0; bottom: 0; flex-direction: column; overflow-y: auto; }
  .flyout { width: 100%; max-width: none; }
  .machine-row .combo { flex: 1 1 45%; }
  .app-footer { flex-direction: column; align-items: center; }
}
