
:root {
  color-scheme: light;
  --bg-page: #0b1a38;
  --bg-sidebar: #081430;
  --text: #eef2f8;
  --muted: #a9b4c9;
  --hint: #7c88a3;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.26);
  --surface1: #12234a;
  --surface2: #16294f;
  --accent-bg: rgba(79, 143, 224, 0.18);
  --accent-text: #8fc0f5;
  --accent-fill: #4f8fe0;
  --success-bg: rgba(29, 111, 66, 0.28);
  --success-text: #8fd6a4;
  --warning-bg: rgba(154, 118, 10, 0.3);
  --warning-text: #f2cc72;
  --danger-bg: rgba(163, 45, 45, 0.28);
  --danger-text: #f0a3a3;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.6;
}
a { color: inherit; }
.app { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 216px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--border);
}
.sidebar .logo { font-weight: 600; font-size: 15px; margin: 0 0 2px; padding: 0 8px; letter-spacing: 0.3px; }
.sidebar .logo-sub { font-size: 11px; color: var(--hint); padding: 0 8px; margin-bottom: 16px; }
.sidebar .role-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}
.sidebar .role-box .role-name { font-size: 13px; font-weight: 600; margin: 0 0 2px; }
.sidebar .role-box .role-tag { font-size: 11px; color: var(--muted); margin: 0 0 8px; }
.sidebar .role-switch { display: inline-block; font-size: 11.5px; color: var(--accent-text); text-decoration: none; }
.sidebar .role-switch:hover { text-decoration: underline; }
.navitem {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none;
  font-size: 13px; margin-bottom: 2px;
}
.navitem.active { background: var(--accent-bg); color: var(--accent-text); font-weight: 600; }
.navitem:hover:not(.active) { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.nav-divider { height: 1px; background: var(--border); margin: 10px 4px; }
.navicon { flex-shrink: 0; opacity: 0.85; }
.navitem.active .navicon { opacity: 1; }
.navdot { flex-shrink: 0; font-size: 14px; line-height: 1; color: var(--hint); width: 15px; text-align: center; }
.navitem.active .navdot { color: var(--accent-text); }
.navlabel { display: inline-flex; align-items: center; gap: 8px; }
.navgroup-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 9px 10px; border-radius: 8px; border: none; background: none;
  color: var(--muted); font-size: 13px; margin-bottom: 2px; cursor: pointer; font-family: inherit;
  text-align: left;
}
.navgroup-toggle:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.navgroup-toggle.open { color: var(--text); }
.navgroup-toggle .chev { font-size: 10px; color: var(--hint); transition: transform 0.15s ease; flex-shrink: 0; }
.navgroup-toggle.open .chev { transform: rotate(90deg); }
.navsub { max-height: 0; overflow: hidden; transition: max-height 0.18s ease; }
.navsub.open { max-height: 640px; }
.navsub-label { font-size: 10.5px; color: var(--hint); padding: 8px 10px 2px 20px; text-transform: uppercase; letter-spacing: 0.05em; }
.navsub .navitem { padding-left: 14px; font-size: 12.5px; }
.navgroup-toggle-sub { padding: 7px 10px 7px 20px; font-size: 12px; margin-bottom: 0; }
.navsub-sub { max-height: 0; overflow: hidden; transition: max-height 0.18s ease; }
.navsub-sub.open { max-height: 200px; }
.navsub-sub .navitem { padding-left: 24px; font-size: 12px; }

.lang-switch { display: flex; gap: 4px; margin-top: 10px; }
.lang-btn {
  flex: 1; padding: 5px 6px; font-size: 11px; border-radius: 6px;
  border: 1px solid var(--border); background: none; color: var(--muted);
  cursor: pointer; font-family: inherit;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent-bg); font-weight: 600; }
.main > .lang-switch { max-width: 200px; margin: 0 0 14px; }

.main { flex: 1; min-width: 0; padding: 30px 40px 60px; max-width: 1020px; }
.crumb { font-size: 12px; color: var(--hint); margin: 0 0 8px; }
.crumb a { color: var(--hint); text-decoration: none; }
h1.page-title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.page-sub { font-size: 13px; color: var(--muted); margin: 0 0 24px; }

.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.card { background: var(--surface1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card h3 { font-size: 13.5px; font-weight: 600; margin: 0 0 4px; }
.card p.sub { font-size: 11.5px; color: var(--hint); margin: 0; }

.stat-card { background: var(--surface1); border-radius: 12px; padding: 16px; }
.stat-label { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.stat-value { font-size: 22px; font-weight: 600; margin: 0; }
.stat-value-lines { font-size: 14px; font-weight: 600; margin: 0; line-height: 1.7; }
.stat-value-lines .n { font-size: 15px; font-weight: 700; }

.badge { display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.badge-accent { background: var(--accent-bg); color: var(--accent-text); }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-muted { background: rgba(255, 255, 255, 0.06); color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--text);
  text-decoration: none; cursor: pointer; font-family: inherit;
}
.btn:hover { background: rgba(255, 255, 255, 0.06); }
.btn-primary { background: #fff; border-color: #fff; color: var(--bg-page); font-weight: 600; }
.btn-primary:hover { background: #dbe6f5; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; cursor: default; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 9px 10px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.03); white-space: nowrap; }
td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.table-scroll table { min-width: 720px; }
.table-scroll td, .table-scroll th { border-color: var(--border); }

.section-title { font-size: 14.5px; font-weight: 600; margin: 28px 0 12px; display: flex; align-items: center; justify-content: space-between; }
.section-title:first-of-type { margin-top: 0; }
.section-note { font-size: 11.5px; color: var(--hint); margin: 8px 0 0; }
.section-block { margin-bottom: 30px; }
.section-block-head { font-size: 13.5px; font-weight: 600; margin: 0 0 4px; }
.section-block-desc { font-size: 12px; color: var(--hint); margin: 0 0 10px; }

input[type=text], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=password], textarea, select {
  font-family: inherit; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--border-strong); border-radius: 6px; width: 100%;
  background: rgba(255, 255, 255, 0.04); color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--hint); }
label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
textarea { resize: vertical; min-height: 70px; }
.check-row { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); margin: 0 0 6px; }
.check-group { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 4px; }

.notify { background: var(--accent-bg); color: var(--accent-text); padding: 12px 16px; border-radius: 12px; font-size: 13.5px; margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; }

.timeline-step { display: flex; align-items: center; gap: 10px; flex: 1; flex-direction: column; }
.timeline-dot { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.timeline-row { display: flex; align-items: center; }
.timeline-line { flex: 1; height: 2px; margin-bottom: 30px; }

.cal-head-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 14px; }
.cal-nav-btn { background: transparent; border: 1px solid var(--border-strong); color: var(--text); width: 30px; height: 30px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.cal-nav-btn:hover:not([disabled]) { background: rgba(255, 255, 255, 0.06); }
.cal-nav-btn[disabled] { opacity: 0.3; cursor: default; }
.cal-month-label { font-size: 15px; font-weight: 600; min-width: 110px; text-align: center; }
.cal-month { display: none; }
.cal-month.show { display: block; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-dow { font-size: 11px; color: var(--muted); text-align: center; padding: 7px 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.03); }
.cal-cell { min-height: 82px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; }
.cal-cell.has-event { cursor: pointer; }
.cal-cell.has-event:hover { background: rgba(255, 255, 255, 0.04); }
.cal-cell.out { background: rgba(255, 255, 255, 0.015); }
.cal-cell.out .cal-daynum { color: rgba(255, 255, 255, 0.2); }
.cal-daynum { font-size: 11.5px; color: var(--muted); }
.cal-event { display: block; margin-top: 4px; font-size: 10.5px; padding: 2px 5px; border-radius: 5px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-progress { background: var(--warning-bg); color: var(--warning-text); }
.ev-scheduled { background: var(--accent-bg); color: var(--accent-text); }
.ev-done { background: var(--success-bg); color: var(--success-text); }

.detail-panel { display: none; margin-top: 16px; background: var(--surface1); border-radius: 12px; padding: 16px 18px; }
.detail-panel.show { display: block; }
.detail-panel dl { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; font-size: 13px; margin: 0; }
.detail-panel dt { color: var(--muted); }
.detail-panel dd { margin: 0; }

.quote-preview { display: none; margin-top: 28px; border: 1px solid var(--border); border-radius: 12px; padding: 22px 26px; background: var(--surface1); }
.quote-preview.show { display: block; }
.quote-preview h2 { font-size: 16px; margin: 0 0 2px; }
.quote-preview .meta { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.quote-total-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.quote-total-row.grand { font-size: 16px; font-weight: 600; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }

/* ---- 報價單信頭樣式（PDF 匯出區塊）---- */
.pdf-sheet { background: #fff; color: #1a1a1a; padding: 26px 28px; border-radius: 4px; }
.pdf-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #1c3d6e; padding-bottom: 12px; margin-bottom: 14px; }
.pdf-head-left { display: flex; align-items: flex-start; gap: 12px; }
.pdf-logo { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex-shrink: 0; margin-top: 2px; }
.pdf-head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pdf-logo-badge { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.pdf-company { font-size: 17px; font-weight: 700; color: #1c3d6e; margin: 0; }
.pdf-company-en { font-size: 11px; color: #666; margin: 2px 0 6px; }
.pdf-addr { font-size: 11.5px; color: #444; margin: 1px 0; }
.pdf-head-right h2 { font-size: 20px; color: #1c3d6e; margin: 0; text-align: right; }
.pdf-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: #f3f5f8; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }
.pdf-meta div { display: flex; flex-direction: column; font-size: 11px; color: #666; }
.pdf-meta b { font-size: 12.5px; color: #1a1a1a; margin-top: 2px; }
.pdf-two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 16px; }
.pdf-box { border: 1px solid #dde2e8; border-radius: 6px; padding: 10px 14px; }
.pdf-box-title { font-size: 12px; font-weight: 700; color: #1c3d6e; margin: 0 0 6px; background: #eef2f7; margin: -10px -14px 8px; padding: 6px 14px; border-radius: 6px 6px 0 0; }
.pdf-kv { width: 100%; border-collapse: collapse; font-size: 12px; }
.pdf-kv td { padding: 3px 0; vertical-align: top; }
.pdf-kv td:first-child { color: #666; width: 70px; }
.pdf-kv td:last-child { color: #1a1a1a; }
.pdf-pay { font-size: 12px; line-height: 1.7; margin: 0; color: #1a1a1a; }
.pdf-items { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 4px; }
.pdf-items th { background: #1c3d6e; color: #fff; padding: 8px 10px; text-align: left; font-weight: 600; }
.pdf-items td { padding: 7px 10px; border-bottom: 1px solid #e5e8ec; }
.pdf-totals { max-width: 320px; margin-left: auto; }
.pdf-totals .quote-total-row { color: #1a1a1a; }
.pdf-totals .quote-total-row.grand { border-top: 1px solid #1c3d6e; color: #1c3d6e; }
.pdf-notes { margin-top: 18px; border: 1px solid #dde2e8; border-radius: 6px; padding: 12px 16px; }
.pdf-notes .pdf-box-title { margin: -12px -16px 8px; padding: 6px 16px; }
.pdf-notes ol { margin: 0; padding-left: 18px; font-size: 11px; line-height: 1.75; color: #333; }
.pdf-notes li { margin-bottom: 2px; }
.pdf-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 22px; }
.pdf-sign-label { font-size: 12px; color: #444; margin: 0 0 6px; }
.pdf-sign-box { border: 1px solid #c7cdd6; border-radius: 6px; height: 70px; }
/* PDF 匯出時避免內容在分頁處被硬生生截斷 */
.pdf-box, .pdf-notes, .pdf-sign, .pdf-items tr, .pdf-head, .pdf-meta { page-break-inside: avoid; break-inside: avoid; }
/* PDF 한 장에 들어가도록 여백·서명란을 조였다. 서명란만 2쪽으로 넘어가던 문제 대응. */
.pdf-sheet { padding: 20px 24px; }
.pdf-notes { margin-top: 12px; padding: 10px 14px; }
.pdf-notes ol { line-height: 1.6; }
.pdf-sign { gap: 16px; margin-top: 14px; }
.pdf-sign-box { height: 52px; }

.center-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 40px; }
.landing-card { max-width: 640px; width: 100%; text-align: center; }
.landing-card h1 { font-size: 24px; margin: 0 0 8px; }
.landing-card p { color: var(--muted); font-size: 14px; margin: 0 0 32px; }
.role-choice { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.role-choice a { display: block; padding: 24px 18px; border: 1px solid var(--border); border-radius: 14px; text-decoration: none; color: var(--text); }
.role-choice a:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.04); }
.role-choice h3 { font-size: 14.5px; margin: 0 0 4px; }
.role-choice p { font-size: 12px; color: var(--hint); margin: 0; }

.checklist { font-size: 13px; color: var(--muted); line-height: 1.9; }

.file-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.file-list li { padding: 7px 0; border-bottom: 1px solid var(--border); color: var(--muted); }
.file-list li:last-child { border-bottom: none; }
.file-list a { color: var(--accent-text); text-decoration: none; display: flex; align-items: center; gap: 6px; }
.file-list a:hover { text-decoration: underline; }
.file-list a::before { content: "↗"; font-size: 11px; color: var(--hint); flex-shrink: 0; }
.file-list li.more-link a { color: var(--hint); font-style: italic; }
.file-list li.more-link a::before { content: "＋"; }
.resource-card h3 { font-size: 13.5px; }
.resource-card.empty { border: 1px dashed var(--border-strong); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--hint); min-height: 140px; }
.resource-card.empty h3 { color: var(--hint); margin-bottom: 6px; }

.approval-readonly { background: rgba(255, 255, 255, 0.03); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 14px 16px; font-size: 12.5px; color: var(--hint); }
.approval-readonly b { color: var(--muted); }

/* ---- SPA-only additions ---- */
.spa-sidebar-hidden { display: none !important; }
