/* ==========================================================================
   XDAS-style HITL Invoice Validation Module
   Enterprise document-intelligence review workstation
   ========================================================================== */

:root {
  /* Surfaces */
  --bg-app:          #eef2f5;
  --bg-surface:      #ffffff;
  --bg-canvas:       #e2e8ed;
  --bg-toolbar:      #f7f9fb;

  /* Pale blue section chrome */
  --blue-pale:       #d9edf7;
  --blue-pale-2:     #e8f4fa;
  --blue-border:     #bcdcec;
  --blue-text:       #1b7fa8;

  /* Accents */
  --teal:            #0d8f9e;
  --teal-dark:       #0a7482;
  --green:           #2db55d;
  --green-cta:       #00a44f;
  --green-cta-dark:  #00893f;
  --amber:           #e8a317;
  --red:             #d64545;

  /* Lines + type */
  --border:          #d5e0e8;
  --border-strong:   #c2d1db;
  --input-border:    #ccd8e0;
  --text:            #1f2a33;
  --text-mid:        #4b5b67;
  --text-soft:       #74858f;

  --radius:          6px;
  --radius-lg:       8px;
  --shadow-sm:       0 1px 2px rgba(24, 48, 66, .07);
  --shadow-md:       0 2px 8px rgba(24, 48, 66, .10);

  --font: "Inter", "Segoe UI", "Open Sans", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; }

/* ==========================================================================
   App shell
   ========================================================================== */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 8px;
  gap: 8px;
}

/* ---------- Brand / title strip ---------- */

.app-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  flex: none;
}

.app-bar h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0;
  color: var(--text);
}

.brand-marks {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  padding-right: 6px;
}

.brand-marks .divider {
  width: 1px;
  height: 26px;
  background: var(--border);
}

.env-chip {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--teal-dark);
  background: var(--blue-pale-2);
  border: 1px solid var(--blue-border);
  border-radius: 999px;
  padding: 3px 10px;
}

.pane-toggle {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--green-cta);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.pane-toggle:hover { background: var(--green-cta-dark); }

/* ---------- Back-to-dashboard link ---------- */

.dash-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--teal-dark);
  background: var(--blue-pale-2);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .14s, border-color .14s;
}
.dash-link:hover { background: #dcecf5; border-color: var(--teal); }
.dash-link + .user-box { margin-left: 4px; }

@media (max-width: 720px) {
  .dash-link span { display: none; }
}

/* ---------- Signed-in user + logout ---------- */

.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.user-av {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #fff;
  background: linear-gradient(135deg, #2bb3a3, #6cc04a);
}
.user-av.admin { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); }

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.user-role {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.logout-btn {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--bg-toolbar);
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .14s, border-color .14s, background .14s;
}
.logout-btn:hover { color: var(--red); border-color: var(--red); background: rgba(214,69,69,.06); }

@media (max-width: 720px) {
  .user-box .user-meta { display: none; }
}

/* Owner tag on the queue rail (admin view) */
.owner-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--teal-dark);
  background: var(--blue-pale-2);
  border: 1px solid var(--blue-border);
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 4px;
}
.owner-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

/* ---------- Metadata strip ---------- */

.meta-bar {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  background: var(--blue-pale-2);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  flex: none;
}

.meta-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 14px;
  min-width: 0;
}

.meta-item .k {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.meta-item .v {
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.meta-item .v.score  { color: var(--green); font-weight: 600; }
.meta-item .v.score.med  { color: var(--amber); }
.meta-item .v.score.low  { color: var(--red); }

.meta-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius);
  color: var(--teal);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover  { background: var(--blue-pale); border-color: var(--teal); }
.icon-btn:active { background: #cfe6f2; }
.icon-btn svg { width: 17px; height: 17px; }

/* ==========================================================================
   Split workspace
   ========================================================================== */

.workspace {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.pane-doc  { flex: 0 0 46%; }
.pane-form { flex: 1 1 auto; }

.app.doc-collapsed  .pane-doc  { flex: 0 0 0; border-width: 0; opacity: 0; }
.app.form-collapsed .pane-form { flex: 0 0 0; border-width: 0; opacity: 0; }

/* ---------- Splitter with the two collapse tabs ---------- */

.splitter {
  flex: none;
  width: 22px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: col-resize;
  user-select: none;
}

.splitter::before {
  content: "";
  position: absolute;
  inset: 8px 50% 8px 50%;
  width: 1px;
  transform: translateX(-.5px);
  background: var(--border);
}

.splitter-btn {
  position: relative;
  width: 20px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--green-cta);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.splitter-btn:hover { background: var(--green-cta-dark); }

/* ==========================================================================
   Left pane — document viewer
   ========================================================================== */

.doc-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
}

.tool-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-mid);
  cursor: pointer;
}
.tool-btn:hover:not(:disabled) { background: #e6edf2; border-color: var(--border); color: var(--text); }
.tool-btn:disabled { opacity: .35; cursor: default; }
.tool-btn svg { width: 16px; height: 16px; }

/* Control that cannot act in the current source mode */
.tool-btn.inert,
.page-field.inert {
  opacity: .38;
  cursor: not-allowed;
}

.tool-sep {
  width: 1px;
  height: 20px;
  background: var(--border-strong);
  margin: 0 5px;
}

.page-field {
  width: 54px;
  height: 26px;
  text-align: center;
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: #fff;
}

.page-total {
  font-size: 13px;
  color: var(--text-mid);
  white-space: nowrap;
  margin-right: 4px;
}

.zoom-label {
  font-size: 12px;
  color: var(--text-mid);
  min-width: 46px;
  height: 26px;
  padding: 0 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.zoom-label:hover { background: #e6edf2; border-color: var(--border); color: var(--text); }

/* Stepper through repeated matches of an annotated value */
.match-step {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.match-step[hidden] { display: none; }

.match-pos {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--teal-dark);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: center;
}

/* Inline validation for the page-number box */
.page-warn {
  flex: none;
  padding: 5px 12px;
  font-size: 12.5px;
  color: #a8480a;
  background: #fff6ec;
  border-bottom: 1px solid #f2d6b8;
}
.page-warn[hidden] { display: none; }

/* Secondary action inside the load-documents prompt */
.link-alt {
  background: none;
  border: none;
  padding: 2px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--teal);
  text-decoration: underline;
  cursor: pointer;
}
.link-alt:hover { color: var(--teal-dark); }

.src-toggle {
  height: 24px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--teal-dark);
  background: var(--blue-pale-2);
  border: 1px solid var(--blue-border);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.src-toggle:hover { background: var(--blue-pale); border-color: var(--teal); }

.doc-name {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
  padding-left: 8px;
}

/* ---------- Canvas ---------- */

.doc-canvas {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--bg-canvas);
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.doc-page {
  background: #fff;
  box-shadow: var(--shadow-md);
  border: 1px solid #c8d3da;
  border-radius: 3px;
  overflow: hidden;
  transform-origin: top center;
  width: 100%;
  max-width: 900px;
  height: 100%;
  min-height: 560px;
  display: flex;
}

.doc-page iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.doc-page img {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- Locally rendered PDF pages ---------- */

.doc-canvas.pdf-mode {
  display: block;
  padding: 12px 0 40px;
}

.pdf-page {
  position: relative;
  margin: 0 auto 14px;
  background: #fff;
  box-shadow: var(--shadow-md);
  border: 1px solid #c8d3da;
  border-radius: 2px;
  overflow: hidden;
}

.pdf-page canvas { display: block; }

.pdf-layer,
.source-highlight-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Highlight painted over a located source value */
.source-highlight-box {
  position: absolute;
  background: rgba(214, 245, 190, .45);
  border: 1.5px solid var(--green);
  border-radius: 3px;
  box-shadow: 0 0 0 3px rgba(45, 181, 93, .15);
  animation: highlightIn .3s ease-out, highlightPulse 1.5s ease-in-out .3s 2;
}

@keyframes highlightIn {
  from { opacity: 0; transform: scale(1.4); }
  to   { opacity: 1; transform: none; }
}

/* Brief glow so the eye catches the box after an auto-scroll */
@keyframes highlightPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(45, 181, 93, .15); }
  50%      { box-shadow: 0 0 0 6px rgba(45, 181, 93, .28); }
}

/* Image sources carry the same overlay so bbox highlights still land */
.doc-page.img-page { position: relative; }

.doc-loading,
.doc-fallback {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 28px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}

.doc-fallback .ff-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.doc-fallback svg { width: 46px; height: 46px; color: var(--border-strong); }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #fff;
  background: var(--teal);
  border: none;
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  text-decoration: none;
}
.link-btn:hover { background: var(--teal-dark); }

/* ==========================================================================
   Right pane — extraction / validation form
   ========================================================================== */

.form-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: var(--blue-pale);
  border-bottom: 1px solid var(--blue-border);
}

.form-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--blue-text);
  white-space: nowrap;
}

.filter-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-wrap label {
  font-size: 14px;
  color: var(--text-mid);
  white-space: nowrap;
}

select.control,
input.control,
textarea.control {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 7px 9px;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}

select.control { min-width: 190px; cursor: pointer; }

input.control::placeholder,
textarea.control::placeholder { color: #a9b6c0; }

.control:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(13,143,158,.15);
}

.control.edited {
  border-color: var(--amber);
  background: #fffdf5;
}

/* No value was extracted. Rendered in the ordinary field style — NA reads as a
   normal value, not as greyed-out or disabled. The class is retained for
   behaviour (select-on-focus, annotation guard), not for appearance. */
.control.na {
  color: var(--text);
  font-style: normal;
  background: #fff;
}

/* ---------- Scroll body ---------- */

.form-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 12px 84px;
}

/* ---------- Field grid ---------- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
}

@media (max-width: 1300px) {
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.field { min-width: 0; }
.field.hidden { display: none; }
.field.span-2 { grid-column: span 2; }

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  min-height: 20px;
}

.field-label .name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-label .spacer { margin-left: auto; }

.conf {
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.conf.high { color: var(--green); }
.conf.med  { color: var(--amber); }
.conf.low  { color: var(--red); }
.conf.none { color: var(--text-soft); font-weight: 500; }

.conf-dot {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--green);
}
.conf-dot.med  { color: var(--amber); }
.conf-dot.low  { color: var(--red); }
.conf-dot.none { color: var(--border-strong); }

/* Crosshair button — locate this value on the source document */
.conf-dot-btn {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  padding: 0;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.conf-dot-btn:hover { background: rgba(45,181,93,.14); transform: scale(1.12); }
.conf-dot-btn:active { transform: scale(.96); }

/* Field whose value is currently highlighted on the document */
.field.annotated .control,
.field.field-selected .control {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(45,181,93,.18);
  background: #f8fdfa;
}
.field.annotated .conf-dot-btn,
.field.field-selected .conf-dot-btn { background: rgba(45,181,93,.18); }

/* Active state on the annotation icon itself */
.field.annotation-active .conf-dot { color: var(--green); }
.field.annotation-active .conf-dot-btn { box-shadow: 0 0 0 2px rgba(45,181,93,.25); }

/* Batch verification outcome (Verify all) — quieter than the active highlight,
   so a whole-record pass reads as a background state rather than a selection. */
.field.verified .control { border-color: #9cd6b3; background: #f7fdf9; }
.field.verified .conf-dot { color: var(--green); }

.field.missing .control { border-color: #e9b3b3; background: #fdf7f7; }
.field.missing .conf-dot { color: var(--red); }

.verify-btn { white-space: nowrap; }

/* Value could not be located in the document text */
.field.notfound .control {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(214,69,69,.16);
  background: #fdf6f6;
}
.field.notfound .conf-dot-btn { background: rgba(214,69,69,.16); }
.field.notfound .conf-dot { color: var(--red); }

.kebab {
  width: 16px;
  height: 20px;
  flex: none;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  padding: 0;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: 3px;
}
.kebab:hover { background: #eef2f5; color: var(--text); }

/* Field focus → source-highlight hook */
.field.linked .control {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(13,143,158,.18);
}

/* ==========================================================================
   Search row
   ========================================================================== */

.search-row {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.search-box {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search-box > svg {
  position: absolute;
  left: 9px;
  width: 15px;
  height: 15px;
  color: var(--text-soft);
  pointer-events: none;
}

.search-box input.control { padding-left: 30px; padding-right: 28px; }

.search-clear {
  position: absolute;
  right: 6px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: none;
  background: #e3eaf0;
  color: var(--text-mid);
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.search-clear:hover { background: var(--border-strong); color: var(--text); }

.search-count {
  font-size: 12.5px;
  color: var(--text-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 74px;
  text-align: right;
}
.search-count.empty { color: var(--red); }

/* ---------- View toggle ---------- */

.view-toggle {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  flex: none;
}

.vt-btn {
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 500;
  background: #fff;
  border: none;
  color: var(--text-mid);
  cursor: pointer;
  white-space: nowrap;
}
.vt-btn + .vt-btn { border-left: 1px solid var(--border-strong); }
.vt-btn:hover:not(:disabled) { background: #eef3f7; }
.vt-btn.on { background: var(--teal); color: #fff; }
.vt-btn:disabled { opacity: .4; cursor: default; }

/* ==========================================================================
   Line item region: navigator rail + accordion column
   ========================================================================== */

.lines-region {
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.lines-col {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 2px dashed var(--border-strong);
  padding-left: 10px;
}

/* ---------- Navigator rail ---------- */

.line-rail {
  flex: none;
  display: none;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 300px);
  width: 34px;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: var(--blue-pale-2);
  border: 1px solid var(--blue-border);
  border-radius: 999px;
}
.line-rail.on { display: flex; }

.rail-key {
  flex: none;
  width: 26px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 9px;
  color: var(--teal-dark);
  background: #fff;
  border: 1px solid var(--blue-border);
  border-radius: 999px;
  cursor: pointer;
}
.rail-key:hover { background: var(--teal); color: #fff; border-color: var(--teal); }

.rail-chips {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 2px 0;
  min-height: 0;
}
.rail-chips::-webkit-scrollbar { display: none; }

.rail-chip {
  position: relative;
  flex: none;
  width: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-mid);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: background .1s, color .1s, transform .1s;
}
.rail-chip:hover { border-color: var(--teal); transform: scale(1.08); }

.rail-chip.current {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(13,143,158,.2);
}

/* Status dot: amber = edited, red = holds a sub-95% field */
.rail-chip.edited::after,
.rail-chip.lowconf::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--amber);
}
.rail-chip.lowconf::after { background: var(--red); }

.rail-chip.dim { opacity: .3; }
.rail-chip.hit { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }

/* ---------- Peek tooltip ---------- */

.rail-tip {
  position: absolute;
  left: 40px;
  display: none;
  flex-direction: column;
  gap: 2px;
  max-width: 260px;
  padding: 7px 10px;
  background: #21323d;
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(20,35,45,.3);
  pointer-events: none;
  transform: translateY(-50%);
  z-index: 20;
}
.rail-tip.on { display: flex; }
.rail-tip b  { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; opacity: .75; font-weight: 600; }
.rail-tip em { font-style: normal; color: #8fe0ab; font-weight: 600; }
.rail-tip span { word-break: break-word; }

/* ---------- Focus mode pager ---------- */

.focus-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--bg-toolbar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.focus-pos { font-size: 13.5px; color: var(--text-mid); }
.focus-pos b { color: var(--text); font-weight: 600; }

.focus-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
}
.focus-hint.on { color: var(--green); font-weight: 600; }

.acc.focused { border-color: var(--teal); }
.acc.focused > .acc-head { background: #cfe8f3; }

/* List-mode jump target flash */
.acc.flash { animation: accFlash .9s ease-out; }
@keyframes accFlash {
  0%   { box-shadow: 0 0 0 3px rgba(13,143,158,.4); }
  100% { box-shadow: 0 0 0 3px rgba(13,143,158,0); }
}

/* ---------- Line item accordions ---------- */

.lines-wrap {
  margin-top: 16px;
  border-left: 2px dashed var(--border-strong);
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lines-empty {
  margin-top: 16px;
  padding: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.acc {
  border: 1px solid var(--blue-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.acc.hidden { display: none; }

.acc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--blue-pale);
}

.acc-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--blue-text);
  white-space: nowrap;
}

.acc-sum {
  font-size: 12px;
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.acc-head select.control {
  margin-left: auto;
  max-width: 300px;
  min-width: 140px;
  padding: 5px 8px;
}

.acc-body {
  padding: 12px 10px;
  border-top: 1px solid var(--blue-border);
}
.acc.collapsed .acc-body { display: none; }
.acc.collapsed .chev svg { transform: rotate(180deg); }

.chev svg { transition: transform .15s; }

/* ---------- Add line row ---------- */

.add-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.add-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--green);
  background: #fff;
  color: var(--green);
  cursor: pointer;
}
.add-btn:hover { background: var(--green); color: #fff; }
.add-btn svg { width: 15px; height: 15px; }

/* ---------- Sticky action bar ---------- */

.action-bar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(to top, #fff 62%, rgba(255,255,255,0));
  pointer-events: none;
}

.action-bar > * { pointer-events: auto; }

.queue-note {
  font-size: 12.5px;
  color: var(--text-soft);
  white-space: nowrap;
}

.btn {
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}

.btn-ghost {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text-mid);
}
.btn-ghost:hover { background: #f2f6f9; color: var(--text); border-color: var(--text-soft); }

.btn-danger { background: #fff; border-color: #e8b4b4; color: var(--red); }
.btn-danger:hover { background: #fdf3f3; border-color: var(--red); }

.btn-primary {
  background: var(--green-cta);
  color: #fff;
  font-weight: 600;
  padding: 9px 30px;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--green-cta-dark); }
.btn-primary:disabled { background: #a9c9b7; cursor: default; }

.pane-form { position: relative; }

/* ==========================================================================
   Record queue rail
   ========================================================================== */

.queue {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-mid);
}

.queue .nav-btn {
  height: 26px;
  padding: 0 10px;
  font-size: 12.5px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-mid);
  cursor: pointer;
}
.queue .nav-btn:hover:not(:disabled) { background: #eef3f7; color: var(--text); }
.queue .nav-btn:disabled { opacity: .4; cursor: default; }

.progress {
  flex: 1 1 auto;
  height: 5px;
  border-radius: 3px;
  background: #dfe7ec;
  overflow: hidden;
  min-width: 60px;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--green);
  transition: width .25s;
}

.status-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.status-pill.pending   { background: #fff4e0; color: #a86b06; border: 1px solid #f0d9ae; }
.status-pill.released  { background: #e4f7ec; color: #1a7a41; border: 1px solid #b6e4c9; }
.status-pill.rejected  { background: #fdecec; color: #a83232; border: 1px solid #f0c2c2; }

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #21323d;
  color: #fff;
  font-size: 13px;
  padding: 10px 15px;
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(20,35,45,.28);
  animation: rise .18s ease-out;
  max-width: 380px;
}
.toast.ok  { background: #16724a; }
.toast.err { background: #96322f; }
.toast svg { width: 16px; height: 16px; flex: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   Completion state
   ========================================================================== */

.done-screen {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 40px;
  color: var(--text-mid);
}
.done-screen svg { width: 54px; height: 54px; color: var(--green); }
.done-screen h3 { margin: 0; font-size: 19px; color: var(--text); font-weight: 600; }
.done-screen p  { margin: 0; font-size: 14px; max-width: 420px; }
.done-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ==========================================================================
   Scrollbars
   ========================================================================== */

.form-body::-webkit-scrollbar,
.doc-canvas::-webkit-scrollbar { width: 11px; height: 11px; }

.form-body::-webkit-scrollbar-thumb,
.doc-canvas::-webkit-scrollbar-thumb {
  background: #bccad4;
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: content-box;
}
.form-body::-webkit-scrollbar-thumb:hover,
.doc-canvas::-webkit-scrollbar-thumb:hover { background: #9dafbc; background-clip: content-box; }
