/* ジエイデン株式会社 WMS
   Brand colours live in the first block: change --brand* to re-theme. */
:root {
  color-scheme: only light;  /* stop phone browsers auto-darkening the brand colours */
  /* Mio Pearl — taken from the logo: taupe #D7C4B7 and black */
  --taupe: #d7c4b7;          /* exact logo background */
  --brand: #000000;          /* the black of the M: primary actions, active nav */
  --brand-hover: #2b2725;
  --brand-ink: #ffffff;
  --brand-soft: #f1e9e3;     /* taupe tint for highlights */
  --brand-line: #d7c4b7;

  --paper: #f7f3f0;          /* app background: pale taupe */
  --surface: #ffffff;
  --ink: #1a1715;
  --ink-2: #554d47;
  --ink-3: #7f746c;
  --line: #e3d8d0;
  --line-soft: #efe8e2;

  --ok: #2f7353;   --ok-soft: #e4f0e8;
  --warn: #93590c; --warn-soft: #f8ecda;
  --err: #a8322a;  --err-soft: #f8e5e2;
  --in: #2f7353;   --out: #a8322a;

  --chart-1: #000000;
  --chart-2: #a88a76;

  --seal: #c0392b;           /* hanko red, printed documents only */

  --sans: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", "Noto Sans CJK JP", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --display: "Bodoni Moda", "Shippori Mincho", "Noto Serif CJK JP", serif;
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", "Noto Serif JP", "Noto Serif CJK JP", "Songti SC", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 6px; --r: 10px; --r-lg: 16px;
  --rail: 236px;
  --tabbar: 64px;
  --shadow: 0 1px 2px rgb(26 33 40 / .06), 0 8px 24px rgb(26 33 40 / .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: only light; background: #f7f3f0; }
body {
  margin: 0; font: 15px/1.6 var(--sans); color: var(--ink); background: var(--paper);
  font-feature-settings: "palt" 1; -webkit-font-smoothing: antialiased;
}
body:not(.signed-in) .rail, body:not(.signed-in) .tabbar, body:not(.signed-in) .view { display: none; }
body.has-sheet { overflow: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
small { font-size: 12.5px; }
b { font-weight: 700; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.warn-text { color: var(--warn); font-style: normal; font-weight: 500; }
.block { display: block; }
.pre { white-space: pre-line; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hint { color: var(--ink-3); font-size: 13px; }

/* ------------------------------------------------------------ layout */
body.signed-in { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 20px; }
.brand-logo { width: 38px; height: auto; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-word { font-size: 12px; letter-spacing: .32em; font-weight: 500; color: var(--ink); white-space: nowrap; }
.brand-name { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
}
.nav-link svg, .tab svg, .more-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-link:hover { background: var(--line-soft); text-decoration: none; color: var(--ink); }
.nav-link.active { background: var(--brand); color: var(--brand-ink); }
.rail-foot { border-top: 1px solid var(--line-soft); padding-top: 10px; }
.account { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.account:hover { background: var(--line-soft); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.account-text { min-width: 0; display: flex; flex-direction: column; }
.account-text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text small { color: var(--ink-3); }

.view { padding: 28px clamp(16px, 4vw, 44px) 64px; max-width: 1180px; width: 100%; outline: none; }
.loading { height: 3px; width: 120px; margin: 40px auto; background: linear-gradient(90deg, transparent, var(--brand), transparent); background-size: 200% 100%; animation: load 1s linear infinite; border-radius: 2px; }
@keyframes load { to { background-position: -200% 0; } }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--display); font-size: 28px; letter-spacing: .01em; }
.page-head p { margin-top: 4px; }
.page-actions, .action-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action-row { margin: 18px 0 22px; }
.back { display: inline-block; color: var(--ink-3); font-size: 13.5px; margin-bottom: 10px; }
.back::before { content: "‹ "; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { font-size: 16px; }
.panel h3 { font-size: 14.5px; margin: 18px 0 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 + .panel, .grid-2 { margin-bottom: 18px; }
.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; font-size: 13.5px; }

/* ------------------------------------------------------------ stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); color: inherit;
}
a.stat:hover { text-decoration: none; border-color: var(--brand-line); }
.stat > span { color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.stat > b { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1.25; }
.stat > small { color: var(--ink-3); }
.stat.is-bad { border-color: #e9b4af; background: var(--err-soft); }
.stat.is-warn { border-color: #ecd09d; background: var(--warn-soft); }
.stats-item .stat > b { font-size: 22px; }
.chart-box { position: relative; height: 260px; }

/* ------------------------------------------------------------ lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line-soft); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; color: inherit; }
a.list-row:hover { text-decoration: none; background: var(--paper); }
.list-row > span:first-child:not(.delta), .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-row small { color: var(--ink-3); }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; flex: none; }
.delta { width: 46px; flex: none; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; border-radius: var(--r-sm); padding: 2px 0; background: var(--line-soft); color: var(--ink-2); }
.delta.up { background: var(--ok-soft); color: var(--in); }
.delta.down { background: var(--err-soft); color: var(--out); }
.empty-line { color: var(--ink-3); padding: 8px 2px; }
.count { color: var(--ink-3); font-size: 13.5px; margin: 0 0 8px; }

/* ------------------------------------------------------------ badges & chips */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; line-height: 1.7; }
.badge-in, .badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-out, .badge-info { background: var(--brand-soft); color: var(--brand); }
.badge-none, .badge-archived { background: var(--line-soft); color: var(--ink-3); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-void { background: var(--err-soft); color: var(--err); text-decoration: line-through; }
.type-chip { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line); font-weight: 700; font-size: 12.5px; color: var(--ink-2); background: var(--surface); }
.cert-dot { font-size: 11px; font-weight: 700; color: var(--brand); border: 1px solid var(--brand-line); border-radius: 4px; padding: 0 5px; margin-left: 4px; white-space: nowrap; }
.chips, .chips-list { display: flex; gap: 6px; flex-wrap: wrap; }
.chips-list { list-style: none; padding: 0; margin: 10px 0 0; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; }
li.chip { cursor: default; font-family: var(--mono); font-size: 12.5px; }
.chip:hover { border-color: var(--brand-line); color: var(--ink); }

/* ------------------------------------------------------------ buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; font-size: 14.5px; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-soft); border-color: transparent; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger-text { color: var(--err); }
.btn-icon { width: 40px; padding: 0; }
.btn-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn-wide { width: 100%; }
.btn-in, .btn-out { min-height: 56px; font-size: 17px; font-weight: 700; color: #fff; border: 0; }
.btn-in { background: var(--in); } .btn-out { background: var(--out); }
.btn-in:hover, .btn-out:hover { filter: brightness(.93); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input, select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 11px; min-height: 40px; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[disabled] { background: var(--line-soft); color: var(--ink-3); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
input[type=file] { padding: 7px; font-size: 13.5px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline > span { white-space: nowrap; }
.field.inline input { width: auto; }
.tick { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.input-with { display: flex; gap: 6px; }
.input-with select { width: 90px; flex: none; }
.stepper { display: flex; }
.stepper button { width: 44px; border: 1px solid var(--line); background: var(--paper); font-size: 20px; cursor: pointer; color: var(--ink); }
.stepper button:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.stepper button:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.stepper input { border-radius: 0; text-align: center; font-weight: 700; font-size: 18px; border-left: 0; border-right: 0; -moz-appearance: textfield; }

/* the scan field — the most-used control in the app */
.scan { position: relative; display: flex; gap: 8px; align-items: center; }
.scan input {
  min-height: 52px; padding-left: 46px; font-size: 17px; font-family: var(--mono); letter-spacing: .02em;
  border: 2px solid var(--brand-line); border-radius: var(--r);
}
.scan input:focus { border-color: var(--brand); }
.scan-ico { position: absolute; left: 14px; width: 22px; height: 22px; fill: none; stroke: var(--brand); stroke-width: 1.7; stroke-linecap: round; pointer-events: none; }
.scan .btn-icon { width: 52px; min-height: 52px; border-radius: var(--r); background: var(--brand); border-color: var(--brand); color: var(--brand-ink); flex: none; }

.seg { display: inline-flex; background: var(--line-soft); border-radius: var(--r-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 13px; border-radius: 5px; font: inherit; font-size: 14px; color: var(--ink-2); cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.seg-big { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin-bottom: 16px; padding: 4px; }
.seg-big button { padding: 10px 12px; display: flex; flex-direction: column; font-size: 16px; font-weight: 700; text-align: left; }
.seg-big button small { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.seg-big button.on { background: var(--brand); color: var(--brand-ink); }
.seg-big button.on small { color: inherit; opacity: .8; }
.seg-small button { padding: 3px 10px; font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .scan { flex: 1 1 320px; }
.toolbar > input[type=search], .toolbar > input:not([type]) { flex: 1 1 220px; width: auto; }
.toolbar > select, .toolbar > input[type=date] { width: auto; }

.notice { padding: 10px 14px; border-radius: var(--r-sm); background: var(--brand-soft); margin-bottom: 14px; font-size: 14px; }
.notice-err { background: var(--err-soft); color: var(--err); }
.notice-ok { background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.notice a { margin-right: 6px; }

/* ------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
.table th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table th.num, .table td.num { text-align: right; }
.table.rows { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; border-collapse: separate; border-spacing: 0; }
.table.rows tbody tr { cursor: pointer; }
.table.rows tbody tr:hover { background: #f8f9f8; }
.table.rows tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 7px 10px; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; }
.table .desc { max-width: 340px; }
.row-end { text-align: right; white-space: nowrap; }
tr.is-void td { color: var(--ink-3); }
tr.is-void td b { text-decoration: line-through; }
.nowrap td, .nowrap th { white-space: nowrap; }
.scroll-x { overflow-x: auto; }
.table input.qty { width: 72px; text-align: right; }
.table input.price { width: 120px; text-align: right; }

/* ------------------------------------------------------------ item & stock */
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.item-head h1 { font-family: var(--display); font-size: 26px; margin: 2px 0 6px; }
.sku-big { font-size: 15px; color: var(--ink-3); }
.stock-grid { align-items: start; }
.stock-item { margin: 14px 0; }
.item-card { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--r); background: var(--brand-soft); }
.onhand { text-align: center; display: flex; flex-direction: column; }
.onhand b { font-size: 34px; line-height: 1; color: var(--brand); }
.onhand small { color: var(--ink-2); }
#stock-form { margin-top: 8px; }

.sell-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.sell-side { position: sticky; top: 20px; }
#cart { margin-top: 14px; }
.totals { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; }
.total-line b { font-size: 28px; font-variant-numeric: tabular-nums; }
.fx-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); flex-wrap: wrap; }
.fx-in { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fx-in input { width: 96px; min-height: 32px; padding: 4px 8px; text-align: right; }
.fx-out { font-size: 14px; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty h2 { font-size: 18px; margin-bottom: 6px; color: var(--ink); }
.empty .btn { margin-top: 14px; }
.empty-small { padding: 28px 12px; border: 1px dashed var(--line); border-radius: var(--r); }

/* ------------------------------------------------------------ tasks */
.upload-panel { padding: 0; }
.upload { display: flex; gap: 14px; align-items: center; padding: 20px; cursor: pointer; border-radius: var(--r-lg); }
.upload:hover { background: var(--brand-soft); }
.upload svg { width: 36px; height: 36px; fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.upload span { display: flex; flex-direction: column; }
.upload small { color: var(--ink-3); }
#ai-status { padding: 0 20px 16px; }
.task-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 12px 12px 14px; }
.task.done { opacity: .62; }
.task .check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--brand-line); background: var(--surface); cursor: pointer; flex: none; margin-top: 1px; color: #fff; font-weight: 700; }
.task.done .check { background: var(--ok); border-color: var(--ok); }
.task-who { font-size: 14px; }
.task-text { margin-top: 2px; }
.task-edit { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.task-edit .row { display: flex; gap: 8px; }

/* ------------------------------------------------------------ sheet, toast, camera */
.sheet-wrap { position: fixed; inset: 0; background: rgb(20 28 34 / .45); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
.sheet { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; animation: rise .18s ease-out; }
.sheet-wide { width: min(820px, 100%); }
.sheet-title { font-size: 19px; margin-bottom: 8px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet .muted { margin-bottom: 14px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.viewer { background: var(--paper); border-radius: var(--r); display: grid; place-items: center; min-height: 320px; overflow: hidden; }
.viewer img { max-width: 100%; max-height: 70vh; }
.viewer iframe { width: 100%; height: 70vh; border: 0; }
.more-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.more-nav a { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); font-weight: 500; }
.account-sheet { display: flex; flex-direction: column; gap: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

.toasts { position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100% - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r); font-size: 14.5px; box-shadow: var(--shadow); animation: rise .18s ease-out; transition: opacity .3s; }
.toast-err { background: var(--err); }
.toast.out { opacity: 0; }

.camera { position: fixed; inset: 0; z-index: 70; background: rgb(20 28 34 / .9); display: grid; place-items: center; padding: 16px; transition: background .2s; }
.camera.flash { background: rgb(44 122 87 / .92); }
.camera-box { width: min(440px, 100%); background: var(--surface); border-radius: var(--r-lg); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
#camera-reader { border-radius: var(--r); overflow: hidden; }
#camera-hint { text-align: center; color: var(--ink-2); font-size: 14px; }

/* ------------------------------------------------------------ login */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: var(--taupe); }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: var(--r-lg); padding: 32px 28px 22px; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; }
.login-logo { width: 150px; height: auto; margin: 6px auto 0; }
.login-card h1 { font-family: var(--serif); font-size: 14px; font-weight: 500; color: var(--ink-2); }
.login-card .seg { align-self: center; }

/* ------------------------------------------------------------ printed documents (the paper) */
.paper {
  position: relative; background: #fff; color: #111; width: 100%; max-width: 820px; margin: 0 auto 40px;
  padding: 44px 48px; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12.5px; line-height: 1.55;
}
.paper-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 14px; }
.paper-title h1 { font-family: var(--serif); font-size: 30px; letter-spacing: .35em; font-weight: 700; }
.paper-title p { font-size: 11px; letter-spacing: .2em; color: #555; margin-top: 2px; }
.paper-meta { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0; font-size: 12px; }
.paper-meta dt { color: #555; }
.paper-meta dd { margin: 0; text-align: right; font-weight: 700; }
.paper-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 22px 0 18px; }
.to-name { font-family: var(--serif); font-size: 19px; font-weight: 700; border-bottom: 1px solid #111; padding-bottom: 4px; margin-bottom: 8px; }
.to-name span { font-size: 15px; margin-left: 8px; }
.from { position: relative; text-align: right; padding-right: 74px; }
.paper-logo { max-height: 58px; max-width: 140px; margin-bottom: 8px; }
.from-name { font-family: var(--serif); font-size: 15px; font-weight: 700; }
.paper .small { font-size: 11.5px; color: #333; }
.seal { position: absolute; right: 0; top: 4px; width: 60px; height: 60px; border: 1.5px solid var(--seal); color: var(--seal); display: grid; place-items: center; font-family: var(--serif); font-size: 13px; opacity: .55; }
.paper-total { display: flex; justify-content: space-between; align-items: baseline; border: 1.5px solid #111; padding: 10px 14px; margin-bottom: 14px; width: 62%; }
.paper-total span { font-size: 12px; }
.paper-total b { font-size: 22px; font-variant-numeric: tabular-nums; }
.paper-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.paper-table th { background: #f1f2f1; border: 1px solid #999; padding: 5px 6px; font-weight: 700; text-align: left; white-space: nowrap; }
.paper-table td { border: 1px solid #bbb; padding: 5px 6px; vertical-align: top; }
.paper-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.paper-table tfoot td { font-weight: 700; background: #f7f7f7; }
.paper-fx, .paper-notes { margin-top: 10px; font-size: 11.5px; color: #333; }
.paper-foot { margin-top: 26px; display: grid; grid-template-columns: 1fr; gap: 16px; border-top: 1px solid #999; padding-top: 12px; }
.paper-foot h3 { font-size: 12px; margin-bottom: 4px; }
.sign { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-top: 18px; }
.sign div { border-bottom: 1px solid #111; height: 46px; display: flex; align-items: flex-end; }
.sign span { font-size: 10.5px; color: #555; transform: translateY(18px); }
.void-stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); border: 4px solid var(--err); color: var(--err); font-size: 48px; font-weight: 700; padding: 6px 28px; opacity: .45; letter-spacing: .1em; pointer-events: none; }

/* ------------------------------------------------------------ mobile */
.tabbar { display: none; }
@media (max-width: 900px) {
  body.signed-in { display: block; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .rail { display: none; }
  .view { padding: 18px 16px 40px; }
  .page-head h1 { font-size: 23px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--ink-3); background: none; border: 0; font-family: inherit; padding: 6px 0; cursor: pointer; text-decoration: none !important; }
  .tab.active { color: var(--brand); font-weight: 700; }
  .tab-scan { justify-self: center; width: 58px; height: 58px; margin-top: -22px; border-radius: 50%; border: 4px solid var(--paper); background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); }
  .tab-scan svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .toasts { bottom: calc(var(--tabbar) + 16px); }
  .grid-2, .sell-grid { grid-template-columns: 1fr; }
  .sell-side { position: static; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat > b { font-size: 21px; }
  .form { grid-template-columns: 1fr; }
  .sheet-wrap { place-items: end stretch; padding: 0; }
  .sheet, .sheet-wide { width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }

  /* list tables become cards: SKU + status on top, main text full width, figures below */
  .table.rows, .table.cart { border: 0; background: none; }
  .table.rows thead, .table.cart thead { display: none; }
  .table.rows tbody, .table.cart tbody { display: flex; flex-direction: column; gap: 8px; }
  .table.rows tr, .table.cart tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
  .table.rows td, .table.cart td { border: 0; padding: 0; display: flex; gap: 6px; align-items: baseline; text-align: left; order: 3; }
  .table.rows td[data-label]::before, .table.cart td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: 12px; font-family: var(--sans); font-weight: 400; }
  .table.rows td:first-child, .table.cart td:first-child { order: 0; flex: 1 1 auto; }
  .table.rows td:first-child::before, .table.cart td:first-child::before, .table.rows td.desc::before { display: none; }
  .table.rows .row-end, .table.cart .row-end { order: 1; }
  .table.rows td.desc { order: 2; flex: 1 1 100%; font-size: 15px; font-weight: 500; display: block; }
  .table.rows td.desc .block { font-weight: 400; }
  .table .desc { max-width: none; }
  .table.cart td:first-child { flex-direction: column; gap: 0; }
  .paper { padding: 22px 16px; }
  .paper-head { flex-direction: column; gap: 10px; }
  .paper-title h1 { font-size: 24px; letter-spacing: .2em; }
  .paper-meta dd { white-space: nowrap; }
  .paper-parties { grid-template-columns: 1fr; }
  .paper-total { width: 100%; }
  .paper-table { font-size: 10.5px; }
  .paper .scroll, .paper-table { display: block; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------ print */
@page { size: A4; margin: 12mm; }
@media print {
  body { background: #fff; display: block !important; padding: 0 !important; }
  .rail, .tabbar, .no-print, .toasts, .sheet-wrap, .camera { display: none !important; }
  .view { padding: 0; max-width: none; }
  .paper { border: 0; box-shadow: none; padding: 0; max-width: none; margin: 0; }
  .paper-table { display: table; }
  .paper-table tr { break-inside: avoid; }
}

/* review fixes */
.panel-head select { width: auto; min-height: 34px; padding: 4px 30px 4px 10px; }
.scan input::placeholder { font-family: var(--sans); letter-spacing: 0; font-size: 15px; color: var(--ink-3); }
.table.compact .mono { white-space: nowrap; }
