:root {
  --ui-bg: #f3f7f2;
  --ui-bg-soft: #edf4ef;
  --ui-surface: #ffffff;
  --ui-surface-green: #f8fbf8;
  --ui-deep-green: #214f3c;
  --ui-green: #3e755d;
  --ui-green-soft: #dceadf;
  --ui-green-pale: #edf5ef;
  --ui-text: #1f2b25;
  --ui-muted: #7b8880;
  --ui-border: #dfe8e1;
  --ui-gold: #b78942;
  --element-wood: #18a857;
  --element-fire: #d9382f;
  --element-earth: #9a7422;
  --element-metal: #d48705;
  --element-water: #3977d8;
  --shadow: 0 12px 34px rgba(42, 74, 56, .08);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }
html { background: var(--ui-bg); }
body {
  margin: 0;
  color: var(--ui-text);
  background:
    radial-gradient(circle at 12% 0%, rgba(206, 226, 211, .52), transparent 34%),
    var(--ui-bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}
button, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1500px, calc(100% - 40px)); margin: 0 auto; padding: 22px 0 60px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  min-height: 66px; margin-bottom: 22px;
}
.brand-block { display: flex; align-items: center; gap: 13px; }
.sn49-chip {
  border: 1px solid #cbdcce; background: rgba(255,255,255,.78); color: var(--ui-deep-green);
  border-radius: 12px; padding: 10px 11px; font-size: 12px; font-weight: 800; letter-spacing: .08em;
}
.brand-title { font-size: 20px; font-weight: 780; letter-spacing: .08em; }
.brand-subtitle { color: var(--ui-muted); font-size: 12px; margin-top: 2px; }
.top-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ghost-btn, .sync-badge {
  border: 1px solid var(--ui-border); background: rgba(255,255,255,.78); border-radius: 999px;
  color: var(--ui-green); padding: 8px 13px; font-size: 12px;
}
.sync-badge { color: #6b7d71; }

.mode-row { display: flex; justify-content: center; margin-bottom: 22px; }
.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: #e5eee7; }
.mode-btn { min-width: 96px; padding: 9px 20px; border: 0; border-radius: 999px; background: transparent; color: #698074; font-weight: 700; }
.mode-btn.is-active { background: var(--ui-deep-green); color: #fff; box-shadow: 0 5px 18px rgba(33,79,60,.17); }

.view-panel { display: none; }
.view-panel.is-active { display: block; }
.person-card, .chart-card, .side-card, .compat-card {
  background: rgba(255,255,255,.91); border: 1px solid var(--ui-border); box-shadow: var(--shadow);
}
.person-card {
  border-radius: var(--radius-xl); padding: 22px 26px; margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 28px;
}
.person-main { display: flex; align-items: center; gap: 15px; }
.avatar-seal {
  width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(145deg, #315f4b, #1d4737); color: #eff7f1; font-size: 22px; font-weight: 750;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.eyebrow { color: #789083; font-size: 10px; letter-spacing: .16em; font-weight: 800; }
h1, h2 { margin: 0; }
h1 { margin-top: 4px; font-size: 28px; }
h2 { margin-top: 4px; font-size: 20px; }
.person-meta { color: var(--ui-muted); font-size: 13px; margin-top: 5px; }
.person-calendar { display: grid; gap: 5px; color: #52645a; font-size: 13px; text-align: right; }
.person-calendar span:last-child { color: #8c9a91; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.chart-card { border-radius: var(--radius-xl); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 24px 17px; }
.legend { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.legend-item { min-width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: #f3f5f4; }
.wood { color: var(--element-wood); }
.fire { color: var(--element-fire); }
.earth { color: var(--element-earth); }
.metal { color: var(--element-metal); }
.water { color: var(--element-water); }
.chart-scroll { overflow-x: auto; }
.bazi-table { width: 100%; min-width: 730px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.bazi-table th, .bazi-table td { padding: 12px 11px; text-align: center; vertical-align: top; border-top: 1px solid #eef2ef; }
.bazi-table thead th { color: #8b9890; background: var(--ui-surface-green); font-weight: 600; border-top: 0; }
.bazi-table thead th:first-child { width: 110px; text-align: left; padding-left: 24px; }
.bazi-table tbody th { color: #8b9890; font-weight: 500; text-align: left; padding-left: 24px; background: #fbfcfb; }
.bazi-table tbody tr:nth-child(even) td { background: #fafcfb; }
.bazi-table tbody tr:nth-child(even) th { background: #f6f9f7; }
.pillar-head { display: grid; gap: 2px; }
.pillar-head strong { color: #5b6c62; font-weight: 700; }
.pillar-head span { font-size: 10px; color: #9ca7a0; letter-spacing: .08em; }
.cell-main { min-height: 22px; }
.glyph-cell { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 72px; }
.glyph { font-size: 38px; line-height: 1; font-weight: 800; }
.element-seal {
  width: 25px; height: 25px; border-radius: 8px; display: grid; place-items: center;
  font-size: 10px; font-weight: 800; background: currentColor; color: inherit; position: relative;
}
.element-seal::after { content: attr(data-label); position: absolute; inset: 1px; display: grid; place-items: center; background: white; border-radius: 7px; }
.stacked { display: grid; gap: 3px; justify-content: center; }
.stacked span { line-height: 1.35; }
.shensha { color: var(--ui-gold); }
.muted-cell { color: #405148; }

.insight-stack { display: grid; gap: 14px; }
.side-card { border-radius: var(--radius-lg); padding: 18px; }
.side-card-title { font-weight: 750; color: var(--ui-deep-green); margin-bottom: 12px; }
.relation-group + .relation-group { margin-top: 15px; }
.relation-label { font-size: 11px; color: var(--ui-muted); margin-bottom: 7px; }
.chips, .book-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.chips span, .book-pills span { padding: 6px 8px; background: var(--ui-green-pale); color: #426553; border-radius: 9px; font-size: 11px; }
.book-card p, .engine-card p { color: #718078; font-size: 12px; line-height: 1.65; margin: 0 0 12px; }
.book-pills span { background: #f7f3ea; color: #8c6d39; }
.status-line { display: flex; gap: 8px; align-items: center; font-size: 12px; color: #466352; margin-bottom: 9px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #d7a84d; box-shadow: 0 0 0 4px #f6eddc; }

.compat-card { border-radius: var(--radius-xl); padding: 30px; max-width: 980px; margin: 0 auto; }
.compat-lead { color: var(--ui-muted); margin: 10px 0 26px; }
.compat-selectors { display: grid; grid-template-columns: 1fr 42px 1fr; gap: 14px; align-items: end; }
.compat-selectors label { display: grid; gap: 8px; color: #718078; font-size: 12px; }
.compat-selectors select { width: 100%; border: 1px solid var(--ui-border); border-radius: 14px; padding: 12px 13px; background: #fbfdfb; color: var(--ui-text); }
.compat-symbol { height: 43px; display: grid; place-items: center; color: #93a098; }
.empty-state { min-height: 260px; display: grid; place-items: center; align-content: center; gap: 8px; color: #76877d; text-align: center; }
.empty-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px; background: var(--ui-green-pale); color: var(--ui-deep-green); font-size: 20px; font-weight: 800; }
.empty-state strong { color: #405247; }
.empty-state span { font-size: 12px; }

@media (max-width: 1080px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .insight-stack { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 20px, 1500px); padding-top: 12px; }
  .topbar { align-items: flex-start; }
  .top-actions { max-width: 190px; }
  .sync-badge { display: none; }
  .person-card { align-items: flex-start; padding: 18px; }
  .person-calendar { text-align: left; }
  .person-card { flex-direction: column; gap: 14px; }
  .card-head { align-items: flex-start; flex-direction: column; }
  .bazi-table { min-width: 650px; }
  .insight-stack { grid-template-columns: 1fr; }
  .compat-card { padding: 22px 18px; }
  .compat-selectors { grid-template-columns: 1fr; }
  .compat-symbol { height: auto; }
}
