/* Docket — industrial precision.
 *
 * Near-black on warm off-white, one hi-vis accent, hairline rules, 2px
 * corners, tabular monospace for every number. The reference is site
 * equipment and measuring instruments, not a SaaS dashboard: flat fills, no
 * glows, no gradients, nothing rounded enough to look soft.
 */

:root {
  color-scheme: light dark;

  /* Hi-vis is a fill, never text on white — same as it works on a vest. */
  --hivis: #d9f24a;
  --hivis-deep: #b9d42c;
  --hivis-soft: rgba(217, 242, 74, 0.22);

  --ok: #1a7f4b;
  --warn: #a8620a;
  --bad: #c2321f;

  --paper: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #efefea;
  --ink: #0b0b0c;
  --text: #0b0b0c;
  --text-soft: #56574f;
  --text-faint: #8b8c82;
  --line: #e2e2db;
  --line-strong: #c7c8bf;

  --r: 2px;
  --r-lg: 3px;

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Roboto Mono', Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;

    --paper: #0c0d0b;
    --surface: #141613;
    --surface-2: #1c1f1a;
    --ink: #f7f7f4;
    --text: #f2f2ec;
    --text-soft: #a1a399;
    --text-faint: #6f7168;
    --line: #262922;
    --line-strong: #3a3e34;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  font-family: var(--sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.011em;
}

/* --- Layout ------------------------------------------------------------- */

.phone {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 18px calc(28px + env(safe-area-inset-bottom));
}

/* On a laptop the full-height column left a dead void between the copy and
   the action. Above phone width it becomes a bordered card sized to its
   content instead. */
@media (min-width: 620px) {
  .phone {
    min-height: 0;
    margin: 44px auto 64px;
    padding: 30px 32px 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
  }
  .spacer { flex: 0 0 auto; min-height: 26px; }
}

.wide { max-width: 1240px; margin: 0 auto; padding: 22px 22px 72px; }

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.masthead h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

/* A hi-vis chip, cut square. */
.masthead h1::before {
  content: '';
  width: 13px;
  height: 13px;
  background: var(--hivis);
  border-radius: 1px;
}

.masthead h1 span { color: var(--text-faint); font-weight: 500; letter-spacing: 0.1em; }

.masthead .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  text-align: right;
  line-height: 1.6;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.masthead a {
  color: var(--text-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 1px;
  transition: all 0.15s var(--ease);
}

.masthead a:hover { color: var(--text); border-bottom-color: var(--ink); }

/* --- Screens ------------------------------------------------------------ */

.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; animation: rise 0.28s var(--ease) both; }

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

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.screen-title {
  font-size: 29px;
  font-weight: 680;
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin: 12px 0 10px;
}

.screen-sub {
  font-size: 14.5px;
  color: var(--text-soft);
  line-height: 1.55;
  margin: 0 0 24px;
  max-width: 44ch;
}

/* Numbered rule rather than a pill — a spec sheet, not a tag. */
.step-label {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.step-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.spacer { flex: 1; min-height: 18px; }

/* --- Controls ----------------------------------------------------------- */

.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  background: var(--hivis);
  color: #0b0b0c;
  border: 1px solid var(--hivis-deep);
  padding: 15px 22px;
  border-radius: var(--r);
  cursor: pointer;
  width: 100%;
  transition: all 0.15s var(--ease);
}

.btn:hover:not(:disabled) { background: var(--hivis-deep); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink); }

.btn-row { display: flex; gap: 8px; margin-top: 10px; }

.link-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 13px 0;
  transition: color 0.15s var(--ease);
}

.link-btn:hover { color: var(--text); }

/* Options read as a stacked register: hairline separators, hi-vis edge on
   hover, no cards floating on cards. */
.option {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  padding: 15px 12px;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: all 0.15s var(--ease);
}

.option:first-of-type { border-top: 1px solid var(--line); }
.option:hover { border-left-color: var(--hivis); background: var(--surface-2); padding-left: 16px; }
.option .opt-label { font-size: 15.5px; font-weight: 600; letter-spacing: -0.018em; }
.option .opt-hint { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; line-height: 1.45; }

input[type='text'], input[type='number'], input[type='email'], input[type='password'], textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  color: var(--text);
  transition: all 0.15s var(--ease);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
textarea { min-height: 128px; resize: vertical; line-height: 1.55; }

/* --- Dropzone ----------------------------------------------------------- */

.dropzone {
  border: 1px dashed var(--line-strong);
  background: var(--surface);
  border-radius: var(--r);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.15s var(--ease);
}

.dropzone:hover, .dropzone.dragover { border-color: var(--ink); border-style: solid; }
.dropzone.has-image { padding: 0; border-style: solid; border-color: var(--line-strong); cursor: default; }
.dropzone img { width: 100%; display: block; }

.dz-icon { width: 30px; height: 30px; margin: 0 auto 14px; color: var(--text-faint); }
.dz-icon svg { width: 100%; height: 100%; }
.dz-prompt { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.dz-hint { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); margin-top: 6px; letter-spacing: 0.02em; }

.overlay-box {
  position: absolute;
  border: 1.5px solid var(--hivis-deep);
  background: var(--hivis-soft);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  pointer-events: none;
}

.overlay-box.show { opacity: 1; }

.overlay-label {
  position: absolute;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
  background: #0b0b0c;
  color: var(--hivis);
  padding: 2px 6px;
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  pointer-events: none;
  white-space: nowrap;
}

.overlay-label.show { opacity: 1; }

.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--hivis-deep);
  box-shadow: 0 0 10px 1px var(--hivis-soft);
  top: 0;
  opacity: 0;
  z-index: 2;
}

.scan-line.run { animation: scan 1.9s linear infinite; opacity: 1; }

@keyframes scan {
  0% { top: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* --- Thinking ----------------------------------------------------------- */

.thinking-steps { padding: 0; margin: 22px 0 0; border-top: 1px solid var(--line); }

.thinking-steps li {
  list-style: none;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.01em;
  color: var(--text-faint);
  padding: 11px 0 11px 26px;
  border-bottom: 1px solid var(--line);
  position: relative;
  transition: color 0.25s var(--ease);
}

.thinking-steps li::before {
  content: '';
  position: absolute;
  left: 2px; top: 50%;
  transform: translateY(-50%);
  width: 7px; height: 7px;
  background: var(--line-strong);
  border-radius: 1px;
  transition: all 0.25s var(--ease);
}

.thinking-steps li.active { color: var(--text); }
.thinking-steps li.active::before { background: var(--hivis); animation: blink 1.1s steps(2, start) infinite; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.thinking-steps li.done { color: var(--text-soft); }
.thinking-steps li.done::before { background: var(--ok); }

/* --- Quote sheet -------------------------------------------------------- */

.docket {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 0 16px 16px;
}

.docket-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 9px;
  border-bottom: 1px solid var(--ink);
}

.docket-head .label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.line-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.line-item:last-child { border-bottom: none; }

.li-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.li-main { flex: 1; min-width: 0; }
.li-name { font-size: 14.5px; font-weight: 580; line-height: 1.3; letter-spacing: -0.015em; }
.li-qty { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); margin-top: 3px; letter-spacing: 0.01em; }

.li-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.li-amount {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 90px;
  text-align: right;
  cursor: text;
  padding: 3px 6px;
  border-radius: var(--r);
  border: 1px solid transparent;
  transition: all 0.15s var(--ease);
}

.li-amount:hover { border-color: var(--line-strong); }
.li-amount:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* A stencilled tag: mono caps behind a colour bar. */
.stamp {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  padding: 2px 7px 2px 6px;
  border-left: 3px solid currentColor;
  background: var(--surface-2);
  white-space: nowrap;
  display: inline-block;
}

.stamp.matched { color: var(--ok); }
.stamp.adjusted { color: var(--warn); }
.stamp.review { color: var(--bad); }

.li-note { font-size: 12.5px; color: var(--text-soft); margin-top: 8px; line-height: 1.5; }

.li-override {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  margin-top: 8px;
  padding: 5px 8px;
  background: var(--hivis-soft);
  border-left: 2px solid var(--hivis-deep);
  display: inline-block;
  letter-spacing: 0.01em;
}

.li-actions { margin-top: 9px; display: flex; gap: 14px; }

.li-actions button {
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0;
  text-transform: uppercase;
  transition: color 0.15s var(--ease);
}

.li-actions button:hover { color: var(--bad); }

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 15px;
  margin-top: 4px;
  border-top: 2px solid var(--ink);
}

.summary-row .label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.summary-row .value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

/* --- Stats -------------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.stat { background: var(--surface); padding: 16px 10px; text-align: center; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }

.stat .n {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat .k {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 8px;
}

.readiness {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-soft);
  border-left: 2px solid var(--hivis-deep);
  padding: 3px 0 3px 14px;
  margin: 18px 0;
}

/* --- Notices ------------------------------------------------------------ */

.notice {
  font-size: 12.5px;
  line-height: 1.5;
  padding: 11px 13px;
  margin: 11px 0;
  border-radius: var(--r);
  border-left: 2px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-soft);
}

.notice.warn { border-left-color: var(--warn); }
.notice.error { border-left-color: var(--bad); color: var(--bad); }

.sync-pill {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sync-pill .dot { width: 6px; height: 6px; border-radius: 1px; background: var(--text-faint); }
.sync-pill.synced { color: var(--ok); border-color: var(--ok); }
.sync-pill.synced .dot { background: var(--ok); }

/* --- Advanced mode ------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px 22px;
  margin-bottom: 18px;
}

.panel-label {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid var(--ink);
  white-space: nowrap;
}

td { padding: 10px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num { font-family: var(--mono); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.tabs { display: flex; gap: 0; margin-bottom: 20px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }

.tab {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 11px 14px;
  margin-bottom: -1px;
  cursor: pointer;
  color: var(--text-faint);
  transition: all 0.15s var(--ease);
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--hivis-deep); }

.empty { font-family: var(--mono); font-size: 12px; color: var(--text-faint); padding: 30px 0; text-align: center; }

.pos { color: var(--ok); }
.neg { color: var(--bad); }

.agent-fn { padding: 15px 0; border-bottom: 1px solid var(--line); }
.agent-fn:last-child { border-bottom: none; }
.agent-fn .fn-name { font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.agent-fn .fn-desc { font-size: 13px; color: var(--text-soft); margin-top: 6px; line-height: 1.5; max-width: 78ch; }

.agent-fn .fn-route {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 8px;
  letter-spacing: 0.02em;
}

@media (max-width: 560px) {
  .wide { padding: 18px 14px 56px; }
  .panel { padding: 14px 13px 18px; }
  .screen-title { font-size: 25px; }
}

/* --- Jobs page ---------------------------------------------------------- */

.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.job-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.job-grid input { font-size: 14px; }

.plan-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .plan-split { grid-template-columns: 1fr; } }

td a, .job-link { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
td a:hover, .job-link:hover { border-bottom-color: var(--ink); }

.row-open {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 4px 9px;
  cursor: pointer;
  color: var(--text-soft);
  transition: all 0.15s var(--ease);
}

.row-open:hover { border-color: var(--ink); color: var(--text); }

/* Inline editing in advanced mode. */
.cell-input {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 5px 7px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r);
  color: var(--text);
}

.cell-input:hover { border-color: var(--line); }
.cell-input:focus { outline: none; border-color: var(--ink); }
.cell-input.num { font-family: var(--mono); text-align: right; }

.row-actions { display: flex; gap: 6px; white-space: nowrap; }

.row-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-soft);
  transition: all 0.15s var(--ease);
}

.row-btn:hover { border-color: var(--ink); color: var(--text); }
.row-btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.row-btn.save { background: var(--hivis); border-color: var(--hivis-deep); color: #0b0b0c; }
.row-btn.save:hover { background: var(--hivis-deep); color: #0b0b0c; }

.token-secret {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  background: var(--hivis-soft);
  border-left: 2px solid var(--hivis-deep);
  padding: 10px 12px;
  margin: 10px 0;
}

/* --- Guided export ------------------------------------------------------ */

.export-steps { margin: 4px 0 0; padding: 0; counter-reset: step; list-style: none; }

.export-steps li {
  counter-increment: step;
  position: relative;
  padding: 11px 0 11px 34px;
  font-size: 14.5px;
  line-height: 1.5;
  border-bottom: 1px solid var(--line);
}

.export-steps li:last-child { border-bottom: none; }

.export-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 11px;
  width: 21px;
  height: 21px;
  background: var(--hivis);
  color: #0b0b0c;
  border-radius: 1px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.opt-kind {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}
