:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1c1f23;
  --muted: #646a73;
  --line: #e3e3df;
  --accent: #1f4e79;
  --accent-soft: #e8eef5;
  --ok: #2e6b3f;
  --warn: #8a5a00;
  --bad: #a3302a;
  --bad-soft: #fbefee;
  --radius: 6px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
h2 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.cap { text-transform: capitalize; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }

.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mark { width: 18px; height: 18px; border-radius: 4px; background: var(--accent); }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a { color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: var(--radius); }
nav a:hover { background: var(--bg); }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 0.75rem; text-align: center; }
.account { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 0.85rem; }
.notice { padding: 6px 24px; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--line); }

main { max-width: 1180px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }

.btn { font: inherit; font-size: 0.9rem; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #173d60; color: #fff; }
.btn.small { padding: 4px 10px; font-size: 0.82rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.qty { width: 70px; text-align: right; }
.row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table th.num { text-align: right; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.has-issue td { background: var(--bad-soft); }
.table tr.detail td { background: var(--bg); color: var(--muted); font-size: 0.85rem; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.strike { text-decoration: line-through; }

.stock { font-size: 0.82rem; color: var(--ok); }
.stock.low { color: var(--warn); }
.stock.out { color: var(--bad); }
.issue { color: var(--bad); font-size: 0.82rem; margin-top: 4px; }
.erp { font-size: 0.78rem; color: var(--muted); }
.erp.synced { color: var(--ok); }
.erp.retrying { color: var(--warn); }
.erp.failed { color: var(--bad); font-weight: 600; }

.usuals { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.usual { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.usual-side { display: flex; gap: 10px; align-items: center; white-space: nowrap; }

.checkout { display: grid; gap: 14px; position: sticky; top: 16px; }
.checkout label { display: grid; gap: 4px; font-size: 0.85rem; font-weight: 600; }
.checkout label select, .checkout label input { font-weight: 400; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.totals { margin: 0; display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 12px; }
.totals div { display: flex; justify-content: space-between; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; }
.totals .grand { font-weight: 700; font-size: 1.05rem; }
.totals .grand dt { color: var(--text); }
.problems { margin: 0; padding: 10px 12px 10px 28px; background: var(--bad-soft); border-radius: var(--radius); color: var(--bad); font-size: 0.85rem; }
.callout { padding: 10px 12px; background: var(--accent-soft); border-radius: var(--radius); margin-bottom: 12px; font-size: 0.9rem; }
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state p { margin: 8px 0 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; display: grid; gap: 6px; }
.stat strong { font-size: 1.8rem; font-weight: 600; }
.meter { position: relative; height: 8px; background: var(--bg); border-radius: 4px; }
.meter span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; }
.meter i { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); }
.bar-row { display: grid; grid-template-columns: 70px 1fr 90px; gap: 12px; align-items: center; padding: 6px 0; font-size: 0.9rem; }
.bar { height: 10px; background: var(--bg); border-radius: 3px; }
.bar span { display: block; height: 100%; background: #9aa5b1; border-radius: 3px; }
.bar span.on { background: var(--accent); }
.toggle { font-size: 0.85rem; display: flex; gap: 6px; align-items: center; }
.log { list-style: none; margin: 0; padding: 0; font-size: 0.82rem; display: grid; gap: 6px; }
.log time { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.log .ok { color: var(--ok); }
.log .warn { color: var(--warn); }
.log .error { color: var(--bad); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-size: 0.9rem; max-width: calc(100% - 32px); }

@media (max-width: 820px) {
  .split { grid-template-columns: 1fr; }
  .checkout { position: static; }
  main { padding: 16px; }
  .top { padding: 12px 16px; gap: 10px; }
}
