
:root {
  --font-sans: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic",
    "Yu Gothic UI", "Meiryo", "Noto Sans JP", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", "BIZ UDGothic", monospace;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2227;
  --muted: #59626d;
  --border: #dde2e8;
  --border-strong: #c3cad3;
  --accent: #1f5fbf;
  --accent-hover: #194f9f;
  --accent-soft: #e8f0fc;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warning: #8a5a00;
  --warning-soft: #fff4d6;
  --success: #1a7f37;
  --success-soft: #e6f4ea;
  --radius: 6px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);
  color-scheme: light;
  text-spacing-trim: trim-start;
  text-autospace: normal;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #181c21;
    --text: #e4e8ec;
    --muted: #9ba5b1;
    --border: #2b323a;
    --border-strong: #3d4651;
    --accent: #6ea2f5;
    --accent-hover: #8db6f7;
    --accent-soft: #1b2a40;
    --on-accent: #0e1520;
    --danger: #f28b82;
    --danger-soft: #3a1d1b;
    --warning: #f2c14e;
    --warning-soft: #352a12;
    --success: #6fcf8a;
    --success-soft: #16301f;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans);
  font-size: 14px; line-height: 1.6; line-break: strict; overflow-wrap: anywhere;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius); }
h1, h2, h3 { font-feature-settings: "palt"; word-break: auto-phrase; text-wrap: balance; margin: 0; }
h1 { font-size: 22px; line-height: 1.35; }
h2 { font-size: 17px; line-height: 1.4; }
h3 { font-size: 15px; line-height: 1.4; }
p { margin: 0; text-wrap: pretty; }
code, .mono { font-family: var(--font-mono); font-size: 13px; }
code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
pre { margin: 0; overflow-x: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
pre code { border: 0; padding: 0; background: none; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; }

/* 骨組み: PC は左サイドバー、狭い画面は上部 */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 16px; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px; color: var(--text); text-decoration: none; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: block; padding: 8px 10px; border-radius: var(--radius); color: var(--text); text-decoration: none; min-height: 36px; }
.nav a:hover { background: var(--bg); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav { order: 1; }
.sidebar .logout { order: 2; margin-top: auto; }
@media (min-width: 861px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
main { padding: 24px 32px 48px; max-width: 1180px; width: 100%; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 12px; gap: 8px; }
  .sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 6px 10px; min-height: 44px; display: inline-flex; align-items: center; }
  .sidebar .logout { margin-top: 0; }
  main { padding: 16px 16px 40px; }
}
@media (min-width: 861px) { .sidebar-top { display: contents; } }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { color: var(--muted); margin-top: 4px; max-inline-size: 48em; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.stack > * + * { margin-top: 12px; }
.section-tight { margin-top: 8px; }
.panel.stack > * + * { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; font-feature-settings: "palt"; line-height: 1.4; white-space: nowrap;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--bg); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-danger:hover { filter: brightness(0.95); background: var(--danger); color: var(--surface); }
.btn-link { border: 0; background: none; color: var(--accent); padding: 6px 4px; font-weight: 400; }
.btn-link:hover { background: none; text-decoration: underline; color: var(--accent-hover); }
.btn-link.danger { color: var(--danger); }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.6; cursor: progress; }
@media (max-width: 860px) { .btn { min-height: 44px; } }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 帯・札 */
.banner { border-radius: var(--radius); padding: 10px 14px; border: 1px solid; margin-bottom: 16px; }
.banner strong { display: block; }
.banner-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.banner-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.banner-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.6; white-space: nowrap; border: 1px solid transparent; font-feature-settings: "palt"; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--success); background: var(--success-soft); }
.badge-warn { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-neutral { color: var(--muted); background: var(--bg); border-color: var(--border); }

/* 数値の要点（カードにせず 1 枚のパネルに並べる） */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.figure { padding: 14px 16px; border-left: 1px solid var(--border); }
.figure:first-child { border-left: 0; }
.figure dt { color: var(--muted); font-size: 13px; }
.figure dd { margin: 2px 0 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.35; }
.figure dd small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
@media (max-width: 600px) { .figure { border-left: 0; border-top: 1px solid var(--border); } .figure:first-child { border-top: 0; } }

/* 表 */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; line-height: 1.5; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--bg); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
meter { width: 88px; height: 8px; vertical-align: middle; margin-right: 6px; }
@media (max-width: 720px) {
  table.responsive thead { display: none; }
  table.responsive tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  table.responsive tbody tr:last-child { border-bottom: 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  table.responsive td > .cell { display: block; text-align: right; }
  table.responsive td.primary { display: block; text-align: left; font-weight: 700; padding-bottom: 6px; }
  table.responsive td.primary::before { content: none; }
}

/* 空の状態 */
.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 28px 20px; text-align: center; }
.empty h2 { font-size: 16px; }
.empty p { color: var(--muted); margin: 6px auto 14px; max-inline-size: 36em; }

/* はじめにの手順 */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { counter-increment: step; content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--bg); border: 1px solid var(--border-strong); }
.steps li.done::before { content: "✓"; background: var(--success-soft); color: var(--success); border-color: transparent; }
.steps li p { color: var(--muted); font-size: 13px; }
@media (max-width: 600px) { .steps li { grid-template-columns: 28px minmax(0, 1fr); } .steps li > :last-child { grid-column: 2; } }

/* フォーム */
.form { max-width: 560px; }
.field { margin-bottom: 18px; }
.field > label, .field > .label { display: block; font-weight: 700; margin-bottom: 4px; }
.field .hint { color: var(--muted); font-size: 12px; margin-bottom: 6px; line-height: 1.5; }
.field .error { color: var(--danger); font-size: 13px; margin-top: 4px; font-weight: 700; }
.optional { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 7px 10px; min-height: 40px; width: 100%; max-width: 100%;
}
input.short { width: 12em; }
input.mid { width: 20em; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
input::placeholder { color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; min-height: 36px; }
.check input { width: 18px; height: 18px; }
.readonly { padding: 7px 0; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 24px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
dl.props { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

/* ログイン */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: 100%; max-width: 400px; padding: 24px; }
.login h1 { margin-bottom: 6px; }
.login p.muted { margin-bottom: 20px; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a { transition: background-color 150ms ease, border-color 150ms ease; }
}
