:root {
  --bg: #f6f1e9;
  --panel: #fffaf2;
  --ink: #231f20;
  --muted: #6f6258;
  --line: #e6dacb;
  --red: #b3261e;
  --red-bg: #fff0ef;
  --gold: #8a5a16;
  --good: #1f7a3b;
  --bad: #a32020;
  --flat: #6b7280;
  --shadow: 0 18px 50px rgba(64, 43, 24, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Noto Sans HK", Arial, sans-serif;
  background: radial-gradient(circle at top left, #fff8ed 0, var(--bg) 42%, #efe5d8 100%);
  color: var(--ink);
  line-height: 1.55;
}

.hero {
  padding: 48px 20px 32px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(120deg, rgba(255,255,255,.78), rgba(255,248,236,.55)),
    radial-gradient(circle at 85% 25%, rgba(138,90,22,.18), transparent 26%);
}
.hero > div, .app-shell { max-width: 1180px; margin: 0 auto; }
.eyebrow { margin: 0 0 8px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 700; font-size: 12px; }
h1 { margin: 0; font-size: clamp(34px, 6vw, 64px); letter-spacing: -.04em; }
.subtitle { color: var(--muted); max-width: 760px; margin: 12px 0 0; font-size: 17px; }

.app-shell { padding: 28px 18px 56px; }
.panel, .section {
  background: rgba(255,250,242,.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
}
h2 { margin: 0 0 18px; font-size: 25px; }
h3 { margin: 18px 0 8px; font-size: 18px; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
label { display: block; font-weight: 700; color: #3f352f; }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  border-radius: 14px;
  border: 1px solid #d5c7b9;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(138,90,22,.12); }
.events-label { margin-top: 18px; }

.toggles { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: #fffdf8;
  cursor: pointer;
  transition: .2s ease;
}
.toggle input { width: auto; margin: 0; }
.toggle.active {
  color: var(--red);
  border-color: rgba(179,38,30,.55);
  background: var(--red-bg);
  box-shadow: 0 0 0 4px rgba(179,38,30,.07);
}
.toggle.active span { font-weight: 800; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: .16s ease;
}
button:hover { transform: translateY(-1px); }
.primary { color: white; background: #2d2420; }
.secondary { color: #2d2420; background: #eadfce; }
.note { color: var(--muted); font-size: 14px; }
.status { margin: 14px 0; color: var(--gold); font-weight: 800; }
.hidden { display: none; }

.warning {
  padding: 12px 14px;
  border: 1px solid rgba(179,38,30,.25);
  background: var(--red-bg);
  color: var(--red);
  border-radius: 16px;
}

.pillars {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.pillar {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 20px;
  padding: 16px;
}
.pillar h3 { margin-top: 0; color: var(--muted); }
.gz { font-size: 38px; font-weight: 900; letter-spacing: .06em; margin: 6px 0; }
.badges { display: flex; gap: 7px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #efe6d7;
  color: #56483e;
  margin: 2px 2px 2px 0;
}
.badge.good { color: var(--good); background: #edf8ef; }
.badge.bad { color: var(--bad); background: #fff0f0; }
.badge.flat { color: var(--flat); background: #f2f3f5; }
.badge.wood { background: #eaf7ed; color: #167336; }
.badge.fire { background: #fff0ed; color: #b3261e; }
.badge.earth { background: #f8edcf; color: #805515; }
.badge.metal { background: #edf0f2; color: #45515c; }
.badge.water { background: #eaf2ff; color: #1e4f91; }

.two-col { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; }
.bar { height: 14px; border-radius: 999px; background: #eadfce; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #8a5a16, #2d2420); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: #fffdf8; border-radius: 16px; overflow: hidden; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
th { background: #f1e7d8; color: #4d4037; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #fff5e5; }
.detail-box {
  margin-top: 14px;
  padding: 16px;
  border: 1px dashed #cbbca8;
  background: #fffdf8;
  border-radius: 18px;
}
select.year-select { max-width: 360px; }
.small { font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px; }
.footer { text-align: center; color: var(--muted); padding: 20px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .grid, .pillars, .two-col { grid-template-columns: 1fr; }
  .panel, .section { padding: 18px; border-radius: 18px; }
  .hero { padding-top: 34px; }
  .gz { font-size: 32px; }
}


/* v4.4 additions */
.version-pill { display:inline-flex; align-items:center; gap:6px; padding:5px 10px; border-radius:999px; background:#2d2420; color:#fff; font-size:12px; font-weight:900; }
.analysis-grid { display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap:14px; }
.analysis-card { border:1px solid var(--line); background:#fffdf8; border-radius:18px; padding:15px; }
.analysis-card h3 { margin-top:0; }
.score-grid { display:grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap:10px; }
.score-card { background:#fffdf8; border:1px solid var(--line); border-radius:16px; padding:12px; text-align:center; }
.score-card strong { display:block; font-size:24px; }
.tag-row { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0; }
.status-good { color: var(--good); font-weight:900; }
.status-bad { color: var(--bad); font-weight:900; }
.status-flat { color: var(--flat); font-weight:900; }
.v2-table-small th, .v2-table-small td { font-size:13px; padding:8px 10px; }
.liunian-table { max-height: 460px; overflow:auto; border:1px solid var(--line); border-radius:16px; }
.liunian-table table { border-radius:0; }
.logic-list li { margin-bottom:8px; }
.muted-box { border:1px dashed #cbbca8; border-radius:16px; padding:12px 14px; background:#fffaf3; color:#574c43; }
.pillar .meta-line { margin: 5px 0; }
@media (max-width: 900px) {
  .analysis-grid, .score-grid { grid-template-columns:1fr; }
  .liunian-table { max-height: 360px; }
}

/* v4.4 rectification / verification additions */
.rectification-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  margin: 12px 0 18px;
}
.rectification-card {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 18px;
  padding: 16px;
}
.rectification-card.best {
  border-color: rgba(31,122,59,.35);
  background: #f2fbf4;
}
.candidate-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}
.candidate-card {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 16px;
  padding: 13px;
}
.candidate-card.best {
  border-color: rgba(31,122,59,.45);
  box-shadow: 0 0 0 4px rgba(31,122,59,.08);
}
.confidence-meter { height: 10px; border-radius: 999px; background: #eadfce; overflow: hidden; margin: 8px 0; }
.confidence-meter span { display: block; height: 100%; background: linear-gradient(90deg, #8a5a16, #1f7a3b); }
.reason-list { margin: 8px 0 0; padding-left: 18px; }
.reason-list li { margin-bottom: 5px; }
.event-type-pill { display:inline-flex; border-radius:999px; padding:2px 8px; font-size:12px; font-weight:800; background:#efe6d7; color:#56483e; }
@media (max-width: 900px) {
  .rectification-summary, .candidate-list { grid-template-columns: 1fr; }
}

/* v4.4 additions */
.timezone-helper {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fffdf8;
  border: 1px dashed #d5c7b9;
}
.report-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.report-toolbar h2 { margin-bottom: 4px; }
.domain-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.domain-grid > div,
.color-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffaf3;
  padding: 12px 14px;
}
.domain-grid h3,
.color-panel h3 { margin-top: 0; }
.color-panel {
  margin-top: 12px;
  border-color: rgba(138,90,22,.25);
  background: #fff8ea;
}

@media (max-width: 900px) {
  .report-toolbar, .domain-grid { display: block; }
  .domain-grid > div { margin-bottom: 10px; }
}

@media print {
  :root { --shadow: none; }
  body {
    background: #fff;
    color: #111;
    font-size: 12px;
  }
  .hero, .input-panel, .footer, .no-print, #status { display: none !important; }
  .app-shell { padding: 0; max-width: none; }
  .section, .panel {
    box-shadow: none;
    border: 1px solid #ddd;
    border-radius: 0;
    break-inside: avoid;
    page-break-inside: avoid;
    padding: 14px;
    margin: 0 0 12px;
    background: #fff;
  }
  .pillars, .analysis-grid, .two-col, .domain-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .liunian-table { max-height: none; overflow: visible; }
  button { display: none !important; }
  a { color: #111; text-decoration: none; }
}


/* v4.4 hidden-stem activation UI */
.hidden-activation { margin-top: 1rem; border: 1px solid rgba(127,127,127,.25); border-radius: 14px; padding: 1rem; background: rgba(127,127,127,.05); }
.hidden-activation h3 { margin-top: 0; }
.hidden-activation table { width: 100%; }
.hidden-activation .tag-list { display: flex; gap: .35rem; flex-wrap: wrap; }
.hidden-activation .tag { display: inline-block; padding: .12rem .45rem; border-radius: 999px; border: 1px solid rgba(127,127,127,.35); font-size: .82rem; }
.hidden-activation .muted { opacity: .75; }
.hidden-activation .bad-text { color: #a33; font-weight: 600; }
.hidden-activation .good-text { color: #276b3a; font-weight: 600; }
.hidden-activation .flat-text { color: #666; }


.hkm-box {
  border: 1px solid rgba(120, 120, 120, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(250, 250, 250, 0.7);
  margin: 8px 0 14px;
}
.hkm-box ul { margin: 8px 0 6px 1.2rem; }
.hkm-box li { margin: 5px 0; }
@media print {
  .hkm-box { border: 1px solid #ccc; background: #fff; }
}
