/* ============================================================
   退休財務預測模型 — Design System
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg-base: #080b12;
  --bg-primary: #0d1117;
  --bg-secondary: #151b28;
  --bg-card: #1a2234;
  --bg-card-alt: #1e2740;
  --bg-input: #0f1520;
  --bg-hover: #242e42;

  --border: #2a3550;
  --border-light: #354160;
  --border-active: #4a5a80;

  --text-primary: #e6eaf0;
  --text-secondary: #9ca8bc;
  --text-muted: #5e6a80;

  --gold: #f0b429;
  --gold-dim: rgba(240, 180, 41, 0.12);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.1);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.12);
  --purple: #a78bfa;

  --font-cn: 'Noto Sans TC', 'PingFang TC', sans-serif;
  --font-num: 'Inter', 'SF Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.5);
  --shadow-glow-green: 0 0 20px rgba(52,211,153,.15);
  --shadow-glow-red: 0 0 20px rgba(248,113,113,.15);
  --shadow-glow-gold: 0 0 20px rgba(240,180,41,.1);

  --transition: 0.25s cubic-bezier(.4,0,.2,1);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-cn);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------- App Layout ---------- */
.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, var(--bg-base) 0%, var(--bg-base) 85%, transparent 100%);
  padding: 20px 0 0;
  backdrop-filter: blur(12px);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 32px;
  filter: drop-shadow(0 0 8px rgba(96,165,250,.3));
}

.logo-area h1 {
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, #e6eaf0 0%, #60a5fa 50%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: .5px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.version-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.25);
  color: #60a5fa;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.subtitle {
  font-size: .8rem;
  color: var(--text-muted);
  letter-spacing: .3px;
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--green-dim);
  border: 1px solid rgba(52,211,153,.2);
  font-size: .78rem;
  color: var(--green);
}

.badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52,211,153,.4); }
  50% { opacity: .7; box-shadow: 0 0 0 6px rgba(52,211,153,0); }
}

/* ---------- Tab Navigation ---------- */
.tab-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-cn);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(96,165,250,.15), rgba(167,139,250,.1));
  color: #fff;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.05);
  border: 1px solid rgba(96,165,250,.25);
}

.tab-icon { font-size: 1rem; }

/* ---------- Tab Content ---------- */
.app-main { padding-top: 24px; }

.tab-content {
  display: none;
  animation: fadeIn .3s ease;
}

.tab-content.active { display: block; }

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

/* ---------- Parameters Section ---------- */
#params-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
}

.param-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}

.param-section:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

.param-section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.param-section-note {
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(42,53,80,.4);
  gap: 12px;
}

.param-row:last-child { border-bottom: none; }

.param-label {
  font-size: .88rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
}

.param-input {
  width: 120px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--gold-dim);
  color: var(--gold);
  font-family: var(--font-num);
  font-size: .92rem;
  font-weight: 600;
  text-align: right;
  outline: none;
  transition: var(--transition);
}

.param-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240,180,41,.15);
}

.param-input:hover { border-color: var(--border-light); }

.param-input.computed {
  background: transparent;
  color: var(--text-primary);
  border-style: dashed;
  cursor: default;
  pointer-events: none;
}

.param-unit {
  font-size: .78rem;
  color: var(--text-muted);
  width: 24px;
  text-align: left;
}

/* ---------- Table Section ---------- */
.table-header-area {
  margin-bottom: 16px;
}

.table-header-area h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.table-subtitle {
  font-size: .82rem;
  color: var(--text-secondary);
}

.table-note {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
}

.table-wrapper::-webkit-scrollbar { height: 8px; }
.table-wrapper::-webkit-scrollbar-track { background: var(--bg-secondary); border-radius: 4px; }
.table-wrapper::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: var(--border-active); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 12px;
  text-align: center;
  border-bottom: 2px solid var(--border);
  letter-spacing: .2px;
}

/* Column group headers */
thead tr.col-group th {
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: .75rem;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 1px;
}

th.group-a { color: var(--green); background: rgba(52,211,153,.04) !important; }
th.group-b { color: var(--amber); background: rgba(251,191,36,.04) !important; }
th.group-basic { color: var(--blue); }
th.group-asset { color: var(--purple); background: rgba(167,139,250,.04) !important; }

tbody td {
  padding: 8px 12px;
  text-align: right;
  font-family: var(--font-num);
  font-size: .82rem;
  border-bottom: 1px solid rgba(42,53,80,.3);
  color: var(--text-primary);
  transition: background .15s;
}

tbody tr:hover td { background: var(--bg-hover); }

tbody td:first-child,
tbody td:nth-child(2) {
  text-align: center;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-num);
  position: sticky;
  background: var(--bg-card);
  z-index: 5;
}
tbody td:first-child { left: 0; }
tbody td:nth-child(2) { left: 52px; }
tbody tr:hover td:first-child,
tbody tr:hover td:nth-child(2) { background: var(--bg-hover); }

thead th:first-child,
thead th:nth-child(2) {
  position: sticky;
  z-index: 15;
}
thead th:first-child { left: 0; }

/* Separator borders between column groups */
td.sep-left, th.sep-left { border-left: 2px solid var(--border-light) !important; }

/* Value coloring */
.val-neg { color: var(--red); }
.val-pos { color: var(--green); }
.val-zero { color: var(--text-muted); }
.val-highlight { color: var(--gold); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: .75rem;
  font-weight: 600;
  font-family: var(--font-cn);
  text-align: center;
}

.badge-safe { background: var(--green-dim); color: var(--green); }
.badge-pledge { background: var(--blue-dim); color: var(--blue); }
.badge-warn { background: var(--amber-dim); color: var(--amber); }
.badge-danger { background: var(--red-dim); color: var(--red); }
.badge-na { color: var(--text-muted); }

/* One-time income highlight row */
tr.has-onetime td { background: rgba(96,165,250,.03); }
tr.has-onetime:hover td { background: var(--bg-hover); }

/* ---------- Dashboard ---------- */
#dashboard-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dash-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: var(--transition);
}

.dash-section:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-lg);
}

.dash-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-title .icon { font-size: 1.3rem; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.dash-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  transition: var(--transition);
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-light);
}

.dash-card .value {
  font-family: var(--font-num);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -.5px;
}

.dash-card .label {
  font-size: .78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.dash-card.positive .value { color: var(--green); }
.dash-card.negative .value { color: var(--red); }
.dash-card.info .value { color: var(--blue); }
.dash-card.warn .value { color: var(--amber); }
.dash-card.neutral .value { color: var(--text-primary); }

.dash-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.dash-ab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}

.dash-strategy {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.dash-strategy-title {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.strategy-a .dash-strategy-title { color: var(--green); }
.strategy-b .dash-strategy-title { color: var(--amber); }

.dash-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(42,53,80,.3);
}

.dash-metric:last-child { border-bottom: none; }

.dash-metric .metric-label {
  font-size: .84rem;
  color: var(--text-secondary);
}

.dash-metric .metric-value {
  font-family: var(--font-num);
  font-size: 1rem;
  font-weight: 600;
}

.check-yes {
  color: var(--green);
}

.check-no {
  color: var(--red);
}

.conclusion-box {
  background: linear-gradient(135deg, rgba(96,165,250,.06), rgba(52,211,153,.06));
  border: 1px solid rgba(96,165,250,.15);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-top: 12px;
}

.conclusion-box .conclusion-title {
  font-weight: 700;
  color: var(--green);
  margin-bottom: 8px;
  font-size: .95rem;
}

.conclusion-box p {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .app {
    padding: 0 10px calc(40px + env(safe-area-inset-bottom));
  }

  #params-container {
    grid-template-columns: 1fr;
  }

  .tab-nav {
    padding: 6px;
    gap: 2px;
  }

  .tab-btn {
    flex-direction: column;
    padding: 8px 4px;
    gap: 4px;
    flex: 1;
  }

  .tab-btn .tab-label {
    display: block;
    font-size: 0.65rem;
    white-space: nowrap;
  }

  .tab-btn .tab-icon {
    font-size: 1.1rem;
  }

  .param-input {
    font-size: 16px; /* Prevents Safari auto-zoom on iOS */
  }

  .help-btn {
    width: 24px;
    height: 24px;
    font-size: 0.85rem;
    margin-left: 8px;
  }

  .logo-area h1 { font-size: 1.2rem; }

  .dash-ab-grid {
    grid-template-columns: 1fr;
  }

  .header-badge { display: none; }
}

/* ---------- Scrollbar Global ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ---------- Help Button ---------- */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
  border: 1px solid var(--border);
  transition: var(--transition);
  user-select: none;
  vertical-align: middle;
}

.help-btn:hover {
  background: var(--blue-dim);
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 0 8px rgba(96,165,250,0.4);
}

.param-label {
  display: flex;
  align-items: center;
}

/* ---------- Modal Dialog ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 6, 10, 0.7);
  backdrop-filter: blur(8px);
}

.modal-dialog {
  position: relative;
  width: 90%;
  max-width: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  z-index: 1001;
}

.modal.active .modal-dialog {
  transform: scale(1);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(42, 53, 80, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--blue);
}

.modal-close-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.6rem;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--red);
}

.modal-body {
  padding: 20px;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.7;
  max-height: 60vh;
  overflow-y: auto;
  white-space: pre-line;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(42, 53, 80, 0.4);
  display: flex;
  justify-content: flex-end;
  background: var(--bg-secondary);
}

.modal-btn {
  padding: 7px 18px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  background: var(--blue-dim);
  color: var(--blue);
  font-weight: 600;
  font-family: var(--font-cn);
  cursor: pointer;
  transition: var(--transition);
}

.modal-btn:hover {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 0 12px rgba(96,165,250,0.3);
}

/* ---------- Dashboard Charts ---------- */
.dash-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
}

.chart-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-wrapper {
  position: relative;
  height: 320px;
  width: 100%;
}

@media (max-width: 1200px) {
  .dash-charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dash-charts-grid {
    grid-template-columns: 1fr;
  }
  .chart-wrapper {
    height: 260px;
  }
}

/* ---------- Preset Bar ---------- */
.preset-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.preset-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  flex: 1.8;
  min-width: 320px;
}

.preset-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.preset-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.preset-desc {
  flex: 1.2;
  min-width: 280px;
  padding-left: 24px;
  border-left: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

@media (max-width: 992px) {
  .preset-desc {
    border-left: none;
    border-top: 1px dashed var(--border);
    padding-left: 0;
    padding-top: 16px;
    margin-top: 8px;
    flex: 1 1 100%;
  }
}

.preset-btn {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-family: var(--font-cn);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.preset-btn:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.preset-btn.active {
  background: linear-gradient(135deg, rgba(240, 180, 41, 0.16), rgba(251, 191, 36, 0.1));
  color: var(--gold);
  border-color: rgba(240, 180, 41, 0.5);
  box-shadow: 0 0 12px rgba(240, 180, 41, 0.15);
}

@media (max-width: 768px) {
  .preset-bar {
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .preset-buttons {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }
  .preset-btn {
    width: 100%;
    text-align: center;
  }
}

/* ---------- Footer ---------- */
.app-footer {
  margin-top: 40px;
  padding: 28px 0 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-main p {
  margin-bottom: 6px;
  line-height: 1.6;
}

.footer-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 4px auto 10px;
  opacity: 0.8;
}

.footer-links {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.footer-links a {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
  transition: var(--transition);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.footer-links a:hover {
  color: #fff;
  background: var(--blue-dim);
  text-decoration: none;
}

.footer-sep {
  color: var(--border);
  font-size: 0.7rem;
}

.app-footer a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.app-footer a:hover {
  color: var(--gold-light);
  text-decoration: underline;
}

/* ---------- Terms Modal Overrides ---------- */
.terms-dialog {
  max-width: 640px;
}

.terms-body {
  white-space: normal;
  font-size: 0.88rem;
  line-height: 1.8;
}

.terms-body h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--blue);
  margin: 0 0 8px 0;
}

.terms-body p {
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.terms-body a {
  color: var(--gold);
  text-decoration: none;
  transition: var(--transition);
}

.terms-body a:hover {
  text-decoration: underline;
  color: #f0c56e;
}

.terms-body ul {
  margin: 6px 0 8px 20px;
  padding: 0;
  list-style: none;
}

.terms-body ul li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.terms-body ul li::before {
  content: '✕';
  position: absolute;
  left: 0;
  color: var(--red);
  font-size: 0.7rem;
  font-weight: 700;
  top: 3px;
}

.terms-body strong {
  color: var(--text-primary);
}

.terms-divider {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 14px 0;
}

.terms-updated {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 8px;
  font-style: italic;
}

/* ---------- Guide Section ---------- */
.guide-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  max-width: 900px;
  margin: 0 auto 30px;
}

.guide-box h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--blue);
  margin-top: 25px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.guide-box h2:first-of-type {
  margin-top: 0;
}

.guide-box h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 18px;
  margin-bottom: 10px;
}

.guide-box p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 15px;
}

.guide-box ul, .guide-box ol {
  margin-left: 20px;
  margin-bottom: 15px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
}

.guide-box li {
  margin-bottom: 8px;
}

.guide-box strong {
  color: var(--text-primary);
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0 25px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.guide-table th, .guide-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.guide-table th {
  background: var(--bg-card-alt);
  color: var(--text-primary);
  font-weight: 600;
}

.guide-table td {
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-highlight {
  background: linear-gradient(135deg, rgba(96,165,250,.06), rgba(167,139,250,.06));
  border: 1px solid rgba(96,165,250,.15);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 20px 0;
}

.guide-highlight h4 {
  color: var(--gold);
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 600;
}

.guide-highlight p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

/* ---------- FAQ Accordion ---------- */
.faq-container {
  margin: 15px 0 25px;
}

details.faq-item {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
  transition: var(--transition);
}

details.faq-item[open] {
  border-color: var(--border-active);
}

details.faq-item summary {
  padding: 16px 20px;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  list-style: none; /* Hide default arrow */
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
}

details.faq-item summary::-webkit-details-marker {
  display: none; /* Hide default arrow for Safari */
}

details.faq-item summary:hover {
  background: var(--bg-hover);
}

details.faq-item summary::after {
  content: "＋";
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--blue);
  transition: transform 0.2s;
}

details.faq-item[open] summary::after {
  content: "－";
  color: var(--gold);
}

.faq-content {
  padding: 0 20px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.faq-content p {
  margin-top: 12px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.7;
}

.faq-content p:last-child {
  margin-bottom: 0;
}

.faq-content ul {
  margin-top: 8px;
  margin-bottom: 8px;
  margin-left: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.faq-content ul li {
  margin-bottom: 4px;
}

/* ---------- Table Insights Box ---------- */
.table-insights-box {
  background: linear-gradient(135deg, rgba(26, 34, 52, 0.6) 0%, rgba(21, 27, 40, 0.8) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px 24px;
}

.table-insights-box .insight-title {
  grid-column: 1 / -1;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
}

.insight-item {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.insight-item span.icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.insight-item strong {
  color: var(--text-primary);
}

.insight-highlight {
  color: var(--gold);
}

.insight-green {
  color: var(--green);
}

.insight-red {
  color: var(--red);
}

@media (max-width: 768px) {
  .table-insights-box {
    grid-template-columns: 1fr;
    padding: 14px 16px;
    gap: 8px;
  }
}

