:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16202c;
  --ink-2: #3c4a5c;
  --line: #d5dbe3;
  --accent: #1d4f91;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef8;
  --warn: #9a3412;
  --warn-soft: #fdecdf;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --surface: #1a212b;
    --ink: #eef2f6;
    --ink-2: #c3ccd7;
    --line: #2f3a47;
    --accent: #6ea2e6;
    --accent-ink: #0b1420;
    --accent-soft: #1d2c40;
    --warn: #fdba74;
    --warn-soft: #3a2416;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 20px; -webkit-user-select: none; user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; -webkit-user-select: text; user-select: text; }

.top { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: none; padding: 10px 18px; font-weight: 700; color: var(--ink-2); border-bottom: 3px solid transparent; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.status { margin-left: auto; display: flex; gap: 16px; font-size: 15px; color: var(--ink-2); }

.alert { background: var(--warn-soft); color: var(--warn); font-weight: 700; padding: 12px 16px; border-bottom: 2px solid var(--warn); }

main { padding: 16px; }

/* 会計 */
.reg { display: grid; grid-template-columns: 1fr 1.1fr; gap: 20px; }
@media (max-width: 820px) { .reg { grid-template-columns: 1fr; } }
.reg-left, .reg-right { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.item-name { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.qty { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 20px; }
.qbtn { width: 110px; height: 110px; border-radius: 16px; border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent); font-size: 56px; font-weight: 700; line-height: 1; }
.qty-num { font-size: 88px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.qty-num small { font-size: 28px; margin-left: 6px; }
.line { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--line); font-size: 24px; }
.line strong { font-size: 36px; font-variant-numeric: tabular-nums; }
.line.big strong { font-size: 56px; color: var(--accent); }
.line.big.short strong, .line.big.short span { color: var(--warn); }

.money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mbtn { height: 84px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 26px; font-weight: 700; }
.mbtn:active, .qbtn:active { transform: scale(0.97); }
.mbtn.exact { grid-column: span 3; background: var(--accent-soft); border: 2px solid var(--accent); color: var(--accent); }
.mbtn.clear { grid-column: span 3; height: 60px; font-size: 20px; font-weight: 400; }
.confirm { width: 100%; height: 110px; margin-top: 16px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-size: 40px; font-weight: 800; }
.confirm:disabled { opacity: 0.35; }
.reg-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--ink-2); font-size: 18px; }
.keys { font-size: 15px; }
@media (max-width: 820px) { .keys { display: none; } }
.link { border: 0; background: none; color: var(--ink-2); text-decoration: underline; padding: 12px; }

/* 会計の結果 */
.done { position: fixed; inset: 0; background: rgb(0 0 0 / 0.55); display: flex; align-items: center; justify-content: center; z-index: 10; }
.done-box { background: var(--surface); border-radius: 20px; padding: 32px 40px; width: min(560px, 92vw); text-align: center; }
.done-no { font-size: 32px; }
.done-no strong { font-size: 120px; color: var(--accent); display: block; line-height: 1.1; font-variant-numeric: tabular-nums; }
.done-qty { font-size: 40px; font-weight: 700; margin: 8px 0; }
.done-change { font-size: 32px; }
.done-change strong { font-size: 52px; }

/* 売上・設定 */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 18px; font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.card span { color: var(--ink-2); font-size: 16px; }
.card strong { font-size: 36px; font-variant-numeric: tabular-nums; }
.card small { color: var(--ink-2); font-size: 16px; }
h2 { font-size: 20px; margin: 24px 0 8px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.note { color: var(--ink-2); font-size: 16px; }
.closings { padding-left: 20px; }
.form { display: grid; gap: 14px; max-width: 520px; }
.form label { display: grid; gap: 6px; font-size: 17px; color: var(--ink-2); }
.msg { color: var(--accent); font-weight: 700; }
.danger { margin-top: 32px; max-width: 520px; }
.danger summary { color: var(--ink-2); padding: 8px 0; }
