:root {
  --primary-color: #1a237e; /* 深藍色 */
  --primary-light: #534bae;
  --primary-dark: #000051;
  --secondary-color: #ffb300; /* 琥珀金點綴 */
  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --text-main: #2c3e50;
  --text-muted: #7f8c8d;
  --border-radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family:
    'Segoe UI', 'Roboto', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-size: 18px;
  line-height: 1.55;
  margin: 0;
  padding: 40px 20px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 40px;
}

h1 {
  color: var(--primary-dark);
  font-size: 2.2em;
  letter-spacing: 1px;
  margin-bottom: 10px;
  position: relative;
  display: inline-block;
}

h1::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: var(--secondary-color);
  border-radius: 2px;
}

.header-sub {
  color: var(--text-muted);
  margin-top: 15px;
}

.card {
  background: var(--card-bg);
  padding: 30px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 25px;
  border: 1px solid rgba(0, 0, 0, 0.03);
  transition: var(--transition);
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.08);
}
button:active {
  transform: translateY(0) scale(0.98);
}

.section-title {
  font-size: 1.3em;
  color: var(--primary-color);
  margin-bottom: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  border-left: 6px solid var(--secondary-color);
  padding-left: 15px;
}

/* 計算時間戳（嵌在 section-title 內） */
.calc-timestamp {
  margin-left: auto;
  font-size: 0.7em;
  font-weight: 500;
  color: var(--text-muted);
  border-left: none;
  padding-left: 0;
  border: 1px solid var(--border-color, #e0e6ed);
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg-color);
}
.calc-timestamp.stale {
  color: #c62828;
  border-color: #ef9a9a;
  background: #ffebee;
}
@keyframes staleBlink {
  0%,
  100% {
    background-color: #ffebee;
  }
  50% {
    background-color: #fff3e0;
  }
}
.calc-timestamp.stale {
  animation: staleBlink 1.6s ease-in-out infinite;
}

/* Stale banner（橘色全寬警告） */
.stale-banner {
  margin: 0 0 16px 0;
  padding: 12px 16px;
  background: #fff3e0;
  color: #c62828;
  border: 2px solid #ffb300;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.3px;
  animation: staleBlink 1.6s ease-in-out infinite;
}

/* 計算按鈕 stale 狀態 — 橘色邊框閃爍 */
@keyframes btnStaleBlink {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.6);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.15);
  }
}
.btn-calc.btn-stale {
  animation: btnStaleBlink 1.6s ease-in-out infinite;
  border: 2px solid #ffb300;
}

/* 計算按鈕 loading spinner */
.btn-calc.loading {
  cursor: wait;
  opacity: 0.85;
}
.btn-calc .spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 可折疊區塊 */
.card.collapsible .section-title {
  cursor: pointer;
  user-select: none;
  justify-content: space-between;
}
.card.collapsible .section-title::after {
  content: '▼';
  font-size: 0.7em;
  color: var(--text-muted);
  transition: transform 0.3s ease;
  margin-left: 8px;
}
.card.collapsible.collapsed .section-title::after {
  transform: rotate(-90deg);
}
.card.collapsible .card-body {
  overflow: hidden;
  transition:
    max-height 0.35s ease,
    opacity 0.25s ease,
    margin-top 0.25s ease;
  max-height: 5000px;
  opacity: 1;
}
.card.collapsible.collapsed .card-body {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}
.card.collapsible.collapsed {
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  column-gap: 32px;
  row-gap: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

label {
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 1em;
  color: var(--text-main);
}

input:not([type='checkbox']),
select {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #e0e6ed;
  border-radius: var(--border-radius);
  font-size: 1em;
  transition: var(--transition);
  background-color: #fcfdfe;
}

input[type='checkbox'] {
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0 8px 0 0;
  border: none;
  background: none;
  cursor: pointer;
  vertical-align: middle;
  -webkit-appearance: checkbox;
  appearance: checkbox;
}

.form-group-checkbox {
  flex-direction: row !important;
  align-items: center;
  margin-top: auto;
  padding-bottom: 12px;
}
.form-group-checkbox label {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--text-main);
}

.form-group-checkbox-guarantor {
  display: flex;
  flex-direction: column;
}
.form-group-checkbox-guarantor label.g-unknown-label {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}

.input-preview {
  display: block;
  margin-top: 5px;
  font-size: 0.85em;
  font-weight: 700;
  color: var(--primary-color);
  min-height: 1.2em;
  letter-spacing: 0.5px;
}

.error-msg {
  display: none;
  margin-top: 6px;
  font-size: 0.85em;
  font-weight: 600;
  color: #c62828;
  line-height: 1.4;
}
.error-msg::before {
  content: '⚠ ';
}
input:not([type='checkbox']).has-error,
select.has-error {
  border-color: #c62828;
  background-color: #ffebee;
}
input:not([type='checkbox']).has-error:focus,
select.has-error:focus {
  box-shadow: 0 0 0 4px rgba(198, 40, 40, 0.15);
}

input:not([type='checkbox']):focus,
select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(26, 35, 126, 0.1);
  background-color: #fff;
}

.highlight-input {
  border-color: #ffcc80;
  background-color: #fffde7;
}

.btn-group {
  display: flex;
  gap: 20px;
  margin-top: 25px;
}

button {
  flex: 1;
  padding: 18px;
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1.05em;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-calc {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
}
.btn-calc:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(26, 35, 126, 0.25);
}

.btn-print {
  background: linear-gradient(135deg, #2e7d32, #43a047);
  display: none;
}

/* 清除草稿 — 無底色的次要按鈕 */
.btn-clear-draft {
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
  font-size: 0.9em;
  padding: 8px 16px;
  flex: initial;
  min-width: auto;
  width: auto;
  display: inline-block;
}
.btn-print:hover {
  background: linear-gradient(135deg, #1b5e20, #2e7d32);
  transform: translateY(-2px);
}

/* 按鈕變體 */
.btn-primary {
  background: var(--primary-color);
  color: white;
  padding: 10px 20px;
  font-size: 0.95em;
  flex: initial;
}
.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
  border: 1px solid #cbd5e1;
  padding: 10px 20px;
  font-size: 0.95em;
  flex: initial;
  box-shadow: none;
}
.btn-secondary:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

/* 結果卡片優化 */
.result-card {
  margin-top: 35px;
  padding: 35px;
  background: linear-gradient(to bottom right, #ffffff, #f8faff);
  border: 1px solid #d1d9e6;
  border-radius: var(--border-radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  display: none;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-dashboard {
  display: grid;
  grid-template-columns: 240px 1fr 1fr;
  gap: 20px;
  margin-bottom: 25px;
}

/* SVG 圓形 Gauge */
.score-gauge {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #edf2f7;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.score-gauge svg {
  display: block;
}
.gauge-score-text {
  font-size: 2.2em;
  font-weight: 800;
  fill: var(--primary-dark);
}
.gauge-score-suffix {
  font-size: 0.5em;
  fill: var(--text-muted);
}
.gauge-track {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 12;
}
.gauge-fill {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  transition:
    stroke-dashoffset 1.2s cubic-bezier(0.17, 0.67, 0.83, 0.67),
    stroke 0.4s ease;
  transform: rotate(-90deg);
  transform-origin: center;
}
.gauge-label {
  margin-top: 6px;
  font-size: 0.9em;
  color: var(--text-muted);
  font-weight: 600;
}

.result-stat {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  border: 1px solid #edf2f7;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.result-stat-label {
  font-size: 0.95em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

.result-stat-value {
  font-size: 1.8em;
  font-weight: 800;
  color: var(--primary-dark);
}

.result-value-highlight {
  color: var(--secondary-color);
  text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.05);
}

.stat-suffix {
  font-size: 0.6em;
  color: var(--text-muted);
}

/* 等級卡片配色（grade-A~E 由 renderDashboard 切換；深色模式於下方覆寫） */
.result-stat.grade-A {
  background: #e8f5e9;
  border-color: #c8e6c9;
}
.result-stat.grade-B {
  background: #e0f2f1;
  border-color: #b2dfdb;
}
.result-stat.grade-C {
  background: #fff3e0;
  border-color: #ffe0b2;
}
.result-stat.grade-D {
  background: #fbe9e7;
  border-color: #ffccbc;
}
.result-stat.grade-E {
  background: #ffebee;
  border-color: #ffcdd2;
}
.result-stat.grade-A .result-stat-value {
  color: #2e7d32;
}
.result-stat.grade-B .result-stat-value {
  color: #00695c;
}
.result-stat.grade-C .result-stat-value {
  color: #e65100;
}
.result-stat.grade-D .result-stat-value {
  color: #bf360c;
}
.result-stat.grade-E .result-stat-value {
  color: #c62828;
}

/* 評分組成（5P 分項橫條） */
.score-breakdown {
  margin: 5px 0 25px;
  background: #fff;
  border: 1px solid #edf2f7;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.score-breakdown-title {
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 14px;
}
.breakdown-row {
  display: grid;
  grid-template-columns: 110px 1fr 76px;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.breakdown-row:last-child {
  margin-bottom: 0;
}
.breakdown-label {
  font-size: 0.9em;
  font-weight: 600;
  color: var(--text-main);
}
.breakdown-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
}
.breakdown-bar-empty {
  background: transparent;
}
.breakdown-fill {
  height: 100%;
  width: 0;
  border-radius: 5px;
  background: linear-gradient(
    90deg,
    var(--primary-color),
    var(--primary-light)
  );
  transition: width 0.8s ease;
}
.breakdown-score {
  font-size: 0.9em;
  font-weight: 700;
  color: var(--primary-dark);
  text-align: right;
  white-space: nowrap;
}
.breakdown-score.neg {
  color: #c62828;
}

/* 儀表板進度條 */
.gauge-container {
  margin: 30px 0;
  background: #f1f4f8;
  padding: 20px;
  border-radius: 15px;
}

.gauge-heading {
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 5px;
}
.gauge-sub {
  font-size: 0.9em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.dti-footer {
  font-size: 0.9em;
  color: var(--text-muted);
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dti-value {
  color: var(--primary-color);
}

.progress-container {
  width: 100%;
  height: 14px;
  background-color: #e2e8f0;
  border-radius: 7px;
  margin: 15px 0;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 1s cubic-bezier(0.17, 0.67, 0.83, 0.67);
  background: linear-gradient(90deg, #4caf50, #8bc34a);
}

.progress-limit-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: #d32f2f;
  z-index: 10;
  box-shadow: 0 0 5px rgba(211, 47, 47, 0.5);
}

/* 刻度依真實百分比定位（取代舊 space-between 平均分布造成的位置失真） */
.progress-scale {
  position: relative;
  height: 1.4em;
  font-size: 0.85em;
  color: var(--text-muted);
  margin-top: 5px;
}
.progress-scale span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.progress-scale span:first-child {
  transform: none;
} /* 0% 靠左對齊 */
.progress-scale span:last-child {
  transform: translateX(-100%);
} /* 100% 靠右不出界 */
.progress-scale .scale-veto {
  color: #c62828;
  font-weight: 700;
}

/* 70% 否決線（固定）— 與本級上限 marker（實線）以虛線區分 */
.progress-veto-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 3px dashed #c62828;
  z-index: 9;
  opacity: 0.85;
}

.status-msg {
  margin-top: 25px;
  padding: 22px;
  border-radius: var(--border-radius);
  font-weight: 700;
  text-align: center;
  font-size: 1.2em;
  letter-spacing: 0.5px;
}

.status-pass {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}
.status-warn {
  background-color: #fff3e0;
  color: #e65100;
  border: 1px solid #ffe0b2;
}
.status-fail {
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ffcdd2;
}

/* 提示訊息樣式（取代 inline cssText） */
.hint {
  display: block;
  margin-top: 15px;
  padding: 14px;
  border-radius: var(--border-radius);
  font-size: 0.9em;
  font-weight: 600;
}
.hint-success {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}
.hint-warn {
  background-color: #fff3e0;
  color: #e65100;
  border: 1px solid #ffe0b2;
}
.hint-error {
  background-color: #ffebee;
  color: #c62828;
  border: 2px solid #ef9a9a;
}
.hint-info {
  background-color: #e8eaf6;
  color: #283593;
  border: 1px solid #c5cae9;
}

/* 預核章狀態 */
.system-seal-pass {
  border-color: #2e7d32 !important;
  color: #2e7d32 !important;
}
.system-seal-fail {
  border-color: #d32f2f !important;
  color: #d32f2f !important;
}
.system-seal-warn {
  border-color: #e65100 !important;
  color: #e65100 !important;
}

/* 否決清單 */
.veto-list {
  text-align: left;
  margin: 8px 0 0 0;
  padding-left: 20px;
}
.veto-list li {
  margin-bottom: 4px;
}

/* 進度條 marker E 級隱藏 */
.progress-limit-marker.hidden {
  display: none;
}

/* 動態保證人列 */
#guarantorContainer {
  margin-top: 15px;
}
#guarantorList {
  margin-top: 5px;
}
.guarantor-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e8ecf1;
  margin-bottom: 10px;
  align-items: start;
}
.guarantor-row .form-group {
  margin-bottom: 0;
}
.guarantor-row input:not([type='checkbox']) {
  padding: 10px 14px;
}

/* 擔保品鎖定提示 */
#collateralLockMsg {
  user-select: none;
}

/* 橘色警示框（yearsHint / collateralLockMsg / minorWarn 共用；原 inline style 收斂） */
.notice-warn {
  display: none;
  margin-top: 8px;
  padding: 10px;
  background-color: #fff3e0;
  color: #e65100;
  border: 1px solid #ffe0b2;
  border-radius: 8px;
  font-size: 0.85em;
  font-weight: 600;
}
.notice-warn-strong {
  margin-top: 15px;
  padding: 14px;
  border-radius: var(--border-radius);
  font-size: 0.95em;
  border: 2px solid #ffb300;
}

/* DTI 溢出徽章 */
.overflow-badge {
  display: none;
  margin-left: 8px;
  padding: 2px 8px;
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 700;
}

/* 專業小叮嚀框 */
.tip-box {
  margin-top: 20px;
  padding: 15px;
  background-color: #fcfcfc;
  border: 1px dashed #d1d9e6;
  border-radius: 8px;
  font-size: 0.85em;
  color: var(--text-muted);
}
.tip-box-suggested {
  border: 1px solid var(--primary-color);
  background: linear-gradient(135deg, #e8eaf6, #c5cae9);
  color: var(--primary-dark);
}
.tip-box-consolidation {
  border: 1px solid #ff9800;
  background: linear-gradient(135deg, #fff8e1, #fff3e0);
  color: #e65100;
}

/* Tooltip 提示氣泡 */
.tooltip-icon {
  position: relative;
  display: inline-block;
  margin-left: 6px;
  color: var(--text-muted);
  cursor: help;
  font-style: normal;
  font-weight: normal;
  font-size: 0.95em;
  user-select: none;
}
.tooltip-text {
  visibility: hidden;
  width: 240px;
  background-color: #334155;
  color: #fff;
  text-align: left;
  border-radius: 8px;
  padding: 10px 14px;
  position: absolute;
  z-index: 100;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  font-size: 0.8em;
  line-height: 1.45;
  font-weight: normal;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  white-space: normal;
}
/* Tooltip 箭頭 */
.tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #334155 transparent transparent transparent;
}
.tooltip-icon:hover .tooltip-text,
.tooltip-icon:focus .tooltip-text {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* 列印專屬樣式 */
.print-area {
  display: none;
}

/* 響應式 — 行動裝置 */
@media (max-width: 768px) {
  body {
    font-size: 16px;
    padding: 20px 12px;
    line-height: 1.55;
  }
  .card {
    padding: 20px 16px;
    margin-bottom: 16px;
  }
  h1 {
    font-size: 1.6em;
  }
  .section-title {
    font-size: 1.15em;
  }
  .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .guarantor-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }
  .guarantor-row .form-group {
    display: flex;
    flex-direction: column;
  }
  .btn-group {
    flex-direction: column;
    gap: 12px;
  }
  button {
    padding: 16px;
    font-size: 1.05em;
  }
  .result-card {
    padding: 22px 16px;
  }
  .result-dashboard {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }
  .score-gauge {
    grid-column: span 2;
    grid-row: auto;
  }
  .g-unknown-placeholder {
    display: none !important;
  }
  .result-stat-value {
    font-size: 1.4em;
  }
  .score-breakdown {
    padding: 14px;
  }
  .breakdown-row {
    grid-template-columns: 86px 1fr 64px;
    gap: 8px;
  }
  .gauge-container {
    padding: 14px;
  }
  .progress-scale {
    font-size: 0.75em;
  }
  .status-msg {
    font-size: 1.05em;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .result-dashboard {
    grid-template-columns: 1fr;
  }
  .header {
    margin-bottom: 24px;
  }
  h1 {
    font-size: 1.4em;
  }
}

/* 深色模式 — 自動跟隨系統 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --primary-color: #818cf8;
    --primary-light: #a5b4fc;
    --primary-dark: #c7d2fe;
    --secondary-color: #fbbf24;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
  }
  body {
    background-color: var(--bg-color);
    color: var(--text-main);
  }
  .card {
    background: var(--card-bg);
    border-color: rgba(255, 255, 255, 0.06);
  }
  input:not([type='checkbox']),
  select {
    background-color: #0f172a;
    color: var(--text-main);
    border-color: #334155;
  }
  input:not([type='checkbox']):focus,
  select:focus {
    background-color: #0f172a;
  }
  .highlight-input {
    background-color: #1e293b;
    border-color: #fbbf24;
  }
  .result-card {
    background: linear-gradient(to bottom right, #1e293b, #0f172a);
    border-color: #334155;
  }
  .result-stat {
    background: #0f172a;
    border-color: #334155;
  }
  .gauge-container {
    background: #0f172a;
  }
  .progress-container {
    background-color: #334155;
  }
  .guarantor-row {
    background: #0f172a;
    border-color: #334155;
  }
  .score-gauge {
    background: #0f172a;
    border-color: #334155;
  }
  .gauge-track {
    stroke: #334155;
  }
  .score-breakdown {
    background: #0f172a;
    border-color: #334155;
  }
  .breakdown-bar {
    background: #334155;
  }
  .breakdown-bar-empty {
    background: transparent;
  }
  .hint-info {
    background-color: #1e293b;
    color: #a5b4fc;
    border-color: #334155;
  }
  .hint-success {
    background-color: #14331f;
    color: #81c784;
    border-color: #1b5e20;
  }
  .hint-warn {
    background-color: #3a2a12;
    color: #ffb74d;
    border-color: #92600a;
  }
  .hint-error {
    background-color: #3f1d1d;
    color: #f87171;
    border-color: #7f1d1d;
  }
  .status-pass {
    background-color: #14331f;
    color: #81c784;
    border-color: #1b5e20;
  }
  .status-warn {
    background-color: #3a2a12;
    color: #ffb74d;
    border-color: #92600a;
  }
  .status-fail {
    background-color: #3f1d1d;
    color: #f87171;
    border-color: #7f1d1d;
  }
  .error-msg {
    color: #f87171;
  }
  input:not([type='checkbox']).has-error,
  select.has-error {
    background-color: #3f1d1d;
    border-color: #ef5350;
  }
  .breakdown-score.neg {
    color: #f87171;
  }
  .result-stat.grade-A {
    background: #14331f;
    border-color: #1b5e20;
  }
  .result-stat.grade-B {
    background: #0e2a28;
    border-color: #00695c;
  }
  .result-stat.grade-C {
    background: #3a2a12;
    border-color: #92600a;
  }
  .result-stat.grade-D {
    background: #3a1c10;
    border-color: #bf360c;
  }
  .result-stat.grade-E {
    background: #3f1d1d;
    border-color: #7f1d1d;
  }
  .result-stat.grade-A .result-stat-value {
    color: #81c784;
  }
  .result-stat.grade-B .result-stat-value {
    color: #4db6ac;
  }
  .result-stat.grade-C .result-stat-value {
    color: #ffb74d;
  }
  .result-stat.grade-D .result-stat-value {
    color: #ff8a65;
  }
  .result-stat.grade-E .result-stat-value {
    color: #f87171;
  }
  .input-preview {
    color: #a5b4fc;
  }
  .notice-warn {
    background-color: #3a2a12;
    color: #fbbf24;
    border-color: #92600a;
  }
  .notice-warn-strong {
    border-color: #b45309;
  }
  .overflow-badge {
    background-color: #3f1d1d;
    color: #f87171;
    border-color: #7f1d1d;
  }
  .tip-box {
    background-color: #1e293b;
    border-color: #334155;
  }
  .tip-box-suggested {
    border-color: #3f51b5;
    background: linear-gradient(135deg, #1e293b, #1a237e);
    color: #c7d2fe;
  }
  .tip-box-consolidation {
    border-color: #ff9800;
    background: linear-gradient(135deg, #2a1f10, #3e2723);
    color: #ffe0b2;
  }
  .stale-banner {
    background-color: #3a2a12;
    color: #fbbf24;
    border-color: #b45309;
  }
  .calc-timestamp {
    background-color: #1e293b;
    border-color: #334155;
  }
  .calc-timestamp.stale {
    background-color: #3f1d1d;
    color: #f87171;
    border-color: #7f1d1d;
  }
  .btn-primary {
    background: var(--primary-color);
    color: #fff;
  }
  .btn-primary:hover {
    background: var(--primary-light);
  }
  .btn-secondary {
    background: #334155;
    color: var(--text-main);
    border-color: #475569;
  }
  .btn-secondary:hover {
    background: #475569;
  }
}

/* 折疊面板焦點樣式 (鍵盤無障礙) */
.section-title:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

@media print {
  body {
    background-color: #fff;
    padding: 0;
    color: #000;
  }
  .container {
    box-shadow: none;
    padding: 0;
    max-width: 100%;
  }
  .no-print {
    display: none !important;
  }
  .print-area {
    display: block;
    padding: 20px;
  }

  .print-header {
    text-align: center;
    border-bottom: 2px solid #1a237e;
    padding-bottom: 15px;
    margin-bottom: 30px;
  }
  .print-title {
    font-size: 28px;
    font-weight: bold;
    color: #1a237e;
    margin-bottom: 5px;
  }
  .print-subtitle {
    font-size: 14px;
    color: #555;
  }

  .print-section {
    margin-bottom: 25px;
  }
  .print-section-title {
    font-weight: bold;
    font-size: 18px;
    border-left: 5px solid #1a237e;
    padding-left: 10px;
    margin-bottom: 15px;
  }

  /* 專業報表表格 */
  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    table-layout: fixed;
  }
  .print-table th,
  .print-table td {
    border: 1px solid #000;
    padding: 10px;
    text-align: left;
    font-size: 14px;
    word-wrap: break-word;
  }
  .print-table th {
    background-color: #f2f2f2 !important;
    width: 35%;
    font-weight: bold;
    -webkit-print-color-adjust: exact;
  }

  .print-result-box {
    border: 2px solid #1a237e;
    padding: 20px;
    margin-top: 20px;
    background: #f8faff !important;
    -webkit-print-color-adjust: exact;
    position: relative;
  }
  .print-result-title {
    font-size: 20px;
    font-weight: bold;
    color: #1a237e;
    margin-bottom: 10px;
  }

  .disclaimer {
    margin-top: 30px;
    font-size: 12px;
    color: #666;
    border-top: 1px solid #ccc;
    padding-top: 10px;
    line-height: 1.5;
  }

  .system-seal {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 100px;
    height: 100px;
    border: 3px double #d32f2f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    text-align: center;
    color: #d32f2f;
    font-weight: bold;
    font-size: 14px;
    transform: rotate(-15deg);
    opacity: 0.9;
    padding: 5px;
  }
  .system-seal-pass {
    border-color: #2e7d32 !important;
    color: #2e7d32 !important;
  }
  .system-seal-fail {
    border-color: #d32f2f !important;
    color: #d32f2f !important;
  }
  .system-seal-warn {
    border-color: #e65100 !important;
    color: #e65100 !important;
  }
}

/* Modal 樣式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 0;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  animation: modalFadeIn 0.2s ease;
}
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #edf2f7;
}
.modal-header h3 {
  margin: 0;
  font-size: 1.1em;
  color: var(--primary-dark);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 8px;
  line-height: 1;
}
.modal-close:hover {
  color: var(--text-main);
}
.modal-body {
  padding: 20px;
}
.btn-debt-estimator {
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  margin-left: 8px;
}
.btn-debt-estimator:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}
#debtEstimatedMonthly {
  font-weight: 800;
}

/* 雷達圖容器 */
.radar-chart-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}
.radar-legend {
  font-size: 0.85em;
  color: var(--text-muted);
  text-align: center;
}

/* 決策分析卡 */
.insight-card {
  margin-top: 20px;
  padding: 20px;
}
.insight-header {
  font-size: 1.15em;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.insight-subtitle {
  font-size: 0.75em;
  font-weight: 400;
  color: var(--text-muted);
}
.insight-section {
  margin-bottom: 16px;
}
.insight-section:last-child {
  margin-bottom: 0;
}

/* 強弱項 */
.sw-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.95em;
}
.sw-strength {
  background: #e8f5e9;
  color: #2e7d32;
}
.sw-weakness {
  background: #fff3e0;
  color: #e65100;
}
.sw-badge {
  font-weight: 700;
  font-size: 0.85em;
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 64px;
  text-align: center;
}
.sw-strength .sw-badge {
  background: #c8e6c9;
}
.sw-weakness .sw-badge {
  background: #ffe0b2;
}

/* 建議條 */
.suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #edf2f7;
  font-size: 0.93em;
  line-height: 1.5;
}
.suggestion-item:last-child {
  border-bottom: none;
}
.suggestion-icon {
  flex-shrink: 0;
  font-size: 1em;
}
.suggestion-text {
  flex: 1;
  color: var(--text-main);
}
.suggestion-gain {
  flex-shrink: 0;
  font-size: 0.85em;
  font-weight: 700;
  color: #d35400;
  background: #fff3e0;
  padding: 1px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.suggestion-disclaimer {
  font-size: 0.78em;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
  .sw-strength {
    background: #14331f;
    color: #81c784;
  }
  .sw-weakness {
    background: #3a2a12;
    color: #ffb74d;
  }
  .sw-strength .sw-badge {
    background: #1b5e20;
  }
  .sw-weakness .sw-badge {
    background: #92600a;
  }
  .suggestion-item {
    border-color: #334155;
  }
  .suggestion-gain {
    background: #3a2a12;
    color: #ffb74d;
  }
}

/* 列印隱藏 */
@media print {
  .radar-chart-container,
  .insight-card {
    display: none !important;
  }
}

/* 響應式 */
@media (max-width: 768px) {
  .radar-chart-container {
    flex-direction: column;
  }
  .sw-row {
    font-size: 0.88em;
    padding: 6px 10px;
  }
  .suggestion-item {
    font-size: 0.88em;
  }
}
