/* ==========================================================================
   BMEDmgt UI — 設計系統
   ==========================================================================

   為什麼有這支檔案：
   全站超過 90 個頁面的版型是用 Bootstrap 的 class 名稱寫的
   (row / col-md-* / card / badge bg-* / form-select / d-flex / mb-3 …)，
   但專案並沒有載入 Bootstrap，style.css 裡也只有零星幾個同名 class。
   結果就是這些頁面（尤其是「臨床系統紀錄」「財編關聯審核」）整頁散開、
   沒有卡片、沒有網格，看起來像壞掉。

   這裡用自己的實作補齊那些 class，並統一成一套現代化的視覺語彙：
   柔和底色 + 白色卡片 + 細邊框 + 圓角 + 低調陰影 + 清楚的層級。
   完全自帶、不依賴 CDN（院內網路不一定連得出去，Service Worker 也只快取同源資源）。

   載入順序：style.css → ui.css，共用元件以本檔為準；
   各頁面自己的 <style> 仍然最後生效，頁面專屬的微調不受影響。
   ========================================================================== */

:root {
    /* 色票 */
    --c-bg: #f4f6fa;
    --c-surface: #ffffff;
    --c-surface-2: #f8fafc;
    --c-border: #e3e8ef;
    --c-border-strong: #cfd6e0;
    --c-text: #1f2733;
    --c-text-soft: #4a5566;
    --c-muted: #6b7789;

    --c-primary: #0d6efd;
    --c-primary-dark: #0b5ed7;
    --c-primary-soft: #e7f0ff;
    --c-success: #16a34a;
    --c-success-soft: #e6f6ec;
    --c-warning: #f59e0b;
    --c-warning-soft: #fef3e2;
    --c-danger: #dc2626;
    --c-danger-soft: #fdeaea;
    --c-info: #0ea5e9;
    --c-info-soft: #e4f4fd;
    --c-secondary: #64748b;
    --c-secondary-soft: #eef1f5;
    --c-dark: #334155;

    /* 形狀與陰影 */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 2px 10px rgba(16, 24, 40, .07);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

    --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui,
        -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --transition: .16s ease;
}

/* ==========================================================================
   Base
   ========================================================================== */

body {
    font-family: var(--font-sans);
    background-color: var(--c-bg);
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--c-text);
    font-weight: 700;
    line-height: 1.35;
}

h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
h5 { font-size: 14px; }

a { color: var(--c-primary); }
a:hover { color: var(--c-primary-dark); }

code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .92em;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    color: var(--c-text-soft);
}

hr {
    border: 0;
    border-top: 1px solid var(--c-border);
    margin: 16px 0;
}

:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* ==========================================================================
   Layout：container / grid
   ========================================================================== */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 20px 40px;
}

.container-fluid {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 20px 40px;
}

.container-narrow { max-width: 820px; margin: 0 auto; padding: 20px; }

.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -12px;
    margin-right: -12px;
}

.row > * {
    box-sizing: border-box;
    padding-left: 12px;
    padding-right: 12px;
    width: 100%;
}

/* gutter */
.g-0 { margin-left: 0; margin-right: 0; }
.g-0 > * { padding-left: 0; padding-right: 0; }
.g-1 { margin: -2px; } .g-1 > * { padding: 2px; }
.g-2 { margin: -4px; } .g-2 > * { padding: 4px; }
.g-3 { margin: -8px; } .g-3 > * { padding: 8px; }
.g-4 { margin: -12px; } .g-4 > * { padding: 12px; }

.col { flex: 1 0 0%; }
.col-auto { width: auto; flex: 0 0 auto; }

.col-1 { width: 8.3333%; } .col-2 { width: 16.6667%; } .col-3 { width: 25%; }
.col-4 { width: 33.3333%; } .col-5 { width: 41.6667%; } .col-6 { width: 50%; }
.col-7 { width: 58.3333%; } .col-8 { width: 66.6667%; } .col-9 { width: 75%; }
.col-10 { width: 83.3333%; } .col-11 { width: 91.6667%; } .col-12 { width: 100%; }

@media (min-width: 768px) {
    .col-md-1 { width: 8.3333%; } .col-md-2 { width: 16.6667%; } .col-md-3 { width: 25%; }
    .col-md-4 { width: 33.3333%; } .col-md-5 { width: 41.6667%; } .col-md-6 { width: 50%; }
    .col-md-7 { width: 58.3333%; } .col-md-8 { width: 66.6667%; } .col-md-9 { width: 75%; }
    .col-md-10 { width: 83.3333%; } .col-md-11 { width: 91.6667%; } .col-md-12 { width: 100%; }
    .col-md-auto { width: auto; flex: 0 0 auto; }
}

@media (min-width: 992px) {
    .col-lg-1 { width: 8.3333%; } .col-lg-2 { width: 16.6667%; } .col-lg-3 { width: 25%; }
    .col-lg-4 { width: 33.3333%; } .col-lg-5 { width: 41.6667%; } .col-lg-6 { width: 50%; }
    .col-lg-7 { width: 58.3333%; } .col-lg-8 { width: 66.6667%; } .col-lg-9 { width: 75%; }
    .col-lg-10 { width: 83.3333%; } .col-lg-11 { width: 91.6667%; } .col-lg-12 { width: 100%; }
}

@media (min-width: 1200px) {
    .col-xl-2 { width: 16.6667%; } .col-xl-3 { width: 25%; } .col-xl-4 { width: 33.3333%; }
    .col-xl-6 { width: 50%; } .col-xl-8 { width: 66.6667%; } .col-xl-12 { width: 100%; }
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }
@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
}

.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-fill { flex: 1 1 auto !important; }

.justify-content-start { justify-content: flex-start !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-around { justify-content: space-around !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.align-items-center { align-items: center !important; }
.align-items-baseline { align-items: baseline !important; }
.align-self-center { align-self: center !important; }
.align-middle { vertical-align: middle !important; }

.gap-0 { gap: 0 !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }
.gap-4 { gap: 24px !important; }

/* spacing scale: 0=0 1=4 2=8 3=16 4=24 5=48 */
.m-0 { margin: 0 !important; } .m-1 { margin: 4px !important; } .m-2 { margin: 8px !important; }
.m-3 { margin: 16px !important; } .m-4 { margin: 24px !important; } .m-5 { margin: 48px !important; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 4px !important; } .mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 16px !important; } .mt-4 { margin-top: 24px !important; } .mt-5 { margin-top: 48px !important; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 4px !important; } .mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; } .mb-4 { margin-bottom: 24px !important; } .mb-5 { margin-bottom: 48px !important; }
.ms-0 { margin-left: 0 !important; } .ms-1 { margin-left: 4px !important; } .ms-2 { margin-left: 8px !important; }
.ms-3 { margin-left: 16px !important; } .ms-auto { margin-left: auto !important; }
.me-0 { margin-right: 0 !important; } .me-1 { margin-right: 4px !important; } .me-2 { margin-right: 8px !important; }
.me-3 { margin-right: 16px !important; } .me-auto { margin-right: auto !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.my-2 { margin-top: 8px !important; margin-bottom: 8px !important; }
.my-3 { margin-top: 16px !important; margin-bottom: 16px !important; }
.my-4 { margin-top: 24px !important; margin-bottom: 24px !important; }

.p-0 { padding: 0 !important; } .p-1 { padding: 4px !important; } .p-2 { padding: 8px !important; }
.p-3 { padding: 16px !important; } .p-4 { padding: 24px !important; } .p-5 { padding: 48px !important; }
.pt-0 { padding-top: 0 !important; } .pt-2 { padding-top: 8px !important; } .pt-3 { padding-top: 16px !important; }
.pb-0 { padding-bottom: 0 !important; } .pb-2 { padding-bottom: 8px !important; } .pb-3 { padding-bottom: 16px !important; }
.px-2 { padding-left: 8px !important; padding-right: 8px !important; }
.px-3 { padding-left: 16px !important; padding-right: 16px !important; }
.px-4 { padding-left: 24px !important; padding-right: 24px !important; }
.py-1 { padding-top: 4px !important; padding-bottom: 4px !important; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-3 { padding-top: 16px !important; padding-bottom: 16px !important; }
.py-4 { padding-top: 24px !important; padding-bottom: 24px !important; }
.py-5 { padding-top: 48px !important; padding-bottom: 48px !important; }

.text-start { text-align: left !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-nowrap { white-space: nowrap !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--c-muted) !important; }
.text-primary { color: var(--c-primary) !important; }
.text-success { color: var(--c-success) !important; }
.text-warning { color: #b45309 !important; }
.text-danger { color: var(--c-danger) !important; }
.text-info { color: #0369a1 !important; }
.text-secondary { color: var(--c-secondary) !important; }
.text-dark { color: var(--c-text) !important; }
.text-white { color: #fff !important; }
.small, small { font-size: 12.5px; }
.fw-normal { font-weight: 400 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.fst-italic { font-style: italic !important; }
.lh-1 { line-height: 1.1 !important; }

.h1 { font-size: 28px; font-weight: 700; }
.h2 { font-size: 22px; font-weight: 700; }
.h3 { font-size: 26px; font-weight: 700; }
.h4 { font-size: 18px; font-weight: 700; }
.h5 { font-size: 15px; font-weight: 700; }
.display-6 { font-size: 32px; font-weight: 700; }

.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }
.h-100 { height: 100% !important; }
.mw-100 { max-width: 100% !important; }
.overflow-auto { overflow: auto !important; }
.position-relative { position: relative !important; }
.rounded { border-radius: var(--radius) !important; }
.rounded-pill { border-radius: var(--radius-pill) !important; }
.border { border: 1px solid var(--c-border) !important; }
.border-0 { border: 0 !important; }
.border-top { border-top: 1px solid var(--c-border) !important; }
.border-bottom { border-bottom: 1px solid var(--c-border) !important; }
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }

.bg-white { background-color: var(--c-surface) !important; }
.bg-light { background-color: var(--c-surface-2) !important; }
.bg-body { background-color: var(--c-bg) !important; }

/* ==========================================================================
   Card
   ========================================================================== */

.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 14px 18px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.card-header h1, .card-header h2, .card-header h3,
.card-header h4, .card-header h5 { margin: 0; }

.card-body { padding: 18px; }
.card-footer {
    padding: 12px 18px;
    background: var(--c-surface-2);
    border-top: 1px solid var(--c-border);
}
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 6px; }
.card-text { margin: 0; color: var(--c-text-soft); }

/* 卡片內若直接接表格，去掉圓角外的縫隙 */
.card-body.p-0 > .table-responsive > .table,
.card-body.p-0 > .table { margin-bottom: 0; }

/* ==========================================================================
   Page header
   ========================================================================== */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-header h2, .page-header h3 { margin: 0; }

.page-subtitle {
    color: var(--c-muted);
    font-size: 13.5px;
    margin: 4px 0 0;
}

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--c-secondary);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--transition), border-color var(--transition),
                color var(--transition), box-shadow var(--transition);
}

.btn:hover { color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--c-primary); border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }
.btn-secondary { background: var(--c-secondary); border-color: var(--c-secondary); }
.btn-secondary:hover { background: #52607a; border-color: #52607a; }
.btn-success { background: var(--c-success); border-color: var(--c-success); }
.btn-success:hover { background: #12833c; border-color: #12833c; }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-warning { background: var(--c-warning); border-color: var(--c-warning); color: #3d2c07; }
.btn-warning:hover { background: #d98806; border-color: #d98806; color: #3d2c07; }
.btn-info { background: var(--c-info); border-color: var(--c-info); }
.btn-info:hover { background: #0284c7; border-color: #0284c7; }
.btn-light {
    background: var(--c-surface); border-color: var(--c-border); color: var(--c-text);
}
.btn-light:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-dark { background: var(--c-dark); border-color: var(--c-dark); }
.btn-dark:hover { background: #1e293b; border-color: #1e293b; }

/* outline 系列：白底 + 彩色框線，hover 才填色 */
.btn-outline, .btn-outline-primary, .btn-outline-secondary, .btn-outline-success,
.btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-outline-dark {
    background: var(--c-surface);
}
.btn-outline { border-color: var(--c-border-strong); color: var(--c-text-soft); }
.btn-outline:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-outline-primary { border-color: var(--c-primary); color: var(--c-primary); }
.btn-outline-primary:hover { background: var(--c-primary); color: #fff; }
.btn-outline-secondary { border-color: var(--c-border-strong); color: var(--c-text-soft); }
.btn-outline-secondary:hover { background: var(--c-secondary); border-color: var(--c-secondary); color: #fff; }
.btn-outline-success { border-color: var(--c-success); color: var(--c-success); }
.btn-outline-success:hover { background: var(--c-success); color: #fff; }
.btn-outline-danger { border-color: var(--c-danger); color: var(--c-danger); }
.btn-outline-danger:hover { background: var(--c-danger); color: #fff; }
.btn-outline-warning { border-color: var(--c-warning); color: #b45309; }
.btn-outline-warning:hover { background: var(--c-warning); color: #3d2c07; }
.btn-outline-info { border-color: var(--c-info); color: #0369a1; }
.btn-outline-info:hover { background: var(--c-info); color: #fff; }
.btn-outline-dark { border-color: var(--c-border-strong); color: var(--c-text); }
.btn-outline-dark:hover { background: var(--c-dark); color: #fff; }

.btn-link {
    background: none; border-color: transparent; color: var(--c-primary);
    padding-left: 4px; padding-right: 4px;
}
.btn-link:hover { color: var(--c-primary-dark); text-decoration: underline; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block, .btn.w-100 { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group > .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group > .btn:only-child { border-radius: var(--radius-sm); }

/* 關閉鈕 (alert / modal) */
.btn-close {
    width: 26px; height: 26px; padding: 0;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: inherit; opacity: .5;
    cursor: pointer; font-size: 0; line-height: 1; flex-shrink: 0;
}
.btn-close::before { content: "×"; font-size: 20px; }
.btn-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }

/* ==========================================================================
   Badge
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    background: var(--c-secondary-soft);
    color: var(--c-text-soft);
}

/* bg-* 語意色：用「柔和底 + 深色字」，比實心更耐看也更好讀 */
.badge.bg-primary { background: var(--c-primary-soft); color: #0a4fb3; }
.badge.bg-success { background: var(--c-success-soft); color: #12703a; }
.badge.bg-warning { background: var(--c-warning-soft); color: #a35a05; }
.badge.bg-danger { background: var(--c-danger-soft); color: #b02020; }
.badge.bg-info { background: var(--c-info-soft); color: #0369a1; }
.badge.bg-secondary { background: var(--c-secondary-soft); color: #4b5768; }
.badge.bg-light { background: var(--c-surface-2); color: var(--c-muted); }
.badge.bg-dark { background: #e2e6ec; color: var(--c-dark); }
.badge.text-dark { color: #a35a05; }

/* 非 badge 上的 bg-* (例如色塊、進度條) 仍給實心 */
.bg-primary:not(.badge) { background-color: var(--c-primary) !important; }
.bg-success:not(.badge) { background-color: var(--c-success) !important; }
.bg-warning:not(.badge) { background-color: var(--c-warning) !important; }
.bg-danger:not(.badge) { background-color: var(--c-danger) !important; }
.bg-info:not(.badge) { background-color: var(--c-info) !important; }
.bg-secondary:not(.badge) { background-color: var(--c-secondary) !important; }
.bg-dark:not(.badge) { background-color: var(--c-dark) !important; }

.badge-pill { border-radius: var(--radius-pill); }

/* ==========================================================================
   Table
   ========================================================================== */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-surface);
    font-size: 13.5px;
}

.table th {
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: .02em;
    color: var(--c-muted);
    background: var(--c-surface-2);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-text-soft);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--transition); }
.table tbody tr:nth-child(even) { background: transparent; }
.table-hover tbody tr:hover, .table tbody tr:hover { background: #f6f9ff; }
.table-striped tbody tr:nth-child(odd) { background: var(--c-surface-2); }
.table-sm th, .table-sm td { padding: 7px 10px; font-size: 12.5px; }
.table thead.table-light th, .table .table-light th { background: var(--c-surface-2); }
.table a { color: var(--c-primary); text-decoration: none; font-weight: 500; }
.table a:hover { text-decoration: underline; }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--c-text-soft);
}

.form-control, .form-select {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7789' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}

.form-control::placeholder { color: #9aa5b4; }
.form-control[readonly], .form-control:disabled, .form-select:disabled {
    background: var(--c-surface-2);
    color: var(--c-muted);
    cursor: default;
}

textarea.form-control { min-height: 88px; resize: vertical; }
.form-control-sm, .form-select-sm { padding: 5px 9px; font-size: 12.5px; }
.form-control-lg { padding: 11px 14px; font-size: 15px; }
.form-text { display: block; margin-top: 4px; font-size: 12px; color: var(--c-muted); }

/* checkbox / radio / switch */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 26px;
    margin-bottom: 4px;
}
.form-check-input {
    width: 16px; height: 16px; margin: 0;
    accent-color: var(--c-primary);
    cursor: pointer; flex-shrink: 0;
}
.form-check-label { cursor: pointer; margin: 0; }
.form-check-inline { display: inline-flex; margin-right: 14px; }

.form-switch { align-items: flex-start; }
.form-switch .form-check-input {
    appearance: none; -webkit-appearance: none;
    position: relative;
    width: 38px; height: 21px;
    border-radius: var(--radius-pill);
    background: #cbd5e1;
    transition: background-color var(--transition);
    margin-top: 2px;
}
.form-switch .form-check-input::after {
    content: "";
    position: absolute; top: 2px; left: 2px;
    width: 17px; height: 17px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}
.form-switch .form-check-input:checked { background: var(--c-primary); }
.form-switch .form-check-input:checked::after { transform: translateX(17px); }

/* input group */
.input-group { display: flex; width: 100%; }
.input-group > .form-control, .input-group > .form-select { flex: 1 1 auto; width: 1%; }
.input-group > :not(:first-child) { margin-left: -1px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > :not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .form-control:focus, .input-group > .form-select:focus { z-index: 2; }
.input-group-text {
    display: flex; align-items: center;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--c-text-soft);
    background: var(--c-surface-2);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.input-group-sm > .form-control, .input-group-sm > .form-select,
.input-group-sm > .input-group-text, .input-group-sm > .btn {
    padding: 5px 9px; font-size: 12.5px;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13.5px;
}

.alert-success { background: var(--c-success-soft); border-color: #bfe6cd; color: #12703a; }
.alert-info { background: var(--c-info-soft); border-color: #bfe6f8; color: #0369a1; }
.alert-warning { background: var(--c-warning-soft); border-color: #f6ddb0; color: #a35a05; }
.alert-danger, .alert-error { background: var(--c-danger-soft); border-color: #f6c9c9; color: #b02020; }
.alert-secondary { background: var(--c-secondary-soft); border-color: var(--c-border); color: var(--c-text-soft); }
.alert-primary { background: var(--c-primary-soft); border-color: #c5dbff; color: #0a4fb3; }
.alert-dismissible { justify-content: space-between; }
.alert .btn-close { margin-left: auto; }
.alert a { font-weight: 600; text-decoration: underline; }

.fade { transition: opacity .15s linear; }
.fade:not(.show) { opacity: 0; }
.alert.fade { opacity: 1; }

/* ==========================================================================
   Empty state / misc
   ========================================================================== */

.empty-state {
    padding: 44px 20px;
    text-align: center;
    color: var(--c-muted);
}
.empty-state .empty-icon { font-size: 34px; opacity: .5; display: block; margin-bottom: 10px; }
.empty-state h4 { color: var(--c-text-soft); margin: 0 0 6px; }
.no-data { padding: 36px 20px; text-align: center; color: var(--c-muted); }

.breadcrumb {
    display: flex; flex-wrap: wrap; gap: 6px;
    list-style: none; padding: 0; margin: 0 0 14px;
    font-size: 13px; color: var(--c-muted);
}
.breadcrumb-item + .breadcrumb-item::before { content: "/"; margin-right: 6px; color: var(--c-border-strong); }
.breadcrumb-item.active { color: var(--c-text-soft); }

.progress {
    height: 8px; background: var(--c-surface-2);
    border-radius: var(--radius-pill); overflow: hidden;
}
.progress-bar { height: 100%; background: var(--c-primary); transition: width .3s ease; }

.list-group { border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.list-group-item {
    display: block; padding: 12px 16px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
}
.list-group-item:last-child { border-bottom: 0; }

/* 統計卡：全站多處使用 (stat-card / stats-card) */
.stat-card, .stats-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover, .stats-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-icon {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; flex-shrink: 0;
    border-radius: var(--radius);
    background: var(--c-primary-soft); color: var(--c-primary);
    font-size: 19px;
}
.stat-info { flex: 1; min-width: 0; }
.stat-value, .stats-value { font-size: 24px; font-weight: 700; color: var(--c-text); line-height: 1.2; }
.stat-label, .stats-label { font-size: 12.5px; color: var(--c-muted); }
.stat-link { margin-left: auto; font-size: 12.5px; color: var(--c-primary); text-decoration: none; white-space: nowrap; }
.stat-link:hover { text-decoration: underline; }
.stats-row, .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-primary .stat-icon { background: var(--c-primary-soft); color: var(--c-primary); }
.stat-secondary .stat-icon { background: var(--c-secondary-soft); color: var(--c-secondary); }
.stat-success .stat-icon { background: var(--c-success-soft); color: var(--c-success); }
.stat-warning .stat-icon { background: var(--c-warning-soft); color: #b45309; }
.stat-danger .stat-icon { background: var(--c-danger-soft); color: var(--c-danger); }
.stat-info .stat-icon { background: var(--c-info-soft); color: #0369a1; }

/* ==========================================================================
   Modal（style.css 已有 .modal / .modal-content / .modal-header，這裡補齊缺的層）
   ========================================================================== */

.modal-dialog {
    max-width: 520px;
    margin: 8vh auto;
    width: calc(100% - 32px);
}
.modal-content {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-title { font-size: 15px; font-weight: 700; margin: 0; }
.modal-header { border-bottom: 1px solid var(--c-border); }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 18px;
    background: var(--c-surface-2);
    border-top: 1px solid var(--c-border);
}

/* ==========================================================================
   既有頁面沿用的零星 class（補齊後才不會出現沒有樣式的區塊）
   ========================================================================== */

/* Bootstrap 5.3 的 subtle / emphasis 色階 */
.bg-primary-subtle { background-color: var(--c-primary-soft) !important; }
.bg-success-subtle { background-color: var(--c-success-soft) !important; }
.bg-warning-subtle { background-color: var(--c-warning-soft) !important; }
.bg-danger-subtle { background-color: var(--c-danger-soft) !important; }
.bg-info-subtle { background-color: var(--c-info-soft) !important; }
.bg-secondary-subtle { background-color: var(--c-secondary-soft) !important; }
.border-primary-subtle { border-color: #c5dbff !important; }
.border-success-subtle { border-color: #bfe6cd !important; }
.border-warning-subtle { border-color: #f6ddb0 !important; }
.border-danger-subtle { border-color: #f6c9c9 !important; }
.border-info-subtle { border-color: #bfe6f8 !important; }
.text-primary-emphasis { color: #0a4fb3 !important; }
.text-success-emphasis { color: #12703a !important; }
.text-warning-emphasis { color: #a35a05 !important; }
.text-danger-emphasis { color: #b02020 !important; }
.text-info-emphasis { color: #0369a1 !important; }

/* 舊制維修單的處理狀態（DealStatuses 的中文值直接當 class） */
.status-已處理 { background: var(--c-success-soft); color: #12703a; }
.status-待料中 { background: var(--c-warning-soft); color: #a35a05; }
.status-外乍處理中 { background: var(--c-info-soft); color: #0369a1; }
.status-已取消 { background: var(--c-secondary-soft); color: #4b5768; }

/* 儀表板警示卡的文字區塊 */
.alert-content { flex: 1; min-width: 0; }
.alert-content strong { display: block; color: var(--c-text); }

/* 未知分類的通知標籤也要有底色，不會變成裸字 */
.category-badge { background: var(--c-secondary-soft); color: var(--c-text-soft); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 767px) {
    .container, .container-fluid { padding: 14px 14px 32px; }
    .page-header { flex-direction: column; align-items: stretch; }
    .header-actions { width: 100%; }
    .table th, .table td { padding: 10px; }
    h2 { font-size: 19px; }
}

/* ==========================================================================
   共用頁面樣板（Shared page patterns）
   ==========================================================================
   全站 200 多個頁面是用同一套 class 詞彙做出來的：
   .dashboard-header / .stats-row / .stat-card / .filter-card / .content-card /
   .data-table / .action-btn / .empty-state …
   原本每個頁面都把同一份 CSS 複製一份在自己的 <style> 裡（逐字相同），
   造成同樣的元件在不同頁面各自演化、風格散掉。
   這裡集中定義一次，頁面只留真正屬於自己的樣式。
   ========================================================================== */

/* --- 頁首 --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.header-left h2 {
    margin: 0;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--c-text);
}
.header-left h2 i { color: var(--c-primary); }
.header-description { margin: 6px 0 0; color: var(--c-muted); font-size: 13.5px; }
.dashboard-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dashboard-date {
    color: var(--c-muted);
    font-size: 13px;
    padding: 7px 14px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
}

/* --- 頁首動作鈕 --- */
.action-btn-outline, .action-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}
.action-btn-outline {
    background: var(--c-surface);
    border-color: var(--c-border-strong);
    color: var(--c-text-soft);
}
.action-btn-outline:hover { background: var(--c-surface-2); color: var(--c-text); }
.action-btn-primary {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
}
.action-btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); color: #fff; }

/* --- 橫幅提示 --- */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 13.5px;
}
.alert-banner.alert-success { background: var(--c-success-soft); border-color: #bfe6cd; color: #12703a; }
.alert-banner.alert-danger { background: var(--c-danger-soft); border-color: #f6c9c9; color: #b02020; }
.alert-banner.alert-warning { background: var(--c-warning-soft); border-color: #f6ddb0; color: #a35a05; }
.alert-banner.alert-info { background: var(--c-info-soft); border-color: #bfe6f8; color: #0369a1; }
.alert-close {
    margin-left: auto;
    border: 0;
    background: none;
    color: inherit;
    opacity: .55;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.alert-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }

/* --- 警示卡（需要注意的項目） --- */
.alert-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 20px; }
.alert-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-left: 3px solid var(--c-warning);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.alert-card.alert-danger { border-left-color: var(--c-danger); }
.alert-card.alert-info { border-left-color: var(--c-info); }
.alert-icon { font-size: 22px; flex-shrink: 0; }
.alert-action {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-primary);
    text-decoration: none;
    white-space: nowrap;
}
.alert-action:hover { text-decoration: underline; }

/* --- 篩選區 --- */
.filter-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    margin-bottom: 20px;
}
.filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}
.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.filter-group.filter-search { flex: 1 1 240px; }
.filter-group.filter-checkbox { justify-content: flex-end; }
.filter-label { font-size: 12.5px; font-weight: 600; color: var(--c-text-soft); }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }

.input-icon { position: relative; display: flex; align-items: center; }
.input-icon i {
    position: absolute;
    left: 11px;
    color: var(--c-muted);
    font-size: 13px;
    pointer-events: none;
}
.input-icon input { padding-left: 32px; }

/* --- 內容卡 + 資料表 --- */
.content-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 20px;
}
.content-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
}
.content-card .card-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.content-card .card-header h4 i { color: var(--c-primary); }
.content-card .card-body { padding: 18px; }
.content-card .card-body.p-0 { padding: 0; }
.record-count { font-size: 12.5px; color: var(--c-muted); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    padding: 11px 14px;
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--c-muted);
    background: var(--c-surface-2);
    border-bottom: 1px solid var(--c-border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-text-soft);
    vertical-align: middle;
}
.data-table tbody tr { transition: background-color var(--transition); }
.data-table tbody tr:hover { background: #f6f9ff; }
.data-table tbody tr:last-child td { border-bottom: 0; }

.id-link { font-weight: 600; color: var(--c-primary); text-decoration: none; }
.id-link:hover { text-decoration: underline; }

/* 表格列內的小動作鈕 */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 11px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--c-border-strong);
    background: var(--c-surface);
    color: var(--c-text-soft);
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}
.action-btn:hover { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.action-btn.btn-view:hover { background: var(--c-primary); border-color: var(--c-primary); }
.action-btn.btn-edit:hover { background: var(--c-info); border-color: var(--c-info); }
.action-btn.btn-delete:hover { background: var(--c-danger); border-color: var(--c-danger); }

/* --- 空狀態 --- */
.empty-state h5 { margin: 0 0 6px; font-size: 15px; color: var(--c-text-soft); }
.empty-state p { margin: 0 0 14px; }
.empty-icon { font-size: 34px; opacity: .5; display: block; margin-bottom: 10px; }

/* --- 狀態標籤（各頁自行定義顏色變體，這裡只給共同底樣式） --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--c-secondary-soft);
    color: var(--c-text-soft);
}

/* 沒有 class 的表單元素也要有一致外觀（頁面移除內嵌樣式後仍然好看） */
.filter-group > input, .filter-group > select, .filter-group > textarea,
.form-group > input:not([type="checkbox"]):not([type="radio"]),
.form-group > select, .form-group > textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-group > input:focus, .filter-group > select:focus,
.form-group > input:focus, .form-group > select:focus, .form-group > textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}

/* --- 其餘共用樣板（第二批集中定義） --- */
.action-buttons { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.content-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
/* 圖表容器一定要有「確定的高度」。
   Chart.js 是 responsive:true + maintainAspectRatio:false，會把 canvas 撐滿父層；
   父層若只有 min-height（高度由內容決定），就會變成
   canvas 變大 → 容器變高 → canvas 再變大 的無限迴圈，整頁一直往下長。 */
.chart-container {
    position: relative;
    width: 100%;
    height: 320px;
    padding: 18px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chart-container h3, .chart-container h4 {
    margin: 0 0 12px;
    font-size: 15px;
    text-align: center;
}

/* 保險絲：萬一哪個容器沒有確定高度，也不會無限長大 */
.chart-container > canvas { max-height: 100%; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.form-row > .form-group { flex: 1; min-width: 180px; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 20px 0 0;
    list-style: none;
    padding: 0;
}
.pagination a, .pagination span, .pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-surface);
    color: var(--c-text-soft);
    text-decoration: none;
    font-size: 13px;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}
.pagination a:hover, .pagination .page-link:hover {
    background: var(--c-surface-2);
    border-color: var(--c-border-strong);
    color: var(--c-text);
}
.pagination .active, .pagination .page-item.active .page-link {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
    font-weight: 600;
}
.pagination .disabled, .pagination .page-item.disabled .page-link { opacity: .45; pointer-events: none; }
.pagination-info { font-size: 13px; color: var(--c-muted); }
.pagination-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-indicator { font-size: 13px; color: var(--c-text-soft); padding: 0 6px; }
