/* =============================================================
   Saleslip 販売管理システム モック 共通スタイル
   デザイントークン + レイアウト + コンポーネント
   ============================================================= */

:root {
  /* カラートークン */
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-soft: #e8f1fc;
  --accent-softer: #f3f8fe;

  --nav-bg: #e9eef6;
  --nav-bg-hover: #dbe4f1;
  --nav-line: #d5dde9;
  --nav-text: #44546b;
  --nav-text-sub: #7386a0;
  --nav-text-active: var(--accent-strong);

  --page-bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafc;

  --ink: #1a2330;
  --ink-2: #4b5563;
  --ink-3: #8a94a3;
  --line: #e3e7ee;
  --line-strong: #cdd4de;
  --field-border: #97a1b0;

  --good: #0ca30c;
  --good-bg: #e9f7e9;
  --good-ink: #056d05;
  --warn: #b97700;
  --warn-bg: #fdf3dd;
  --serious: #c25525;
  --serious-bg: #fdeee6;
  --bad: #d03b3b;
  --bad-bg: #fdebeb;
  --bad-ink: #b02a2a;
  --neutral-bg: #eef1f5;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(16, 24, 38, .05), 0 1px 3px rgba(16, 24, 38, .06);
  --shadow-2: 0 4px 16px rgba(16, 24, 38, .10);
  --shadow-3: 0 12px 40px rgba(16, 24, 38, .18);

  --font: "Inter", "Segoe UI", "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", "Meiryo", sans-serif;
  --mono: "Consolas", "SF Mono", "Cascadia Code", monospace;

  --sidebar-w: 172px;
  --topbar-h: 52px;
  --topnav-h: 48px;
}

* { box-sizing: border-box; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- レイアウト ---------- */
.layout { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.content {
  padding: 14px 18px 44px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- 最上段: アプリナビ(ブランド+モジュールメニュー) ---------- */
.app-topnav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topnav-h);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  z-index: 60;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 29px; height: 29px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3987e5, #1c5cab);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px;
  letter-spacing: -.5px;
  flex: none;
}
.brand-logo { width: 28px; height: 28px; object-fit: contain; flex: 0 0 auto; }
.login-brand-logo { width: 40px; height: 40px; }
.brand-setting-preview { display: block; width: 180px; height: 72px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.brand-name { color: var(--ink); font-weight: 700; font-size: 14.5px; letter-spacing: .02em; }
.brand-sub { font-size: 10.5px; color: var(--nav-text-sub); margin-top: 1px; }

/* 伝票入力の別ウィンドウ(タブへ切り離しも可)。モジュールナビは出さない。
   固定バーにせず、ウィンドウ高さいっぱいにヘッダ・明細・登録バーを収める。 */
.popup-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
  overflow: hidden;
}
.popup-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 10px 10px;
}
.popup-topbar {
  flex: none;
  height: 36px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
}
.popup-topbar .brand-mark { width: 22px; height: 22px; font-size: 11px; border-radius: 6px; }
.popup-topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  min-width: 0;
}
.popup-topbar-title .code { font-family: var(--mono); font-weight: 700; }
.popup-action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.popup-content > .org-map-page {
  flex: 1;
  min-height: 0;
}
.popup-shell .org-map-canvas {
  min-height: 0;
}
.order-total-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: baseline;
  font-size: 12.5px;
  color: var(--ink-2);
}
.order-total-bar b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
.order-invoice-summary {
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.order-invoice-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px 12px;
  align-items: baseline;
}
.order-invoice-row .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 4.5em;
  color: var(--ink);
}
.order-invoice-total {
  margin-top: 2px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  font-weight: 600;
  color: var(--ink);
}
.entry-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.entry-dense table.grid-edit td .muted.small {
  margin-top: 2px;
  font-size: 11px;
}
.popup-content .slip-entry {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.popup-content .slip-entry > fieldset {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 8px;
}
.popup-content .slip-head { flex: none; }
.popup-content .slip-lines {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.popup-content .slip-lines .card-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.popup-content .slip-lines .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.popup-content .slip-lines .slip-total-bar { flex: none; }
.popup-content .action-bar { flex: none; margin-top: 0; }

/* 入力ウィンドウ専用の高密度。マスタ等の通常画面には効かない */
.popup-shell .card-head { padding: 6px 10px; gap: 8px; }
.popup-shell .card-head h2 { font-size: 12.5px; }
.popup-shell .card-body { padding: 8px 10px; }
.popup-shell .form-grid { gap: 6px 10px; }
.popup-shell .field { gap: 2px; }
.popup-shell .field > label { font-size: 11px; }
.popup-shell .field-hint { display: none; }
.popup-shell input:not([type=checkbox]):not([type=radio]),
.popup-shell select {
  padding: 4px 8px;
  font-size: 12.5px;
}
.popup-shell .code-input-wrap .resolved-name { padding: 4px 8px; font-size: 12.5px; border-radius: 6px; }
.popup-shell .lookup-btn { width: 26px; height: 26px; }
.popup-shell .pill-group { padding: 2px; }
.popup-shell .pill-group label { padding: 4px 9px; font-size: 12px; }
.popup-shell table.grid-edit { font-size: 12.5px; }
.popup-shell table.grid-edit th { padding: 4px 6px; font-size: 10.5px; }
.popup-shell table.grid-edit td { padding: 1px; }
.popup-shell table.grid-edit td input,
.popup-shell table.grid-edit td select { padding: 4px 6px; font-size: 12.5px; }
.popup-shell table.grid-edit td .cell-static { padding: 4px 6px; }
.popup-shell .slip-total-bar { padding: 6px 10px; gap: 16px; }
.popup-shell .slip-total-bar .t-value { font-size: 14px; }
.popup-shell .slip-total-bar .t-grand .t-value { font-size: 17px; }
.popup-shell .action-bar { padding: 6px 10px; border-radius: 8px; }
.popup-shell .action-bar .bar-note { display: none; }
.popup-shell .close-guard { margin-top: 6px; padding: 5px 10px; font-size: 12px; }
.popup-shell .btn { padding: 5px 11px; font-size: 12.5px; }

.module-nav {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  align-self: stretch;
  align-items: center;
}
.module-nav::-webkit-scrollbar { display: none; }
.module-tab {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--nav-text);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 7px 13px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}
.module-tab:hover { color: var(--ink); background: var(--nav-bg-hover); text-decoration: none; }
.module-tab.active {
  color: var(--nav-text-active);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

/* ---------- サイドバー ---------- */
.sidebar {
  position: fixed;
  inset: var(--topnav-h) auto 0 0;
  width: var(--sidebar-w);
  background: var(--nav-bg);
  color: var(--nav-text);
  border-right: 1px solid var(--nav-line);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c3cedd transparent;
}

.nav { padding: 12px 9px 20px; flex: 1; }
.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--nav-text-sub);
  padding: 0 9px 7px;
}
.nav a,
.nav button.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 9px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--nav-text);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  text-decoration: none;
  margin-bottom: 2px;
  line-height: 1.3;
  cursor: pointer;
}
.nav a:hover,
.nav button.nav-link:hover { background: var(--nav-bg-hover); color: var(--ink); text-decoration: none; }
.nav a.active,
.nav button.nav-link.active {
  background: var(--surface);
  color: var(--nav-text-active);
  font-weight: 600;
  box-shadow: var(--shadow-1);
}
.nav a .nav-icon,
.nav button.nav-link .nav-icon { width: 16px; height: 16px; flex: none; opacity: .8; }
.nav a.active .nav-icon,
.nav button.nav-link.active .nav-icon { opacity: 1; }

.sidebar-foot {
  padding: 11px 14px;
  border-top: 1px solid var(--nav-line);
  font-size: 10.5px;
  color: var(--nav-text-sub);
  line-height: 1.5;
}

/* タイトル行は廃止(パンくず・検索は最上段/ダッシュボードへ統合) */
body.has-topnav .layout, .has-topnav .layout { padding-top: var(--topnav-h); }
.topnav-spacer { flex: 1; }

/* ダッシュボード用グローバル検索 */
.dash-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 14px;
  max-width: 560px;
  margin-bottom: 12px;
  color: var(--ink-3);
}
.dash-search svg { width: 16px; height: 16px; flex: none; }
.dash-search input {
  border: none;
  padding: 0;
  font-size: 13.5px;
  background: transparent;
}
.dash-search input:focus { box-shadow: none; }
.dash-search kbd {
  font-family: var(--font);
  font-size: 10.5px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink-3);
  white-space: nowrap;
}
.topbar-title { font-size: 15px; font-weight: 700; }
.topbar-crumb { font-size: 12px; color: var(--ink-3); }
.topbar-crumb b { color: var(--ink-2); font-weight: 600; }
.topbar-spacer { flex: 1; }

.global-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  width: 260px;
  color: var(--ink-3);
  font-size: 12.5px;
}
.global-search svg { width: 14px; height: 14px; }
.global-search kbd {
  margin-left: auto;
  font-family: var(--font);
  font-size: 10.5px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink-3);
}

.logout-form { display: grid; margin: 0; }
.topbar-icon-btn {
  position: relative;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.topbar-icon-btn:hover { background: var(--neutral-bg); }
.topbar-icon-btn svg { width: 18px; height: 18px; }
.notif-dot {
  position: absolute; top: 6px; right: 7px;
  width: 7px; height: 7px;
  background: var(--bad);
  border: 1.5px solid #fff;
  border-radius: 50%;
}

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 27px; height: 27px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3987e5, #7c5fd3);
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}
.user-chip .user-name { font-size: 12.5px; font-weight: 600; }
.user-chip .user-role { font-size: 10.5px; color: var(--ink-3); }

/* ---------- ページヘッダ ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 19px; letter-spacing: -.01em; }
.page-head .page-desc { color: var(--ink-3); font-size: 12px; margin-top: 3px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- カード ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 13.5px; }
.card-head .card-sub { font-size: 11.5px; color: var(--ink-3); }
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 14px; }
.card-body.tight { padding: 0; }

/* 承認待ち(下書き・未承認・確認中)の会員入力カード。一目で分かるようグレー地にする */
.card.status-pending { background: var(--neutral-bg); }

/* 画面を上下に分ける(会員入力: 上=基本情報、下=タブ) */
.split-card { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.split-card .split-top { flex: 1 1 50%; min-height: 0; overflow-y: auto; border-bottom: 1px solid var(--line); }
.split-card .split-bottom { flex: 1 1 50%; min-height: 0; display: flex; flex-direction: column; }
.split-card .split-bottom .card-body { flex: 1; min-height: 0; overflow-y: auto; }
/* 会員入力: 基本情報は固定表示、タブ以降だけ1スクロール */
.split-card.entry-dense {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.popup-content > .card.split-card.entry-dense {
  flex: 1;
  min-height: 0;
}
.split-card.entry-dense .entry-id-bar {
  flex: none;
  background: var(--accent-soft);
  border-bottom-color: var(--line);
}
.split-card.entry-dense .entry-id-bar-row {
  width: 100%;
}
.split-card.entry-dense .entry-id-bar-status {
  margin-left: auto;
}
.split-card.entry-dense .entry-basic {
  flex: none;
  background: var(--accent-softer);
}
.split-card.entry-dense .entry-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.split-card.entry-dense .entry-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 4px 10px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.split-card.entry-dense .entry-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.entry-age-label {
  font-size: 12.5px;
  white-space: nowrap;
  padding: 0 2px;
}
.card.status-pending.split-card.entry-dense .entry-id-bar {
  background: #dfe4ea;
}
.card.status-pending.split-card.entry-dense .entry-basic {
  background: var(--neutral-bg);
}
.card.status-pending.split-card.entry-dense .entry-scroll {
  background: var(--surface);
}
.btn-danger-soft {
  background: var(--bad-bg);
  color: var(--bad-ink);
  border-color: #f0c0c0;
}
.btn-danger-soft:hover {
  background: #fbdcdc;
  color: var(--bad-ink);
}
.btn-warn-soft {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #efd7a0;
}
.btn-warn-soft:hover {
  background: #fae9c0;
  color: var(--warn);
}

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  transition: background .12s, box-shadow .12s;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--neutral-bg); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #b02a2a; }
.btn-danger-ghost { background: var(--bad-bg); color: var(--bad-ink); }
.btn-danger-ghost:hover { background: #fbdcdc; }
.btn-sm { font-size: 12px; padding: 5px 10px; border-radius: 7px; }
.btn-lg { font-size: 14px; padding: 11px 22px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- フォーム ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex; gap: 6px; align-items: center;
}
.req {
  font-size: 9.5px;
  color: var(--bad-ink);
  background: var(--bad-bg);
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 700;
}
.opt-badge {
  font-size: 9.5px;
  color: var(--ink-3);
  background: var(--neutral-bg);
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 600;
}

input[type="text"], input[type="number"], input[type="date"], input[type="month"],
input[type="password"], input[type="email"], input[type="search"], input[type="tel"],
select, textarea {
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--field-border);
  border-radius: 8px;
  padding: 6px 10px;
  width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
/* プレースホルダーは入力値と誤認しないよう十分薄いグレー */
input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
  color: var(--ink-3);
  opacity: 1;
}
input::-moz-placeholder,
textarea::-moz-placeholder {
  color: var(--ink-3);
  opacity: 1;
}
/* 日付の未入力表示(yyyy/mm/dd)はグレー、値ありは黒 */
input[type="date"],
input[type="month"] {
  color: var(--ink-3);
}
input[type="date"].has-value,
input[type="month"].has-value {
  color: var(--ink);
}
input[type="date"][readonly].has-value,
input[type="month"][readonly].has-value {
  color: var(--ink-2);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42,120,214,.15);
}
input[readonly], .readonly {
  background: var(--surface-2);
  color: var(--ink-2);
  border-style: dashed;
}
input.ta-r { text-align: right; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 64px; }

.field-invalid > label { color: var(--bad-ink); }
.field-invalid input, .field-invalid select, .field-invalid textarea {
  border-color: var(--bad);
  background: var(--bad-bg);
}

.form-grid {
  display: grid;
  gap: 10px 14px;
}
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-6 { grid-template-columns: repeat(6, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

/* ---------- 高密度入力(ラベル左・内容幅) ---------- */
.entry-dense .section-label { margin-bottom: 6px; }
.bonus-section-label {
  margin: 2px 0 4px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
}
.bonus-rate-details {
  margin-top: 6px;
  font-size: 11px;
}
.bonus-rate-details summary {
  width: fit-content;
  color: var(--ink-3);
  cursor: pointer;
}
.bonus-rate-summary {
  margin-top: 5px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  line-height: 1.5;
}
.bonus-calc-table thead tr:first-child th {
  background: var(--surface-2);
}
.bonus-calc-table .bonus-group-heading {
  text-align: center;
}
.entry-id-bar {
  flex: none;
  padding: 8px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.entry-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.entry-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
}
.field-h {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.field-h > label {
  flex: 0 0 auto;
  width: 4.6em;
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.2;
  text-align: right;
}
.field-h.label-md > label { width: 5.5em; }
.field-h.label-lg > label { width: 7.2em; }
.field-h.label-xl > label { width: 8.2em; }
/* 会員入力: ラベル幅を揃え、入力の開始位置をそろえる */
.entry-dense .field-h > label,
.entry-dense .field-h.label-md > label,
.entry-dense .field-h.label-lg > label,
.entry-dense .field-h.label-xl > label {
  width: 7.5em;
  white-space: normal;
}
.field-h > input,
.field-h > select,
.field-h > textarea,
.field-h > .code-input-wrap,
.field-h > .bank-code-wrap {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.field-h.align-start { align-items: flex-start; }
.field-h.align-start > label { padding-top: 5px; }
.field-h .req {
  font-size: 12px;
  padding: 0;
  background: transparent;
  color: var(--bad-ink);
  font-weight: 700;
  line-height: 1;
}
.field-h.fw-xs { flex: 0 0 auto; width: auto; }
.entry-dense .field-h.fw-xs > input,
.entry-dense .field-h.fw-xs > select {
  flex: 0 0 auto;
  width: 8em;
  min-width: 8em;
}
.field-h.fw-sm { flex: 0 0 auto; width: 190px; }
.field-h.fw-md { flex: 0 0 auto; width: 230px; }
/* 紹介者: 会員番号7桁 + 氏名表示 */
.field-h.fw-intro {
  flex: 1 1 280px;
  min-width: 260px;
  max-width: 420px;
}
.field-h.fw-intro .code-input-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.code-input-wrap input.code.code-sm {
  width: 10ch;
  min-width: 10ch;
  max-width: 10ch;
  font-variant-numeric: tabular-nums;
}
.field-h.fw-pos {
  flex: 1 1 auto;
  min-width: 320px;
  max-width: 100%;
}
.field-h.fw-pos > .code-input-wrap {
  flex-wrap: wrap;
}
.field-h.fw-nick { flex: 0 0 auto; width: 200px; }
.field-h.fw-code {
  flex: 0 0 auto;
  width: auto;
}
.field-h.fw-code > input {
  flex: 0 0 auto;
  width: 10ch;
  min-width: 10ch;
  max-width: 10ch;
  font-variant-numeric: tabular-nums;
}
.field-h > label.label-2line {
  line-height: 1.15;
  white-space: normal;
}
.field-h.align-center { align-items: center; }
/* 全銀協: 銀行4桁 / 支店3桁 + 名称ラベル */
.bank-code-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.bank-code-wrap input.bank-cd {
  flex: 0 0 auto;
  width: 4.5em;
  min-width: 4.5em;
  max-width: 4.5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.bank-code-wrap input.branch-cd {
  flex: 0 0 auto;
  width: 3.5em;
  min-width: 3.5em;
  max-width: 3.5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.bank-code-wrap .bank-nm {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--line-strong);
  border-radius: 0;
  padding: 4px 2px;
  color: var(--ink-2);
  font-size: 12.5px;
}
.bank-code-wrap .bank-nm:focus {
  border-bottom-color: var(--accent);
  box-shadow: none;
  outline: none;
}
.bank-code-wrap .bank-nm::placeholder { color: var(--ink-3); opacity: 1; }
/* 日付は yyyy/mm/dd + カレンダーアイコン分の固定幅(ラベル幅は別) */
.field-h.fw-date {
  flex: 0 0 auto;
  width: auto;
}
.field-h.fw-date > input[type="date"] {
  flex: 0 0 auto;
  width: 9.6em;
  min-width: 9.6em;
  max-width: 9.6em;
}
.field-h.fw-grow { flex: 1 1 200px; }
.field-h.fw-full { flex: 1 1 100%; width: 100%; }
/* 住所1・2: 広いとき横並び、狭いとき折り返して縦並び */
.entry-row-addr .field-h.fw-grow {
  flex: 1 1 260px;
  min-width: min(100%, 220px);
}
/* 会員名・メール: 登録日+会員区分と同じ幅 → 性別・電話が有効期限と横位置で揃う */
.entry-dense .field-h.fw-cap-addr {
  flex: 0 0 auto;
  width: calc(7.5em + 6px + 9.6em + 10px + 190px);
  max-width: 100%;
}
.entry-panel {
  margin-left: calc(7.5em + 6px);
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: calc(100% - 7.5em - 6px);
}
/* 口座タブ: ボーナス振込 / 定期購入引落 */
.entry-account-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}
.entry-account-col {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.entry-account-col .col-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-strong);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.entry-account-col .entry-rows { gap: 5px; }
.entry-account-col .field-h.fw-full > input,
.entry-account-col .field-h.fw-full > select {
  flex: 1 1 auto;
}
.popup-shell .entry-dense .field-h > label { font-size: 11px; }
.popup-shell .entry-dense .code-input-wrap .resolved-name { padding: 4px 8px; }

.field-hint { font-size: 11px; color: var(--ink-3); }
.field-auto {
  font-size: 11px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 600;
}

.code-input-wrap { display: flex; gap: 6px; align-items: center; position: relative; }
.code-input-wrap input.code {
  width: 16ch;
  min-width: 16ch;
  flex: none;
  font-family: var(--mono);
}
.code-input-wrap > .btn { flex: none; }
.code-input-wrap .resolved-name {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lookup-btn {
  flex: none;
  width: 31px; height: 31px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.lookup-btn:hover { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.lookup-btn svg { width: 15px; height: 15px; }

/* オートコンプリート */
.ac-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 340px;
  max-height: 260px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-3);
  z-index: 90;
  padding: 5px;
}
.ac-item {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.ac-item:hover, .ac-item.sel { background: var(--accent-soft); }
.ac-item .ac-code { font-family: var(--mono); font-size: 12px; color: var(--accent-strong); width: 64px; flex: none; }
.ac-item .ac-sub { margin-left: auto; font-size: 11px; color: var(--ink-3); }

/* ---------- 組織図ツリー(展開式インデントツリー、上位者ピッカー用) ---------- */
.org-tree-scroll {
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 4px;
}
.org-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  white-space: nowrap;
}
.org-tree-toggle {
  width: 18px; height: 18px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-3);
  flex: none;
}
.org-tree-toggle-spacer { display: inline-block; width: 18px; flex: none; }
.org-tree-node.occupied {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px;
  border-radius: 6px;
}
.org-tree-node.occupied .code { font-family: var(--mono); color: var(--ink-3); font-size: 12px; }
.org-tree-node.occupied.highlight { background: var(--accent-soft); }
.org-tree-node.occupied.pickable {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.org-tree-node.occupied.pickable:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.org-tree-node.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: none;
  padding: 2px 10px;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 12.5px;
}
.org-tree-node.empty:hover { background: var(--accent-soft); }
.org-tree-search-results { list-style: none; margin: 0 0 12px; padding: 0; max-height: 160px; overflow-y: auto; }

/* ラジオピル */
.pill-group { display: inline-flex; background: var(--neutral-bg); border-radius: 9px; padding: 3px; gap: 2px; }
.pill-group label {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.pill-group input { display: none; }
.pill-group input:checked + span { }
.pill-group label:has(input:checked) {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: var(--shadow-1);
}

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--accent); }

/* ---------- テーブル ---------- */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 7px 12px;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
/* 並び替え可能な列ヘッダー(Components/Shared/SortableHeader.razor)
   通常は ink-3、ホバー/現在の並び替え列だけ ink（黒） */
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--ink); background: var(--surface-3, var(--surface-2)); }
table.data thead th.sortable.sorted { color: var(--ink); }
table.data thead th .sort-mark { margin-left: 4px; font-size: 10px; }

table.data tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { cursor: default; }
table.data tbody tr:hover { background: var(--accent-softer); }
table.data tr.clickable { cursor: pointer; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
/* 一覧の本文・副次テキストは黒（プレースホルダー用グレーと誤認しない） */
table.data .code { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
table.data a.link-inline {
  color: var(--accent-strong);
  text-decoration: none;
  font-family: inherit;
}
table.data a.link-inline:hover { text-decoration: underline; }
table.data .sub { font-size: 11.5px; color: var(--ink); }
table.data tbody .muted,
table.data tbody .small { color: var(--ink); }
table.data.order-list thead tr:first-child th,
table.data.member-list thead tr:first-child th { border-bottom: none; padding-bottom: 2px; }
table.data.order-list thead tr:last-child th,
table.data.member-list thead tr:last-child th {
  padding-top: 2px;
  font-weight: 600;
}
table.data.order-list tbody tr.order-row-top td,
table.data.member-list tbody tr.order-row-top td {
  border-bottom: none;
  padding-bottom: 2px;
}
table.data.order-list tbody tr.order-row-bottom td,
table.data.member-list tbody tr.order-row-bottom td {
  padding-top: 2px;
  vertical-align: top;
  color: var(--ink);
  font-size: 12.5px;
}
.order-status-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.order-status-badges .badge {
  font-size: 10.5px;
  padding: 3px 7px;
}
table.data.order-list tbody tr.order-row-top:hover,
table.data.order-list tbody tr.order-row-top:hover + tr.order-row-bottom,
table.data.order-list tbody tr.order-row-bottom:hover,
table.data.order-list tbody tr.order-row-top:has(+ tr.order-row-bottom:hover),
table.data.member-list tbody tr.order-row-top:hover,
table.data.member-list tbody tr.order-row-top:hover + tr.order-row-bottom,
table.data.member-list tbody tr.order-row-bottom:hover,
table.data.member-list tbody tr.order-row-top:has(+ tr.order-row-bottom:hover) {
  background: var(--accent-softer);
}
table.data .remarks-cell {
  max-width: 220px;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
table.data tfoot td {
  padding: 8px 12px;
  font-weight: 700;
  background: var(--surface-2);
  border-top: 2px solid var(--line-strong);
}
tr.row-danger td { background: #fdf6f6; }
tr.row-selected td { background: var(--accent-softer); }
tr.row-muted td,
tr.row-muted td .muted,
tr.row-muted td .sub,
tr.row-muted td .code,
tr.row-muted td .small {
  color: var(--ink-3);
}
tr.row-total th { background: var(--surface-2, #f3f4f6); font-weight: 600; }

/* 明細グリッド(編集用) */
table.grid-edit { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid-edit th {
  background: var(--surface-2);
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 700;
  padding: 8px 8px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
table.grid-edit td { border: 1px solid var(--line); padding: 3px; background: #fff; }
table.grid-edit td input, table.grid-edit td select {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 13px;
  background: transparent;
}
table.grid-edit td input:hover { background: var(--surface-2); }
table.grid-edit td input:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(42,120,214,.14); }
table.grid-edit td .cell-static { padding: 7px 8px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.grid-edit .num input { text-align: right; font-variant-numeric: tabular-nums; }
table.grid-edit .row-del {
  width: 30px; text-align: center;
}
/* 1明細=2行。明細内は破線、明細間は実線 */
table.grid-edit thead tr:first-child th { border-bottom: none; }
table.grid-edit thead tr + tr th { border-top: 1px dashed var(--line); font-weight: 600; }
table.grid-edit tbody tr.r1 td { border-bottom: none; }
table.grid-edit tbody tr.r2 td { border-top: 1px dashed var(--line); border-bottom: 1.5px solid var(--line-strong); }
table.grid-edit tbody tr.even td { background: #f6f9fd; }

.close-guard {
  display: flex;
  gap: 10px;
  align-items: center;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
  margin-top: 12px;
}
.close-guard.ok {
  background: var(--good-bg);
  border: 1px solid #cdeacd;
  color: var(--good-ink);
}
.close-guard.ng {
  background: var(--bad-bg);
  border: 1px solid #f0c7c7;
  color: var(--bad-ink);
}
.row-del button {
  border: none; background: transparent; color: var(--ink-3);
  cursor: pointer; width: 26px; height: 26px; border-radius: 6px;
  display: inline-grid; place-items: center;
}
.row-del button:hover { background: var(--bad-bg); color: var(--bad-ink); }
.row-del svg { width: 14px; height: 14px; }

/* ---------- バッジ・ステータス ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.plain::before { display: none; }
.badge-good { background: var(--good-bg); color: var(--good-ink); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-serious { background: var(--serious-bg); color: var(--serious); }
.badge-bad { background: var(--bad-bg); color: var(--bad-ink); }
.badge-neutral { background: var(--neutral-bg); color: var(--ink-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- KPI タイル ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 11px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.kpi-label { font-size: 11.5px; font-weight: 600; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.kpi-value .unit { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.kpi-delta { font-size: 11.5px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.delta-up { color: #006300; }
.delta-down { color: var(--bad-ink); }
.kpi-note { font-size: 11px; color: var(--ink-3); }
.kpi-zero { background: var(--surface-2); opacity: .68; }
.kpi-alert:not(.kpi-zero) { border-color: #e4b3a0; background: var(--serious-bg); }
.kpi-alert:not(.kpi-zero) .kpi-value { color: var(--serious); }
.dashboard-section { margin-top: 18px; }
.dashboard-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dashboard-section-head h2 { margin: 0; font-size: 16px; }
.dashboard-batch-alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--bad); border-radius: var(--radius); background: var(--bad-bg); color: var(--bad-ink); }
.dashboard-alert-link { color: var(--bad-ink); font-weight: 700; white-space: nowrap; }
.dashboard-mfa-note { margin-top: 18px; border: 1px solid var(--warn); background: var(--warn-bg); }

/* ---------- タブ ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 0 4px;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font);
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tab .count {
  font-size: 10.5px;
  background: var(--neutral-bg);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 5px;
}
.tab.active .count { background: var(--accent-soft); color: var(--accent-strong); }

/* インデックス／フォルダ風タブ(選択タブが内容面とつながる) */
.tabs.tabs-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 0;
  background: #c9daf0;
  border-bottom: 1px solid var(--line-strong);
  flex: none;
}
.tabs.tabs-bar .tabs-bar-tabs {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  min-width: 0;
  overflow: visible;
}
.tabs.tabs-bar .tabs-bar-status {
  flex: none;
  margin-bottom: 6px;
  margin-right: 4px;
}
.tabs.tabs-bar .tab {
  padding: 7px 16px 9px;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--ink-2);
  background: transparent;
  position: relative;
  z-index: 0;
}
.tabs.tabs-bar .tab:hover {
  background: rgba(255, 255, 255, .45);
  color: var(--ink);
}
.tabs.tabs-bar .tab.active {
  background: var(--surface);
  color: var(--accent-strong);
  border-color: var(--line-strong);
  border-bottom-color: var(--surface);
  box-shadow: none;
  z-index: 1;
}
/* タブ内容面＝選択タブと同色(白)。基本情報の薄い青と差を付ける */
.split-card.entry-dense .entry-scroll > .card-body {
  background: var(--surface);
  flex: none;
}
.card.status-pending .tabs.tabs-bar {
  background: #c5ccd6;
}
.card.status-pending .tabs.tabs-bar .tab.active {
  background: var(--surface);
  border-bottom-color: var(--surface);
}

/* タブ切替時に高さが変わらないよう、全ペインを同じグリッドセルに重ねて
   最も縦幅の大きいペインに揃える(非表示ペインも高さ計算には参加させる) */
.tabstack { display: grid; }
.tabstack .tabpane {
  grid-area: 1 / 1;
  min-width: 0;
}
.tabstack .tabpane.tabpane-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* ---------- フィルターバー（検索パネル: 共通UI 薄い青） ---------- */
.filter-bar,
.panel-search {
  display: flex;
  gap: 8px 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #f0f7ff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.filter-bar .field,
.panel-search .field { min-width: 130px; }
.filter-bar .field.grow,
.panel-search .field.grow { flex: 1; min-width: 200px; }
.filter-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }

/* ---------- モーダル ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 38, .45);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 720px;
  animation: modalIn .18s ease-out;
}
.modal.modal-sm { max-width: 460px; }
.modal.modal-lg { max-width: 940px; }
.modal.modal-xl { max-width: 1200px; }
@keyframes modalIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15px; }
.modal-close {
  margin-left: auto;
  border: none; background: none;
  width: 30px; height: 30px;
  border-radius: 7px;
  display: grid; place-items: center;
  cursor: pointer; color: var(--ink-3);
}
.modal-close:hover { background: var(--neutral-bg); color: var(--ink); }
.modal-body { padding: 16px 18px; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 16px 16px;
}
.modal-foot .foot-note { margin-right: auto; font-size: 11.5px; color: var(--ink-3); align-self: center; }

.confirm-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  flex: none;
}
.confirm-icon.warn { background: var(--warn-bg); color: var(--warn); }
.confirm-icon.danger { background: var(--bad-bg); color: var(--bad-ink); }
.confirm-icon svg { width: 22px; height: 22px; }

/* ---------- トースト（横一列バナー） ---------- */
.toast-area {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  /* 成功・情報（既定）: 薄い緑＋黒字 */
  background: var(--good-bg);
  color: var(--ink);
  border-bottom: 1px solid #b7dfb7;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  padding: 12px 20px;
  text-align: center;
  box-shadow: var(--shadow-1);
  animation: toastIn .22s ease-out;
  pointer-events: auto;
}
.toast.toast-warn {
  background: var(--warn-bg);
  color: var(--ink);
  border-bottom-color: #efd59a;
}
.toast svg { width: 17px; height: 17px; color: var(--good); flex: none; }
.toast.toast-warn svg { color: var(--warn); }
@keyframes toastIn {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- ユーティリティ ---------- */
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-14 { margin-top: 10px; }
.mt-18 { margin-top: 12px; } .mt-24 { margin-top: 16px; }
.mb-14 { margin-bottom: 10px; } .mb-18 { margin-bottom: 12px; }
.flex { display: flex; } .aic { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.ml-auto { margin-left: auto; }
.muted { color: var(--ink); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 12px; align-items: start; }
.grid-main-side > *, .grid-2col > *, .grid-3col > * { min-width: 0; }

.divider { height: 1px; background: var(--line); margin: 18px 0; border: none; }

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* 伝票合計フッター */
.slip-total-bar {
  display: flex;
  gap: 22px;
  justify-content: flex-end;
  align-items: baseline;
  padding: 10px 14px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-wrap: wrap;
}
.slip-total-bar .t-item { display: flex; align-items: baseline; gap: 9px; }
.slip-total-bar .t-label { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.slip-total-bar .t-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.slip-total-bar .t-grand .t-value { font-size: 21px; font-weight: 800; color: var(--accent-strong); }

/* 保存アクションバー */
.action-bar {
  position: sticky;
  bottom: 0;
  margin-top: 14px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  padding: 9px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 30;
}
.action-bar .bar-note { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.action-bar .bar-note kbd {
  font-family: var(--font); font-size: 10.5px;
  border: 1px solid var(--line-strong); border-radius: 4px;
  background: var(--surface-2); padding: 1px 5px;
}

/* 空状態 */
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}
.empty svg { width: 36px; height: 36px; margin-bottom: 10px; opacity: .4; }

/* ステップ(締処理) */
.steps { display: flex; gap: 0; margin-bottom: 12px; }
.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-right: none;
  position: relative;
  font-size: 13px;
  color: var(--ink-3);
}
.step:first-child { border-radius: 10px 0 0 10px; }
.step:last-child { border-radius: 0 10px 10px 0; border-right: 1px solid var(--line); }
.step .step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--neutral-bg);
  color: var(--ink-3);
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
  flex: none;
}
.step.done .step-num { background: var(--good-bg); color: var(--good-ink); }
.step.current { color: var(--ink); font-weight: 600; background: var(--accent-softer); }
.step.current .step-num { background: var(--accent); color: #fff; }

/* ログインページ */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--page-bg);
}
.login-hero {
  background:
    radial-gradient(1000px 600px at 20% 0%, rgba(57,135,229,.35), transparent 60%),
    radial-gradient(800px 500px at 90% 100%, rgba(124,95,211,.25), transparent 55%),
    #0d1521;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
}
.login-hero .hero-title { font-size: 30px; font-weight: 800; line-height: 1.35; letter-spacing: -.01em; }
.login-hero .hero-sub { color: #9aa7ba; margin-top: 14px; font-size: 14px; line-height: 1.8; }
.login-panel {
  display: grid;
  place-items: center;
  padding: 40px;
}
.login-card { width: 100%; max-width: 400px; }
.login-card .card-body { padding: 30px; }
.hero-points { display: flex; flex-direction: column; gap: 14px; margin-top: 34px; }
.hero-point { display: flex; gap: 12px; align-items: flex-start; color: #c6d0dd; font-size: 13px; line-height: 1.6; }
.hero-point svg { width: 18px; height: 18px; color: #3987e5; flex: none; margin-top: 2px; }

.mfa-boxes { display: flex; gap: 9px; justify-content: center; }
.mfa-boxes input {
  width: 46px; height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  font-family: var(--mono);
}

/* チャート共通 */
.viz-root {
  color-scheme: light;
  --surface-1: #ffffff;
  --viz-text: #52514e;
  --viz-muted: #898781;
  --viz-grid: #e9e8e4;
  --viz-axis: #c3c2b7;
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --series-3: #eda100;
}
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: #17212f;
  color: #fff;
  font-size: 11.5px;
  border-radius: 7px;
  padding: 6px 10px;
  box-shadow: var(--shadow-2);
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
  z-index: 60;
  display: none;
}

/* 印刷風プレビュー */
.pdf-preview {
  background: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2);
  padding: 34px 38px;
  font-size: 12px;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- レスポンシブ ----------
   要件 3.4: モバイルでも全機能が動作すること(操作性は PC 優先) */

.nav-toggle { display: none; }
.nav-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 38, .45);
  z-index: 49;
  display: none;
}

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid-main-side { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

/* スマートフォンのみサイドバーをドロワー化する。
   タブレット(768px〜)では画面幅に余裕があるため常時表示のままにする(UI規約 3.4)。
   レイアウトの詰め(フォーム段組み・横スクロール等)は 860px の指定を別に持つ。 */
@media (max-width: 767px) {
  .sidebar {
    left: -290px;
    width: 264px;
    box-shadow: var(--shadow-3);
  }
  body.nav-open .sidebar, .nav-open .sidebar { left: 0; }
  body.nav-open .nav-backdrop, .nav-open .nav-backdrop { display: block; }
  body.nav-open, .nav-open { overflow: hidden; }
  /* サイドバーが浮くので本文の左オフセットを外す(常時表示時は外さないこと) */
  .main { margin-left: 0; }
  .nav-toggle { display: grid; }
}

@media (max-width: 860px) {
  /* 最上段ナビ簡略化 */
  .app-topnav { padding: 0 8px; gap: 6px; }
  .module-tab { padding: 7px 10px; font-size: 12.5px; }
  .user-chip > div:last-child { display: none; }
  .user-chip { padding: 4px; border: none; }

  .content { padding: 14px 14px 90px; }
  .page-head { gap: 10px; }
  .page-head h1 { font-size: 18px; }
  .page-head-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }

  /* フォームは2列へ集約 */
  .form-grid.cols-3, .form-grid.cols-4, .form-grid.cols-6 { grid-template-columns: repeat(2, 1fr); }
  .span-3, .span-4 { grid-column: span 2; }

  .entry-dense .field-h.fw-xs,
  .entry-dense .field-h.fw-sm,
  .entry-dense .field-h.fw-md,
  .entry-dense .field-h.fw-nick,
  .entry-dense .field-h.fw-pos { width: auto; flex: 1 1 140px; }
  .entry-dense .field-h.fw-date { width: auto; flex: 0 0 auto; }
  .entry-dense .field-h.fw-date > input[type="date"] {
    width: 9.6em;
    min-width: 9.6em;
    max-width: 9.6em;
  }
  .entry-dense .field-h.fw-code > input {
    width: 10ch;
    min-width: 10ch;
    max-width: 10ch;
  }
  .entry-dense .entry-row-addr .field-h.fw-grow {
    flex: 1 1 100%;
    min-width: 100%;
  }
  .entry-dense .entry-account-split { grid-template-columns: 1fr; }
  /* 狭い画面でもラベルは右寄せのまま(入力との対応を保つ) */

  .grid-2col, .grid-3col { grid-template-columns: 1fr; }

  /* テーブル・明細グリッドは横スクロールで全列を維持 */
  .card-body.tight { overflow-x: auto; }
  table.grid-edit { min-width: 720px; }
  .table-wrap table.data { min-width: 640px; }

  .filter-bar { padding: 12px 14px; }
  .filter-bar .field { min-width: calc(50% - 6px); flex: 1; }
  .filter-bar .field.grow { min-width: 100%; }

  .steps { flex-direction: column; }
  .step { border-right: 1px solid var(--line); border-bottom: none; }
  .step:first-child { border-radius: 10px 10px 0 0; }
  .step:last-child { border-radius: 0 0 10px 10px; border-bottom: 1px solid var(--line); }
  .step + .step { border-top: none; }

  .action-bar { flex-wrap: wrap; padding: 10px 12px; position: sticky; }
  .action-bar .bar-note { display: none; }
  .action-bar .ml-auto { margin-left: 0; width: 100%; justify-content: flex-end; flex-wrap: wrap; }

  .slip-total-bar { gap: 12px 20px; padding: 12px 14px; }
  .slip-total-bar .t-value { font-size: 14px; }
  .slip-total-bar .t-grand .t-value { font-size: 18px; }

  .modal-backdrop { padding: 16px 8px; }
  .modal-body { padding: 16px 14px; }
  .modal-head, .modal-foot { padding-left: 14px; padding-right: 14px; }
  .modal-foot { flex-wrap: wrap; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; }

  .ac-list { width: min(340px, calc(100vw - 48px)); }
  .toast { padding: 12px 14px; font-size: 13px; }
  .login-panel { padding: 20px 14px; }
}

@media (max-width: 600px) {
  .app-topnav .brand-name { display: none; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
  .kpi-value { font-size: 21px; }
  .pill-group label { padding: 6px 10px; font-size: 12px; }
  .mfa-boxes input { width: 40px; height: 48px; font-size: 19px; }
}

/* ===== Blazor エラーUI・再接続モーダル(テンプレート由来) ===== */
#blazor-error-ui {
  color-scheme: light only;
  background: lightyellow;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}
#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.components-rejoining-animation {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: block;
}

#components-reconnect-modal {
    background-color: white;
    width: 20rem;
    margin: 20vh auto;
    padding: 2rem;
    border: 0;
    border-radius: 0.5rem;
    box-shadow: 0 3px 6px 2px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete;
    animation: components-reconnect-modal-fadeOutOpacity 0.5s both;
}

#components-reconnect-modal[open] {
    animation: components-reconnect-modal-slideUp 1.5s cubic-bezier(.05, .89, .25, 1.02) 0.3s, components-reconnect-modal-fadeInOpacity 0.5s ease-in-out 0.3s;
    animation-fill-mode: both;
}

#components-reconnect-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.4);
    animation: components-reconnect-modal-fadeInOpacity 0.5s ease-in-out;
    opacity: 1;
}

@keyframes components-reconnect-modal-slideUp {
    0% {
        transform: translateY(30px) scale(0.95);
    }

    100% {
        transform: translateY(0);
    }
}

@keyframes components-reconnect-modal-fadeInOpacity {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes components-reconnect-modal-fadeOutOpacity {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.components-reconnect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#components-reconnect-modal p {
    margin: 0;
    text-align: center;
}

#components-reconnect-modal button {
    border: 0;
    background-color: #6b9ed2;
    color: white;
    padding: 4px 24px;
    border-radius: 4px;
}

#components-reconnect-modal button:hover {
    background-color: #3b6ea2;
}

#components-reconnect-modal button:active {
    background-color: #6b9ed2;
}

.components-rejoining-animation {
    position: relative;
    width: 80px;
    height: 80px;
}

.components-rejoining-animation div {
    position: absolute;
    border: 3px solid #0087ff;
    opacity: 1;
    border-radius: 50%;
    animation: components-rejoining-animation 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.components-rejoining-animation div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes components-rejoining-animation {
    0% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 0;
    }

    4.9% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 0;
    }

    5% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 1;
    }

    100% {
        top: 0px;
        left: 0px;
        width: 80px;
        height: 80px;
        opacity: 0;
    }
}

/* ---------- オンラインヘルプ ---------- */
.help-topnav-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.help-trigger {
  min-width: 32px;
  font-weight: 700;
}
.help-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 38, .35);
  z-index: 110;
}
.help-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  z-index: 111;
  display: flex;
  flex-direction: column;
  animation: helpDrawerIn .18s ease-out;
}
@keyframes helpDrawerIn {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.help-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.help-drawer-head h3 { font-size: 15px; margin: 0; }
.help-drawer-body {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 24px;
}
.help-drawer-foot {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.help-layout {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 12px;
  align-items: start;
}
.help-toc .help-toc-module {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin: 12px 0 4px;
  text-transform: none;
}
.help-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.help-toc-list a {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}
.help-toc-list a:hover { background: var(--surface-2, #f3f5f8); }
.help-toc-list a.active {
  background: color-mix(in srgb, var(--accent, #2f6fed) 12%, transparent);
  font-weight: 600;
}
.help-summary {
  padding: 10px 12px;
  background: var(--surface-2, #f5f7fa);
  border-radius: 10px;
  margin: 0 0 16px;
  line-height: 1.5;
}
.help-markdown {
  line-height: 1.65;
  font-size: 14px;
}
.help-markdown h1 { font-size: 1.35rem; margin: 0 0 12px; }
.help-markdown h2 { font-size: 1.1rem; margin: 1.4em 0 .5em; }
.help-markdown h3 { font-size: 1rem; margin: 1.2em 0 .4em; }
.help-markdown p, .help-markdown ul, .help-markdown ol, .help-markdown table {
  margin: 0 0 .85em;
}
.help-markdown ul, .help-markdown ol { padding-left: 1.3em; }
.help-markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.help-markdown th, .help-markdown td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
}
.help-markdown th { background: var(--surface-2, #f5f7fa); }
.help-markdown code {
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2, #f0f2f5);
}
@media (max-width: 900px) {
  .help-layout { grid-template-columns: 1fr; }
}
