:root {
  --bg: #f3f6f4;
  --panel: #ffffff;
  --ink: #17221c;
  --muted: #66736c;
  --line: #dce5df;
  --green: #176b45;
  --green-dark: #0e4d31;
  --green-soft: #e6f3eb;
  --lime: #9bce5a;
  --red: #b84a3a;
  --red-soft: #fbeae7;
  --amber: #b2781f;
  --amber-soft: #fbf1db;
  --page-glow: #e8f3ec;
  --topbar-bg: #10271d;
  --topbar-ink: #ffffff;
  --topbar-muted: #b8cbc0;
  --nav-bg: rgba(255,255,255,.95);
  --panel-rgb: 255,255,255;
  --surface-soft: #f8faf8;
  --surface-alt: #fafcfb;
  --surface-raised: #ffffff;
  --table-line: #e6ece8;
  --input-border: #ccd8d0;
  --focus-ring: rgba(23,107,69,.18);
  --accent-ink: #ffffff;
  --success: #17613f;
  --success-soft: #dbf1e4;
  --info: #315b70;
  --info-soft: #e8f3f8;
  --neutral-soft: #e8eef2;
  --overlay-shadow: rgba(17,54,34,.18);
  --shadow: 0 16px 45px rgba(21, 54, 37, .08);
  font-family: Inter, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

:root[data-theme="warm"] {
  --bg: #f7f0e6;
  --panel: #fffaf3;
  --ink: #382820;
  --muted: #78665c;
  --line: #e2d1c2;
  --green: #b65337;
  --green-dark: #823d2b;
  --green-soft: #f5dfd4;
  --lime: #e2a76f;
  --red: #a94235;
  --red-soft: #f9e1dc;
  --amber: #9b671f;
  --amber-soft: #f7e9c9;
  --page-glow: #f1dcc8;
  --topbar-bg: #3b2922;
  --topbar-ink: #fffaf3;
  --topbar-muted: #dbc9bc;
  --nav-bg: rgba(255,250,243,.95);
  --panel-rgb: 255,250,243;
  --surface-soft: #f8eee4;
  --surface-alt: #fcf4eb;
  --surface-raised: #fffaf3;
  --table-line: #eadbcf;
  --input-border: #d9c4b3;
  --focus-ring: rgba(182,83,55,.20);
  --accent-ink: #ffffff;
  --success: #456b4e;
  --success-soft: #e2ede0;
  --info: #6b5a78;
  --info-soft: #eee6f2;
  --neutral-soft: #ece4dd;
  --overlay-shadow: rgba(73,43,31,.20);
  --shadow: 0 16px 45px rgba(83, 49, 31, .10);
}

:root[data-theme="night"] {
  --bg: #0d1512;
  --panel: #16211c;
  --ink: #edf5f0;
  --muted: #a9bab0;
  --line: #34463d;
  --green: #58b986;
  --green-dark: #8ad7aa;
  --green-soft: #203b2e;
  --lime: #a6dc72;
  --red: #ff8b7b;
  --red-soft: #452924;
  --amber: #e0ad5c;
  --amber-soft: #44371f;
  --page-glow: #183127;
  --topbar-bg: #08100d;
  --topbar-ink: #f4faf6;
  --topbar-muted: #9fb4a8;
  --nav-bg: rgba(18,29,24,.96);
  --panel-rgb: 22,33,28;
  --surface-soft: #1b2a23;
  --surface-alt: #19261f;
  --surface-raised: #1d2b24;
  --table-line: #31423a;
  --input-border: #4a5f54;
  --focus-ring: rgba(88,185,134,.30);
  --accent-ink: #07130d;
  --success: #8bd6aa;
  --success-soft: #1f3c2d;
  --info: #9ed1e7;
  --info-soft: #203844;
  --neutral-soft: #293831;
  --overlay-shadow: rgba(0,0,0,.48);
  --shadow: 0 18px 50px rgba(0,0,0,.30);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: hidden; scroll-behavior: smooth; }
body { max-width: 100%; margin: 0; min-height: 100vh; overflow-x: hidden; background: radial-gradient(circle at 15% 0%, #e8f3ec 0, transparent 34rem), var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.topbar { height: 78px; padding: 0 max(24px, calc((100vw - 1480px) / 2)); display: flex; align-items: center; justify-content: space-between; color: #fff; background: #10271d; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #10271d; background: var(--lime); font: 800 20px/1 Georgia, serif; }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 19px/1.1 Georgia, "Times New Roman", serif; letter-spacing: .02em; }
.brand small { margin-top: 3px; color: #b8cbc0; font-size: 12px; }
.user-chip { text-align: right; }
.user-chip span, .user-chip small { display: block; }
.user-chip span { font-weight: 700; }
.user-chip small { margin-top: 3px; color: #a9beb2; font-size: 12px; }

.nav-shell { position: sticky; top: 0; z-index: 20; height: 54px; padding: 0 max(24px, calc((100vw - 1480px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(255,255,255,.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.nav-scroll { display: flex; align-items: stretch; gap: 3px; height: 100%; overflow-x: auto; scrollbar-width: none; }
.nav-scroll::-webkit-scrollbar { display: none; }
.nav-scroll a { position: relative; display: grid; place-items: center; padding: 0 15px; color: #536159; font-size: 14px; white-space: nowrap; }
.nav-scroll a::after { content: ""; position: absolute; inset: auto 14px 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.nav-scroll a:hover, .nav-scroll a.active { color: var(--green-dark); }
.nav-scroll a.active::after { background: var(--green); }
.link-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.link-button:hover { color: var(--red); }

.page { width: min(1480px, calc(100% - 40px)); min-width: 0; margin: 0 auto; padding: 34px 0 64px; }
.timezone-notice { margin: -22px 0 18px; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: right; }
.visibility-choice { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.visibility-choice legend { padding: 0 5px; color: var(--ink); font-weight: 700; }
.visibility-choice label { display: block; margin: 5px 0; font-weight: 600; }
.visibility-choice input { width: auto; margin-right: 5px; }
.year-end-lookup-field { align-self: end; min-width: 0; }
.year-end-lookup-field > label { display: block; }
.year-end-query-button { width: 100%; margin-top: 7px; }
.lookup-status { min-height: 34px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.lookup-status.success { color: var(--green); }
.lookup-status.error, .warning-text { color: #b42318; }
.lookup-status.loading { color: var(--ink); }
.compact-lookup { min-width: 230px; }
.application-review-form { min-width: 260px; }
.application-review-form label { display: block; margin-bottom: 7px; }
.application-review-table td { vertical-align: top; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-head h1 { margin: 4px 0 7px; font: 700 clamp(28px, 4vw, 43px)/1.12 Georgia, "Noto Serif TC", serif; letter-spacing: -.025em; }
.page-head p { max-width: 780px; margin: 0; color: var(--muted); line-height: 1.7; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.update-chip { display: inline-flex; align-items: center; gap: 8px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.75); font-size: 12px; white-space: nowrap; }
.update-chip i { width: 8px; height: 8px; border-radius: 50%; background: #38a169; box-shadow: 0 0 0 4px #dff2e6; }

.button { min-height: 42px; padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; transition: .18s ease; }
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(15,75,47,.12); }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--green-dark); background: var(--green-soft); border-color: #c7dfd1; }
.button.ghost { color: var(--ink); background: #fff; border-color: var(--line); }
.button.wide { width: 100%; }

.flash { margin: 0 0 20px; padding: 13px 16px; border: 1px solid; border-radius: 11px; font-size: 14px; }
.flash.success { color: #175f3f; background: #e6f5ec; border-color: #b7ddc6; }
.flash.error { color: #8d3429; background: var(--red-soft); border-color: #efc7c0; }
.flash.info { color: #315b70; background: #e8f3f8; border-color: #c6dfe9; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { min-height: 132px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; justify-content: space-between; background: rgba(255,255,255,.88); box-shadow: 0 8px 28px rgba(24, 64, 41, .045); }
.kpi.accent { color: #fff; border-color: var(--green); background: linear-gradient(135deg, #1e7a50, #155838); }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi.accent span, .kpi.accent small { color: #cde7d6; }
.kpi strong { margin: 8px 0 5px; font: 700 clamp(24px, 3vw, 34px)/1 Georgia, serif; font-variant-numeric: tabular-nums; }
.kpi small { color: #7c8981; font-size: 12px; }

.panel { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { padding: 19px 21px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-head h2, .note-panel h2, .raw-ocr h2, .method-note h2 { margin: 0 0 5px; font: 700 20px/1.2 Georgia, "Noto Serif TC", serif; }
.panel-head p, .note-panel p, .method-note p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.table-search input { width: 220px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: #f8faf8; outline: none; }
.table-search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,69,.1); }
.table-wrap { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 11px 13px; border-bottom: 1px solid #e6ece8; text-align: left; white-space: nowrap; vertical-align: middle; }
.data-table th { position: sticky; top: 0; z-index: 2; color: #fff; background: var(--green); font-weight: 700; }
.data-table[data-sortable] th { cursor: pointer; user-select: none; }
.data-table[data-sortable] th:hover { background: var(--green-dark); }
.data-table th[data-direction="asc"]::after { content: "  ▲"; font-size: 9px; }
.data-table th[data-direction="desc"]::after { content: "  ▼"; font-size: 9px; }
.data-table tbody tr:nth-child(even) { background: #fafcfb; }
.data-table tbody tr:hover { background: var(--green-soft); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td small { display: block; margin-top: 3px; color: #88938d; font-size: 10px; }
.dense th, .dense td { padding: 10px 11px; }
.code { color: var(--green-dark); font-family: ui-monospace, "Cascadia Mono", monospace; font-weight: 700; }
.yield { color: var(--green-dark); font-weight: 800; background: #eff8f2; }
.up { color: var(--red); font-weight: 700; }
.down { color: var(--green); font-weight: 700; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status.達標, .status.已完成 { color: #17613f; background: #dbf1e4; }
.status.未達標, .status.待買 { color: #8a5c16; background: var(--amber-soft); }
.status.超標 { color: #953a30; background: var(--red-soft); }
.status.觀察, .status.部分買進 { color: #4b6170; background: #e8eef2; }
.status.尚未設定, .status.未配置, .status.無法計算 { color: #4b6170; background: #e8eef2; }
.empty { padding: 36px !important; color: var(--muted); text-align: center !important; }
.empty.small { padding: 18px !important; }

.split-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(270px, .8fr); gap: 18px; align-items: start; margin-bottom: 20px; }
.form-panel { padding-bottom: 20px; }
.form-panel > .panel-head { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 0 21px 18px; }
.form-grid .span-2 { grid-column: span 2; }
label { display: grid; gap: 7px; color: #536159; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 41px; padding: 9px 11px; border: 1px solid #ccd8d0; border-radius: 9px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,69,.1); }
textarea { resize: vertical; }
.form-panel > .button { margin-left: 21px; }
.note-panel { padding: 24px; }
.note-panel h2 { margin-top: 7px; }
.note-panel p + p { margin-top: 12px; }
.form-note { color: var(--muted); font-size: 12px; line-height: 1.55; }
.inline-form { display: flex; align-items: center; gap: 6px; }
.ratio-input { width: 78px !important; min-height: 33px; padding: 5px 7px; text-align: right; }
.inline-form button, .small-button { min-height: 32px; padding: 5px 9px; border: 1px solid #c6ddd0; border-radius: 7px; color: var(--green-dark); background: var(--green-soft); cursor: pointer; }
.danger-link { border: 0; color: var(--red); background: transparent; cursor: pointer; }
.trade { display: inline-flex; padding: 4px 8px; border-radius: 7px; font-size: 11px; font-weight: 800; }
.trade.buy { color: #8d3429; background: var(--red-soft); }
.trade.sell { color: #17613f; background: #dbf1e4; }
.trade.stock_dividend { color: #315b70; background: #e8f3f8; }
.note-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

.upload-card { max-width: 820px; margin: 0 auto; padding: 24px; }
.ocr-status { padding: 15px 17px; border-radius: 12px; display: grid; gap: 4px; }
.ocr-status.ready { color: #175f3f; background: #e6f5ec; }
.ocr-status.fallback { color: #805819; background: var(--amber-soft); }
.ocr-status span { font-size: 13px; line-height: 1.5; }
.drop-form { display: grid; gap: 12px; margin-top: 18px; }
.drop-zone { min-height: 260px; padding: 25px; display: grid; place-items: center; align-content: center; border: 2px dashed #b9cec0; border-radius: 15px; color: var(--muted); background: #f8fbf9; cursor: pointer; text-align: center; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.is-dragging { border-color: var(--green); outline: none; background: var(--green-soft); }
.drop-zone.is-dragging { transform: scale(1.006); box-shadow: 0 0 0 4px rgba(47,126,82,.12); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone strong { color: var(--ink); font-size: 17px; }
.drop-zone small { font-weight: 400; }
.drop-prompt { display: grid; place-items: center; gap: 8px; }
.drop-preview { width: min(100%, 560px); display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; align-items: center; text-align: left; }
.drop-preview[hidden] { display: none; }
.drop-preview img { width: 150px; height: 112px; border: 1px solid var(--line); border-radius: 11px; object-fit: contain; background: #fff; }
.drop-preview span { min-width: 0; display: grid; gap: 6px; }
.drop-preview strong { overflow-wrap: anywhere; }
.drop-status { min-height: 21px; margin: 0; color: var(--muted); font-size: 12px; }
.drop-status.success { color: var(--green-dark); }
.drop-status.error { color: var(--red); font-weight: 700; }
.drop-actions { display: flex; justify-content: flex-end; gap: 10px; }
.drop-actions [hidden] { display: none; }
.drop-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 27px; }
.raw-ocr { padding: 24px; }
.raw-ocr summary { cursor: pointer; color: var(--green-dark); font-weight: 800; }
.raw-ocr pre { max-height: 430px; overflow: auto; padding: 14px; border-radius: 10px; color: #32423a; background: #f1f5f2; white-space: pre-wrap; word-break: break-word; font: 12px/1.6 ui-monospace, monospace; }
.ocr-result-summary { display: grid; grid-template-columns: 1.6fr 1.1fr .7fr .8fr; gap: 12px; margin-bottom: 16px; }
.ocr-result-summary article { min-width: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
.ocr-result-summary span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.ocr-result-summary strong { display: block; overflow: hidden; color: var(--ink); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.flash.info small { display: block; margin-top: 5px; opacity: .78; }
.ocr-multi-form { padding-bottom: 0; overflow: hidden; }
.ocr-bulk-date { padding: 16px 20px; display: grid; grid-template-columns: minmax(210px, 300px) auto 1fr; gap: 12px; align-items: end; border-bottom: 1px solid var(--line); background: #f8fbf9; }
.ocr-bulk-date label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 800; }
.ocr-bulk-date input { width: 100%; }
.ocr-bulk-date > span { align-self: center; color: var(--muted); font-size: 12px; line-height: 1.5; }
.ocr-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.ocr-edit-table { min-width: 1540px; }
.ocr-edit-table th, .ocr-edit-table td { padding: 10px 8px; vertical-align: top; }
.ocr-edit-table tr.has-warning td { background: #fffdf7; }
.ocr-edit-table input, .ocr-edit-table select { width: 100%; min-width: 105px; padding: 8px; }
.ocr-stock-autocomplete { min-width: 245px; }
.ocr-field { min-width: 110px; display: grid; gap: 4px; }
.ocr-field small { color: var(--muted); font-size: 10px; white-space: normal; }
.ocr-field em { max-width: 180px; color: var(--red); font-size: 10px; font-style: normal; line-height: 1.35; white-space: normal; }
.ocr-field.field-warning input, .ocr-field.field-warning select { border-color: #d68d3d; background: #fffaf0; box-shadow: 0 0 0 2px rgba(214,141,61,.08); }
.ocr-warning-cell { min-width: 230px; max-width: 290px; white-space: normal !important; }
.ocr-warning-cell > strong { display: block; margin-bottom: 5px; }
.ocr-warning-cell ul { margin: 0; padding-left: 17px; color: #8a5c16; font-size: 11px; line-height: 1.45; }
.ocr-form-footer { padding: 16px 20px; display: flex; justify-content: space-between; gap: 16px; align-items: center; border-top: 1px solid var(--line); }
.ocr-form-footer span { color: var(--muted); font-size: 12px; }

.projection-form, .plan-form { padding: 18px; display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 12px; align-items: end; }
.projection-form .button, .plan-form .button { min-height: 41px; }
.projection-summary { margin-top: 20px; }
.projection-bars { padding: 20px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.projection-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) 118px; align-items: center; gap: 12px; min-width: 0; font-size: 12px; }
.projection-meter { width: 100%; min-width: 0; height: 10px; display: block; border-radius: 999px; overflow: hidden; }
.projection-meter-track { fill: #f3f6f4; stroke: #d9e3dc; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.projection-meter-fill { fill: #287a4f; }
.projection-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.hero-total { margin-bottom: 20px; padding: 31px; border-radius: 18px; display: grid; gap: 7px; color: #fff; background: linear-gradient(120deg, #113c28, #1c7650 70%, #86ba4d); box-shadow: 0 20px 44px rgba(15,75,47,.17); }
.hero-total span { color: #d7eadf; font-size: 13px; }
.hero-total strong { font: 700 clamp(34px, 6vw, 58px)/1 Georgia, serif; }
.hero-total small { color: #cce1d4; }

.performance-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.performance-card { min-height: 260px; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.performance-card.primary-card { background: linear-gradient(145deg, #fff, #eef7f1); }
.performance-card > span { color: var(--muted); font-size: 13px; }
.performance-card > strong { display: block; margin: 14px 0 24px; font: 700 44px/1 Georgia, serif; }
.performance-card dl { margin: 0; display: grid; gap: 11px; }
.performance-card dl div { padding-top: 11px; display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); }
.performance-card dt { color: var(--muted); }
.performance-card dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.year-filter { display: flex; align-items: center; gap: 8px; }
.year-filter input { width: 95px; }
.method-note { padding: 22px; }

.week-board { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 12px; padding: 16px; overflow-x: auto; }
.week-column { min-height: 260px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #f7faf8; }
.week-column header { margin-bottom: 10px; padding: 4px 3px 10px; border-bottom: 1px solid var(--line); }
.week-column header span, .week-column header strong { display: block; }
.week-column header span { color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.week-column header strong { margin-top: 4px; }
.plan-item { margin-top: 9px; padding: 12px; border: 1px solid #dce6df; border-radius: 11px; background: #fff; }
.plan-item > div { display: flex; align-items: center; gap: 9px; }
.plan-item dl { margin: 11px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.plan-item dl div { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 11px; }
.plan-item dd { margin: 0; color: var(--ink); font-weight: 700; }
.empty-state { padding: 54px 24px; text-align: center; }
.empty-state strong { font: 700 24px Georgia, serif; }
.empty-state p { color: var(--muted); }
.error-state { max-width: 680px; margin: 50px auto; }

.admin-add-grid { grid-template-columns: 1.5fr .7fr; }
.admin-table input, .admin-table select { min-width: 84px; min-height: 32px; padding: 5px 7px; font-size: 12px; }
.admin-table td:nth-child(2) input { min-width: 120px; }
.admin-table td:nth-child(9) input { min-width: 130px; }
.toggle { display: inline-flex; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { width: 38px; height: 22px; padding: 2px; border-radius: 999px; background: #bdc8c1; transition: .2s; }
.toggle span::after { content: ""; width: 18px; height: 18px; display: block; border-radius: 50%; background: #fff; transition: .2s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(16px); }

.login-page { width: 100%; min-height: 100vh; padding: 0; display: grid; place-items: center; background: linear-gradient(125deg, #0f2d20 0 48%, #eaf2ed 48% 100%); }
.login-card { width: min(1050px, calc(100% - 40px)); min-height: 570px; display: grid; grid-template-columns: 1.12fr .88fr; border-radius: 24px; overflow: hidden; background: #fff; box-shadow: 0 30px 90px rgba(8,35,22,.25); }
.login-intro { padding: clamp(34px, 6vw, 68px); display: flex; flex-direction: column; justify-content: center; color: #fff; background: radial-gradient(circle at 20% 15%, rgba(155,206,90,.22), transparent 20rem), linear-gradient(145deg, #153e2b, #0b2519); }
.login-intro .eyebrow { color: var(--lime); }
.login-intro h1 { margin: 14px 0 20px; max-width: 580px; font: 700 clamp(34px, 5vw, 56px)/1.1 Georgia, "Noto Serif TC", serif; letter-spacing: -.035em; }
.login-intro p { max-width: 530px; color: #bdd0c4; line-height: 1.8; }
.source-pills { margin-top: 35px; display: flex; flex-wrap: wrap; gap: 8px; }
.source-pills span { padding: 7px 10px; border: 1px solid #365b48; border-radius: 999px; color: #d4e4da; font-size: 11px; }
.login-form { padding: clamp(32px, 5vw, 58px); display: flex; flex-direction: column; justify-content: center; gap: 17px; }
.login-form h2 { margin: 8px 0 16px; font: 700 27px Georgia, serif; }
.register-card { min-height: 670px; }

.profile-grid { grid-template-columns: 1.2fr .8fr; }
.single-column { grid-template-columns: 1fr; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-3 { grid-column: span 3; }
.compact-number { min-width: 112px; width: 100%; }
.dividend-forecast-table { min-width: 1180px; }
.review-inline { min-width: 260px; display: grid; gap: 8px; }
.review-inline input { min-height: 34px; padding: 6px 8px; }
.ratio-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.warning-card { border-color: #e3c483; background: var(--amber-soft); }
.warning-card small { color: #865d1b; }
.inactive-row { opacity: .58; }
.target-table input, .target-table select { min-width: 96px; min-height: 34px; padding: 5px 7px; font-size: 12px; }
.target-table td:nth-child(2) input { min-width: 130px; }
.target-table td:nth-child(6) input { min-width: 150px; }
.review-actions { display: flex; align-items: center; gap: 8px; }
.review-actions form { display: flex; align-items: center; gap: 6px; }
.review-actions input { min-width: 150px; min-height: 32px; padding: 5px 7px; }
.permission-check { display: inline-flex; grid-template-columns: auto 1fr; align-items: center; gap: 5px; margin: 3px 10px 3px 0; }
.permission-check input { width: 16px; min-height: 16px; }
.permission-check span { white-space: nowrap; }
.status.pending { color: #8a5c16; background: var(--amber-soft); }
.status.approved, .status.success, .status.calculated { color: #17613f; background: #dbf1e4; }
.status.rejected, .status.failed { color: #953a30; background: var(--red-soft); }
.status.not_updated { color: #4b6170; background: #e8eef2; }

.batch-transaction-form { padding-bottom: 20px; overflow: visible; }
.batch-table-wrap { padding: 16px 20px 8px; overflow-x: auto; }
.transaction-grid { min-width: 1100px; display: grid; grid-template-columns: 135px 100px minmax(230px, 1.5fr) 105px 105px 125px 105px 85px; gap: 8px; align-items: start; }
.transaction-grid-head { padding: 0 3px 8px; color: var(--muted); font-size: 11px; font-weight: 800; }
.transaction-row { padding: 8px 3px; border-top: 1px solid var(--line); }
.transaction-row input, .transaction-row select { min-height: 39px; }
.transaction-row .danger-link { min-height: 39px; }
.stock-autocomplete { position: relative; min-width: 210px; }
.stock-autocomplete:focus-within { z-index: 30; }
.panel:has(.stock-autocomplete) { overflow: visible; }
.stock-help { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; }
.stock-selection-error { display: block; margin-top: 4px; color: var(--red); font-weight: 700; }
.stock-selection-error[hidden] { display: none; }
.stock-query.invalid-selection { border-color: var(--red); background: #fff8f7; box-shadow: 0 0 0 2px rgba(174,59,49,.08); }
.autocomplete-menu { position: absolute; top: 43px; left: 0; right: 0; z-index: 15; max-height: 285px; overflow-y: auto; border: 1px solid #bfd4c6; border-radius: 10px; background: #fff; box-shadow: 0 18px 38px rgba(17,54,34,.18); }
.autocomplete-menu[hidden] { display: none; }
.autocomplete-menu button { width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid #edf1ee; display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; color: var(--ink); background: #fff; text-align: left; cursor: pointer; }
.autocomplete-menu button:hover, .autocomplete-menu button.active { background: var(--green-soft); }
.autocomplete-menu button strong { color: var(--green-dark); font-family: ui-monospace, monospace; }
.autocomplete-menu button small { color: var(--muted); }
.autocomplete-empty { padding: 14px; color: var(--amber); font-size: 12px; line-height: 1.5; }
.autocomplete-empty a { color: var(--green-dark); font-weight: 800; }
.batch-actions { padding: 12px 20px 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.transaction-note { box-shadow: none; }

.section-head { margin-top: 46px; }
.custom-plan-form { padding-bottom: 18px; }
.custom-plan-meta { padding: 16px 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.custom-plan-row { padding: 8px 20px; display: grid; grid-template-columns: minmax(250px, 1fr) 180px 90px; gap: 10px; align-items: end; border-top: 1px solid var(--line); }
.ratio-live { min-height: 64px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 2px; background: #f8faf8; }
.ratio-live strong { font-size: 20px; }
.ratio-live small { color: var(--muted); }
.ratio-live.warn { border-color: #e3c483; background: var(--amber-soft); }
.custom-plan-card .title-input { min-width: 250px; border: 0; padding: 0; font: 700 21px Georgia, serif; }
.custom-plan-card .data-table select { min-width: 190px; }
.error-text { color: var(--red) !important; }
.schedule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.breakable { overflow-wrap: anywhere; word-break: break-all; }

.section-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 22px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.72); width: fit-content; max-width: 100%; }
.section-tabs a { padding: 9px 14px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 800; }
.section-tabs a.active { color: #fff; background: var(--green); }
.aligned-head { padding-inline: 2px; }
.target-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.target-amount-panel, .allocation-panel, .source-actions-panel { min-width: 0; }
.target-amount-form { padding: 20px 21px; display: grid; grid-template-columns: minmax(240px, 440px) auto; gap: 12px; align-items: end; }
.allocation-table-wrap, .master-table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.allocation-table { min-width: 1780px; }
.allocation-table th, .allocation-table td { padding: 10px 11px; }
.allocation-table .business-cell { min-width: 150px; max-width: 250px; white-space: normal; }
.business-cell details summary { color: var(--green); cursor: pointer; font-weight: 800; }
.business-cell details p { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.muted { color: var(--muted); }
.percent-input { display: grid; grid-template-columns: minmax(76px, 92px) auto; align-items: center; gap: 5px; }
.percent-input input { min-height: 34px; padding: 5px 7px; text-align: right; }
.num-block { display: block; text-align: right; }
.panel-actions { padding: 16px 21px 20px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
.restore-form { display: flex; justify-content: flex-end; margin-top: -6px; }
.master-filters { padding: 18px 21px; display: grid; grid-template-columns: minmax(230px, 1fr) 160px 160px auto auto; gap: 12px; align-items: end; border-bottom: 1px solid var(--line); }
.compact-head { padding-block: 14px; }
.master-table { min-width: 1420px; }
.master-table td:nth-child(2) { min-width: 190px; white-space: normal; }
.master-table td:nth-child(7) { min-width: 220px; }
.row-actions { display: flex; align-items: flex-start; gap: 7px; }
.row-actions form { display: inline-flex; }
.delete-disclosure { position: relative; }
.delete-disclosure > summary { min-height: 32px; padding: 7px 9px; border: 1px solid #efc7c0; border-radius: 7px; color: var(--red); background: var(--red-soft); cursor: pointer; list-style: none; }
.delete-disclosure form { position: absolute; z-index: 8; right: 0; width: 230px; padding: 12px; display: grid; gap: 8px; border: 1px solid #efc7c0; border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.danger-button { min-height: 38px; padding: 8px 12px; border: 1px solid #c86152; border-radius: 8px; color: #fff; background: var(--red); font-weight: 800; cursor: pointer; }
.pagination { padding: 16px 21px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.stock-detail-form { min-width: 0; }
.stock-form-grid textarea { min-height: 116px; }
.four-columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.subhead { margin-top: 4px; border-top: 1px solid var(--line); }
.master-meta .meta-strong { font: 700 17px/1.3 Inter, "Segoe UI", sans-serif; overflow-wrap: anywhere; }
.source-link { color: var(--green); text-decoration: underline; text-underline-offset: 2px; }
.stock-operation-bar { margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 10px; }
.stock-operation-bar form { display: inline-flex; }
.danger-zone { border-color: #efc7c0; }
.danger-zone .panel-head { background: var(--red-soft); }
.danger-zone > form { padding: 20px 21px; display: grid; grid-template-columns: minmax(240px, 420px) auto; gap: 12px; align-items: end; }
.dependency-list { padding: 16px 21px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.dependency { padding: 6px 9px; border-radius: 999px; color: var(--muted); background: #edf2ee; font-size: 12px; }
.dependency.has-data { color: #8d3429; background: var(--red-soft); }
.scenario-strip { margin-bottom: 20px; display: grid; grid-template-columns: repeat(auto-fill,minmax(210px,1fr)); gap: 10px; }
.scenario-card { padding: 15px; display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; box-shadow: 0 7px 22px rgba(25,57,38,.06); }
.scenario-card.active { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.scenario-card small { color: var(--muted); }
.scenario-card span { color: var(--green); font-weight: 800; }
.scenario-form { grid-template-columns: repeat(4,minmax(0,1fr)); }
.span-all { grid-column: 1/-1; }
.scenario-actions,.operation-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.operation-row { margin: -8px 0 22px; }
.filter-pills { margin-bottom: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.filter-pills > a { padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-weight: 800; }
.filter-pills > a.active { color: #fff; border-color: var(--green); background: var(--green); }
.filter-pills form { margin-left: auto; display: flex; gap: 7px; }
.filter-pills input { width: 100px; min-height: 38px; }
.event-chip { margin: 2px 4px 2px 0; padding: 4px 7px; display: inline-block; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; font-weight: 800; }
.copy-year-form { padding: 16px 21px; display: flex; flex-wrap: wrap; align-items: end; gap: 9px; border-top: 1px solid var(--line); }
.copy-year-form label { max-width: 150px; }
.edit-disclosure { position: relative; display: inline-block; margin-right: 6px; }
.edit-disclosure summary { color: var(--green); cursor: pointer; font-weight: 800; }
.edit-disclosure form { position: absolute; z-index: 10; right: 0; width: 310px; padding: 12px; display: grid; gap: 7px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.quarter-entry-grid { padding: 18px 21px 22px; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.quarter-entry { padding: 15px; display: grid; gap: 9px; border: 1px solid var(--line); border-radius: 12px; background: #f9fbf9; }
.quarter-entry h3 { margin: 0; color: var(--green-dark); font: 700 23px Georgia,serif; }
.quarter-entry label { display: grid; gap: 5px; }
.readonly-note { margin: 0 0 20px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #f8faf8; }
.market-update-note { margin: -10px 0 20px; padding: 10px 13px; border-radius: 9px; font-size: 13px; font-weight: 700; }
.market-update-note.allowed { color: var(--green-dark); background: var(--green-soft); }
.market-update-note.closed { color: #8a5c16; background: var(--amber-soft); }
button:disabled { opacity: .55; cursor: not-allowed; }

.allocation-total-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  padding: 18px 22px;
  border: 1px solid #b8d8c6;
  border-radius: 18px;
  background: #effaf4;
}
.allocation-total-card strong { font-size: 1.7rem; color: #157347; }
.allocation-total-card small { color: #4f6f5d; }
.allocation-total-card.warn { background: #fff8e8; border-color: #e7c979; }
.allocation-total-card.warn strong { color: #a15c00; }
.allocation-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.allocation-tools label { min-width: 180px; }
.allocation-tools .check-label { min-width: auto; display: inline-flex; flex-direction: row; align-items: center; gap: 8px; padding-bottom: 10px; white-space: nowrap; }
.allocation-tools .check-label input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; accent-color: var(--green); }
.unsaved-indicator { color: #a15c00; font-weight: 700; padding: 10px 12px; border-radius: 999px; background: #fff1c7; }
.admin-plan-items { min-width: 900px; }
.admin-plan-items input, .admin-plan-items select { min-width: 120px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .projection-form, .plan-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .performance-grid { grid-template-columns: 1fr 1fr; }
  .performance-card.primary-card { grid-column: span 2; }
  .week-board { grid-template-columns: repeat(4, 250px); }
  .target-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .master-filters { grid-template-columns: minmax(220px, 1fr) 150px 150px; }
  .master-filters .button { width: 100%; }
  .four-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenario-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .quarter-entry-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .topbar { height: 66px; padding: 0 16px; }
  .brand small { display: none; }
  .nav-shell { height: 52px; padding: 0 10px 0 4px; }
  .nav-scroll a { padding: 0 12px; font-size: 13px; }
  .page { width: min(100% - 24px, 1480px); padding-top: 24px; }
  .timezone-notice { margin-top: -14px; text-align: left; }
  .year-end-query-button { min-height: 44px; }
  .application-review-form { min-width: 240px; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page-head h1 { font-size: 31px; }
  .head-actions { width: 100%; justify-content: space-between; }
  .kpi-grid, .kpi-grid.compact { grid-template-columns: 1fr 1fr; }
  .kpi { min-height: 115px; padding: 16px; }
  .kpi strong { font-size: 26px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .table-search, .table-search input { width: 100%; }
  .split-grid, .admin-add-grid, .ocr-grid { grid-template-columns: 1fr; }
  .profile-grid, .schedule-grid { grid-template-columns: 1fr; }
  .three-columns { grid-template-columns: 1fr 1fr; }
  .ratio-summary { grid-template-columns: 1fr; }
  .projection-form, .plan-form { grid-template-columns: 1fr 1fr; }
  .performance-grid { grid-template-columns: 1fr; }
  .performance-card.primary-card { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .form-grid .span-3 { grid-column: auto; }
  .login-page { background: #0f2d20; }
  .login-card { width: min(100% - 24px, 560px); grid-template-columns: 1fr; margin: 24px 0; }
  .login-intro { padding: 32px 28px; }
  .login-intro h1 { font-size: 34px; }
  .source-pills { margin-top: 18px; }
  .login-form { padding: 32px 28px; }
  .custom-plan-meta { grid-template-columns: 1fr; }
  .custom-plan-row { grid-template-columns: 1fr 120px auto; }
  .target-amount-form, .danger-zone > form { grid-template-columns: 1fr; }
  .master-filters { grid-template-columns: 1fr 1fr; }
  .master-filters label:first-child { grid-column: span 2; }
  .row-actions { flex-wrap: wrap; }
  .ocr-result-summary { grid-template-columns: 1fr 1fr; }
  .ocr-bulk-date { grid-template-columns: 1fr auto; }
  .ocr-bulk-date > span { grid-column: 1 / -1; }
  .ocr-form-footer { align-items: stretch; flex-direction: column; }
  .ocr-form-footer .button { width: 100%; }
}

@media (max-width: 480px) {
  .user-chip small { display: none; }
  .kpi-grid, .kpi-grid.compact { grid-template-columns: 1fr; }
  .projection-form, .plan-form { grid-template-columns: 1fr; }
  .three-columns, .custom-plan-row { grid-template-columns: 1fr; }
  .four-columns, .master-filters { grid-template-columns: 1fr; }
  .scenario-form { grid-template-columns: 1fr; }
  .quarter-entry-grid { grid-template-columns: 1fr; }
  .filter-pills form { width: 100%; margin-left: 0; }
  .master-filters label:first-child { grid-column: auto; }
  .section-tabs { width: 100%; }
  .section-tabs a { flex: 1; text-align: center; }
  .panel-actions, .restore-form { justify-content: stretch; }
  .panel-actions .button, .restore-form .button { width: 100%; }
  .projection-row { grid-template-columns: 60px 1fr 95px; gap: 8px; }
  .update-chip { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
  .ocr-result-summary { grid-template-columns: 1fr; }
  .ocr-result-summary strong { white-space: normal; }
  .ocr-bulk-date { grid-template-columns: 1fr; }
  .ocr-bulk-date .button { width: 100%; }
  .ocr-bulk-date > span { grid-column: auto; }
  .drop-zone { min-height: 220px; padding: 18px; }
  .drop-preview { grid-template-columns: 1fr; text-align: center; }
  .drop-preview img { width: min(100%, 240px); height: 150px; justify-self: center; }
  .drop-actions { display: grid; grid-template-columns: 1fr; }
  .drop-actions .button { width: 100%; }
  .ocr-stock-autocomplete .autocomplete-menu { min-width: min(320px, calc(100vw - 48px)); max-width: calc(100vw - 48px); }
  .stock-autocomplete { width: 100%; min-width: 0; }
  .stock-autocomplete .autocomplete-menu { min-width: min(300px, calc(100vw - 48px)); max-width: calc(100vw - 48px); }
  .allocation-total-card { grid-template-columns: 1fr; gap: 5px; }
  .allocation-tools { display: grid; grid-template-columns: 1fr; }
  .allocation-tools label { min-width: 0; }
}

@media print {
  .topbar, .nav-shell, .head-actions, .table-search, button, .button { display: none !important; }
  .page { width: 100%; padding: 0; }
  .panel, .kpi { box-shadow: none; }
  .table-wrap { overflow: visible; }
}

/* Theme system: shared semantic surfaces override legacy literal colors. */
body { background: radial-gradient(circle at 15% 0%, var(--page-glow) 0, transparent 34rem), var(--bg); }
.topbar { color: var(--topbar-ink); background: var(--topbar-bg); }
.brand-mark { color: var(--topbar-bg); }
.brand small, .user-chip small { color: var(--topbar-muted); }
.nav-shell { background: var(--nav-bg); }
.nav-scroll a, label { color: var(--muted); }
.button.primary, .section-tabs a.active, .filter-pills > a.active, .data-table th { color: var(--accent-ink); }
.button.secondary, .small-button, .inline-form button { border-color: var(--line); }
.button.ghost, input, select, textarea, .autocomplete-menu, .autocomplete-menu button,
.scenario-card, .filter-pills > a, .edit-disclosure form, .delete-disclosure form,
.ocr-result-summary article, .plan-item, .performance-card {
  color: var(--ink); background: var(--surface-raised); border-color: var(--line);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 82%, transparent); opacity: 1; }
input:focus, select:focus, textarea:focus, .table-search input:focus { box-shadow: 0 0 0 3px var(--focus-ring); }
.panel { background: rgba(var(--panel-rgb),.96); }
.kpi { background: rgba(var(--panel-rgb),.90); box-shadow: var(--shadow); }
.update-chip, .section-tabs { background: rgba(var(--panel-rgb),.78); }
.table-search input, .drop-zone, .ocr-bulk-date, .week-column, .ratio-live,
.quarter-entry, .readonly-note { background: var(--surface-soft); }
.data-table th, .data-table td { border-color: var(--table-line); }
.data-table tbody tr:nth-child(even) { background: var(--surface-alt); }
.data-table tbody tr:hover { background: var(--green-soft); }
.data-table td small { color: var(--muted); }
.yield { color: var(--green-dark); background: var(--green-soft); }
.flash.success, .status.達標, .status.已完成, .status.approved, .status.success,
.status.calculated, .trade.sell, .ocr-status.ready { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 42%, var(--line)); }
.flash.info, .trade.stock_dividend { color: var(--info); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 38%, var(--line)); }
.status.觀察, .status.部分買進, .status.尚未設定, .status.未配置,
.status.無法計算, .status.not_updated, .dependency { color: var(--muted); background: var(--neutral-soft); }
.raw-ocr pre { color: var(--ink); background: var(--surface-soft); }
.projection-meter-track { fill: var(--surface-soft); stroke: var(--line); }
.projection-meter-fill { fill: var(--green); }
.performance-card.primary-card { background: linear-gradient(145deg, var(--surface-raised), var(--green-soft)); }
.login-page { background: linear-gradient(125deg, var(--topbar-bg) 0 48%, var(--page-glow) 48% 100%); }
.login-card { background: var(--surface-raised); box-shadow: 0 30px 90px var(--overlay-shadow); }
.login-intro { color: var(--topbar-ink); background: radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--lime) 24%, transparent), transparent 20rem), linear-gradient(145deg, var(--topbar-bg), color-mix(in srgb, var(--topbar-bg) 82%, #000)); }
.autocomplete-menu { border-color: var(--line); box-shadow: 0 18px 38px var(--overlay-shadow); }
.autocomplete-menu button { border-color: var(--table-line); }
.stock-query.invalid-selection { background: var(--red-soft); }
.ocr-edit-table tr.has-warning td, .ocr-field.field-warning input,
.ocr-field.field-warning select { background: var(--amber-soft); }
.drop-preview img { background: var(--surface-raised); }

.theme-switcher { position: fixed; z-index: 60; display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: 999px; color: var(--ink); background: color-mix(in srgb, var(--panel) 94%, transparent); box-shadow: 0 8px 26px var(--overlay-shadow); backdrop-filter: blur(14px); }
.theme-switcher-auth { top: 15px; right: max(215px, calc((100vw - 1480px) / 2 + 215px)); }
.theme-switcher-guest { top: 18px; right: 18px; }
.theme-switcher-label { padding-left: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.theme-options { display: flex; gap: 3px; }
.theme-option { min-height: 32px; padding: 5px 9px; border: 1px solid transparent; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }
.theme-option i { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.theme-option[data-theme-value="warm"] i { background: #b65337; box-shadow: 0 0 0 2px #f5dfd4; }
.theme-option[data-theme-value="night"] i { background: #18251f; box-shadow: 0 0 0 2px #58b986; }
.theme-option:hover, .theme-option[aria-pressed="true"] { color: var(--green-dark); border-color: var(--line); background: var(--green-soft); }
.theme-option:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
.theme-save-status { min-width: 38px; padding-right: 5px; color: var(--muted); font-size: 10px; }

:root[data-theme="night"] .kpi.accent,
:root[data-theme="night"] .hero-total { color: #f4faf6; }
:root[data-theme="night"] .up { color: #ff8b7b; }
:root[data-theme="night"] .down { color: #72d69d; }
:root[data-theme="night"] .button.primary { color: #07130d; }
:root[data-theme="night"] img { filter: brightness(.94); }

@media (max-width: 900px) {
  .theme-switcher-auth { top: 13px; right: 145px; }
  .theme-switcher-label, .theme-save-status, .theme-option span { display: none; }
  .theme-option { width: 30px; padding: 5px; justify-content: center; }
}

@media (max-width: 560px) {
  .theme-switcher-auth { top: 72px; right: 10px; }
  .theme-switcher-guest { top: 10px; right: 10px; }
  .theme-switcher { padding: 4px; }
  .theme-option { min-height: 28px; width: 28px; }
  .login-page { background: var(--topbar-bg); }
}
