:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #16202c;
  --muted: #5b6573;
  --line: #d6dbe3;
  --brand: #1f3a5f;
  --brand-ink: #ffffff;
  --ok: #1b7a3d;
  --ok-bg: #e7f5ec;
  --bad: #b00020;
  --bad-bg: #fdecef;
  --busy: #8a5a00;
  --tap: 48px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0 0 8px; }
h2 { font-size: 18px; }
h2 small { font-weight: 400; color: var(--muted); font-size: 14px; }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
.loading { color: var(--muted); }

.topbar { position: sticky; top: 0; z-index: 10; background: var(--brand); color: var(--brand-ink); padding: 8px 16px calc(8px); }
.topbar-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; max-width: 640px; margin: 0 auto; }
.topbar-row.sub { margin-top: 4px; font-size: 13px; }
.store { font-size: 13px; opacity: .9; }
.bizdate { font-size: 18px; font-weight: 700; }
.chip { background: rgba(255,255,255,.18); border-radius: 999px; padding: 2px 10px; }
.chip:empty { display: none; }
.chip.done { background: #ffffff; color: var(--ok); font-weight: 700; }
.save-state { font-weight: 700; }
.save-state.ok { color: #b9f3cc; }
.save-state.busy { color: #ffe08a; }
.save-state.bad { color: #ffd0d8; background: var(--bad); padding: 2px 8px; border-radius: 6px; }

.section { margin: 20px 0; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.card-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.card-head select { flex: 1; }
.idx { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 14px; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 4px; }
.money-field { display: block; }
.money-field .lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.money-field.required .lbl::after { content: ' *'; color: var(--bad); }
.money-wrap { display: flex; align-items: center; gap: 4px; }
.money-wrap .yen { color: var(--muted); font-size: 14px; }
input, select, textarea {
  font: inherit; font-size: 17px; width: 100%; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink);
}
input.money { text-align: right; font-variant-numeric: tabular-nums; min-width: 0; }
input.invalid { border-color: var(--bad); background: var(--bad-bg); }
textarea { min-height: 80px; }
.field-error { display: block; color: var(--bad); font-size: 12px; min-height: 0; }
.field-error:empty { display: none; }
.payout { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted); }
.payout b { color: var(--ink); font-size: 17px; }
.row-card input[type=text]:not(.money) { margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.add { border-style: dashed; color: var(--brand); }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.small { min-height: 36px; padding: 0 10px; font-size: 14px; }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.5); }
.btn.icon { width: var(--tap); padding: 0; font-size: 22px; flex: none; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.btn-row.wrap { flex-wrap: wrap; justify-content: flex-start; }

.sum-list { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.sum-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #eef0f3; }
.sum-list > div:last-child { border-bottom: none; }
.sum-list dt { color: var(--muted); }
.sum-list dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.neg dd, .neg b { color: var(--bad); }

.totals-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
}
.totals-bar div { display: flex; flex-direction: column; align-items: center; }
.totals-bar span { font-size: 11px; color: var(--muted); }
.totals-bar b { font-size: 16px; font-variant-numeric: tabular-nums; }
.totals-bar .neg b { color: var(--bad); }

.notice { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.notice p { margin: 4px 0; }
.notice.ok { background: var(--ok-bg); border-color: #b4dfc3; }
.notice.bad { background: var(--bad-bg); border-color: #f2b8c3; }
.notice ul { margin: 6px 0; padding-left: 20px; }
.error { color: var(--bad); font-weight: 700; }
.operator { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; background: #fff7e0; border: 1px solid #f0d78c; border-radius: 10px; font-size: 14px; }
.operator.mine { background: var(--ok-bg); border-color: #b4dfc3; }
.handovers { font-size: 13px; color: var(--muted); margin: 6px 0; }
.diff { display: grid; grid-template-columns: 1fr; gap: 8px; font-size: 13px; }
.diff h3 { font-size: 13px; margin: 6px 0 2px; }
#conflict-box { scroll-margin-top: 110px; }
.btn-col { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.btn-col .btn { min-height: var(--tap); height: auto; padding: 10px 12px; }
.confirm-area { margin: 24px 0 8px; }

.ro-head { display: flex; justify-content: space-between; gap: 8px; }
.ro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-size: 14px; margin-top: 6px; }
.image-actions { margin: 12px 0; }
.ro-details { margin: 16px 0; }
.ro-details > summary { cursor: pointer; padding: 12px 0; font-weight: 700; color: var(--brand); }
.image-area { margin: 12px 0; }
.save-tip { background: #fff7e0; border-color: #f0d78c; font-size: 17px; }
.report-img { -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 12px; background: #fff; }

dialog { border: none; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg { padding: 16px; }
.block-label { display: block; margin-top: 12px; font-weight: 700; color: var(--bad); }

.login-page { padding-bottom: 0; display: grid; min-height: 100vh; place-items: center; }
.login-box { width: min(380px, calc(100vw - 32px)); background: #fff; border-radius: 16px; padding: 24px; border: 1px solid var(--line); }
.login-box label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.count-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 8px; }
.count-field { display: block; }
.count-field .lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
select.count { font-size: 18px; text-align: center; }
.count-error { grid-column: 1 / -1; }
select.count.unset { color: var(--muted); background: #fff7e0; }

/* 見出しの横に並べるボタン（日報とシフトの切り替えなど） */
.inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* hidden 属性の要素は、ボタンの display 指定より優先して隠す（公開前のシフトのボタンなど） */
[hidden] { display: none !important; }
