/* ===========================================================
   Design tokens
   =========================================================== */
:root {
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --primary-soft: #e8f0fe;

  --bg: #f5f4ef;
  --panel: #ffffff;
  --surface-1: #faf9f5;
  --surface-2: #f0eee9;
  --line: #e4e2db;
  --line-strong: #cdcac0;

  --ink-1: #1f1d1a;
  --ink-2: #4a4742;
  --ink-3: #76726a;
  --ink-4: #a3a097;
  --ink-5: #c8c5bb;

  --ok: #137333;
  --ok-soft: #e6f4ea;
  --warn: #b06a16;
  --warn-soft: #fbf0dc;
  --err: #c5221f;
  --err-soft: #fce8e6;

  /* 見積ステータス */
  --q-pending: #76726a;       --q-pending-soft: #efeee9;
  --q-quoted: #137333;        --q-quoted-soft: #e6f4ea;
  --q-substituted: #6244a8;   --q-substituted-soft: #ece4f5;
  --q-unable: #c5221f;        --q-unable-soft: #fce8e6;
  --q-declined: #4a4742;      --q-declined-soft: #e6e4dd;

  /* 発注ステータス */
  --o-none: #a3a097;          --o-none-soft: #f6f5f1;
  --o-placed: #1a73e8;        --o-placed-soft: #e8f0fe;
  --o-canceled: #76726a;      --o-canceled-soft: #efeee9;

  /* 納入ステータス */
  --d-未納入: #c5221f;        --d-未納入-soft: #fce8e6;
  --d-部分納入: #b06a16;      --d-部分納入-soft: #fbf0dc;
  --d-納入済: #137333;        --d-納入済-soft: #e6f4ea;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(31,29,26,.04);
  --shadow-md: 0 2px 8px rgba(31,29,26,.06);
  --shadow-lg: 0 12px 32px rgba(31,29,26,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Helvetica Neue', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--ink-1);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
.mono, .num { font-family: 'SF Mono', 'JetBrains Mono', Consolas, monospace; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ===========================================================
   Shell: sidebar + main
   =========================================================== */
.shell { display: grid; grid-template-columns: 224px 1fr; flex: 1; min-height: 0; }

.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.sb-brand {
  padding: 14px 16px 12px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.sb-mark {
  width: 26px; height: 26px;
  background: var(--ink-1); color: white;
  border-radius: 5px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  letter-spacing: 0.04em;
}
.sb-brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.sb-brand-sub { font-size: 10px; color: var(--ink-3); letter-spacing: 0.05em; }

.sb-role {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  background: var(--surface-2); margin: 10px;
  padding: 2px; border-radius: var(--r-sm);
}
.sb-role-btn {
  background: transparent; border: none; padding: 6px;
  font-size: 11px; color: var(--ink-3); cursor: pointer;
  border-radius: 3px; font-weight: 500; font-family: inherit;
}
.sb-role-btn.active { background: var(--panel); color: var(--ink-1); box-shadow: var(--shadow-sm); }

.sb-section {
  font-size: 10px; color: var(--ink-3);
  padding: 8px 16px 4px; letter-spacing: 0.06em; font-weight: 500;
  text-transform: uppercase;
}
.sb-nav { padding: 0 8px; flex: 1; min-height: 0; overflow-y: auto; }
.sb-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 12.5px;
  cursor: pointer; border: none; background: transparent;
  width: 100%; text-align: left; font-family: inherit;
}
.sb-item:hover { background: var(--surface-2); }
.sb-item.active { background: var(--ink-1); color: white; font-weight: 500; }
.sb-item .sb-icon { font-size: 13px; opacity: 0.9; }
.sb-item .sb-count {
  margin-left: auto; font-size: 10px; color: var(--ink-4);
  background: var(--surface-2); padding: 1px 5px; border-radius: 8px;
}
.sb-item.active .sb-count { background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.9); }
.sb-divider { height: 1px; background: var(--line); margin: 8px 12px; }

.sb-foot {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sb-foot .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: white;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.sb-user-name { font-size: 12px; font-weight: 500; }
.sb-user-sub { font-size: 10px; color: var(--ink-3); }

/* ===========================================================
   Main area
   =========================================================== */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
#pageArea { flex: 1; min-height: 0; position: relative; overflow: hidden; }

.topbar {
  height: 56px; flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 18px; gap: 14px;
  z-index: 5;
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 19px; font-weight: 600; color: var(--ink-1); letter-spacing: -0.01em; }
.crumbs .sep { color: var(--ink-5); font-weight: 400; }
.crumbs .now { color: var(--ink-1); font-weight: 600; }
.tb-spacer { flex: 1; }
.tb-search {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-1); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: var(--r-md);
  width: 220px; font-size: 12px; color: var(--ink-3);
}
.tb-icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--ink-3); cursor: pointer;
  background: transparent; border: none;
  position: relative;
}
.tb-icon-btn:hover { background: var(--surface-1); color: var(--ink-1); }
.tb-icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--err);
}

.page {
  padding: 14px 18px;
  height: 100%;
  display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.page-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; margin-right: -4px; }
.page-h {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 18px; margin-bottom: 8px; flex-shrink: 0;
}
.page-h > div:first-child:not(.page-actions) { display: none; }  /* Page title/sub now lives in topbar */
.page-h:not(:has(.page-actions)) { display: none; }  /* Empty header collapses */
.page-title, .page-sub { display: none; }
.page-actions { display: flex; gap: 6px; }

/* ===========================================================
   Components
   =========================================================== */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.card-h {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card-title { font-size: 13px; font-weight: 600; }
.card-sub { font-size: 11px; color: var(--ink-3); }
.card-body { padding: 14px; }
.card-foot {
  padding: 10px 14px;
  background: var(--surface-1);
  border-top: 1px solid var(--line);
  display: flex; gap: 6px; justify-content: flex-end; align-items: center;
}

.btn {
  font-family: inherit; font-size: 12px; font-weight: 500;
  padding: 5px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink-1);
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-1); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-dark { background: var(--ink-1); color: white; border-color: var(--ink-1); }
.btn-dark:hover { background: #000; }
.btn-success { background: var(--ok); color: white; border-color: var(--ok); }
.btn-success:hover { filter: brightness(1.05); }
.btn-warn { color: var(--warn); border-color: var(--line-strong); }
.btn-warn:hover { background: var(--warn-soft); }
.btn-danger { color: var(--err); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--err-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-1); }
.btn-sm { padding: 3px 8px; font-size: 11px; }
.btn-xs { padding: 2px 6px; font-size: 10px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.input, .select, textarea {
  font-family: inherit; font-size: 13px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink-1);
}
.input:focus, .select:focus, textarea:focus {
  outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary);
}
.field-label { font-size: 11px; color: var(--ink-3); margin-bottom: 3px; }

/* Tables */
.tbl-wrap { overflow: auto; border-radius: var(--r-md); }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl thead th {
  text-align: left; padding: 7px 10px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 500; color: var(--ink-3);
  letter-spacing: 0.03em; white-space: nowrap;
}
.tbl tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover td { background: var(--surface-1); }
.tbl tbody tr.selected td { background: var(--primary-soft); }
.tbl-num { text-align: right; font-family: 'SF Mono', monospace; font-variant-numeric: tabular-nums; font-size: 12px; }
.tbl-id { font-family: 'SF Mono', monospace; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* Dual stripe (二軸ステート視覚化) */
.tbl-stripe { padding: 0 !important; width: 6px; position: relative; }
.tbl-stripe::before, .tbl-stripe::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 3px;
}
.tbl-stripe::before { left: 0; }
.tbl-stripe::after { left: 3px; }

/* Chip / Badge */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 500;
  padding: 1px 6px 2px; border-radius: 3px;
  letter-spacing: 0.02em; white-space: nowrap; line-height: 1.5;
}
.chip-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

.chip-q-pending { background: var(--q-pending-soft); color: var(--q-pending); }
.chip-q-pending .chip-dot { background: var(--q-pending); }
.chip-q-quoted { background: var(--q-quoted-soft); color: var(--q-quoted); }
.chip-q-quoted .chip-dot { background: var(--q-quoted); }
.chip-q-substituted { background: var(--q-substituted-soft); color: var(--q-substituted); }
.chip-q-substituted .chip-dot { background: var(--q-substituted); }
.chip-q-unable { background: var(--q-unable-soft); color: var(--q-unable); }
.chip-q-unable .chip-dot { background: var(--q-unable); }
.chip-q-declined { background: var(--q-declined-soft); color: var(--q-declined); }
.chip-q-declined .chip-dot { background: var(--q-declined); }

.chip-o-none { background: var(--o-none-soft); color: var(--o-none); }
.chip-o-none .chip-dot { background: var(--o-none); }
.chip-o-placed { background: var(--o-placed-soft); color: var(--o-placed); font-weight: 600; }
.chip-o-placed .chip-dot { background: var(--o-placed); }
.chip-o-canceled { background: var(--o-canceled-soft); color: var(--o-canceled); text-decoration: line-through; }

.chip-d-未納入 { background: var(--d-未納入-soft); color: var(--d-未納入); }
.chip-d-部分納入 { background: var(--d-部分納入-soft); color: var(--d-部分納入); }
.chip-d-納入済 { background: var(--d-納入済-soft); color: var(--d-納入済); }

.chip-deal {
  background: var(--primary-soft); color: var(--primary);
  font-family: 'SF Mono', monospace; font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Stat cards */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--panel); margin-bottom: 16px; }
.stat { padding: 12px 14px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }
.stat-l { font-size: 11px; color: var(--ink-3); margin-bottom: 4px; }
.stat-v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-v small { font-size: 12px; color: var(--ink-3); margin-left: 3px; font-weight: 400; }
.stat-d { font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }

/* Subtabs */
.subtabs { display: inline-flex; gap: 2px; background: var(--surface-1); padding: 2px; border-radius: var(--r-sm); }
.subtab { padding: 4px 10px; font-size: 12px; color: var(--ink-3); border-radius: 3px; cursor: pointer; }
.subtab.active { background: var(--panel); color: var(--ink-1); font-weight: 500; box-shadow: var(--shadow-sm); }

/* Tabs (large) */
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab {
  padding: 8px 14px; font-size: 12.5px; color: var(--ink-3);
  border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ink-1); }
.tab.active { color: var(--ink-1); border-bottom-color: var(--ink-1); font-weight: 500; }
.tab-count { font-size: 10px; background: var(--surface-2); color: var(--ink-3); padding: 1px 5px; border-radius: 8px; }
.tab.active .tab-count { background: var(--ink-1); color: white; }

/* Checkbox */
.cb {
  width: 14px; height: 14px; border: 1.5px solid var(--line-strong); border-radius: 3px;
  background: var(--panel); display: inline-grid; place-items: center; flex-shrink: 0; vertical-align: middle;
}
.cb.checked { background: var(--ink-1); border-color: var(--ink-1); }
.cb.checked::after {
  content: ""; width: 7px; height: 4px;
  border-left: 1.5px solid white; border-bottom: 1.5px solid white;
  transform: rotate(-45deg) translate(1px, -1px);
}
.cb.disabled { background: var(--surface-2); border-style: dashed; cursor: not-allowed; }

/* Master-detail layout */
.md-layout {
  display: grid; grid-template-columns: 360px 1fr; gap: 12px;
  flex: 1; min-height: 0;
}
.md-list, .md-detail { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.md-list > .card { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.md-list > .card > div:last-child { flex: 1; min-height: 0; overflow-y: auto; }

/* Detail card: header / tabs fixed, content scrollable. Card sizes to content (max = parent height) */
.md-detail { overflow: hidden; align-items: flex-start; }
.md-detail > .card {
  display: flex; flex-direction: column;
  max-height: 100%; min-height: 0;
  width: 100%;
  overflow: hidden;
}
.md-detail > .card[hidden] { display: none; }
.md-detail > .card > .card-h,
.md-detail > .card > [data-tabset] { flex-shrink: 0; }

/* Tab-pane: only active is shown. Scrolls when overflowing card max-height. */
.md-detail > .card > .tab-pane { display: none; }
.md-detail > .card > .tab-pane.active {
  display: block;
  min-height: 0; overflow-y: auto;
}

/* For .md-detail cards without tabs (vendor-rfq-list / vendor-orders) — wrap content in .md-card-body */
.md-detail > .card > .md-card-body { min-height: 0; overflow-y: auto; }
.md-list-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  position: relative;
}
.md-list-item:hover { background: var(--surface-1); }
.md-list-item.selected { background: var(--primary-soft); }
.md-list-item.selected::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 3px; background: var(--primary);
}

/* Note */
.note {
  background: var(--warn-soft); border: 1px solid #ecd6a8; color: #856404;
  padding: 8px 12px; border-radius: var(--r-sm); font-size: 11.5px;
  display: flex; gap: 8px; align-items: flex-start;
}
.note-info { background: var(--primary-soft); border-color: #c9d8ee; color: #1557b0; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(31,29,26,0.4);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: 92vh; width: 100%; max-width: 880px;
}
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; background: var(--surface-1); border-top: 1px solid var(--line); display: flex; gap: 6px; justify-content: flex-end; align-items: center; }

/* Cell edit (inline editable - readonly by default, becomes editable in edit mode) */
.cell-edit {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit; font-size: inherit; color: inherit;
  padding: 2px 4px;
  outline: none;
  border-radius: 2px;
  margin: 0;
  cursor: default;
}
.cell-edit:read-only { cursor: default; }
.cell-edit:not(:read-only) { cursor: text; }
.cell-edit:not(:read-only):hover { background: var(--surface-1); }
.cell-edit:not(:read-only):focus { background: white; box-shadow: inset 0 0 0 2px var(--primary); }
.cell-edit.mono { font-family: 'SF Mono', 'JetBrains Mono', Consolas, monospace; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.cell-edit.muted { color: var(--ink-3); }
.cell-edit.tbl-num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-edit.small { font-size: 10.5px; }

/* Select also disabled in non-editing mode (looks like text) */
select.cell-edit {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%237a746a' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 18px;
}
select.cell-edit:disabled, select.cell-edit[data-readonly] {
  background-image: none; padding-right: 4px;
  color: var(--ink-1); opacity: 1;
}
.tab-pane:not(.editing-mode) select.cell-edit { pointer-events: none; }
.tab-pane:not(.editing-mode) select.cell-edit { background-image: none; padding-right: 4px; }
.tab-pane.editing-mode .cell-edit:not(:focus) { background: #fafaf5; }

/* Add-row button (visible only in editing mode) */
.add-row-btn {
  padding: 6px 14px;
  background: var(--surface-1);
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-3);
  cursor: pointer;
  text-align: left;
  width: 100%;
  border-left: none; border-right: none; border-bottom: none;
  font-family: inherit;
  display: none;
}
.tab-pane.editing-mode .add-row-btn { display: block; }
.add-row-btn:hover { background: var(--surface-2); color: var(--ink-1); }

/* Edit mode action buttons */
.edit-actions { display: contents; }
.tab-pane.editing-mode .btn-edit-start { display: none; }
.tab-pane:not(.editing-mode) .btn-edit-save,
.tab-pane:not(.editing-mode) .btn-edit-cancel { display: none; }
.tab-pane.editing-mode { background: linear-gradient(180deg, #fffbe8 0%, transparent 50px); }
.editing-banner {
  background: var(--warn-soft); border: 1px solid #ecd6a8; color: #856404;
  padding: 5px 10px; font-size: 11px;
  display: none;
}
.tab-pane.editing-mode .editing-banner { display: block; }

/* Autocomplete dropdown (sample) */
.ac-dropdown {
  position: absolute;
  top: 100%; left: 0;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  z-index: 10;
  min-width: 320px;
  max-height: 240px; overflow-y: auto;
  display: none;
}
.tab-pane.editing-mode .ac-dropdown.show { display: block; }
.ac-h { padding: 5px 10px; background: var(--surface-1); font-size: 10px; color: var(--ink-3); border-bottom: 1px solid var(--line); }
.ac-item {
  padding: 5px 10px; cursor: pointer;
  border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
}
.ac-item:hover, .ac-item.active { background: var(--primary-soft); }
.ac-model { font-family: 'SF Mono', Consolas, monospace; font-weight: 500; font-size: 12px; }
.ac-meta { font-size: 10px; color: var(--ink-3); }
.ac-price { font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.ac-count { font-size: 9.5px; color: var(--ink-4); }
td.has-ac { position: relative; }

/* AG Grid mock (一括入力モーダル用) */
.aggrid-mock { border: 1px solid var(--line-strong); border-radius: var(--r-sm); height: 360px; display: flex; flex-direction: column; overflow: hidden; }
.aggrid-mock .ag-h { background: var(--surface-2); display: grid; grid-template-columns: 40px 1.4fr 1fr 1.6fr 70px; font-size: 11px; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--line-strong); }
.aggrid-mock .ag-h > div { padding: 6px 8px; border-right: 1px solid var(--line); }
.aggrid-mock .ag-body { flex: 1; overflow: auto; }
.aggrid-mock .ag-row { display: grid; grid-template-columns: 40px 1.4fr 1fr 1.6fr 70px; font-size: 12px; border-bottom: 1px solid var(--line); }
.aggrid-mock .ag-row > div { padding: 5px 8px; border-right: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aggrid-mock .ag-row.empty > div { color: var(--ink-4); font-style: italic; }
.aggrid-mock .ag-row .row-no-cell { background: var(--surface-1); color: var(--ink-3); text-align: center; }
.aggrid-mock .ag-row.pasted { background: #e6f4ea; }

/* Wizard steps (CSV 取込モーダル用) */
.wizard-steps { display: flex; gap: 4px; padding: 10px 0; }
.wizard-step { flex: 1; padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface-1); font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.wizard-step.active { background: var(--ink-1); color: white; }
.wizard-step.done { background: #e6f4ea; color: #1e8e3e; }
.wizard-num { width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); color: var(--ink-3); display: grid; place-items: center; font-size: 10px; font-weight: 600; }
.wizard-step.active .wizard-num { background: white; color: var(--ink-1); }
.wizard-step.done .wizard-num { background: #1e8e3e; color: white; }

/* Vendor line card (見積回答) */
.v-card {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 10px; background: var(--panel); margin-bottom: 5px;
  position: relative;
}
.v-card-quoted { border-left: 3px solid var(--q-quoted); }
.v-card-substituted { border-left: 3px solid var(--q-substituted); background: linear-gradient(90deg, var(--q-substituted-soft) 0%, var(--panel) 30%); }
.v-card-unable { border-left: 3px solid var(--q-unable); background: linear-gradient(90deg, var(--q-unable-soft) 0%, var(--panel) 30%); }
.v-card-pending { border-left: 3px solid var(--ink-5); }
.v-card .v-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.v-card .v-meta { flex: 1; min-width: 220px; }
.v-card .v-meta-title { font-size: 12.5px; font-weight: 600; }
.v-card .v-meta-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

/* File upload */
.file-zone { border: 1.5px dashed var(--line-strong); border-radius: var(--r-sm); padding: 18px; text-align: center; color: var(--ink-3); font-size: 12px; background: var(--surface-1); }
.file-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--surface-1); border-radius: 3px; margin-bottom: 3px; font-size: 11.5px; }

/* Login */
.login-overlay { position: fixed; inset: 0; background: var(--ink-1); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.login-box { background: var(--panel); border-radius: var(--r-lg); padding: 28px 24px; max-width: 360px; width: 100%; text-align: center; }
.login-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--surface-2); padding: 2px; border-radius: var(--r-sm); margin-bottom: 18px; }
.login-tab { padding: 7px; font-size: 12px; color: var(--ink-3); border-radius: 3px; cursor: pointer; border: none; background: transparent; font-family: inherit; font-weight: 500; }
.login-tab.active { background: var(--panel); color: var(--ink-1); box-shadow: var(--shadow-sm); }
.login-form { display: none; flex-direction: column; gap: 8px; }
.login-form.active { display: flex; }
.google-btn { background: white; color: #3c4043; border: 1px solid #dadce0; padding: 10px; border-radius: 6px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; font-family: inherit; }
.google-icon { width: 16px; height: 16px; background: linear-gradient(45deg,#4285f4,#34a853,#fbbc04,#ea4335); border-radius: 50%; }

/* Screens */
.screen { display: none; height: 100%; min-height: 0; }
.screen.active { display: flex; flex-direction: column; }

/* Tab content */
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.tab-pane > .tbl-wrap { max-height: 100%; }
/* Settings tabs need flex layout for full-height fill */
#screen-admin-settings .tab-pane.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
/* Invoice tabs use same flex layout */
#screen-admin-invoices .tab-pane.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* Mock helper banner */
.mock-banner {
  background: #2a2826; color: #c8c5bb;
  padding: 6px 16px; font-size: 11px; display: flex; gap: 12px; align-items: center;
  border-bottom: 1px solid #1a1816;
  flex-shrink: 0;
}
.mock-banner button {
  background: rgba(255,255,255,.1); color: white; border: none;
  padding: 3px 9px; border-radius: 3px; font-size: 11px; cursor: pointer; font-family: inherit;
}
.mock-banner button:hover { background: rgba(255,255,255,.2); }
.mock-banner button.active { background: var(--primary); }

/* Utility */
.muted { color: var(--ink-3); }
.muted-2 { color: var(--ink-4); }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.ai-c { align-items: center; }
.jc-sb { justify-content: space-between; }

/* ===========================================================
   Shared utilities (5 HTML 横断、レビュー指摘で集約 2026-04-29)
   page-title 仕様メモ：mockup ではタイトルはトップバーのパンくずに集約。
   各 HTML の .page-title / .page-sub は display:none（上の方の rule）。
   将来 SEO / 印刷に使う可能性があるので HTML 側の <div class="page-title"> は残置。
   =========================================================== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink-1); color: white;
  padding: 10px 18px; border-radius: var(--r-md);
  font-size: 12.5px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
  z-index: 600;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--err); }

.loading-row { padding: 30px 12px; text-align: center; color: var(--ink-3); font-size: 12px; }
.hidden { display: none !important; }

.detail-empty {
  flex: 1; display: grid; place-items: center;
  color: var(--ink-3); font-size: 13px;
  padding: 30px;
}

.row-del-btn {
  width: 22px; height: 22px;
  border: 1px solid var(--line-strong); background: var(--panel);
  color: var(--err); border-radius: var(--r-sm);
  cursor: pointer; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.row-del-btn:hover { background: var(--err-soft); }

.modal-h h2 { font-size: 14px; font-weight: 600; margin: 0; }
.modal-h .close {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; color: var(--ink-3); padding: 4px 8px;
}

.form-row { margin-bottom: 12px; }
.form-row .input, .form-row select, .form-row textarea { width: 100%; }

.picker-empty { padding: 14px; text-align: center; color: var(--ink-3); font-size: 12px; }
