:root {
  --bg: #f5f6f8;
  --panel: #fff;
  --text: #1f2430;
  --muted: #667085;
  --line: #d9dde5;
  --accent: #1f5fbf;
  --out: #c62828;
  --low: #b26a00;
  --ok: #2e7d32;
  --un: #5e6ad2;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif; }
header { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; }
nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
nav a.on { background: var(--accent); color: #fff; }
.who { color: var(--muted); font-size: 13px; }
main { padding: 16px; max-width: 1280px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 14px; overflow-x: auto; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.card .n { font-size: 26px; font-weight: 700; }
.card .l { color: var(--muted); font-size: 13px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
input, select, textarea, button { font: inherit; }
input, select, textarea { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); min-width: 0; }
textarea { min-height: 60px; }
input.num { width: 90px; text-align: right; }
button { padding: 6px 14px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
button.sub { background: #fff; color: var(--accent); }
button.danger { background: #fff; color: var(--out); border-color: var(--out); }
button.link { background: none; border: none; color: var(--accent); padding: 0 4px; text-decoration: underline; }
button.small { padding: 2px 8px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #eef1f6; position: sticky; top: 0; font-weight: 600; }
td.r, th.r { text-align: right; }
td.wrap { white-space: normal; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f0f5ff; }
.badge { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; color: #fff; }
.badge.out { background: var(--out); }
.badge.low { background: var(--low); }
.badge.ok { background: var(--ok); }
.badge.uncounted { background: var(--un); }
.badge.check { background: var(--low); }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin: 4px 0; }
.err { color: var(--out); }
.diff { color: var(--out); font-weight: 700; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.tabs button { background: #fff; color: var(--text); border-color: var(--line); }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.preview { padding: 8px 10px; border: 1px dashed var(--line); border-radius: 6px; min-height: 38px; font-size: 14px; }
.login { max-width: 360px; margin: 8vh auto; }
.login .panel { display: flex; flex-direction: column; gap: 10px; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 18px; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog form { display: flex; flex-direction: column; gap: 10px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: .95; }
#toast.bad { background: var(--out); }
.bar { display: inline-block; height: 10px; background: var(--accent); border-radius: 2px; vertical-align: middle; }
.scroll { max-height: 70vh; overflow: auto; }
@media print {
  header, .noprint, #toast { display: none !important; }
  .panel { border: none; padding: 0; }
  .scroll { max-height: none; overflow: visible; }
}
