/* =====================================================================
   Amazon在庫・発注管理 — デザインシステム
   ---------------------------------------------------------------------
   骨組み・面の色・部品の作りはロイズ向けシステム（会場選定・士業リレーション管理）と同じ。
   ブランド色だけスコープテックの紺に差し替えている。
     ブランド #171047（夜空の紺。scopetown.jp の見出し・ボタンの色）
     金 #dd9933 はロゴの星にだけ使う（ほかの場所には使わない）
   使う人：50代中心・PC主体。文字は一段大きく、押す場所は 48px 以上にする。

   色の決まりごと
     - 地は生成り寄りの白（ロイズと同じ）。紺はボタン・選択中の印・番号にだけ使う
     - 色が付くのは「紺」と「状態の色（足りている・不足・注意）」だけ。
       入荷待ちなど情報の色は、別の青を足さず紺の薄い色で表す
     - カードや注意書きの端に色の線を付けない。区別は背景色・見出し・記号で行う
     - 状態には必ず記号と文字を添える（色だけで伝えない）
     - 文字と背景のコントラストは 4.5:1 以上（ライト・ダーク両方）
   ===================================================================== */

:root {
  color-scheme: light;

  /* ブランド（紺） */
  --brand:        #171047;   /* 主ボタン・現在の手順・番号 */
  --brand-hover:  #2a2468;
  --brand-ink:    #2c2a72;   /* 文字・リンク用。白地 12.5:1 */
  --brand-tint:   #e2e0ec;   /* 選択行・選択中のナビ。地と見分けがつく濃さにしている */
  --on-brand:     #ffffff;   /* 紺の塗りの上の文字。16.7:1 */
  --star:         #dd9933;   /* ロゴの星だけ */

  /* 面（ロイズと同じ生成り寄りの白） */
  --bg:           #efede7;   /* ロイズより一段沈めて、白いカードとの差を付ける */
  --surface:      #ffffff;
  --surface-2:    #f9f8f5;
  --fill:         rgba(118, 116, 110, 0.14);
  --fill-strong:  rgba(118, 116, 110, 0.24);
  --field:        #ffffff;   /* 入力欄は白にして、どこに書くかをはっきりさせる */
  --sidebar:      #fbfaf8;

  /* 文字（ロイズと同じ墨） */
  /* 50代の方が読むので、補足・注記も 7:1 以上にしている（薄い灰色の文字は使わない） */
  --ink:          #141414;   /* 18.4:1 */
  --ink-2:        #3d3c38;   /* 11:1 */
  --ink-3:        #4f4d48;   /*  8:1 */

  /* 区切り */
  --separator:    #d9d6ce;
  --line:         #d4d1c8;   /* カード・表の外枠。影だけに頼らず面の境目を見せる */
  --border:       #8a867c;   /* 入力欄の枠。白地で 3.6:1（どこに書くかを見失わない） */

  /* 状態色（意味ごとに固定。彩度をそろえ、地の生成りになじむ薄い色にしている） */
  --ok:        #1f7a3a;  --ok-tint:     #e8f2ea;   /* 足りている・送信済み */
  --danger:    #b42318;  --danger-tint: #f9e9e6;   /* 不足・エラー・削除 */
  --caution:   #9a5200;  --caution-tint:#f8eedf;   /* 再発注の候補・注意 */
  --info:      var(--brand-ink); --info-tint: var(--brand-tint); /* 発注済み・入荷待ち */
  --on-danger: #ffffff;

  /* 文字サイズ（50代の方が PC で読む前提で、標準より一段大きくしている） */
  --t-large:   32px;
  --t-title2:  26px;
  --t-title3:  21px;
  --t-headline:18px;
  --t-body:    18px;
  --t-callout: 17px;   /* 表・フォーム */
  --t-sub:     16px;
  --t-foot:    15px;
  --t-caption: 14px;   /* これより小さい文字は使わない */

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(26, 26, 26, 0.04), 0 1px 3px rgba(26, 26, 26, 0.06);
  --hit: 48px;          /* 押せる場所の最小の高さ（マウスでも外さない大きさ） */
  --sidebar-w: 260px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --brand:       #4b45a6;   /* 暗い地では紺が沈むので一段明るく。白文字 7.2:1 */
    --brand-hover: #5852b5;
    --brand-ink:   #b9b6ec;
    --brand-tint:  rgba(150, 145, 225, 0.16);
    --on-brand:    #ffffff;
    --star:        #e8ad52;

    --bg:        #141413;
    --surface:   #1f1f1d;
    --surface-2: #262624;
    --fill:        rgba(235, 232, 222, 0.10);
    --fill-strong: rgba(235, 232, 222, 0.18);
    --field:     #2a2a27;
    --sidebar:   #191918;

    --ink:   #f5f4ef;
    --ink-2: #d2d0c8;
    --ink-3: #b8b6ae;

    --separator: #3a3a36;
    --line:      #3d3d39;
    --border:    #77756d;

    --ok:      #5fd47f;  --ok-tint:      rgba(95, 212, 127, 0.14);
    --danger:  #ff7b72;  --danger-tint:  rgba(255, 123, 114, 0.14);
    --caution: #f0a94f;  --caution-tint: rgba(240, 169, 79, 0.14);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

/* ---------------------------------------------------------------------
   基本
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: var(--t-body);
  line-height: 1.6;
  font-feature-settings: "palt" 0;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); text-decoration: none; }
/* 本文中のリンクは常に下線を付けて、押せる文字だと分かるようにする */
/* hidden 属性は display 指定より常に優先（ボタン等が消えない崩れを防ぐ） */
[hidden] { display: none !important; }
.main a:not(.btn):not(.nav-item):not(.to-top) { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; font-weight: 600; }
.main a:not(.btn):not(.nav-item):not(.to-top):hover { text-decoration-thickness: 2.5px; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9em; padding: 1px 6px; border-radius: 6px; background: var(--fill);
}
strong, b { font-weight: 600; }

/* キーボード操作時のフォーカスを必ず見せる */
:focus-visible {
  outline: 3px solid var(--brand-ink);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------------
   画面の骨組み：サイドバー＋本文（HIG のサイドバー。階層は2段まで）
   --------------------------------------------------------------------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--separator);
  padding: var(--s5) var(--s3) var(--s4);
  overflow-y: auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s3) var(--s5); }
.brand-mark {
  flex: none; width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
}
.brand-name { font-size: var(--t-headline); font-weight: 700; line-height: 1.3; }
.brand-sub  { font-size: var(--t-caption); color: var(--ink-2); line-height: 1.3; }

.nav-group {
  font-size: var(--t-caption); font-weight: 600; color: var(--ink-2);
  padding: var(--s4) var(--s3) var(--s2);
}
.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--hit); padding: 0 var(--s3); margin: 2px 0;
  border-radius: 10px;
  color: var(--ink); font-size: var(--t-callout); font-weight: 500;
}
.nav-item:hover { background: var(--fill); text-decoration: none; }
.nav-item svg { flex: none; width: 20px; height: 20px; color: var(--ink-2); }
.nav-item[aria-current="page"] {
  background: var(--brand-tint); color: var(--ink); font-weight: 600;
}
.nav-item[aria-current="page"] svg { color: var(--brand-ink); }
.sidebar-foot { margin-top: auto; padding-top: var(--s4); border-top: 1px solid var(--separator); }

.main { margin-left: var(--sidebar-w); min-width: 0; }

/* 狭い画面ではサイドバーを引き出し式にする */
.topbar { display: none; }
.scrim  { display: none; }

@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.28);
  }
  .main { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; gap: var(--s2);
    position: sticky; top: 0; z-index: 20;
    min-height: 52px; padding: 0 var(--s2);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--separator);
  }
  .topbar-title { font-weight: 600; font-size: var(--t-headline); }
  .icon-btn {
    width: var(--hit); height: var(--hit); padding: 0; display: grid; place-items: center;
    border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer;
  }
  .icon-btn svg { width: 24px; height: 24px; }
  .icon-btn:hover { background: var(--fill); }
}

.wrap { max-width: 1180px; margin: 0 auto; padding: var(--s8) var(--s8) 96px; }
@media (max-width: 960px) { .wrap { padding: var(--s6) var(--s5) 80px; } }

/* ---------------------------------------------------------------------
   文字の階層
   --------------------------------------------------------------------- */
h1 {
  font-size: var(--t-large); font-weight: 700; line-height: 1.25;
  letter-spacing: 0.005em; margin: 0 0 var(--s2);
  line-break: strict; overflow-wrap: anywhere;
}
h1, h2, h3, .brand-name { line-break: strict; }
@media (max-width: 640px) {
  :root { --t-large: 25px; --t-title2: 20px; }
}
h2 {
  font-size: var(--t-title3); font-weight: 700; line-height: 1.35;
  margin: var(--s10) 0 var(--s3);
}
h3 { font-size: var(--t-headline); font-weight: 600; margin: var(--s6) 0 var(--s2); }
.sub.note-after { margin-top: var(--s3); }
.sub {
  color: var(--ink-2); font-size: var(--t-callout); line-height: 1.7;
  margin: 0 0 var(--s5); max-width: 72ch;
}
.muted { color: var(--ink-2); font-size: var(--t-foot); }
.dim   { color: var(--ink-3); }
.unit  { font-size: var(--t-foot); color: var(--ink-2); margin-left: 2px; font-weight: 400; }
.num   { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------------------------------------------
   数値のまとめ（サマリータイル）
   --------------------------------------------------------------------- */
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: var(--s4); margin: var(--s5) 0 var(--s6);
}
.card {
  background: var(--surface); border-radius: var(--r);
  padding: var(--s4); box-shadow: var(--shadow), 0 0 0 1px var(--line);
}
.card .k { font-size: var(--t-foot); font-weight: 500; color: var(--ink-2); margin-bottom: var(--s1); }
.card .v {
  font-size: var(--t-title2); font-weight: 700; line-height: 1.25;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.card .u { font-size: var(--t-foot); color: var(--ink-2); font-weight: 500; margin-left: 3px; }
/* 一番大事な指標は塗りで目立たせる（ブランド塗り＋墨文字） */
.card.hero { background: var(--brand); color: var(--on-brand); }
.card.hero .k, .card.hero .u { color: rgba(255, 255, 255, 0.78); }

/* ---------------------------------------------------------------------
   表（グループ化された一覧）
   --------------------------------------------------------------------- */
.tbl-wrap {
  overflow-x: auto; background: var(--surface);
  border-radius: var(--r); box-shadow: var(--shadow), 0 0 0 1px var(--line);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: var(--t-callout); font-variant-numeric: tabular-nums; }
th {
  text-align: left; font-size: var(--t-foot); font-weight: 600; color: var(--ink-2);
  padding: var(--s3) var(--s4); background: var(--surface-2);
  border-bottom: 1px solid var(--separator); white-space: nowrap;
}
td {
  padding: var(--s3) var(--s4); height: var(--hit);
  border-bottom: 1px solid var(--separator); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: color-mix(in srgb, var(--fill) 45%, transparent); }
table tr:first-child:hover th { background: var(--surface-2); }
td .muted { display: block; margin-top: 2px; }
/* 表は列を押しつぶさない。短い値は改行させず、収まらなければ表の中で横スクロールする。
   名称＋住所のように長い文を持つ列だけ、読める幅を確保したうえで折り返す */
th, td { white-space: nowrap; }
td:has(> .muted):not(.remark), td.wrap { white-space: normal; min-width: 15em; max-width: 26em; }
td.remark { white-space: normal; min-width: 0; }
td.remark .muted { display: inline; margin: 0 var(--s2) 0 0; }
.sub-line { display: block; margin-top: 2px; font-size: var(--t-foot); color: var(--ink-2); font-weight: 400; }
.tbl-wrap + .sub, .tbl-wrap + p, .tbl-wrap + .note { margin-top: var(--s3); }
.pick td { background: var(--brand-tint); }
tr.avg td { background: var(--surface-2); color: var(--ink-2); }
.pick:hover td { background: var(--brand-tint); }

/* スコア：数値とバーを並べる（バーだけで値を伝えない） */
.meter { display: flex; align-items: center; gap: var(--s2); min-width: 120px; }
.meter-val { width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: var(--t-sub); }
.bar { flex: 1; height: 6px; background: var(--fill-strong); border-radius: 3px; overflow: hidden; min-width: 56px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* ---------------------------------------------------------------------
   バッジ類 — 意味ごとに見た目を分け、必ず文字（と記号）を添える
   --------------------------------------------------------------------- */
/* 優先度 A/B/C：序列なので色ではなく濃淡で表す */
.rank {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  border-radius: 7px; font-size: var(--t-caption); font-weight: 700;
}
.rank.A { background: var(--ink); color: var(--surface); }
.rank.B { background: var(--fill-strong); color: var(--ink); }
.rank.C { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--border); }

/* データの出典：実測／推計／未取得 */
.src {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px; font-size: var(--t-caption); font-weight: 600;
  white-space: nowrap; margin-right: var(--s2);
}
.src.measured  { color: var(--ink); background: var(--fill); }
.src.estimated { color: var(--caution); box-shadow: inset 0 0 0 1px currentColor; }
.src.missing   { color: var(--ink-3); }
.src.sample    { color: var(--caution); box-shadow: inset 0 0 0 1px currentColor; }

/* 問い合わせ状況 */
.status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: var(--t-foot); font-weight: 600; white-space: nowrap;
}
.status .sym { font-size: 11px; line-height: 1; }
.status.untouched { color: var(--ink-2); background: var(--fill); }
.status.calling   { color: var(--info);    background: var(--info-tint); }
.status.ok        { color: var(--ok);      background: var(--ok-tint); }
.status.ng        { color: var(--danger);  background: var(--danger-tint); }
.status.hold      { color: var(--caution); background: var(--caution-tint); }

/* 平均との比較（↑↓）。記号と文字で伝える */
.trend { display: inline-block; margin-left: var(--s2); font-size: var(--t-caption); font-weight: 600; white-space: nowrap; }
.trend.up   { color: var(--ok); }
.trend.down { color: var(--caution); }

/* 旧クラス（互換のため残す。新規には .src / .status を使う） */
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: var(--t-caption); font-weight: 600; margin-right: var(--s2); }
.tag.ok   { color: var(--ink); background: var(--fill); }
.tag.est  { color: var(--caution); box-shadow: inset 0 0 0 1px currentColor; }
.tag.none { color: var(--ink-3); }

.warn { color: var(--caution); font-size: var(--t-foot); font-weight: 600; }
.warn::before { content: "⚠︎ "; }

/* ---------------------------------------------------------------------
   お知らせ（コールアウト）
   --------------------------------------------------------------------- */
.note {
  background: var(--surface); border-radius: var(--r);
  padding: var(--s4) var(--s5); margin: var(--s4) 0;
  font-size: var(--t-callout); line-height: 1.75; color: var(--ink);
  box-shadow: var(--shadow), 0 0 0 1px var(--line);
}
.note b:first-child, .note strong:first-child {
  display: block; color: var(--ink); font-size: var(--t-callout); margin-bottom: var(--s1);
}
.note.ok  { background: var(--ok-tint);     box-shadow: none; color: var(--ink); }
.note.err { background: var(--danger-tint); box-shadow: none; color: var(--ink); }
.note.caution { background: var(--caution-tint); box-shadow: none; color: var(--ink); }

/* ---------------------------------------------------------------------
   ボタン
   主ボタン＝ブランド塗り（画面に1つ）／二次＝灰の塗り／削除＝赤文字（主ボタンにしない）
   大きさではなくスタイルで優先度を分ける
   --------------------------------------------------------------------- */
button, .btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--hit); padding: 0 var(--s5);
  border: 0; border-radius: 10px;
  background: var(--brand); color: var(--on-brand);
  font: inherit; font-size: var(--t-callout); font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.12s ease, transform 0.06s ease;
}
button:hover, .btn:hover { background: var(--brand-hover); text-decoration: none; }
button:active, .btn:active { transform: scale(0.98); }
/* 押せないボタンは薄くせず、灰色の塗り＋点線の枠で「押せない」とはっきり分ける */
button:disabled, .btn[aria-disabled="true"],
button:disabled:hover, .btn[aria-disabled="true"]:hover {
  background: var(--fill-strong); color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--border);
  cursor: not-allowed; transform: none;
}

/* 二番目のボタンは白地に紺の枠。地の色に溶けないようにする */
.btn.sec, button.sec { background: var(--surface); color: var(--brand-ink); font-weight: 600; box-shadow: inset 0 0 0 2px var(--brand-ink); }
.btn.sec:hover, button.sec:hover { background: var(--brand-tint); }
.btn.danger, button.danger { background: var(--surface); color: var(--danger); font-weight: 600; box-shadow: inset 0 0 0 2px var(--danger); }
.btn.danger:hover, button.danger:hover { background: var(--danger-tint); }

/* 表の中などの小さめのボタン。指で触る端末では 44pt に戻す */
.btn.sm, button.sm { min-height: var(--hit); padding: 0 var(--s4); font-size: var(--t-callout); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
/* 表のセルは flex にすると表の行として振る舞わなくなり、ボタンが縦に折り返して
   行が 100px 近くまで膨らむ。セルのまま、ボタンを1行に並べる */
td.actions { display: table-cell; white-space: nowrap; }
td.actions > * + * { margin-left: var(--s2); }
.actions + .actions { margin-top: var(--s2); }
.inline { display: inline; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin: var(--s4) 0 var(--s3); }
.toolbar .spacer { flex: 1; }
.toolbar-label { font-size: var(--t-foot); color: var(--ink-2); font-weight: 500; }

/* ---------------------------------------------------------------------
   セグメントコントロール（排他的な選択肢。5〜7個まで、幅をそろえる）
   --------------------------------------------------------------------- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--fill); border-radius: 10px;
  max-width: 100%; overflow-x: auto;
}
.seg-item {
  /* 日本語のラベルは長さがまちまちなので、縮めず内容の幅を確保する。
     そのうえで最小幅をそろえて、短いラベル同士は均等に見せる */
  flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; min-width: 72px; padding: 0 var(--s4);
  border-radius: 8px; color: var(--ink); font-size: var(--t-foot); font-weight: 500;
  white-space: nowrap; cursor: pointer; user-select: none;
}
.seg-item:hover { text-decoration: none; background: var(--fill); }
.seg-item.on, .seg-item[aria-current="true"],
.seg-item input:checked + span {
  background: var(--surface); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
@media (pointer: coarse) {
  .seg-item, .seg label.seg-item span { min-height: var(--hit); }   /* HIG：指で触る端末は 44pt */
}
.seg { scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
@media (max-width: 640px) {
  .seg { display: flex; flex-wrap: wrap; overflow: visible; width: 100%; }
  .seg-item { flex: 1 1 auto; min-width: 0; }
}
/* ラジオで作るセグメント（フォーム用） */
.seg label.seg-item { padding: 0; margin: 0; }
.seg label.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg label.seg-item span {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; min-height: 42px; padding: 0 var(--s4); border-radius: 8px;
}
.seg label.seg-item:hover { background: transparent; }
.seg label.seg-item input:focus-visible + span { outline: 3px solid var(--brand-ink); outline-offset: 1px; }
.seg.yesno label.seg-item input:checked + span[data-v="1"] { color: var(--ok); }
.seg.yesno label.seg-item input:checked + span[data-v="0"] { color: var(--danger); }

/* ---------------------------------------------------------------------
   フォーム（グループ化された入力欄）
   --------------------------------------------------------------------- */
form.box, .panel {
  background: var(--surface); border-radius: var(--r-lg);
  padding: var(--s6); margin: var(--s4) 0; box-shadow: var(--shadow), 0 0 0 1px var(--line);
}
.panel-title, form.box h3 {
  font-size: var(--t-title3); font-weight: 700; margin: 0 0 var(--s1);
}
.panel-sub { color: var(--ink-2); font-size: var(--t-callout); margin: 0 0 var(--s4); }
.group {
  background: var(--surface-2); border-radius: var(--r);
  padding: var(--s2) var(--s4); margin: var(--s4) 0;
}
.group-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  min-height: 56px; padding: var(--s2) 0; border-bottom: 1px solid var(--separator);
}
.group-row:last-child { border-bottom: 0; }
.group-row .q { font-size: var(--t-callout); font-weight: 500; }
@media (max-width: 640px) { .group-row { flex-direction: column; align-items: stretch; } }

label {
  display: block; font-size: var(--t-callout); font-weight: 600; color: var(--ink);
  margin: var(--s4) 0 6px;
}
label:first-child,
input[type=hidden]:first-child + label,
input[type=hidden]:first-child + input[type=hidden] + label { margin-top: 0; }
input[type=text], input[type=number], input[type=date], input[type=password],
input[type=email], input[type=search], input[type=tel], input[type=url], textarea, select {
  width: 100%; min-height: var(--hit); padding: 10px var(--s3);
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--field); color: var(--ink);
  font: inherit; font-size: var(--t-callout); line-height: 1.4;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand-ink); background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 35%, transparent);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
input[type=file] {
  display: block; width: 100%; min-height: var(--hit);
  font: inherit; font-size: var(--t-sub); color: var(--ink-2);
}
input[type=file]::file-selector-button {
  min-height: var(--hit); margin-right: var(--s3); padding: 0 var(--s4);
  border: 0; border-radius: 10px; background: var(--surface); color: var(--brand-ink);
  box-shadow: inset 0 0 0 2px var(--brand-ink);
  font: inherit; font-size: var(--t-callout); font-weight: 600; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--brand-tint); }
input[type=checkbox], input[type=radio] { width: 24px; height: 24px; accent-color: var(--brand); }
/* チェックボックスはラベル全体を押せる範囲にする（44pt） */
.check { display: flex; align-items: center; gap: var(--s3); min-height: var(--hit); color: var(--ink); font-size: var(--t-callout); font-weight: 500; margin-top: var(--s2); cursor: pointer; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s3) var(--s4); }
:not(input[type=hidden]) + .row { margin-top: var(--s4); }
.seg + .row, .seg + .group { margin-top: var(--s4); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); align-items: center; }
form.box > button, .panel > button,
form.box > .actions, .panel > .actions { margin-top: var(--s5); }
/* 枠の中の最初と最後の要素は外側の余白を持たない（上下の余白を枠の padding だけでそろえる） */
form.box > :first-child, .panel > :first-child { margin-top: 0; }
form.box > :last-child, .panel > :last-child { margin-bottom: 0; }
@media (max-width: 640px) { form.box, .panel { padding: var(--s4); } }
form.box > button + .muted, .panel > button + .muted { margin-left: var(--s3); }

/* ---------------------------------------------------------------------
   段階的に開示（詳細を隠す）
   --------------------------------------------------------------------- */
details { margin-top: var(--s3); }
summary {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: var(--hit); padding: 0 var(--s3); margin-left: calc(-1 * var(--s3));
  border-radius: 10px; cursor: pointer; list-style: none;
  color: var(--brand-ink); font-size: var(--t-callout); font-weight: 700;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: "›"; display: inline-block; font-size: 20px; line-height: 1; transition: transform 0.15s ease; }
details[open] > summary::before { transform: rotate(90deg); }
summary:hover { background: var(--fill); }

/* ---------------------------------------------------------------------
   出典・フッター
   --------------------------------------------------------------------- */
footer {
  margin-top: 56px; padding-top: var(--s5); border-top: 1px solid var(--separator);
  font-size: var(--t-foot); color: var(--ink-2); line-height: 1.75;
}
footer ul { padding-left: 1.2em; margin: var(--s2) 0; }
footer li { margin: 2px 0; }

/* ---------------------------------------------------------------------
   ログイン
   --------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s6); }
.login { width: 100%; max-width: 380px; }
.login .brand { justify-content: center; padding-bottom: var(--s6); }
.login .brand-mark { width: 48px; height: 48px; border-radius: 12px; font-size: 20px; }
.login h1 { text-align: center; font-size: 24px; }
.login .sub { text-align: center; margin-left: auto; margin-right: auto; }
.login form.box button { width: 100%; margin-top: var(--s5); }

/* ---------------------------------------------------------------------
   ページ送り
   --------------------------------------------------------------------- */
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s3); margin-top: var(--s5); }

/* ---------------------------------------------------------------------
   アクセシビリティの設定に従う
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --separator: var(--border); --ink-2: var(--ink); }
  .card, .tbl-wrap, form.box, .panel, .note { box-shadow: 0 0 0 1px var(--border); }
}

/* ---------------------------------------------------------------------
   印刷：操作部品を消して表だけ残す
   --------------------------------------------------------------------- */
@media print {
  :root { color-scheme: light; }
  .sidebar, .topbar, .scrim, .actions, .toolbar, details, form.box, .seg { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
  .wrap { padding: 0; max-width: none; }
  .card, .tbl-wrap, .note { box-shadow: 0 0 0 1px #ccc; }
}
