/* =========================================================================
   VegeDesk 画面テーマ「場内サイン」
   市場の場内サイン（区画を示すブロック文字・安全色・相場板の等幅数字）を下敷きにした
   画面専用スタイル。media="screen" で読み込むので印刷結果には影響しない
   （印刷は print-legacy.css が担当）。
   Bootstrap 5 のクラス名はそのまま使い、見た目だけをここで上書きする。
   ========================================================================= */

/* ---- Tokens ------------------------------------------------------------ */
:root {
    /* ink / paper */
    --ink: #18201b;
    --ink-2: #4a534d;
    --ink-3: #6b736e;
    --paper: #ffffff;
    --surface: #ffffff;
    --surface-2: #f7f8f6;
    --surface-3: #eceee9;
    --rule: #d6dad5;
    --rule-2: #b9bfb9;
    --rule-strong: #18201b;

    /* brand: ベジコープの緑 */
    --green: #2f6b3f;
    --green-ink: #1f4a2b;
    --green-tint: #e7f0e9;
    --green-tint-2: #cfe1d4;

    /* signal: JIS 安全色（黄=注意／赤=危険） */
    --signal: #f2c230;
    --signal-ink: #18201b;
    --signal-tint: #fdf4d3;
    --signal-rule: #e6c867;
    --danger: #b3261e;
    --danger-tint: #fbeae8;
    --danger-rule: #e3b7b3;
    --info: #2c5d8f;
    --info-tint: #e6eef6;
    --info-rule: #bcd0e4;
    --info-ink: #1d4166;
    --danger-ink: #7d1a15;
    --danger-hover: #8f1e18;
    --signal-hover: #e3b31d;
    --signal-tint-2: #fbedb9;
    --on-ink-2: #b9c4bc;
    --sun-tint: #f4c7c3;
    --sat-tint: #c8d9ec;

    /* 旧テーマ名の互換（各ビュー内の <style> が参照している） */
    --rule-light: var(--rule);
    --green-dark: var(--green-ink);
    --panel: var(--surface);

    /* type */
    --font-ui: "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", Meiryo, sans-serif;
    --font-num: "BIZ UDGothic", "BIZ UDPGothic", Consolas, "Yu Gothic UI", monospace;
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 20px;
    --fs-xxl: 28px;

    /* shape / space */
    --r: 2px;
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;
    --row: 32px;
    --row-sm: 28px;
    --sidebar-w: 240px;

    --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--green);
    --focus-soft: 0 0 0 3px rgba(47, 107, 63, .20);
    --lift: 0 8px 24px rgba(24, 32, 27, .16);

    /* Bootstrap の変数をトークンに寄せる */
    --bs-body-font-family: var(--font-ui);
    --bs-body-font-size: var(--fs-md);
    --bs-body-line-height: 1.6;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--paper);
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--ink-3);
    --bs-tertiary-bg: var(--surface-2);
    --bs-border-color: var(--rule);
    --bs-border-radius: var(--r);
    --bs-border-radius-sm: var(--r);
    --bs-border-radius-lg: var(--r);
    --bs-link-color: var(--green-ink);
    --bs-link-color-rgb: 31, 74, 43;
    --bs-link-hover-color: var(--green);
    --bs-link-hover-color-rgb: 47, 107, 63;
    --bs-success-rgb: 47, 107, 63;
    --bs-primary-rgb: 44, 93, 143;
    --bs-font-monospace: var(--font-num);
}

/* ---- Base -------------------------------------------------------------- */
html, body { height: 100%; overflow: hidden; }
body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    line-height: 1.6;
    line-break: strict;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
::selection { background: var(--green-tint-2); color: var(--ink); }

a { color: var(--green-ink); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--green); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible, summary:focus-visible {
    outline: none; box-shadow: var(--focus-ring); border-radius: var(--r);
}

.font-mono, code, kbd, samp, pre { font-family: var(--font-num); }
code { color: var(--ink); background: var(--surface-3); padding: 1px 4px; border-radius: var(--r); font-size: .92em; }
kbd {
    display: inline-block; min-width: 1.6em; padding: 1px 5px; margin: 0 1px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: var(--r);
    font-size: var(--fs-xs); line-height: 1.4; text-align: center; box-shadow: none;
}
.text-muted { color: var(--ink-3) !important; }
.small, small { font-size: var(--fs-sm); }
hr { border-color: var(--rule); opacity: 1; }

/* スクロールバー: デスクトップアプリ的に細く */
.sidebar, .main-content, .modal-body, .autocomplete-menu, .table-responsive {
    scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent;
}

/* ---- App shell --------------------------------------------------------- */
.app-shell { height: 100vh; }

.skip-link {
    position: absolute; left: -9999px; top: 8px; z-index: 2000;
    background: var(--ink); color: var(--surface); padding: 6px 12px; border-radius: var(--r);
}
.skip-link:focus { left: 8px; color: var(--surface); }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    height: 100vh; overflow-y: auto;
    background: var(--surface);
    color: var(--ink);
    user-select: none;
}

/* ブランドと日付板 */
.brand-block { padding: var(--s-4) var(--s-4) var(--s-3); }
.brand {
    display: block; font-size: 19px; font-weight: 700; letter-spacing: .01em; line-height: 1.2;
    color: var(--ink); text-decoration: none;
}
.brand:hover { color: var(--ink); }

.dayboard {
    display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; column-gap: var(--s-2);
    margin-top: var(--s-3); padding: 8px 10px 7px;
    background: var(--ink); color: var(--surface); border-radius: var(--r);
}
.dayboard-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--on-ink-2); }
.dayboard-date { font-family: var(--font-num); font-size: 22px; font-weight: 700; line-height: 1; letter-spacing: .02em; }
.dayboard-dow {
    font-size: var(--fs-xs); font-weight: 700; padding: 1px 5px; border-radius: var(--r);
    background: var(--surface); color: var(--ink);
}
.dayboard-dow.is-sun { background: var(--sun-tint); }
.dayboard-dow.is-sat { background: var(--sat-tint); }
.dayboard-year { grid-column: 2 / 4; font-family: var(--font-num); font-size: 11px; color: var(--on-ink-2); letter-spacing: .08em; }

/* ナビ */
.sidebar .nav { padding: 0 var(--s-2) var(--s-3); gap: 1px; }
.sidebar .nav-link {
    display: flex; align-items: center; gap: 10px;
    min-height: 30px; padding: 4px 10px; margin: 0;
    color: var(--ink); font-size: var(--fs-sm); line-height: 1.35;
    border: 0; border-radius: var(--r); background: transparent;
    text-align: left;
}
.sidebar .nav-link .bi { font-size: 15px; color: var(--ink-3); width: 16px; flex-shrink: 0; text-align: center; }
.sidebar .nav-link:hover { background: var(--surface-3); color: var(--ink); }
.sidebar .nav-link.active { background: var(--green-tint); color: var(--green-ink); font-weight: 700; }
.sidebar .nav-link.active .bi { color: var(--green); }
.sidebar .nav-link:focus-visible { box-shadow: inset 0 0 0 2px var(--green); }

.nav-zone {
    display: flex; align-items: center; gap: 8px;
    margin: var(--s-4) 2px var(--s-1); padding: 0 8px;
    font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); letter-spacing: .08em;
}
.nav-zone:first-of-type { margin-top: var(--s-2); }

.sidebar-foot {
    margin-top: auto; padding: var(--s-3) var(--s-4) var(--s-4);
}
.sidebar-user { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.sidebar-company { font-size: 11px; color: var(--ink-3); }
.btn-logout {
    margin-top: var(--s-2);
    background: var(--surface-3); color: var(--ink-2); border: 0;
}
.btn-logout:hover { background: var(--rule); color: var(--ink); }

/* 本文 */
.main-content {
    height: 100vh; overflow-y: auto;
    padding: 18px 28px 48px !important;
    background: var(--paper);
    min-width: 0;
}

/* ---- Headings & page head --------------------------------------------- */
.main-content h1 {
    font-size: var(--fs-xl); font-weight: 700; line-height: 1.35;
    letter-spacing: .04em; font-feature-settings: "palt";
    text-transform: none; color: var(--ink);
    margin-bottom: var(--s-4);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--rule-strong);
}
.main-content h1 .text-muted, .main-content h1 small { font-family: var(--font-num); font-size: var(--fs-md); font-weight: 400; letter-spacing: 0; }

.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end !important; justify-content: space-between;
    gap: var(--s-2) var(--s-4);
    padding-bottom: 10px; margin-bottom: var(--s-4) !important;
    border-bottom: 2px solid var(--rule-strong);
}
.page-head h1 { margin: 0 !important; padding: 0; border: 0; }
.page-head > div:last-child:not(:first-child) { display: flex; flex-wrap: wrap; gap: 6px; }

.main-content h2, .main-content .h5, .main-content h5 {
    font-size: var(--fs-lg); font-weight: 700; letter-spacing: .03em; text-transform: none;
    border-bottom: 0; padding-bottom: 0;
}
.main-content h2 {
    padding-bottom: 6px; border-bottom: 1px solid var(--rule-2);
}
.main-content h6, .main-content .h6 { font-size: var(--fs-sm); font-weight: 700; }

/* ページ説明文 */
.main-content > p.text-muted, .main-content > p.small { max-width: 72em; }

/* ---- Width helpers (旧 inline max-width の置き換え) -------------------- */
.mw-200 { max-width: 200px; }
.mw-220 { max-width: 220px; }
.mw-300 { max-width: 300px; }
.mw-320 { max-width: 320px; }
.mw-360 { max-width: 360px; }
.mw-480 { max-width: 480px; }
.mw-560 { max-width: 560px; }
.mw-640 { max-width: 640px; }
.mw-700 { max-width: 700px; }
.mw-720 { max-width: 720px; }
.mw-760 { max-width: 760px; }
.mw-900 { max-width: 900px; }

/* ---- Cards (面) --------------------------------------------------------- */
.card {
    --bs-card-border-color: transparent;
    --bs-card-border-radius: var(--r);
    --bs-card-inner-border-radius: 1px;
    --bs-card-cap-bg: transparent;
    border: 0; border-radius: var(--r);
    background: var(--surface); box-shadow: none;
}
.card-header {
    display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
    min-height: 40px; padding: 8px 14px;
    background: transparent; color: var(--ink);
    border-bottom: 0;
    font-size: var(--fs-sm); font-weight: 700; letter-spacing: .04em; text-transform: none;
}
.card-header.d-flex { justify-content: space-between; }
.card-body { padding: 16px 18px; }
.card-footer { background: transparent; border-top: 0; }
.card.border-warning { border: 1px solid var(--signal-rule) !important; }
.card-header.bg-warning-subtle, .bg-warning-subtle { background: var(--signal-tint) !important; }
.card-header.bg-warning-subtle { border-bottom-color: var(--signal-rule); }

/* 登録/編集フォームのボタン行 */
.card-body > form > .btn:first-of-type { margin-top: var(--s-1); }

/* ---- Tables (相場板) ---------------------------------------------------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ink);
    --bs-table-border-color: var(--rule);
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: var(--surface-2);
    --bs-table-active-bg: var(--green-tint);
    margin-bottom: 0;
    font-size: var(--fs-sm);
    border-radius: 0;
}
.table > :not(caption) > * > * { padding: 7px 10px; border-bottom-color: var(--rule); }
.table-sm > :not(caption) > * > * { padding: 5px 10px; }
.table > thead { background: transparent; color: var(--ink-2); }
.table > thead th, .table > thead td {
    background: transparent;
    color: var(--ink-2);
    font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; text-transform: none;
    white-space: nowrap; vertical-align: bottom;
    border-top: 0;
    border-bottom: 2px solid var(--rule-strong) !important;
}
.table > tbody > tr > * { vertical-align: middle; }
.table > tbody > tr:hover > * { --bs-table-bg-state: var(--surface-2); }
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table > tfoot > tr > * {
    border-top: 2px solid var(--rule-strong); border-bottom: 0;
    background: transparent; font-weight: 700;
}
.card > .table, .card > .table-responsive > .table { margin: 0; }
.card > .table > thead > tr:first-child > *:first-child,
.card > .table-responsive > .table > thead > tr:first-child > *:first-child { border-top-left-radius: 1px; }

/* 数字・コード・日付は等幅（相場板の数字） */
.table td.text-end, .table th.text-end, .table .text-nowrap, input[type="date"], input[type="number"],
.table td.font-mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.table td.text-end .btn, .table td.text-end form { font-family: var(--font-ui); }

.table-dark, .table-dark > thead {
    --bs-table-bg: transparent; --bs-table-color: var(--ink);
    background-color: transparent !important; color: var(--ink) !important;
}
.table-warning, .table > tbody > tr.table-warning > * {
    --bs-table-bg: var(--signal-tint); --bs-table-color: var(--ink);
    --bs-table-bg-state: var(--signal-tint);
    border-color: var(--rule);
}
.table-secondary { --bs-table-bg: var(--surface-3); --bs-table-color: var(--ink); }
.table-success { --bs-table-bg: var(--green-tint); --bs-table-color: var(--ink); }
.table-bordered > :not(caption) > * > * { border-color: var(--rule); }

/* キーボードで選ぶ行: 行全体を塗って枠で囲む（片側の帯は使わない） */
table tbody tr[tabindex] { cursor: pointer; }
table tbody tr[tabindex]:focus,
table tbody tr[tabindex]:focus-visible {
    outline: 2px solid var(--green); outline-offset: -2px; box-shadow: none;
}
table tbody tr[tabindex]:focus > * { --bs-table-bg-state: var(--green-tint); background-color: var(--green-tint); }

/* 空の一覧 */
.table td.text-center.text-muted[colspan] { padding: 28px 10px; font-size: var(--fs-sm); background: var(--surface); }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
    --bs-btn-font-family: var(--font-ui);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--row); padding: 4px 14px;
    font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 700; line-height: 1.2;
    letter-spacing: .04em; text-transform: none; white-space: nowrap;
    border-radius: var(--r); border-width: 1px;
    box-shadow: none;
    transition: background-color .12s, border-color .12s, color .12s;
}
.btn .bi { font-size: 1.05em; line-height: 1; }
.btn-sm { min-height: var(--row-sm); padding: 3px 10px; font-size: var(--fs-xs); }
.btn-lg { min-height: 40px; padding: 6px 20px; font-size: var(--fs-md); }
/* 一覧の編集・削除などアイコンだけの正方形ボタン（文字は title / aria-label） */
.btn-icon { padding: 0; width: var(--row); }
.btn-icon.btn-sm { width: var(--row-sm); }
.btn-icon .bi { font-size: 14px; }
.btn.w-100, .btn.d-block { display: flex; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring) !important; }
.btn:disabled, .btn.disabled { opacity: .45; }

/* 主ボタン（登録・取込など） */
.btn-success, .btn-primary {
    background: var(--green); border-color: var(--green); color: var(--surface);
}
.btn-success:hover, .btn-primary:hover,
.btn-success:active, .btn-primary:active,
.btn-check:checked + .btn-success, .btn-check:checked + .btn-primary {
    background: var(--green-ink) !important; border-color: var(--green-ink) !important; color: var(--surface) !important;
}

/* 副ボタン */
.btn-outline-secondary, .btn-secondary, .btn-light, .btn-outline-dark {
    background: var(--surface-3); border-color: transparent; color: var(--ink);
}
.btn-outline-secondary:hover, .btn-secondary:hover, .btn-light:hover, .btn-outline-dark:hover,
.btn-outline-secondary:active, .btn-secondary:active, .btn-light:active, .btn-outline-dark:active,
.btn-check:checked + .btn-outline-secondary {
    background: var(--rule) !important; border-color: transparent !important; color: var(--ink) !important;
}

.btn-outline-success {
    background: var(--surface); border-color: var(--green); color: var(--green-ink);
}
.btn-outline-success:hover, .btn-outline-success:active, .btn-check:checked + .btn-outline-success {
    background: var(--green-tint) !important; border-color: var(--green) !important; color: var(--green-ink) !important;
}

.btn-outline-primary, .btn-outline-info {
    background: var(--surface); border-color: var(--info-rule); color: var(--info);
}
.btn-outline-primary:hover, .btn-outline-info:hover, .btn-outline-primary:active, .btn-outline-info:active,
.btn-check:checked + .btn-outline-primary {
    background: var(--info-tint) !important; border-color: var(--info) !important; color: var(--info) !important;
}

.btn-outline-danger {
    background: var(--surface); border-color: var(--danger-rule); color: var(--danger);
}
.btn-outline-danger:hover, .btn-outline-danger:active {
    background: var(--danger) !important; border-color: var(--danger) !important; color: var(--surface) !important;
}
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: var(--surface); }

.btn-outline-warning, .btn-warning {
    background: var(--signal); border-color: var(--signal); color: var(--signal-ink);
}
.btn-outline-warning { background: var(--surface); border-color: var(--signal-rule); }
.btn-outline-warning:hover, .btn-warning:hover { background: var(--signal-hover) !important; border-color: var(--signal-hover) !important; color: var(--signal-ink) !important; }

.btn-link { color: var(--green-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.btn-link:hover { color: var(--green); }

.btn-close { opacity: .55; border-radius: var(--r); }
.btn-close:hover { opacity: .9; }
.btn-close:focus-visible { box-shadow: var(--focus-ring); opacity: 1; }

.btn-group > .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-top-left-radius: var(--r); border-bottom-left-radius: var(--r); }
.btn-group > .btn:last-child { border-top-right-radius: var(--r); border-bottom-right-radius: var(--r); }

/* ---- Forms ------------------------------------------------------------- */
.form-label {
    margin-bottom: 4px;
    font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); letter-spacing: .04em;
}
.form-text { font-size: var(--fs-xs); color: var(--ink-3); }

.form-control, .form-select {
    min-height: var(--row);
    padding: 5px 10px;
    font-family: var(--font-ui); font-size: var(--fs-md); line-height: 1.4;
    color: var(--ink); background-color: var(--surface);
    border: 1px solid var(--rule-2); border-radius: var(--r);
    box-shadow: none;
}
.form-select { padding-right: 32px; background-position: right 10px center; }
.form-control-sm, .form-select-sm { min-height: var(--row-sm); padding: 3px 8px; font-size: var(--fs-sm); }
.form-select-sm { padding-right: 28px; }
textarea.form-control { min-height: 72px; line-height: 1.6; }
.form-control::placeholder { color: var(--ink-3); opacity: 1; }
.form-control:hover, .form-select:hover { border-color: var(--ink-3); }
.form-control:focus, .form-select:focus {
    border-color: var(--green); box-shadow: var(--focus-soft); outline: none;
}
.form-control:disabled, .form-select:disabled, .form-control[readonly] {
    background-color: var(--surface-3); color: var(--ink-2); border-color: var(--rule);
}
.form-control.is-invalid, .form-select.is-invalid, .was-validated .form-control:invalid {
    border-color: var(--danger); background-color: var(--danger-tint);
    background-image: none; padding-right: 10px;
}
.form-control.is-invalid:focus, .form-select.is-invalid:focus { box-shadow: 0 0 0 3px rgba(179, 38, 30, .18); }
.invalid-feedback { color: var(--danger); font-size: var(--fs-xs); font-weight: 700; }
.form-control[type="file"] { padding: 3px; }
.form-control[type="file"]::file-selector-button {
    margin: -3px 10px -3px -3px; padding: 5px 12px; height: auto;
    border: 0; border-right: 1px solid var(--rule-2);
    background: var(--surface-3); color: var(--ink); font-family: var(--font-ui); font-weight: 700; font-size: var(--fs-sm);
}
input[type="date"].form-control { min-width: 150px; }

.form-check { min-height: 24px; }
.form-check-input {
    width: 16px; height: 16px; margin-top: .22em;
    border: 1px solid var(--ink-3); background-color: var(--surface);
}
.form-check-input[type="checkbox"] { border-radius: var(--r); }
.form-check-input:checked { background-color: var(--green); border-color: var(--green); }
.form-check-input:focus { border-color: var(--green); box-shadow: var(--focus-soft); }
.form-check-label { font-size: var(--fs-sm); }
.form-switch .form-check-input { width: 2em; border-radius: 2em; }

.input-group-text {
    background: var(--surface-3); border-color: var(--rule-2); color: var(--ink-2);
    font-size: var(--fs-sm); border-radius: var(--r);
}

/* 絞り込みバー（一覧の上の検索・絞り込みフォーム） */
.filter-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin-left: 0; margin-right: 0;
    padding: 10px 12px;
    background: var(--surface); border-radius: var(--r);
}
.filter-bar.row { --bs-gutter-x: 0; --bs-gutter-y: 0; }
.filter-bar.row > * { padding: 0; margin-top: 0; }
.filter-bar .form-control:not([type="date"]):only-child { width: 100%; }

/* ---- Badges（札） -------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 7px; border-radius: var(--r);
    font-family: var(--font-ui); font-size: 11.5px; font-weight: 700; line-height: 1.3;
    letter-spacing: .03em; vertical-align: middle; white-space: nowrap;
}
.badge.bg-success, .badge.text-bg-success {
    background-color: var(--green-tint) !important; color: var(--green-ink) !important;
    box-shadow: inset 0 0 0 1px var(--green-tint-2);
}
.badge.bg-warning, .badge.text-bg-warning {
    background-color: var(--signal) !important; color: var(--signal-ink) !important;
}
.badge.bg-primary, .badge.text-bg-primary, .badge.bg-info, .badge.text-bg-info {
    background-color: var(--info-tint) !important; color: var(--info) !important;
    box-shadow: inset 0 0 0 1px var(--info-rule);
}
.badge.bg-secondary, .badge.text-bg-secondary {
    background-color: var(--surface-3) !important; color: var(--ink-2) !important;
    box-shadow: inset 0 0 0 1px var(--rule);
}
.badge.bg-danger, .badge.text-bg-danger {
    background-color: var(--danger-tint) !important; color: var(--danger) !important;
    box-shadow: inset 0 0 0 1px var(--danger-rule);
}
.badge.bg-light, .badge.text-bg-light {
    background-color: var(--surface) !important; color: var(--ink) !important;
    border: 1px solid var(--rule-2) !important;
}
.badge.bg-dark, .badge.text-bg-dark { background-color: var(--ink) !important; color: var(--surface) !important; }

/* ---- Alerts ------------------------------------------------------------ */
.alert {
    --bs-alert-border-radius: var(--r);
    display: block;
    padding: 10px 14px; margin-bottom: var(--s-4);
    font-size: var(--fs-sm); line-height: 1.6;
    border: 1px solid var(--rule-2); border-radius: var(--r);
    background: var(--surface); color: var(--ink);
}
.alert::before {
    display: inline-block; margin-right: 10px; padding: 1px 6px; border-radius: var(--r);
    font-size: 11px; font-weight: 700; letter-spacing: .06em; line-height: 1.5; vertical-align: 1px;
}
.alert:has(> ul)::before, .alert:has(> div:first-child)::before { margin-bottom: 4px; }
.alert-success { background: var(--green-tint); border-color: var(--green-tint-2); color: var(--green-ink); }
.alert-success::before { content: "完了"; background: var(--green); color: var(--surface); }
.alert-danger { background: var(--danger-tint); border-color: var(--danger-rule); color: var(--danger-ink); }
.alert-danger::before { content: "エラー"; background: var(--danger); color: var(--surface); }
.alert-warning { background: var(--signal-tint); border-color: var(--signal-rule); color: var(--ink); }
.alert-warning::before { content: "注意"; background: var(--signal); color: var(--signal-ink); }
.alert-info { background: var(--info-tint); border-color: var(--info-rule); color: var(--info-ink); }
.alert-info::before { content: "お知らせ"; background: var(--info); color: var(--surface); }
.alert-secondary, .alert-light { background: var(--surface); border-color: transparent; color: var(--ink); }
.alert-dismissible { padding-right: 44px; }
.alert-dismissible .btn-close { padding: 12px 14px; }
.alert a { color: inherit; font-weight: 700; }
.alert ul { margin-top: 2px; }

/* ---- Tabs -------------------------------------------------------------- */
.nav-tabs { border-bottom: 1px solid var(--rule-2); gap: 2px; }
.nav-tabs .nav-link {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 36px; padding: 6px 14px;
    border: 1px solid transparent; border-bottom: 0; border-radius: var(--r) var(--r) 0 0;
    color: var(--ink-2); font-size: var(--fs-sm); font-weight: 700; background: transparent;
    margin-bottom: -1px;
}
.nav-tabs .nav-link:hover { background: var(--surface-3); color: var(--ink); border-color: transparent; }
.nav-tabs .nav-link.active {
    background: var(--surface); color: var(--ink);
    border-color: var(--rule-2); border-bottom: 1px solid var(--surface);
}
.nav-pills .nav-link { border-radius: var(--r); color: var(--ink-2); font-weight: 700; }
.nav-pills .nav-link.active { background: var(--green-tint); color: var(--green-ink); }

/* ---- Pagination -------------------------------------------------------- */
.pagination { --bs-pagination-font-size: var(--fs-sm); gap: 3px; margin-bottom: 0; flex-wrap: wrap; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; padding: 0 9px;
    border: 1px solid var(--rule-2) !important; border-radius: var(--r) !important;
    background: var(--surface); color: var(--ink);
    font-family: var(--font-num); font-size: var(--fs-sm);
}
.page-link:hover { background: var(--surface-3); color: var(--ink); }
.page-link:focus { box-shadow: var(--focus-ring); }
.page-item.active .page-link { background: var(--ink); border-color: var(--ink) !important; color: var(--surface); font-weight: 700; }
.page-item.disabled .page-link { background: var(--surface-2); color: var(--rule-2); }
nav[role="navigation"] p.small, nav .small.text-muted { font-size: var(--fs-xs); color: var(--ink-3); }

/* ---- List group / autocomplete ---------------------------------------- */
.list-group { --bs-list-group-border-color: var(--rule); --bs-list-group-border-radius: var(--r); }
.list-group-item { font-size: var(--fs-sm); color: var(--ink); border-color: var(--rule); }
.list-group-item-action:hover, .list-group-item-action:focus { background: var(--surface-2); color: var(--ink); }
.list-group-item.active {
    background: var(--green); border-color: var(--green); color: var(--surface); z-index: 2;
}
.list-group-item.active .text-muted { color: rgba(255, 255, 255, .8) !important; }
.list-group-item.active .badge.text-bg-primary { background: var(--surface) !important; color: var(--info) !important; }

.autocomplete-menu {
    display: none;
    max-height: 280px; overflow-y: auto;
    margin-top: 2px;
    background: var(--surface);
    border: 1px solid var(--rule-2); border-radius: var(--r);
    box-shadow: var(--lift);
    z-index: 1050;
}
.autocomplete-menu .list-group-item { border-radius: 0; border-left: 0; border-right: 0; cursor: pointer; }
.autocomplete-menu .list-group-item:first-child { border-top: 0; }

/* ---- Modal ------------------------------------------------------------- */
.modal { --bs-modal-border-radius: var(--r); --bs-modal-inner-border-radius: 1px; }
.modal-content {
    border: 0; border-radius: var(--r);
    background: var(--surface); box-shadow: 0 16px 48px rgba(24, 32, 27, .28);
}
.modal-header {
    padding: 12px 18px; background: var(--surface);
    border-bottom: 2px solid var(--rule-strong);
}
.modal-title { font-size: var(--fs-lg); font-weight: 700; letter-spacing: .04em; }
.modal-body { padding: 16px 18px; }
.modal-footer { padding: 10px 18px; background: transparent; border-top: 0; gap: 6px; }
.modal-footer > * { margin: 0; }
.modal-backdrop { --bs-backdrop-bg: var(--ink); --bs-backdrop-opacity: .45; }

/* 手動注文入力（_manual_modal）で使うセル */
#rowsTable td { vertical-align: middle; }
.spec-cell { color: var(--ink-2); }
.amount-cell { font-weight: 700; white-space: nowrap; font-family: var(--font-num); }
.remove-row-btn { line-height: 1; }
#grandTotal, #orderItemsGrandTotal { font-family: var(--font-num); }

/* ---- Description lists ------------------------------------------------- */
dl.row { margin-bottom: 0; }
dl.row > dt { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); letter-spacing: .04em; padding-top: 3px; }
dl.row > dd { font-size: var(--fs-md); color: var(--ink); margin-bottom: 6px; }

/* ---- 伝票風の項目ヘッダ（受注詳細など） -------------------------------- */
/* 折り返しても罫線が崩れないよう、各セルの右と下に1pxの罫を引き、外枠で端を隠す */
.slip-fields {
    display: flex; flex-wrap: wrap;
    margin: 0 0 var(--s-4); padding: 0;
    background: var(--surface); border-radius: var(--r);
    overflow: hidden;
}
.slip-fields > div {
    flex: 1 1 150px; min-width: 0; padding: 8px 14px;
    box-shadow: 1px 0 0 var(--rule), 0 1px 0 var(--rule);
}
.slip-fields > div.is-wide { flex: 2 1 300px; }
.slip-label { display: block; font-size: 11px; font-weight: 700; color: var(--ink-3); letter-spacing: .06em; }
.slip-value { display: block; font-size: var(--fs-md); font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.slip-value.num { font-family: var(--font-num); }
.slip-value .text-muted { font-family: var(--font-num); font-weight: 400; margin-right: 4px; }

.hint { font-size: var(--fs-xs); color: var(--ink-3); }

/* ---- Dashboard -------------------------------------------------------- */
.dash-grid {
    display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
    gap: var(--s-4); margin-bottom: var(--s-5);
}
.board { background: var(--surface); border-radius: var(--r); }
.board-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
    padding: 10px 14px; border-bottom: 2px solid var(--rule-strong);
    font-size: var(--fs-sm); font-weight: 700; letter-spacing: .04em;
}
.board-head .board-date { font-family: var(--font-num); font-weight: 400; color: var(--ink-3); font-size: var(--fs-xs); }
.board-row {
    display: grid; grid-template-columns: 1fr auto 96px; align-items: center; gap: var(--s-3);
    min-height: 52px; padding: 6px 14px;
    border-bottom: 1px solid var(--rule);
    color: var(--ink); text-decoration: none;
}
.board-row:last-child { border-bottom: 0; }
a.board-row:hover { background: var(--surface-2); color: var(--ink); }
.board-label { font-size: var(--fs-md); font-weight: 700; }
.board-label .hint { display: block; font-weight: 400; }
.board-value { font-family: var(--font-num); font-size: 26px; font-weight: 700; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; }
.board-unit { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 400; margin-left: 3px; font-family: var(--font-ui); }
.board-go { justify-self: end; font-size: var(--fs-xs); font-weight: 700; color: var(--green-ink); display: inline-flex; gap: 4px; align-items: center; }
.board-row.is-alert { background: var(--signal-tint); }
.board-row.is-alert:hover { background: var(--signal-tint-2); }
.board-row.is-alert .board-value { background: var(--signal); padding: 4px 8px; border-radius: var(--r); }
.board-row.is-clear .board-value { color: var(--ink-3); }

.work-list { display: flex; flex-direction: column; }
.work-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; min-height: 48px; padding: 8px 14px;
    border: 0; border-bottom: 1px solid var(--rule); background: transparent;
    color: var(--ink); text-decoration: none; text-align: left;
    font-size: var(--fs-md); font-weight: 700;
}
.work-item:last-child { border-bottom: 0; }
.work-item:hover { background: var(--surface-2); color: var(--ink); }
.work-item .bi { font-size: 17px; color: var(--green); width: 20px; text-align: center; }
.work-item .hint { display: block; font-weight: 400; }
.work-item .work-arrow { margin-left: auto; color: var(--ink-3); font-size: 13px; }
.work-item:focus-visible { box-shadow: inset 0 0 0 2px var(--green); outline: none; }

.section-title {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
    margin: 0 0 var(--s-2);
    font-size: var(--fs-lg); font-weight: 700; letter-spacing: .03em;
}

/* ---- Login ------------------------------------------------------------- */
.login-page {
    height: 100%; overflow: auto;
    display: flex; align-items: center; justify-content: center;
    padding: 32px 16px;
    background: var(--paper);
}
.login-panel {
    width: 100%; max-width: 400px;
    background: var(--surface); border-radius: var(--r);
}
.login-head {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-1);
    padding: 18px 22px 16px;
    background: var(--ink); color: var(--surface);
    border-radius: 1px 1px 0 0;
}
.login-head .brand { color: var(--surface); font-size: 24px; }
.login-body { padding: 22px; }
.login-foot {
    padding: 10px 22px;
    font-size: 11px; color: var(--ink-3); letter-spacing: .04em;
}

/* ---- 印刷画面（得意先商品一覧表・茶札など）の画面側ツールバー ---------- */
.picksheet-toolbar, .aggsheet-toolbar, .aggcards-toolbar, .tagsheet-toolbar, .main-content > .no-print.mb-3:has(> .btn) {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 8px 12px; margin-bottom: var(--s-4) !important;
    background: var(--surface); border-radius: var(--r);
    font-family: var(--font-ui); font-size: var(--fs-sm);
    position: sticky; top: -18px; z-index: 5;
}
.picksheet-toolbar .btn, .aggsheet-toolbar .btn, .aggcards-toolbar .btn, .tagsheet-toolbar .btn { font-family: var(--font-ui); }
.picksheet-toolbar .form-control, .aggsheet-toolbar .form-control, .aggcards-toolbar .form-control, .tagsheet-toolbar .form-control,
.picksheet-toolbar .form-select, .aggsheet-toolbar .form-select, .aggcards-toolbar .form-select, .tagsheet-toolbar .form-select { font-family: var(--font-num); }

/* ---- Motion ------------------------------------------------------------ */
.fade { transition-duration: .12s; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---- Narrow windows ---------------------------------------------------- */
@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
    html, body { height: auto; overflow: auto; }
    .app-shell { flex-direction: column; height: auto; }
    .sidebar { width: 100%; height: auto; overflow: visible; }
    .sidebar .nav { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar .nav .nav-zone { grid-column: 1 / -1; }
    .sidebar-foot { margin-top: 0; }
    .main-content { height: auto; overflow: visible; padding: 16px 16px 40px !important; }
    .slip-fields > div.is-wide { grid-column: auto; }
    .card[class*="mw-"], [class*="mw-"] { max-width: 100%; }
    .table { font-size: var(--fs-xs); }
    .card > .table { display: block; overflow-x: auto; }
}
