:root {
  color-scheme: light;
  --ink: #172521;
  --ink-soft: #42534d;
  --muted: #66756f;
  --muted-dark: #aab9b3;
  --surface: #ffffff;
  --surface-soft: #f7f8f6;
  --surface-raised: #fbfcfa;
  --border: #e1e7e3;
  --border-strong: #cbd5cf;
  --nav: #142923;
  --nav-hover: #1e3931;
  --nav-active: #254a3e;
  --accent: #2866c5;
  --accent-hover: #1f53a4;
  --accent-soft: #edf4ff;
  --success: #177245;
  --success-bg: #eaf6ef;
  --warning: #865316;
  --warning-bg: #fff4de;
  --danger: #a63434;
  --danger-bg: #fff0ef;
  --info: #275b96;
  --info-bg: #edf4fc;
  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 41, 35, .05), 0 3px 10px rgba(20, 41, 35, .035);
  --shadow-md: 0 12px 34px rgba(20, 41, 35, .14);
  --sidebar-width: 238px;
  --topbar-height: 68px;
  --ease-ui: cubic-bezier(.2, .7, .2, 1);
  font-family: "Satoshi", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--surface-soft); scroll-behavior: smooth; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--surface-soft); color: var(--ink); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
body, button, input, select, textarea { font-family: "Satoshi", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif; }
button, input, select, textarea { font-size: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(40, 102, 197, .7); outline-offset: 2px; }
::selection { color: #fff; background: #2866c5; }
.skip-link { position: fixed; z-index: 1100; top: 9px; left: 9px; display: inline-flex; min-height: 44px; align-items: center; padding: 8px 13px; border-radius: 8px; color: #fff; background: #173e32; font-weight: 700; text-decoration: none; transform: translateY(-160%); }
.skip-link:focus-visible { outline-color: #fff; transform: translateY(0); }

.app-layout { min-height: 100vh; }
.admin-sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; display: flex; width: var(--sidebar-width); flex-direction: column; color: #f2f7f4; background: var(--nav); border-right: 1px solid rgba(255,255,255,.06); }
.sidebar-topline { display: flex; min-height: 82px; align-items: center; justify-content: space-between; padding: 17px 16px 16px 19px; border-bottom: 1px solid rgba(255,255,255,.09); }
.brand-lockup { display: flex; min-width: 0; min-height: 44px; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgba(220,237,229,.3); border-radius: 9px; color: #f4fbf7; font-size: 12px; font-weight: 800; letter-spacing: .05em; background: rgba(255,255,255,.06); }
.brand-copy { display: grid; min-width: 0; gap: 2px; }
.brand-copy strong { overflow: hidden; color: #f6faf8; font-size: 13px; font-weight: 760; letter-spacing: .045em; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { color: #b4c5bd; font-size: 12px; line-height: 1.25; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px 18px; scrollbar-color: rgba(255,255,255,.24) transparent; scrollbar-width: thin; }
.nav-group { display: grid; gap: 3px; margin: 0 0 20px; }
.nav-group-label { margin: 0 10px 7px; color: #a6b9b0; font-size: 12px; font-weight: 720; letter-spacing: .055em; }
.nav-btn { display: flex; min-height: 44px; align-items: center; gap: 11px; padding: 9px 11px; border: 1px solid transparent; border-radius: 8px; color: #d4e0da; font-size: 14px; font-weight: 540; line-height: 1.25; text-decoration: none; transition: background-color .16s var(--ease-ui), color .16s var(--ease-ui), border-color .16s var(--ease-ui); }
.nav-btn svg { width: 19px; height: 19px; color: #b8cbc1; }
.nav-btn:hover { color: #fff; background: var(--nav-hover); }
.nav-btn:hover svg { color: #edf5f0; }
.nav-btn.active { border-color: rgba(157,194,177,.17); color: #fff; background: var(--nav-active); box-shadow: inset 3px 0 0 #85b8a0; }
.nav-btn.active svg { color: #b8e2cd; }
.sidebar-footer { display: flex; min-height: 66px; align-items: center; gap: 10px; padding: 12px 17px; border-top: 1px solid rgba(255,255,255,.09); }
.sidebar-footer-mark { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 50%; color: #e0efe7; font-size: 13px; font-weight: 750; background: #2c5143; }
.sidebar-footer > span:last-child { display: grid; min-width: 0; gap: 1px; }
.sidebar-footer strong { color: #eff5f1; font-size: 12px; font-weight: 650; }
.sidebar-footer small { color: #a8bcb2; font-size: 12px; }
.nav-close.icon-button { display: none; }
.nav-scrim { display: none; }
body.nav-open { overflow: hidden; }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.admin-header { position: sticky; z-index: 20; top: 0; display: flex; min-height: var(--topbar-height); align-items: center; justify-content: space-between; gap: 20px; padding: 10px clamp(20px, 3vw, 44px); border-bottom: 1px solid var(--border); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.menu-toggle { display: none !important; }
.header-breadcrumb { display: flex; min-width: 0; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.header-breadcrumb > span:first-child { color: #718179; font-size: 12px; font-weight: 760; letter-spacing: .06em; }
.header-breadcrumb strong { overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 660; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb-divider { color: #a7b2ac; }
.header-user { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 15px; }
.preview-links { display: flex; align-items: center; gap: 5px; }
.preview-link { display: inline-flex; min-height: 44px; align-items: center; padding: 7px 9px; border-radius: 7px; color: var(--ink-soft); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.preview-link:hover { color: var(--accent); background: var(--accent-soft); }
.user-meta { display: flex; min-width: 0; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; font-weight: 650; }
#current-user-name { overflow: hidden; max-width: 180px; text-overflow: ellipsis; white-space: nowrap; }
.user-role-badge { padding: 3px 7px; border: 1px solid #dce6df; border-radius: 5px; color: #3f5b4e; background: #f3f8f4; font-size: 11px; font-weight: 740; letter-spacing: .04em; }
.admin-main { width: 100%; max-width: 1640px; min-height: calc(100vh - var(--topbar-height)); margin: 0 auto; padding: clamp(22px, 3vw, 40px); }
.page-container { width: 100%; min-width: 0; }
.view-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin: 0 0 23px; }
.view-header > div { min-width: 0; }
.view-header h1, .view-header h2 { margin: 0; color: var(--ink); font-size: clamp(22px, 2vw, 28px); font-weight: 730; letter-spacing: -.025em; line-height: 1.25; }
.view-header p { max-width: 850px; margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.view-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.text-muted { color: var(--muted); }

.btn { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 650; line-height: 1.25; text-align: center; text-decoration: none; touch-action: manipulation; transition: background-color .16s var(--ease-ui), border-color .16s var(--ease-ui), color .16s var(--ease-ui), box-shadow .16s var(--ease-ui), transform .16s var(--ease-ui); }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .52; }
.btn-primary { border-color: var(--accent); color: #fff; background: var(--accent); box-shadow: 0 1px 2px rgba(20,55,110,.12); }
.btn-primary:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); }
.btn-secondary { border-color: var(--border-strong); color: #263b33; background: var(--surface); }
.btn-secondary:hover:not(:disabled) { border-color: #9eafa5; background: #f7faf8; }
.btn-danger { border-color: #a63434; color: #fff; background: #a63434; }
.btn-success { border-color: #177245; color: #fff; background: #177245; }
.btn-outline-danger { border-color: #d8a5a0; color: #943c37; background: #fff; }
.btn-outline-danger:hover:not(:disabled) { border-color: #bd706a; color: #8a2e2a; background: #fff4f2; }
.btn-sm { min-height: 44px; padding: 7px 10px; font-size: 13px; }
.btn-block { width: 100%; min-height: 48px; font-size: 15px; }
.icon-button { display: inline-grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 8px; color: inherit; background: transparent; cursor: pointer; }
.icon-button:hover { background: rgba(255,255,255,.09); }
.icon-button svg { width: 21px; height: 21px; }

.loading-state, .empty-state { display: grid; min-height: 160px; place-content: center; justify-items: center; gap: 12px; padding: 28px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); background: var(--surface); text-align: center; }
.loading-indicator { width: 24px; height: 24px; border: 2px solid #d9e3dd; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-msg { margin: 12px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.status-msg.error { border-color: #efc4bf; color: #8b2f2b; background: var(--danger-bg); }
.status-msg.success { border-color: #b7dbc4; color: #17613d; background: var(--success-bg); }
.notice { margin: 14px 0 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink-soft); background: var(--surface); font-size: 14px; overflow-wrap: anywhere; }
.notice-warning { border-color: #ead5a6; color: #694713; background: var(--warning-bg); }

.panel, .filter-card, .table-card { min-width: 0; margin: 0 0 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-header { display: flex; min-height: 56px; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.panel-header h2, .panel-header h3 { margin: 0; color: var(--ink); font-size: 15px; font-weight: 700; }
.panel-header > span { color: var(--muted); font-size: 12px; text-align: right; }
.panel-body { min-width: 0; padding: 18px; }
.filter-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; }
.filter-card { align-items: stretch; flex-direction: column; flex-wrap: wrap; }
.filter-card > .search-form { width: 100%; max-width: none; align-items: flex-end; flex-wrap: wrap; }
.filter-card > .search-form > label:not(.visually-hidden) { display: grid; min-width: min(100%, 220px); flex: 1 1 220px; gap: 5px; color: var(--ink-soft); font-size: 13px; font-weight: 650; }
.filter-card > .search-form > label > input, .filter-card > .search-form > label > select { width: 100%; }
.filter-card > .filter-row { width: 100%; }
#filters.search-form { display: grid; grid-template-columns: max-content minmax(220px, 1fr) auto; align-items: center; gap: 9px; }
#filters > .visually-hidden { position: static !important; width: auto !important; height: auto !important; margin: 0 !important; overflow: visible !important; clip: auto !important; clip-path: none !important; white-space: nowrap !important; color: var(--ink-soft); font-size: 0 !important; }
#filters > .visually-hidden::after { content: "搜尋詢盤"; font-size: 13px; font-weight: 650; }
#filters > input { min-width: 220px; min-height: 44px; width: 100%; }
#filters + .filter-row { flex-wrap: wrap; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; }
.filter-row label { display: flex; min-height: 42px; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 13px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.toolbar-left, .toolbar-right { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: 8px; }
.search-form { display: flex; min-width: 0; width: min(100%, 560px); gap: 8px; }
.search-input, .filter-select, .search-form input { min-width: 0; min-height: 44px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--ink); background: #fff; font-size: 14px; }
.search-input { width: min(100%, 400px); }
.search-form input { flex: 1; }
.filter-select { cursor: pointer; }
.search-input::placeholder, input::placeholder, textarea::placeholder { color: #83918b; opacity: 1; }

input, select, textarea { max-width: 100%; color: var(--ink); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea { min-height: 44px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); vertical-align: middle; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid rgba(40,102,197,.16); outline-offset: 1px; }
form { min-width: 0; }
.form-group { margin: 0 0 17px; }
.form-group label, .setting-field label, fieldset label, .modal-body > label, #user-form label { display: block; margin: 8px 0 5px; color: var(--ink-soft); font-size: 13px; font-weight: 640; }
.form-group input, .form-group select, .form-group textarea, .setting-field input:not([type="checkbox"]), .setting-field textarea { display: block; width: 100%; margin: 5px 0; }
.setting-field small, .form-group small, .modal-body small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.setting-field textarea[readonly], input[readonly] { border-color: #e5eae6; color: #5e6c65; background: #f4f6f4; }
.confirm-field { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; color: var(--ink-soft); font-size: 13px; }
fieldset { min-width: 0; margin: 14px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; }
fieldset legend { padding: 0 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
.grid-2, .detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card { display: flex; min-width: 0; align-items: center; gap: 13px; padding: 17px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: #245d9c; background: var(--accent-soft); }
.stat-icon.blue { color: #245d9c; background: #edf4fc; }
.stat-icon.green { color: #256947; background: #edf7f0; }
.stat-icon.amber { color: #865316; background: #fff4de; }
.stat-icon.purple { color: #665396; background: #f4f0fa; }
.stat-info { min-width: 0; }
.stat-info .stat-value { color: var(--ink); font-size: 22px; font-weight: 740; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-info .stat-label { color: var(--muted); font-size: 12px; font-weight: 560; }

.table-responsive { width: 100%; max-width: 100%; overflow: auto; border-radius: inherit; overscroll-behavior-x: contain; scrollbar-color: #b7c4bd #f2f5f2; scrollbar-width: thin; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; color: var(--ink); font-size: 13px; text-align: left; }
.data-table th { position: sticky; z-index: 1; top: 0; padding: 12px 14px; border-bottom: 1px solid var(--border-strong); color: #53635b; background: #f4f7f4; font-size: 12px; font-weight: 720; white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #edf0ed; color: #33443c; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fafcfb; }
.data-table code { overflow-wrap: anywhere; color: #37564a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.table-card { overflow: hidden; }
.filter-card:has(#filters) + .table-card { overflow: auto; overscroll-behavior-x: contain; }
.filter-card:has(#filters) + .table-card .data-table { min-width: 1100px; }
.filter-card:has(#filters) + .table-card .inquiry-link,
.filter-card:has(#filters) + .table-card td:first-child code { white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px; padding: 13px; color: var(--muted); font-size: 13px; }
.empty-cell { padding: 34px 18px !important; color: var(--muted) !important; text-align: center; }
.row-actions { min-width: 230px; white-space: normal; }
.row-actions .btn { margin: 2px; }
.long-cell { min-width: 160px; max-width: min(50vw, 560px); overflow-wrap: anywhere; white-space: pre-wrap; word-break: break-word; }
.cell-sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.cell-followup { color: #8c4d2a; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cell-date { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.inquiry-link, .back-link a { color: #20599f; font-weight: 650; text-decoration: none; }
.inquiry-link:hover, .back-link a:hover { text-decoration: underline; }
.back-link { margin-bottom: 8px; }
.inquiry-id-tag { margin-top: 3px; color: var(--muted); font-size: 12px; }
.info-list .info-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf0ed; font-size: 14px; }
.info-list .info-item .label { width: 120px; flex: 0 0 auto; color: var(--muted); }
.info-list .info-item .val { min-width: 0; flex: 1; color: var(--ink); overflow-wrap: anywhere; }
.desc-box { margin-top: 7px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; color: #33443c; background: #f7f9f7; font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.save-status-msg { font-size: 13px; font-weight: 650; }
.save-status-msg.success { color: var(--success); }
.save-status-msg.error { color: var(--danger); }

.badge, .status-pill { display: inline-flex; min-height: 24px; align-items: center; padding: 3px 8px; border: 1px solid transparent; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.badge-new { border-color: #d8e5f5; color: #28558b; background: #edf4fc; }
.badge-contacted { border-color: #eadbb5; color: #715321; background: #fff6df; }
.badge-quoted { border-color: #d8dbf0; color: #4a4d85; background: #f0f0fa; }
.badge-in_production { border-color: #e0d5ed; color: #664a7d; background: #f5effa; }
.badge-completed, .badge-published { border-color: #c7e2d0; color: #236344; background: #eaf6ef; }
.badge-won { border-color: #c7e2d0; color: #236344; background: #eaf6ef; }
.badge-closed, .badge-archived { border-color: #dfe5e1; color: #53635b; background: #f1f4f2; }
.badge-draft { border-color: #eadbb5; color: #715321; background: #fff6df; }
.badge-withdrawn, .badge-rejected { border-color: #efceca; color: #873b36; background: #fff0ef; }
.status-pill.status-success { border-color: #c7e2d0; color: #236344; background: #eaf6ef; }
.status-pill.status-warning { border-color: #eadbb5; color: #715321; background: #fff6df; }
.status-pill.status-error { border-color: #efceca; color: #873b36; background: #fff0ef; }

.notification-channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 15px 0 19px; }
.notification-channel-grid .panel { margin: 0; }
.notification-channel-grid .panel-body p { margin: 5px 0; overflow-wrap: anywhere; }
.notification-error { min-width: 150px; max-width: 320px; color: #6d4e40; overflow-wrap: anywhere; white-space: pre-wrap; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr)); gap: 14px; }
.settings-sections { display: grid; gap: 16px; }
.settings-group { min-width: 0; margin: 0; padding: 15px; border-color: var(--border); border-radius: 12px; background: #f9fbf9; }
.settings-group > legend { padding: 0 8px; color: var(--ink); font-size: 15px; font-weight: 720; }
.settings-group .settings-grid { margin-top: 2px; }
.settings-submit { margin-top: 16px; }
.settings-submit .panel-body { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.setting-source { margin: 0; padding: 9px 10px; border-left: 3px solid #b6c8bd; border-radius: 0 6px 6px 0; color: var(--muted); background: #f5f8f5; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.setting-source strong { color: var(--ink-soft); }
.setting-field { margin-bottom: 0; }
.setting-field .panel-header { align-items: flex-start; }
.setting-field .panel-body { display: grid; gap: 8px; }
.setting-field textarea, .setting-field input:not([type="checkbox"]) { width: 100%; }
.confirm-field input[type="checkbox"] { flex: 0 0 auto; margin-top: 2px; }

.grid-item-row { display: grid; grid-template-columns: minmax(125px,1.35fr) minmax(110px,1.1fr) minmax(100px,1fr) minmax(80px,.65fr) minmax(110px,.85fr) auto; align-items: end; gap: 9px; margin: 9px 0; padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: #fafcfb; }
.grid-item-row label { display: grid; min-width: 0; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 620; }
.grid-item-row input { width: 100%; min-width: 0; }
.notice-warning + .grid-2 { margin-top: 14px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 13px; margin-top: 17px; }
.media-grid figure { min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.media-grid img { display: block; width: 100%; height: 150px; border-radius: 6px; background: #f3f6f3; object-fit: contain; }
.media-grid figcaption { padding-top: 9px; color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.media-grid figcaption p { margin: 5px 0; color: var(--muted); }
.cms-gallery-row, .cms-section-row { margin: 10px 0; padding: 13px; border: 1px solid var(--border); border-radius: 9px; background: #f7f9f7; }
.cms-gallery-row label, .cms-section-row label { display: block; margin: 7px 0; color: var(--ink-soft); font-size: 13px; font-weight: 620; }
.cms-gallery-row input, .cms-section-row input, .cms-section-row textarea { display: block; width: 100%; margin-top: 5px; }
.gallery-url-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.cms-media-picker { display: grid; max-height: 300px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 9px; overflow: auto; margin: 9px 0; padding: 11px; border: 1px solid #c8d9eb; border-radius: 9px; background: #f2f7fc; }
.cms-media-choice { display: flex; min-height: 44px; flex-direction: column; gap: 6px; padding: 7px; border: 1px solid var(--border); border-radius: 8px; color: var(--ink); background: #fff; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.cms-media-choice:hover { border-color: #8db0d6; background: #f8fbff; }
.cms-media-choice img { width: 100%; height: 90px; border-radius: 5px; background: #f2f5f3; object-fit: contain; }
.view-guidance { margin: -10px 0 17px; padding: 9px 12px; border-left: 3px solid #8fae9e; border-radius: 0 7px 7px 0; color: #5a6d63; background: #f1f6f2; font-size: 13px; line-height: 1.5; }
.cms-language-editor { min-width: 0; margin: 15px 0 18px; }
.cms-language-tabs { display: flex; align-items: stretch; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.cms-language-tab.btn { min-height: 44px; justify-content: center; gap: 7px; }
.cms-language-tab[aria-selected="true"] { border-color: #9bb9aa; color: #173e32; background: #eaf3ed; box-shadow: inset 0 -2px 0 #2866c5; }
.cms-language-tab[aria-selected="true"]::after { content: "正在編輯"; padding-left: 7px; border-left: 1px solid #a9c3b4; color: #315f4b; font-size: 11px; font-weight: 720; white-space: nowrap; }
.cms-language-panel { min-width: 0; padding: 15px; border: 1px solid var(--border); border-radius: 10px; background: #fbfcfb; }
.cms-language-panel[hidden] { display: none !important; }
.cms-language-panel h4 { margin: 0 0 12px; color: var(--ink); font-size: 15px; font-weight: 720; }
.cms-language-panel > label { display: block; margin: 10px 0; color: var(--ink-soft); font-size: 13px; font-weight: 640; }
.cms-language-panel > label input, .cms-language-panel > label textarea { display: block; width: 100%; margin-top: 5px; }
.list-empty td { padding: 28px 18px !important; color: var(--muted) !important; background: #fafcfb; text-align: center; }
.list-empty:not(tr) { margin: 12px 0; padding: 18px; border: 1px dashed var(--border-strong); border-radius: 9px; color: var(--muted); background: #fafcfb; text-align: center; }
.text-center { text-align: center; }

.timeline { display: flex; flex-direction: column; gap: 11px; margin-top: 14px; }
.timeline-item { display: flex; gap: 11px; font-size: 13px; }
.timeline-dot { width: 9px; height: 9px; flex: 0 0 auto; margin-top: 7px; border-radius: 50%; background: var(--accent); }
.timeline-content { min-width: 0; flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fafcfb; overflow-wrap: anywhere; }
.timeline-meta { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.tabs-nav { display: flex; align-items: center; gap: 5px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab-btn { min-height: 44px; padding: 8px 13px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; cursor: pointer; font-size: 14px; font-weight: 650; white-space: nowrap; }
.tab-btn:hover { color: var(--ink); background: #f7f9f7; }
.tab-btn.active { border-bottom-color: var(--accent); color: var(--accent); }
details > summary { min-height: 38px; padding: 6px 0; color: #245b98; cursor: pointer; font-weight: 650; }
.audit-detail { max-width: min(64vw, 780px); max-height: 360px; overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 8px; color: #34443c; background: #f6f8f6; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; white-space: pre-wrap; word-break: break-word; }

#modal-root:empty { display: none; }
.modal-overlay { position: fixed; z-index: 1000; inset: 0; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 22px; background: rgba(13, 27, 22, .54); backdrop-filter: blur(4px); }
.modal-card { display: flex; width: min(100%, 720px); max-height: min(92dvh, 980px); flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.6); border-radius: 14px; background: #fff; box-shadow: var(--shadow-md); }
.modal-card.modal-lg { width: min(100%, 960px); }
.modal-header { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: #fff; }
.modal-header h3 { margin: 0; color: var(--ink); font-size: 17px; font-weight: 720; }
.modal-body { min-height: 0; flex: 1; overflow-y: auto; padding: 18px 20px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: #f8faf8; }
.close-btn { display: inline-grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border: 1px solid transparent; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 24px; line-height: 1; }
.close-btn:hover { color: var(--ink); background: #f1f5f2; }
.modal-body > label input, .modal-body > label textarea, .modal-body > label select, #user-form input, #user-form select { display: block; width: 100%; min-width: 0; margin-top: 5px; }
.modal-body [role="alert"] { color: var(--danger); }

.login-page { display: grid; min-height: 100vh; grid-template-columns: minmax(280px, .82fr) minmax(400px, 1fr); background: #f7f8f6; }
.login-aside { position: relative; display: flex; min-height: 100%; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(30px, 5vw, 72px); color: #f3f8f5; background: #142923; }
.login-aside::after { position: absolute; right: -130px; bottom: -190px; width: 500px; height: 500px; border: 1px solid rgba(214,235,223,.12); border-radius: 50%; box-shadow: 0 0 0 45px rgba(214,235,223,.035), 0 0 0 95px rgba(214,235,223,.025); content: ""; pointer-events: none; }
.login-aside .brand-lockup { position: relative; z-index: 1; width: fit-content; }
.login-aside-copy { position: relative; z-index: 1; max-width: 480px; margin: auto 0; padding: 56px 0; }
.login-aside-copy .eyebrow { margin: 0 0 14px; color: #a8c7b7; font-size: 12px; font-weight: 760; letter-spacing: .11em; text-transform: uppercase; }
.login-aside-copy h2 { max-width: 450px; margin: 0; color: #f4f8f5; font-size: clamp(30px, 4.2vw, 52px); font-weight: 660; letter-spacing: -.045em; line-height: 1.13; text-wrap: balance; }
.login-aside-copy p { max-width: 410px; margin: 19px 0 0; color: #c0d0c8; font-size: 16px; line-height: 1.7; }
.login-aside-footer { position: relative; z-index: 1; color: #a9bbb2; font-size: 12px; }
.login-main { display: grid; min-width: 0; place-items: center; padding: clamp(24px, 6vw, 84px); }
.login-card { width: 100%; max-width: 450px; padding: clamp(23px, 4vw, 38px); border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: 0 10px 34px rgba(21,43,34,.07); }
.login-brand { margin-bottom: 25px; }
.login-brand h1 { margin: 0; color: var(--ink); font-size: 24px; font-weight: 730; letter-spacing: -.025em; line-height: 1.28; }
.login-brand .subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.badge-tag { display: inline-flex; min-height: 28px; align-items: center; margin-bottom: 13px; padding: 4px 9px; border: 1px solid #d5e3da; border-radius: 6px; color: #3f6351; background: #f1f7f3; font-size: 11px; font-weight: 760; letter-spacing: .07em; }
.login-form { display: grid; gap: 2px; }
.login-form .form-group { margin-bottom: 13px; }
.login-form .form-group label { margin-bottom: 6px; color: var(--ink-soft); font-size: 13px; }
.login-form input { min-height: 48px; font-size: 15px; }
.login-form .btn { margin-top: 5px; }
.login-mode-note { min-height: 20px; margin: 12px 0 0; color: var(--muted); font-size: 12px; text-align: left; }
.status-msg:empty { display: none; }
.login-card .status-msg { text-align: left; }
.login-footer { margin-top: 24px; padding-top: 17px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.login-footer .links { display: flex; flex-wrap: wrap; gap: 8px 17px; }
.login-footer a { display: inline-flex; min-height: 44px; align-items: center; color: #275d9c; font-size: 13px; font-weight: 620; text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }
.login-page .login-section .form-group > div { display: flex; align-items: stretch; gap: 8px; }
.login-page .login-section .form-group input { min-width: 0; flex: 1; }
.login-page #login-divider { display: none; align-items: center; gap: 10px; margin: 18px 0; color: #728078; font-size: 12px; }
.login-page #login-divider > div { height: 1px; flex: 1; background: var(--border); }
.login-page #login-divider span { white-space: nowrap; }
.login-page .login-section small { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 1100px) {
  :root { --sidebar-width: 224px; }
  .admin-header { gap: 12px; padding-inline: 20px; }
  .header-user { gap: 8px; }
  .preview-links { gap: 0; }
  .preview-link { padding-inline: 7px; font-size: 12px; }
  .admin-main { padding: 24px; }
  .grid-item-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-item-row .btn { min-height: 44px; }
}

@media (max-width: 900px) {
  html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
  .workspace { margin-left: 0; }
  .admin-sidebar { z-index: 1002; width: min(86vw, 310px); box-shadow: var(--shadow-md); transform: translateX(-103%); visibility: hidden; transition: transform .22s var(--ease-ui); }
  body.nav-open .admin-sidebar { transform: translateX(0); visibility: visible; }
  .nav-close.icon-button { display: inline-grid; }
  .nav-scrim { position: fixed; z-index: 1001; inset: 0; display: block; width: 100%; height: 100%; border: 0; background: rgba(10,23,18,.48); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease-ui); }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .admin-header { min-height: 62px; gap: 9px; padding: 8px 12px; }
  .menu-toggle { display: inline-grid !important; width: 44px; height: 44px; margin-left: -4px; color: var(--ink); }
  .menu-toggle:hover { background: #f0f4f1; }
  .header-breadcrumb { flex: 1; gap: 7px; font-size: 12px; }
  .header-breadcrumb > span:first-child { display: none; }
  .breadcrumb-divider { display: none; }
  .header-breadcrumb strong { font-size: 14px; }
  .header-user { flex: 0 1 auto; gap: 6px; }
  .preview-links { display: none; }
  .user-meta { display: grid; justify-items: end; gap: 1px; max-width: 112px; font-size: 12px; }
  #current-user-name { max-width: 104px; }
  .user-role-badge { padding: 1px 5px; font-size: 10px; }
  .header-user #logout { min-height: 40px; padding: 6px 9px; font-size: 12px; }
  .admin-main { min-height: calc(100dvh - 62px); padding: 19px 14px 28px; }
  .view-header { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 17px; }
  .view-header h1, .view-header h2 { font-size: 23px; }
  .view-actions { width: 100%; }
  .view-actions .btn { flex: 1 1 auto; }
  .grid-2, .detail-grid, .notification-channel-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { align-items: flex-start; gap: 9px; padding: 12px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-info .stat-value { font-size: 19px; }
  .filter-card { align-items: stretch; flex-direction: column; padding: 12px; }
  .search-form { width: 100%; }
  #filters.search-form { grid-template-columns: minmax(0, 1fr) auto; }
  #filters > .visually-hidden { grid-column: 1 / -1; }
  #filters > input { min-width: 0; }
  .filter-card > .search-form > label:not(.visually-hidden) { min-width: 0; flex-basis: 100%; }
  .search-input { width: 100%; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar-left > *, .toolbar-right > * { min-width: 0; flex: 1 1 auto; }
  .filter-row { align-items: stretch; }
  .filter-row label { flex: 1 1 100%; justify-content: space-between; }
  .filter-row select { max-width: 64%; }
  .panel-header { align-items: flex-start; padding: 12px 13px; }
  .panel-header > span { max-width: 50%; }
  .panel-body { padding: 13px; }
  .table-responsive { border: 1px solid #e9eeea; border-radius: 8px; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 690px; }
  .data-table th { padding: 10px 11px; }
  .data-table td { padding: 10px 11px; }
  .grid-item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; padding: 10px; }
  .grid-item-row label:first-child { grid-column: 1 / -1; }
  .grid-item-row .btn { grid-column: 1 / -1; }
  .row-actions { min-width: 200px; }
  .long-cell { max-width: 75vw; }
  .audit-detail { max-width: 76vw; }
  .info-list .info-item { gap: 9px; }
  .info-list .info-item .label { width: 95px; }
  .modal-overlay { align-items: flex-end; padding: 8px; }
  .modal-card, .modal-card.modal-lg { width: 100%; max-width: none; max-height: calc(100dvh - 16px); border-radius: 14px 14px 10px 10px; }
  .modal-header { min-height: 58px; padding: 9px 13px; }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 10px 13px calc(10px + env(safe-area-inset-bottom)); }
  .pagination { justify-content: space-between; }
  .login-page { min-height: 100dvh; grid-template-columns: 1fr; }
  .login-aside { min-height: auto; padding: 18px 20px 20px; }
  .login-aside .brand-mark { width: 38px; height: 38px; }
  .login-aside-copy { margin: 24px 0 0; padding: 0; }
  .login-aside-copy .eyebrow { margin-bottom: 7px; }
  .login-aside-copy h2 { max-width: 600px; font-size: 24px; }
  .login-aside-copy p { margin-top: 6px; font-size: 14px; }
  .login-aside-footer { margin-top: 17px; }
  .login-aside::after { right: -210px; bottom: -260px; width: 370px; height: 370px; }
  .login-main { padding: 20px 14px 28px; }
  .login-card { max-width: 520px; padding: 22px 18px; }
}

@media (max-width: 390px) {
  .admin-header { gap: 4px; padding-inline: 8px; }
  .menu-toggle { margin-left: -5px; }
  .header-user { gap: 4px; }
  .user-meta { max-width: 90px; }
  #current-user-name { max-width: 86px; }
  .header-user #logout { padding-inline: 7px; }
  .admin-main { padding-inline: 11px; }
  .stats-grid { grid-template-columns: 1fr; }
  .search-form { flex-direction: column; }
  .search-form .btn { width: 100%; }
  .grid-item-row { grid-template-columns: 1fr; }
  .grid-item-row label:first-child, .grid-item-row .btn { grid-column: auto; }
  .gallery-url-row { grid-template-columns: 1fr; }
}

@media (min-width: 901px) and (max-width: 1023px) {
  :root { --sidebar-width: 220px; }
  .admin-main { padding: 23px 20px; }
  .admin-header { padding-inline: 18px; }
  .preview-link { padding-inline: 5px; }
  .user-meta { gap: 5px; }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .admin-main { padding: 26px; }
  .grid-2, .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  body { color: #000; background: #fff; font-size: 12pt; }
  .admin-sidebar, .admin-header, .btn, .nav-scrim, #modal-root { display: none !important; }
  .workspace { margin: 0; }
  .admin-main { max-width: none; padding: 0; }
  .panel, .table-card, .filter-card { border: 0; box-shadow: none; }
  .table-responsive { overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
