:root {
  --bg: #F3F5F2;
  --surface: #FFFFFF;
  --ink: #14201B;
  --muted: #4A5852;
  --line: #D9DFDA;
  --line-soft: #E7EBE8;
  --field: #B9C3BD;
  --track: #E4E9E5;
  --accent: #0B6E55;
  --accent-ink: #08513F;
  --accent-soft: #E3F1EC;

  --t-normal-bg: #E3F1EC;   --t-normal-fg: #08513F;
  --t-external-bg: #E6EEF6; --t-external-fg: #24496E;
  --t-scheduled-bg: #FBF0DC; --t-scheduled-fg: #7A4700;
  --t-waiting-bg: #F3EAF7;  --t-waiting-fg: #5E2F7A;
  --t-delivery-bg: #E3F1EC; --t-delivery-fg: #08513F;
  --warn-bg: #FBEBE8;       --warn-fg: #8A2E20; --warn-line: #C4705F;
  --neutral-bg: #E7EBE8;    --neutral-fg: #3D4A44;

  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--sans); font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#root { min-height: 100dvh; }
.shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.center-screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* header */
.top { padding: 18px 20px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 28px; letter-spacing: -.02em; line-height: 1.1; }
h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -.01em; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }
.btn:hover { background: var(--accent-ink); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; min-height: 52px; font-size: 16px; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1.5px solid var(--ink); }
.btn.ghost:hover { background: var(--line-soft); color: var(--ink); }
.linkbtn { text-align: left; background: none; border: 0; padding: 8px 0; color: var(--accent); font-weight: 600; min-height: 44px; }

/* fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.input { min-height: 48px; padding: 0 14px; border: 1.5px solid var(--field); border-radius: 12px; background: var(--surface); width: 100%; }
.input:focus { border-color: var(--accent); outline: none; }

.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.search input { border: 0; outline: none; background: transparent; flex: 1; min-width: 0; color: var(--ink); }

.tabs { display: flex; gap: 6px; padding: 4px; background: var(--track); border-radius: 12px; }
.tab { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; color: var(--muted); white-space: nowrap; padding: 0 6px; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 600; }

/* content */
.content { flex: 1; padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--field); color: inherit; }
.card.warn { border: 1.5px solid var(--warn-line); }
.card-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-title { font-weight: 600; font-size: 16px; }
.card-meta { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.card-meta.warn { color: var(--warn-fg); font-weight: 500; }
.chip-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.chip.normal { background: var(--t-normal-bg); color: var(--t-normal-fg); }
.chip.external { background: var(--t-external-bg); color: var(--t-external-fg); }
.chip.scheduled { background: var(--t-scheduled-bg); color: var(--t-scheduled-fg); }
.chip.waiting_on_client { background: var(--t-waiting-bg); color: var(--t-waiting-fg); }
.chip.delivery { background: var(--t-delivery-bg); color: var(--t-delivery-fg); }
.chip.pickup { background: var(--warn-bg); color: var(--warn-fg); }
.chip.neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); }
.notice.info { background: var(--accent-soft); color: var(--accent-ink); }

.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); }
.empty h2 { color: var(--ink); }

/* workflows */
.stage-list { list-style: none; margin: 0; padding: 0; }
.stage-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.stage-name small { display: block; color: var(--muted); font-size: 12px; }
.expand { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; background: none; border: 0; padding: 0; text-align: left; color: inherit; min-height: 44px; }

/* settings */
.dl { margin: 0; display: flex; flex-direction: column; }
.dl div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.dl div:first-child { border-top: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }

/* main nav: bottom bar on phones, top bar on wide screens */
.nav { position: sticky; bottom: 0; z-index: 3; display: flex; justify-content: space-around; gap: 4px; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(20, 32, 27, .07); }
.nav a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border-radius: 14px; text-decoration: none; color: var(--muted); font-size: 12px; }
.nav a:hover { color: var(--ink); background: var(--line-soft); }
.nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }

@media (min-width: 720px) {
  .nav { order: -1; top: 0; bottom: auto; justify-content: flex-start; padding: 10px 16px; border-top: 0; border-bottom: 1px solid var(--line); box-shadow: 0 6px 20px rgba(20, 32, 27, .05); }
  .nav a { flex: none; max-width: none; flex-direction: row; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 14px; }
  .nav a svg { width: 18px; height: 18px; }
  .top { position: static; }
}

/* login */
.login { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 22px; }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 26px; letter-spacing: -.02em; color: var(--accent); }
.login form { display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.error { color: var(--warn-fg); font-size: 14px; }

/* ---------- forms ---------- */
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 40px; margin-left: -4px; text-decoration: none; font-weight: 600; color: var(--accent); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form-section { gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 > .field { min-width: 0; }
.hint { font-size: 12px; color: var(--muted); }
.hint.center { text-align: center; }
.opt { font-weight: 400; color: var(--muted); }
.label { font-size: 13px; font-weight: 600; }
.textarea { padding: 10px 14px; min-height: 0; line-height: 1.45; resize: vertical; }
select.input { padding: 0 10px; }
.input-with-tag { position: relative; }
.tag-in { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); pointer-events: none; }
.suggest-wrap { position: relative; }
.suggest { list-style: none; margin: 4px 0 0; padding: 4px; position: absolute; top: 100%; left: 0; right: 0; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px -12px rgba(20,32,27,.25); }
.suggest button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; background: none; border: 0; border-radius: 8px; text-align: left; color: var(--ink); min-height: 44px; }
.suggest button:hover { background: var(--line-soft); }
.suggest span { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 8px; }
.error.small { font-size: 12px; }

/* ---------- sheet (dialog) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20, 32, 27, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column; background: var(--bg); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgba(20,32,27,.2); }
@media (min-width: 720px) { .sheet-backdrop { align-items: center; padding: 24px; } .sheet { border-radius: 20px; max-height: 88dvh; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 20px; }
.sheet-body { overflow-y: auto; padding: 4px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet-sub { margin: 6px 0 0; font-size: 13px; font-family: var(--mono); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 999px; background: var(--line-soft); color: var(--ink); flex: none; }

.change { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-size: 14px; }
.change-row { display: flex; align-items: flex-start; gap: 10px; }
.change-row .chip { margin-left: 4px; }
.dot-sm { flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--field); background: var(--surface); }
.dot-sm.done { background: var(--accent); border-color: var(--accent); }
.dot-sm.done svg { width: 11px; height: 11px; }
.dot-sm.now { border-color: var(--accent); background: var(--accent-soft); }
.dot-sm.closed { border-color: var(--muted); background: var(--line-soft); }

.composer { display: flex; flex-direction: column; gap: 12px; }
.composer-meta { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--muted); }
.composer-meta b { color: var(--ink); }
.composer-actions { display: flex; flex-direction: column; gap: 8px; }

.seg { display: flex; gap: 6px; padding: 4px; background: var(--track); border-radius: 12px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; }

.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; color: var(--ink); }
.choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.radio { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--field); background: var(--surface); }
.choice[aria-checked="true"] .radio { border: 5px solid var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

/* ---------- job detail ---------- */
.top-row .chip { flex: none; }
.next-card { gap: 6px; }
.next-card .btn { margin-top: 8px; }
.stages { list-style: none; margin: 0; padding: 0; }
.stage { display: flex; align-items: flex-start; border-top: 1px solid var(--line-soft); }
.stage:first-child { border-top: 0; }
.stage-check { flex: none; width: 44px; height: 44px; margin: 2px 0 0 -10px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: 999px; padding: 0; }
.stage-check:not(:disabled):hover .stage-dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stage-check:disabled { cursor: default; }
.stage-btn { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 12px; padding: 12px 0 10px; background: none; border: 0; text-align: left; color: inherit; min-height: 48px; }
.stage-btn:hover .stage-title { text-decoration: underline; text-decoration-color: var(--field); }
.stage-dot { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--field); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; transition: box-shadow .12s, border-color .12s; }
.stage.done .stage-dot { background: var(--accent); border-color: var(--accent); }
.stage.current .stage-dot { border-color: var(--accent); background: var(--accent-soft); }
.stage-sub.now { color: var(--accent-ink); font-weight: 600; }
.stage.scheduled .stage-dot { border-color: var(--t-scheduled-fg); background: var(--t-scheduled-bg); }
.stage.skipped .stage-dot { border-style: dashed; }
.stage-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stage-title { font-weight: 500; }
.stage.current .stage-title, .stage.scheduled .stage-title { font-weight: 600; }
.stage.pending .stage-title, .stage.skipped .stage-title { color: var(--muted); }
.stage.skipped .stage-title { text-decoration: line-through; }
.stage-title .chip { font-size: 11px; padding: 1px 8px; vertical-align: 1px; }
.stage-sub { font-size: 12px; color: var(--muted); }
.stage.scheduled .stage-sub { color: var(--t-scheduled-fg); font-weight: 500; }
.stage-note { margin-top: 4px; font-size: 13px; padding: 6px 10px; background: var(--bg); border-radius: 8px; white-space: pre-line; overflow-wrap: anywhere; }
.track-link { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn { min-height: 40px; padding: 0 14px; font-size: 14px; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.history li:first-child { border-top: 0; }
.history li > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.history .chip { flex: none; white-space: nowrap; }
.card h2 { font-size: 18px; }
.seg button:disabled { opacity: .45; cursor: default; }
.lang-tag { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-inline-end: 2px; }
.seen { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.seen b { color: var(--ink); font-weight: 600; }
.seen.small { font-size: 12px; }
.seen.not-yet { color: var(--t-scheduled-fg); }
.top .seen { margin-top: 6px; }
.visits { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.visit-list { list-style: none; margin: 0; padding: 0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- workflow editor ---------- */
.wf-list { list-style: none; margin: 0; padding: 0; }
.wf-row { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line-soft); }
.wf-row:first-child { border-top: 0; }
.wf-row-main { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; background: none; border: 0; text-align: left; color: inherit; min-height: 52px; text-decoration: none; }
.wf-row-main:hover .stage-title { text-decoration: underline; text-decoration-color: var(--field); }
.wf-row-main .stage-main { gap: 4px; }
.wf-row-main .chip { font-size: 11px; padding: 1px 8px; }
.wf-num { flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; background: var(--line-soft); font-family: var(--mono); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.wf-move { display: flex; gap: 2px; flex: none; }
.wf-move button { width: 40px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.wf-move button:hover:not(:disabled) { background: var(--line-soft); color: var(--ink); }
.wf-move button:disabled { opacity: .25; cursor: default; }
.wf-flow { overflow-wrap: anywhere; }
.miss { color: var(--t-scheduled-fg); font-size: 12px; }
.lang-group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lang-group legend { padding: 0; margin-bottom: 4px; }
.lang-input { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 8px; }
.lang-input .lang-tag { justify-self: start; font-size: 11px; padding: 1px 5px; cursor: default; }
.save-state { display: block; min-height: 16px; margin-top: 4px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.dd-line { display: block; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn.danger { background: var(--warn-fg); }
.btn.danger:hover { background: #6E2318; }
.linkbtn.danger { color: var(--warn-fg); }
.choice.tall { align-items: flex-start; padding: 12px 14px; }
.choice.tall .radio { margin-top: 1px; }
.choice-text { display: flex; flex-direction: column; gap: 2px; }
.choice-text small { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.35; }
.btn.ghost.danger-text { color: var(--warn-fg); border-color: var(--warn-fg); }

/* ---------- pickup reminders (settings) ---------- */
.rem-steps { margin: 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.rem-preview { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.mail { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.mail-subject { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.mail-body { font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; line-height: 1.5; }
.seg.small-seg button { min-height: 34px; font-size: 13px; }
/* Many options (e.g. client languages): wrap onto more rows instead of overflowing. */
.seg.wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
.seg.wrap button { padding: 0 8px; white-space: nowrap; }
