/* ── Split Seal tokens ─────────────────────────────────────────────── */
:root {
  --heat: #C13A1F;
  --cool: #418FDE;
  --ink:  #101820;
  --bone: #EDE6D8;

  /* derived */
  --ink-2:  #1B2530;      /* raised surfaces on ink */
  --bone-2: #E2D9C6;      /* pressed surfaces on bone */
  --line:   rgba(16, 24, 32, 0.18);

  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --tabbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--bone);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ───────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  background: var(--ink);
  color: var(--bone);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
}

.seal { display: flex; width: 22px; height: 22px; border-radius: 50%;
  overflow: hidden; border: 2px solid var(--bone); flex: none; }
.seal-heat { flex: 1; background: var(--heat); }
.seal-cool { flex: 1; background: var(--cool); }

.wordmark {
  margin: 0; flex: 1;
  font-family: var(--display);
  font-weight: 700; font-size: 20px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.wordmark span { font-weight: 500; color: var(--bone-2); }

.sync-status { display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--bone-2); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7683; }
.sync-status[data-state="syncing"] .sync-dot { background: var(--cool); }
.sync-status[data-state="synced"]  .sync-dot { background: #3f9d5a; }
.sync-status[data-state="error"]   .sync-dot { background: var(--heat); }
.sync-status[data-state="offline"] .sync-dot { background: #b08a3e; }

/* ── Main view ─────────────────────────────────────────────────────── */
.view {
  padding: 16px 14px calc(var(--tabbar-h) + var(--safe-b) + 20px);
  max-width: 720px; margin: 0 auto;
}

.view h2 {
  font-family: var(--display);
  font-size: 26px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
  margin: 4px 0 4px;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 6px;
}
/* module accent: heat for money, cool for technical */
.view h2.accent-heat { border-bottom-color: var(--heat); }
.view h2.accent-cool { border-bottom-color: var(--cool); }

.placeholder {
  margin-top: 14px;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,0.35);
  padding: 16px;
}
.placeholder p { margin: 0 0 8px; }
.placeholder .tag {
  display: inline-block;
  font-family: var(--display); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 12px;
  background: var(--ink); color: var(--bone);
  padding: 2px 8px; margin-bottom: 10px;
}

/* ── Bottom tab bar ────────────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  background: var(--ink);
  padding-bottom: var(--safe-b);
  height: calc(var(--tabbar-h) + var(--safe-b));
}
.tabbar a {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 600; font-size: 13px;
  letter-spacing: 0.04em; text-transform: uppercase; text-align: center;
  color: var(--bone-2); text-decoration: none;
  border-top: 3px solid transparent;
}
.tabbar a.active { color: var(--bone); border-top-color: var(--heat); }
.tabbar a:focus-visible { outline: 2px solid var(--cool); outline-offset: -2px; }

/* ── Lists / stubs ─────────────────────────────────────────────────── */
.list { list-style: none; margin: 14px 0 0; padding: 0; }
.list li {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--cool);
  padding: 10px 12px; margin-bottom: 8px;
}
.list li.money { border-left-color: var(--heat); }
.doc-number { font-weight: 500; letter-spacing: 0.02em; }

@media (prefers-reduced-motion: no-preference) {
  .tabbar a { transition: color 120ms, border-color 120ms; }
}

/* ── Step 2: forms, builder, picker ───────────────────────────────── */
.form-box {
  background: #fff; border: 1px solid var(--line);
  padding: 14px; margin: 14px 0;
}
.form-box h3 {
  font-family: var(--display); font-size: 18px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 10px;
}
.form-box h4 { font-family: var(--display); font-size: 15px; text-transform: uppercase; margin: 16px 0 8px; }
.lbl { display: block; font-size: 11px; color: #6b7683; margin: 10px 0 3px; text-transform: uppercase; letter-spacing: 0.06em; }
.input {
  width: 100%; padding: 10px; margin: 4px 0;
  font-family: var(--mono); font-size: 14px;
  border: 1px solid var(--line); background: var(--bone);
  color: var(--ink); box-sizing: border-box;
}
.input:focus { outline: 2px solid var(--cool); outline-offset: -1px; }
select.input { appearance: auto; }
.input-inline { margin: 0; padding: 7px; font-size: 13px; }
.input-qty { width: 64px; margin: 0; padding: 7px; font-size: 13px; }
.input-price { width: 88px; margin: 0; padding: 7px; font-size: 13px; }

.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.btn {
  font-family: var(--display); font-weight: 700; font-size: 15px;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 11px 16px; border: 1.5px solid transparent; cursor: pointer;
}
.btn-heat { background: var(--heat); color: var(--bone); }
.btn-cool { background: var(--cool); color: #fff; }
.btn-ink  { background: var(--ink);  color: var(--bone); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-small { padding: 5px 10px; font-size: 12px; margin-top: 6px; }
.btn:focus-visible { outline: 2px solid var(--cool); outline-offset: 2px; }
.btn-x { background: none; border: none; color: var(--heat); font-size: 15px; cursor: pointer; padding: 4px 8px; }

.line-row { border-bottom: 1px dashed var(--line); padding: 8px 0; }
.line-credit .input-inline, .line-credit .line-ext { color: var(--cool); }
.line-desc { margin-bottom: 6px; }
.line-nums { display: flex; align-items: center; gap: 6px; }
.line-nums .x { color: #6b7683; }
.line-ext { margin-left: auto; font-weight: 500; min-width: 76px; text-align: right; }
.totals-row { text-align: right; font-size: 17px; padding: 12px 0 2px; }

.check-row { display: block; padding: 6px 0; font-size: 14px; }
.empty-note { color: #6b7683; font-size: 13px; }
.note-warn { background: #fff6e8; border: 1px solid #e0c48a; padding: 10px; font-size: 13px; }
.doc-meta { font-size: 12px; color: #6b7683; margin-top: 2px; }
.tb-item { border-bottom: 1px dashed var(--line); padding: 8px 0; position: relative; }
.tb-item .btn-x { position: absolute; right: 0; top: 6px; }

.overlay {
  position: fixed; inset: 0; background: rgba(16,24,32,0.6); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.panel {
  background: var(--bone); width: 100%; max-width: 720px;
  max-height: 82vh; overflow-y: auto; padding: 18px 16px calc(18px + var(--safe-b));
}
.panel h3 { font-family: var(--display); font-size: 19px; text-transform: uppercase; margin: 0 0 10px; }
.picker-list { max-height: 38vh; overflow-y: auto; margin: 8px 0; }
.picker-item {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 11px 8px; border-bottom: 1px solid var(--line);
  background: #fff; cursor: pointer;
}
.picker-item:active { background: var(--bone-2); }
.picker-price { font-weight: 500; white-space: nowrap; }

/* ── Toasts + error bar ───────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  transform: translateX(-50%) translateY(12px); opacity: 0;
  background: var(--ink); color: var(--bone);
  font-family: var(--mono); font-size: 13px;
  padding: 11px 18px; z-index: 90; max-width: 88vw;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-err { background: var(--heat); color: #fff; }
.err-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 95;
  background: var(--heat); color: #fff;
  font-family: var(--mono); font-size: 12px;
  padding: 10px 40px 10px 12px; word-break: break-word;
}
.err-bar .btn-x { position: absolute; right: 4px; top: 4px; color: #fff; }
textarea.input { resize: vertical; font-family: var(--mono); }

.part-inactive { opacity: 0.45; }
