/*
 * tomovoice 画面の見た目（SPEC §1-3・§1-4）。
 * 色: オレンジ #EA5504（ブランド・主ボタン・選択中・リンク）／墨 #252525（文字）／グレー（面 #F5F5F4・線 #E7E5E4・補助 #78716C）／
 *     赤 #B91C1C（期限超過・エラーだけ）／緑 #15803D（入金済みの印だけ）。
 *     #EA5504 は白地で 3.6:1 しかなく §1-3 の文字 4.5:1 に届かないため、オレンジの「文字」と「白文字を載せる地」は
 *     同じ色相を暗くした --orange-ink（#BF4503。白で 5.2:1・面で 4.7:1）を使う。#EA5504 は文字以外（ロゴ・グラフ・選択中の印・フォーカス枠）。
 * 文字: Noto Sans JP。大きさは 3 段（見出し 20px/700・本文 14px/400・補助 12px/400）。数字は等幅（tabular-nums）。
 * 動き: ダイアログとトーストだけ（JS の WAAPI。ui/motion.js）。ここでは transition を使わない。
 * CSP（§4-5）のため、HTML の style 属性は使わない。値の変わるもの（棒の長さなど）は JS が CSSOM で入れる。
 */

:root {
  --orange: #ea5504;
  --orange-ink: #bf4503;
  --orange-ink-strong: #a03a03;
  --ink: #252525;
  --ink-2: #57534e;         /* 補助文字（灰の面の上） */
  --muted: #78716c;         /* 補助文字（白の上だけ。面の上では 4.4:1 なので --ink-2） */
  --surface: #f5f5f4;       /* 面 */
  --surface-2: #fafaf9;     /* 行ホバー */
  --line: #e7e5e4;          /* 線 */
  --line-strong: #8f8984;   /* 入力欄の枠（白で 3.4:1。§1-3 の「部品の境界」） */
  --red: #b91c1c;
  --green: #15803d;
  --white: #ffffff;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(37, 37, 37, 0.06);
  --shadow-pop: 0 12px 32px rgba(37, 37, 37, 0.18);
  --fs-h: 20px;
  --fs-body: 14px;
  --fs-sub: 12px;
  --header-h: 56px;
  --gutter: 24px;
  --font: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

/* ───────── 土台 ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; }
.icon { flex: none; }
.icon--faint { opacity: 0.45; }
.icon--flip { transform: scaleX(-1); }
a { color: var(--orange-ink); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--orange-ink-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sub); }
.al-left { text-align: left; }
.al-right { text-align: right; }
.al-center { text-align: center; }
.text-alert { color: var(--red); }
.text-ok { color: var(--green); }
.noscript { padding: 24px; }

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  padding: 8px 12px; border: 1px solid var(--ink); border-radius: var(--radius-sm);
  background: var(--white); color: var(--ink); cursor: pointer;
}
.skip-link:focus-visible { top: 8px; }

/* ───────── ヘッダー ───────── */
.header {
  position: sticky; top: 0; z-index: 30;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
body.is-login .header { display: none; }
.header__inner {
  display: flex; align-items: center; gap: 16px;
  max-width: 1440px; height: var(--header-h); margin: 0 auto; padding: 0 var(--gutter);
}
.brand { display: flex; align-items: center; flex: none; border-radius: var(--radius-sm); }
.brand__img { height: 32px; width: auto; }
.mock-chip {
  flex: none; padding: 1px 8px; border: 1px dashed var(--line-strong); border-radius: 4px;
  color: var(--ink-2); font-size: var(--fs-sub); white-space: nowrap;
}
.header .menu-btn { display: none; margin-left: auto; }
.header__panel { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.nav { display: flex; align-items: stretch; gap: 2px; flex: 1; min-width: 0; height: var(--header-h); }
.nav__link {
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px; color: var(--ink); text-decoration: none; white-space: nowrap;
  box-shadow: inset 0 -2px 0 transparent;
}
.nav__link:hover { color: var(--ink); background: var(--surface-2); }
.nav__link[aria-current="page"] { font-weight: 700; box-shadow: inset 0 -2px 0 var(--orange); }
.nav__link[aria-current="page"] .nav__icon { color: var(--orange); }
.nav__link:focus-visible { outline-offset: -2px; }
.user { display: flex; align-items: center; gap: 8px; flex: none; }
.user__label { color: var(--ink-2); white-space: nowrap; }
.user__name { color: var(--ink); font-weight: 700; }

@media (max-width: 1100px) {
  .nav__icon { display: none; }
  .nav__link { padding: 0 10px; }
}
@media (max-width: 860px) {
  .header__inner { padding: 0 16px; gap: 12px; position: relative; }
  .brand__img { height: 28px; }
  .header .menu-btn { display: inline-flex; }
  .header__panel {
    display: none;
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--white); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-pop);
    padding: 8px 0 12px;
  }
  .header__panel.is-open { display: flex; }
  .nav { flex-direction: column; height: auto; }
  .nav__link { padding: 12px 16px; box-shadow: inset 3px 0 0 transparent; }
  .nav__icon { display: block; }
  .nav__link[aria-current="page"] { box-shadow: inset 3px 0 0 var(--orange); }
  .user { padding: 12px 16px 0; border-top: 1px solid var(--line); margin-top: 8px; justify-content: space-between; }
}

/* ───────── エラーの帯（§2-0） ───────── */
.banner { background: var(--red); color: var(--white); }
.banner__inner { display: flex; align-items: flex-start; gap: 12px; max-width: 1440px; margin: 0 auto; padding: 12px var(--gutter); }
.banner__inner > .icon { margin-top: 1px; }
.banner__text { flex: 1; min-width: 0; }
.banner__msg { font-weight: 700; }
.banner__list { margin-top: 4px; padding-left: 1.2em; list-style: disc; }
.banner__id { margin-top: 4px; font-size: var(--fs-sub); }
.banner__close {
  display: inline-flex; padding: 4px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--white); cursor: pointer;
}
.banner__close:hover { background: rgba(255, 255, 255, 0.15); }
.banner :focus-visible { outline-color: var(--white); }

/* ───────── 本体・ページ ───────── */
.main { display: block; max-width: 1440px; margin: 0 auto; padding: 24px var(--gutter) 64px; }
.main:focus-visible { outline: none; }
.view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head__main { min-width: 0; }
.page-head__back { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; margin-bottom: 0; font-size: var(--fs-sub); }
.page-title { font-size: var(--fs-h); font-weight: 700; line-height: 1.4; }
.page-title:focus-visible { outline: none; }
.page-sub { margin-top: 2px; color: var(--ink-2); font-size: var(--fs-sub); }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px 0;
}
.card__titles { min-width: 0; }
.card__title { font-size: var(--fs-body); font-weight: 700; line-height: 1.5; }
.card__sub { color: var(--muted); font-size: var(--fs-sub); }
.card__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card__body { padding: 14px 20px 18px; min-width: 0; }

/* ───────── ボタン ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--white); color: var(--ink);
  font-size: var(--fs-body); line-height: 1.2; white-space: nowrap; text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface); color: var(--ink); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn--primary { border-color: var(--orange-ink); background: var(--orange-ink); color: var(--white); font-weight: 700; }
.btn--primary:hover { border-color: var(--orange-ink-strong); background: var(--orange-ink-strong); color: var(--white); }
.btn--danger { border-color: var(--red); color: var(--red); }
.btn--danger:hover { background: var(--red); color: var(--white); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface); }
.btn--sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-sub); }
.btn--icon { min-width: 36px; padding: 0 6px; }
.btn[aria-busy="true"] { cursor: progress; }
.link-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none;
  color: var(--orange-ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.link-btn:hover { color: var(--orange-ink-strong); }
/* 押せる部品は 24px 四方以上（WCAG 2.2 の 2.5.8。T-37） */
.link-btn.small { min-height: 28px; }

/* ───────── 入力 ───────── */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .field--wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.form-actions__note { color: var(--muted); font-size: var(--fs-sub); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field__label { font-size: var(--fs-sub); font-weight: 700; color: var(--ink); }
.field__req { margin-left: 6px; color: var(--red); font-weight: 400; }
.field__hint { color: var(--muted); font-size: var(--fs-sub); }
.field__error { color: var(--red); font-size: var(--fs-sub); }
.field__ok { color: var(--ink-2); font-size: var(--fs-sub); }
.input {
  width: 100%; min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--white); color: var(--ink);
}
.input:hover { border-color: var(--ink-2); }
.input:focus-visible { outline: 2px solid var(--orange); outline-offset: 0; border-color: var(--orange); }
.input[aria-invalid="true"] { border-color: var(--red); }
.input[readonly] { background: var(--surface); }
.input--num { font-variant-numeric: tabular-nums; }
.input--short { max-width: 160px; }
.select { padding-right: 28px; }
.input-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.input-row > .input { flex: 1; min-width: 0; }
.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; min-height: 24px; }
.check__input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--orange-ink); flex: none; }
.check__hint { display: block; color: var(--muted); font-size: var(--fs-sub); }
.radio-group { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.radio-group legend { margin-bottom: 4px; padding: 0; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented__btn {
  min-height: 28px; padding: 0 10px; border: 0; border-left: 1px solid var(--line-strong);
  background: var(--white); color: var(--ink); font-size: var(--fs-sub); cursor: pointer; white-space: nowrap;
}
.segmented__btn:first-child { border-left: 0; }
.segmented__btn:hover { background: var(--surface); }
.segmented__btn[aria-pressed="true"] { background: var(--ink); color: var(--white); font-weight: 700; }
.segmented__btn:focus-visible { outline-offset: -3px; }

/* ───────── 表（§2-0） ───────── */
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border-radius: var(--radius-sm); }
.table-wrap--scroll { max-height: calc(100vh - 220px); overflow: auto; }
/* 枠の内側に描く（親の overflow:hidden・横スクロールに切られないように。T-48） */
.table-wrap:focus-visible { outline-offset: -2px; }
.table-wrap .btn:focus-visible { outline-offset: -2px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-body); }
.table th, .table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface); color: var(--ink-2); font-size: var(--fs-sub); font-weight: 700; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-link { cursor: pointer; }
/* 行全体を押せる表は、ホバーが見えるように面の色にする（--surface-2 は白と 1.04:1 でほぼ見えない。T-44） */
/* 面の上では --muted が 4.4:1 になるので、ホバー中の行の中の補助文字（--muted を使うもの）は --ink-2 にする（4.5:1 以上。§1-3） */
.table tbody tr.is-link:hover { background: var(--surface); --muted: var(--ink-2); }
.table tbody th { font-weight: 400; text-align: left; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-bottom: 0; }
.table__empty { padding: 24px 12px; color: var(--muted); text-align: center; }
.table__empty-body { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.table--compact th, .table--compact td { padding: 6px 10px; }
.row-link { display: inline-flex; align-items: center; min-height: 28px; color: inherit; text-decoration: none; }
.row-link:hover { color: inherit; text-decoration: underline; }
/* 見出しのセル全体を押せるようにする（T-37） */
.th-sort {
  display: inline-flex; align-items: center; gap: 4px; width: 100%; min-height: 28px; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-align: inherit;
}
.al-right .th-sort { flex-direction: row; justify-content: flex-end; }
.al-center .th-sort { justify-content: center; }

/* ───────── 状態バッジ（§2-0） ───────── */
.badge {
  display: inline-flex; align-items: center; min-height: 20px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 4px;
  font-size: var(--fs-sub); line-height: 1.5; white-space: nowrap;
}
.badge--draft { border-color: var(--line-strong); color: var(--ink-2); background: var(--white); }
.badge--issued { background: var(--ink); color: var(--white); }
.badge--cancelled { border-color: var(--line); color: var(--muted); text-decoration: line-through; background: var(--white); }
.badge--unpaid { border-color: var(--ink); color: var(--ink); background: var(--white); }
.badge--partial { border-color: var(--orange); color: var(--orange-ink); background: var(--white); }
.badge--paid { background: var(--green); color: var(--white); }
.badge--overdue { background: var(--red); color: var(--white); }
.badge--legacy_unconfirmed, .badge--hold { border: 1px dashed var(--line-strong); color: var(--ink-2); background: var(--white); }
.badge--none { border-color: var(--line); color: var(--ink-2); background: var(--white); }
.badge--provisional { border: 1px dashed var(--orange); color: var(--orange-ink); background: var(--white); margin-left: 6px; }

/* ───────── お知らせ・状態 ───────── */
.notice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border: 1px solid var(--line); border-left: 3px solid var(--ink-2);
  border-radius: var(--radius-sm); background: var(--white);
}
.notice > .icon { margin-top: 1px; color: var(--ink-2); }
.notice--warn { border-left-color: var(--orange); }
.notice--warn > .icon { color: var(--orange-ink); }
.notice--error { border-left-color: var(--red); }
.notice--error > .icon { color: var(--red); }
.notice__text { flex: 1; min-width: 0; }
.notice__title { font-weight: 700; }
.notice__msg { color: var(--ink); }
.notice__action { flex: none; align-self: center; }

.state {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white);
}
.state > .icon { color: var(--ink-2); margin-top: 2px; }
.state--error > .icon { color: var(--red); }
.state__title { font-weight: 700; }
.state__msg { margin: 2px 0 12px; color: var(--ink-2); }
.state__meta { margin: -8px 0 12px; color: var(--muted); font-size: var(--fs-sub); }
.pending { display: flex; flex-direction: column; gap: 16px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 12px; color: var(--muted); text-align: center; }
.loading { display: flex; align-items: center; gap: 10px; padding: 24px 4px; color: var(--ink-2); }
.loading__bar { width: 24px; height: 2px; background: var(--orange); }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; }
.kv dt { color: var(--muted); font-size: var(--fs-sub); padding-top: 2px; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

/* ───────── ダイアログ ───────── */
.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--white); color: var(--ink); box-shadow: var(--shadow-pop);
  overflow: auto;
}
.dialog--sm { width: min(440px, calc(100vw - 32px)); }
.dialog--lg { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(37, 37, 37, 0.45); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.dialog__title { font-size: var(--fs-h); font-weight: 700; line-height: 1.4; }
.dialog__error {
  display: flex; gap: 10px; margin: 12px 20px 0; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--red); color: var(--white);
}
.dialog__error ul { padding-left: 1.2em; list-style: disc; }
.dialog__body { padding: 16px 20px; }
.dialog__message { color: var(--ink); }
.dialog__foot {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px 16px; border-top: 1px solid var(--line);
}

/* ───────── トースト ───────── */
.toast-region {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px; max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--white); box-shadow: var(--shadow-pop); pointer-events: auto;
}
.toast--success > .icon { color: var(--white); }
.toast--warn { background: var(--white); color: var(--ink); border: 1px solid var(--line); border-left: 3px solid var(--orange); }
.toast--warn > .icon { color: var(--orange-ink); }
.toast--error { background: var(--red); }
.toast__text { min-width: 0; }
/* 注意・エラーは自動で消さず、× で閉じる（T-51） */
.toast__close {
  display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 28px; min-height: 28px; margin: -4px -6px -4px 4px;
  padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: inherit; cursor: pointer;
}
.toast__close:hover { background: var(--surface); }
.toast--error .toast__close:hover { background: rgba(255, 255, 255, 0.15); }
.toast--error .toast__close:focus-visible { outline-color: var(--white); }
@media (max-width: 600px) {
  .toast-region { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
}

/* ───────── グラフ（§2-2） ───────── */
.chart { position: relative; width: 100%; min-width: 0; }
.chart__svg { width: 100%; height: auto; overflow: visible; }
.chart__line { stroke: var(--line); stroke-width: 1; }
.chart__base { stroke: var(--line-strong); stroke-width: 1; }
.chart__axis { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart__axis.is-current { fill: var(--ink); font-weight: 700; }
.chart__value { fill: var(--ink); font-size: 12px; font-weight: 700; font-family: var(--font); }
.chart__hit { fill: transparent; }
.chart__mark { fill: var(--orange); fill-opacity: 0.42; }
.chart__bar.is-current .chart__mark { fill-opacity: 1; }
.chart__bar:hover .chart__mark, .chart__bar:focus-visible .chart__mark { fill-opacity: 0.7; }
.chart__bar.is-current:hover .chart__mark, .chart__bar.is-current:focus-visible .chart__mark { fill-opacity: 1; }
.chart__bar:focus-visible { outline: none; }
.chart__bar:focus-visible .chart__hit { stroke: var(--orange); stroke-width: 2; }
.chart__tip {
  position: absolute; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--white); box-shadow: var(--shadow-pop); white-space: nowrap;
}
.chart__tip strong { font-size: var(--fs-body); }
.chart__tip span { color: var(--muted); font-size: var(--fs-sub); }
.chart-block { min-width: 0; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbars__row {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(60px, 1fr) 8.5em; align-items: center; gap: 4px 12px;
}
.hbars--ranked .hbars__row { grid-template-columns: 20px minmax(0, 1.2fr) minmax(60px, 1fr) 8.5em; }
.hbars__rank { color: var(--muted); font-size: var(--fs-sub); text-align: right; }
.hbars__label { display: flex; flex-direction: column; min-width: 0; }
.hbars__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.hbars__name { color: var(--ink); text-decoration: none; }
a.hbars__name:hover { text-decoration: underline; color: var(--ink); }
.hbars__meta { color: var(--muted); font-size: var(--fs-sub); }
.hbars__track { display: block; height: 10px; background: var(--surface); border-radius: 0 4px 4px 0; overflow: hidden; }
.hbars__fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--orange); }
.hbars__fill--muted { background: var(--line-strong); }
.hbars__fill--alert { background: var(--red); }
.hbars__value { font-weight: 700; text-align: right; }
@media (max-width: 600px) {
  .hbars__row { grid-template-columns: minmax(0, 1fr) max-content; }
  .hbars--ranked .hbars__row { grid-template-columns: 20px minmax(0, 1fr) max-content; }
  .hbars__track { grid-column: 1 / -1; grid-row: 2; }
  .hbars--ranked .hbars__track { grid-column: 2 / -1; }
}

/* ───────── ログイン（§2-1） ───────── */
body.is-login .main { display: flex; justify-content: center; padding-top: 8vh; }
.login { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 24px; }
.login__logo { width: 280px; max-width: 100%; height: auto; }
.login__card { width: 100%; }
.login__card .card__body { padding: 24px; }
.login__title { font-size: var(--fs-h); font-weight: 700; margin-bottom: 4px; }
.login__lead { color: var(--muted); margin-bottom: 16px; }
.login__staff { display: grid; grid-template-columns: 1fr; gap: 8px; }
.login__staff .btn { justify-content: flex-start; min-height: 44px; }
.login__note { color: var(--ink-2); font-size: var(--fs-sub); text-align: center; }
.login__error { color: var(--red); font-size: var(--fs-sub); }
.login__back { margin-top: 12px; }
.login__mock { color: var(--ink-2); font-size: var(--fs-sub); text-align: center; }

/* ───────── ダッシュボード（§2-2） ───────── */
.dash-meta { color: var(--ink-2); font-size: var(--fs-sub); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--white); color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
a.kpi:hover { border-color: var(--line-strong); color: var(--ink); }
.kpi__label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-2); font-size: var(--fs-sub); font-weight: 700; }
.kpi__value { font-size: var(--fs-h); font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi__count { color: var(--ink-2); font-weight: 400; font-size: var(--fs-body); margin-left: 6px; }
.kpi__meta { color: var(--muted); font-size: var(--fs-sub); }
.kpi--alert .kpi__value { color: var(--red); }
.kpi--alert { border-left: 3px solid var(--red); }
.kpi--alert.is-zero { border-left-color: var(--line); }
.kpi--alert.is-zero .kpi__value { color: var(--ink); }
.kpi__link { display: inline-flex; align-items: center; gap: 2px; min-height: 28px; align-self: flex-start; font-size: var(--fs-sub); }
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-12 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.aging-total { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: var(--fs-sub); color: var(--ink-2); }
.feed { display: flex; flex-direction: column; }
.feed-scroll { max-height: 480px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; border-radius: var(--radius-sm); }
.feed-scroll:focus-visible { outline-offset: -2px; }
.feed__item { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed__item:last-child { border-bottom: 0; }
.feed__item > .icon { margin-top: 2px; color: var(--ink-2); }
.feed__title { min-width: 0; overflow-wrap: anywhere; }
.feed__title a { color: var(--ink); text-decoration: none; }
.feed__title a:hover { text-decoration: underline; color: var(--ink); }
.feed__meta { grid-column: 2; color: var(--muted); font-size: var(--fs-sub); }
.todo { display: flex; flex-direction: column; }
.todo__item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.todo__item:last-child { border-bottom: 0; }
.todo__due { flex: none; min-width: 84px; color: var(--ink-2); font-size: var(--fs-sub); padding-top: 2px; }
.todo__due.is-late { color: var(--red); font-weight: 700; }
.todo__body { min-width: 0; }
.todo__meta { color: var(--muted); font-size: var(--fs-sub); }
.recur { display: flex; flex-direction: column; gap: 8px; }
.recur__line { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.recur__num { font-weight: 700; }
.figure-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-8, .span-6, .span-4 { grid-column: 1 / -1; }
}

/* ───────── 設定（§2-10） ───────── */
.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.tabs { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--header-h) + 16px); }
.tabs__link {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.tabs__link:hover { background: var(--white); color: var(--ink); }
.tabs__link[aria-current="page"] { background: var(--white); font-weight: 700; box-shadow: inset 3px 0 0 var(--orange); }
.tabs__link[aria-current="page"] .icon { color: var(--orange); }
.settings__panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.stat__label { color: var(--ink-2); font-size: var(--fs-sub); }
.stat__value { font-size: var(--fs-h); font-weight: 700; }
.masked { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.masked__value { font-weight: 700; letter-spacing: 0.04em; }
.conflict { display: flex; flex-direction: column; gap: 8px; }
.conflict__lead { margin-bottom: 16px; }
.conflict + .conflict { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.conflict__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.conflict__title { font-weight: 700; }
.flag-inv { display: flex; flex-direction: column; gap: 2px; min-width: 220px; }
.flag-inv__main { overflow-wrap: anywhere; }
.flag-inv__sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.lines-table .input { min-width: 80px; }
.lines-table td { padding: 4px 6px; }
.preview { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
/* 税・端数（2026-10-06 決定で固定。表示だけ） */
.tax-rule { font-size: var(--fs-h); font-weight: 700; line-height: 1.4; }
/* 品目・タグ（2026-10-06 決定） */
.tag-pill {
  display: inline-flex; align-items: center; min-height: 20px; padding: 0 8px;
  border-radius: 4px; background: var(--surface); color: var(--ink-2); font-size: var(--fs-sub); white-space: nowrap;
}
/* 狭い画面でも品名を 1〜2 字ずつに折らない（表は枠の中で横にスクロールする。§1-3） */
.prod-col-name { min-width: 11em; }
.prod__name { overflow-wrap: anywhere; }
.prod__ops { flex-wrap: nowrap; }
.prod__ops .small { white-space: nowrap; }

@media (max-width: 860px) {
  .settings { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .tabs { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .tabs__link { flex: none; }
  .tabs__link[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--orange); }
  .tabs__link .icon { display: none; }
  .tabs__link:focus-visible { outline-offset: -2px; } /* 横スクロールの枠に切られないように（T-48） */
}

/* ───────── 狭い画面（375px でもページ全体を横にスクロールさせない。§1-3） ───────── */
@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .main { padding: 16px var(--gutter) 48px; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-row { grid-template-columns: minmax(0, 1fr); }
  .card__head { padding: 12px 16px 0; }
  .card__body { padding: 12px 16px 16px; }
  .page-head__actions { width: 100%; }
  .dialog__head, .dialog__body { padding-left: 16px; padding-right: 16px; }
  .dialog__foot { padding-left: 16px; padding-right: 16px; }
  .banner__inner { padding: 12px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .header, .banner, .toast-region, .skip-link { display: none !important; }
  body { background: var(--white); }
}
