:root {
  color-scheme: light;
  --ink: #18211d;
  --muted: #68736d;
  --line: #dfe5e1;
  --soft: #f4f6f4;
  --paper: #ffffff;
  --green: #174f3a;
  --green-2: #2e7656;
  --green-soft: #e9f2ed;
  --orange: #d66132;
  --orange-soft: #fff0e8;
  --gold: #a27a18;
  --gold-soft: #f8f1dc;
  --blue: #2f6d91;
  --blue-soft: #e8f2f7;
  --red: #b53a3a;
  --shadow: 0 1px 2px rgba(19, 34, 26, 0.04), 0 8px 24px rgba(19, 34, 26, 0.05);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f7f8f7;
  color: var(--ink);
}

button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  background: #12392b;
  color: white;
}

.brand-block { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: #ffffff; box-shadow: 0 0 0 2px rgba(245, 196, 92, .55); }
.brand-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
.brand-block strong, .brand-block span { display: block; }
.brand-block strong { font-size: 17px; }
.brand-block span { margin-top: 2px; color: rgba(255,255,255,.65); font-size: 11px; white-space: nowrap; }

.primary-nav { display: grid; gap: 4px; margin-top: 24px; }
.nav-item { width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-left: 3px solid transparent; border-radius: 4px; background: transparent; color: rgba(255,255,255,.72); text-align: left; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.07); color: white; }
.nav-item.active { border-left-color: #f5c45c; background: rgba(255,255,255,.11); color: white; font-weight: 700; }

.sidebar-status { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-status strong, .sidebar-status span { display: block; }
.sidebar-status strong { font-size: 12px; }
.sidebar-status span { color: rgba(255,255,255,.55); font-size: 10px; margin-top: 2px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #62c58c; box-shadow: 0 0 0 4px rgba(98,197,140,.12); }

.main-content { min-width: 0; padding: 0 34px 48px; }
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.eyebrow, .section-kicker { margin: 0 0 5px; color: var(--green-2); font-size: 10px; font-weight: 800; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 27px; line-height: 1.2; }
h2 { margin-bottom: 0; font-size: 17px; line-height: 1.3; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.segment { display: inline-grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.segment button { min-width: 68px; height: 32px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); white-space: nowrap; font-size: 12px; }
.segment button.active { background: var(--green); color: white; font-weight: 700; }
.command-button, .primary-button { border: 0; border-radius: 5px; font-weight: 700; }
.command-button { height: 40px; padding: 0 16px; border: 1px solid var(--line); background: white; color: var(--ink); }
.primary-button { min-height: 42px; padding: 0 18px; background: var(--green); color: white; }
.primary-button.small { min-height: 34px; padding: 0 12px; font-size: 12px; }
.command-button:hover, .primary-button:hover { filter: brightness(.96); }

.notice { margin-top: 16px; padding: 11px 14px; border: 1px solid #edc9b7; border-radius: 5px; background: var(--orange-soft); color: #7c371d; font-size: 13px; }
.hidden { display: none !important; }
.readonly-mode .readonly-action { display: none; }
.notice a { margin-left: 8px; color: var(--green); font-weight: 800; }
.view { display: none; padding-top: 24px; }
.view.active { display: block; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { min-height: 116px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); box-shadow: var(--shadow); }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { display: block; margin-top: 10px; font-size: 28px; line-height: 1; }
.metric-meta { display: block; margin-top: 10px; color: var(--muted); font-size: 11px; }
.metric:nth-child(1) { border-top: 3px solid var(--green-2); }
.metric:nth-child(2) { border-top: 3px solid var(--orange); }
.metric:nth-child(3) { border-top: 3px solid var(--blue); }
.metric:nth-child(4) { border-top: 3px solid var(--gold); }
.skeleton { background: linear-gradient(90deg, #f0f2f0 25%, #f7f8f7 50%, #f0f2f0 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 16px; margin-top: 16px; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); box-shadow: var(--shadow); }
.section-heading, .split-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading { margin-bottom: 18px; }
.section-heading.compact { margin-bottom: 12px; }
.text-button { padding: 4px 0; border: 0; background: transparent; color: var(--green-2); font-size: 12px; font-weight: 700; }
.text-button:hover { color: var(--green); }
.loading-block { min-height: 210px; background: var(--soft); border-radius: 5px; }

.issue-bars { display: grid; gap: 13px; }
.issue-bar-row { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(160px, 2fr) 54px; align-items: center; gap: 12px; font-size: 12px; }
.issue-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; overflow: hidden; border-radius: 4px; background: #edf0ee; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--green-2); }
.issue-bar-row:nth-child(2) .bar-fill { background: var(--orange); }
.issue-bar-row:nth-child(3) .bar-fill { background: var(--blue); }
.issue-bar-row:nth-child(4) .bar-fill { background: var(--gold); }
.issue-bar-value { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.pulse-list { display: grid; gap: 10px; }
.pulse-item { padding: 12px; border-left: 3px solid var(--green-2); background: var(--soft); }
.pulse-item:nth-child(2) { border-left-color: var(--orange); }
.pulse-item:nth-child(3) { border-left-color: var(--blue); }
.pulse-item strong { display: block; font-size: 13px; }
.pulse-item span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.table-section { margin-top: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); box-shadow: var(--shadow); }
.table-section.flush { margin-top: 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); text-align: left; font-weight: 700; white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid #edf0ee; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfa; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.note-title { min-width: 230px; max-width: 380px; }
.note-title a, .account-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.note-title a:hover, .account-link:hover { color: var(--green-2); text-decoration: underline; }
.note-title span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 400; }
.tag { display: inline-block; max-width: 180px; padding: 3px 7px; overflow: hidden; border-radius: 4px; background: var(--green-soft); color: var(--green); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.tag.orange { background: var(--orange-soft); color: #8b3f22; }
.tag.blue { background: var(--blue-soft); color: #245a76; }
.delta-up { color: var(--green-2); font-weight: 700; }
.delta-flat { color: var(--muted); }

.toolbar-band { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; border: 1px solid var(--line); border-bottom: 0; border-radius: 7px 7px 0 0; background: var(--soft); }
.toolbar-band strong, .toolbar-band span { display: inline-block; }
.toolbar-band span { margin-left: 8px; color: var(--muted); font-size: 12px; }
select, input { border: 1px solid #cfd7d2; border-radius: 5px; background: white; color: var(--ink); }
select { height: 36px; padding: 0 34px 0 10px; }
.compact-segment button { min-width: 72px; height: 32px; }
.segment button:disabled { cursor: not-allowed; opacity: .45; }

.split-header { min-height: 64px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.split-actions { display: flex; align-items: center; gap: 10px; }
.data-source { padding: 4px 8px; border-radius: 4px; background: var(--soft); color: var(--muted); font-size: 11px; }
.issue-detail-list { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); }
.issue-detail { display: grid; grid-template-columns: 40px minmax(180px, 1fr) 110px 110px minmax(220px, 1.2fr); align-items: center; gap: 14px; padding: 15px 18px; background: white; }
.issue-rank { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 5px; background: var(--green); color: white; font-size: 12px; font-weight: 800; }
.issue-name strong, .issue-name span { display: block; }
.issue-name span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.issue-number { text-align: right; }
.issue-number strong, .issue-number span { display: block; }
.issue-number strong { font-size: 16px; }
.issue-number span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.issue-question { color: #424e48; font-size: 12px; line-height: 1.5; }
.lower-grid { grid-template-columns: 1fr 1fr; }
.compact-list { display: grid; gap: 8px; }
.hotspot-metrics { margin-bottom: 16px; }
.hotspot-layout { grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr); margin-top: 0; }
.hotspot-topic-list { display: grid; gap: 8px; }
.hotspot-topic-row { display: grid; grid-template-columns: 28px minmax(150px, 1.1fr) minmax(100px, 1fr) 70px; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #edf0ee; }
.hotspot-topic-row:last-child { border-bottom: 0; }
.hotspot-rank { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 4px; background: var(--green); color: white; font-size: 11px; font-weight: 800; }
.hotspot-topic-name strong, .hotspot-topic-name span { display: block; }
.hotspot-topic-name span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.hotspot-topic-bar { height: 7px; overflow: hidden; border-radius: 4px; background: #edf0ee; }
.hotspot-topic-bar span { display: block; height: 100%; border-radius: 4px; background: var(--gold); }
.compact-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid #edf0ee; font-size: 12px; }
.compact-row:last-child { border-bottom: 0; }
.empty-state { min-height: 80px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }

.budget-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 18px; }
.budget-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.budget-form label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.budget-form input { width: 100%; height: 40px; padding: 0 10px; color: var(--ink); font-size: 14px; }
.budget-form .primary-button { align-self: end; }
.budget-summary { padding: 22px; border: 1px solid var(--line); border-radius: 7px; background: #12392b; color: white; }
.budget-total span { color: rgba(255,255,255,.65); font-size: 11px; }
.budget-total strong { display: block; margin-top: 9px; font-size: 32px; }
.budget-total p { margin: 7px 0 0; color: #f5c45c; font-size: 15px; font-weight: 700; }
.budget-meter { height: 8px; margin-top: 20px; overflow: hidden; border-radius: 4px; background: rgba(255,255,255,.14); }
.budget-meter span { display: block; width: 0; height: 100%; border-radius: 4px; background: #f5c45c; transition: width .25s ease; }
.budget-status { margin: 8px 0 18px; color: rgba(255,255,255,.7); font-size: 11px; }
.budget-lines { display: grid; gap: 9px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.14); }
.budget-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; color: rgba(255,255,255,.72); font-size: 11px; }
.budget-line strong { color: white; font-variant-numeric: tabular-nums; }
.pricing-note { margin: 12px 0 0; color: var(--muted); font-size: 10px; }

.account-dialog { width: min(620px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 7px; box-shadow: 0 20px 70px rgba(18, 57, 43, .25); }
.account-dialog::backdrop { background: rgba(18, 33, 26, .45); }
.account-dialog form { padding: 22px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.dialog-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--muted); font-size: 22px; line-height: 1; }
.dialog-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 0; }
.dialog-fields label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.dialog-fields .wide { grid-column: 1 / -1; }
.dialog-fields input, .dialog-fields select { width: 100%; height: 40px; padding: 0 10px; color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-error { margin: 0 0 12px; padding: 10px 12px; border-radius: 5px; background: var(--orange-soft); color: #7c371d; font-size: 12px; }
.remove-button { padding: 4px 0; border: 0; background: transparent; color: var(--red); font-size: 11px; font-weight: 700; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .main-content { padding-inline: 22px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .hotspot-layout { grid-template-columns: 1fr; }
  .budget-layout { grid-template-columns: 1fr; }
  .issue-detail { grid-template-columns: 36px minmax(180px, 1fr) 90px 90px; }
  .issue-question { grid-column: 2 / -1; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 16px; }
  .brand-block { padding: 0 0 12px; }
  .primary-nav { display: flex; margin-top: 12px; overflow-x: auto; padding-bottom: 2px; }
  .nav-item { width: auto; min-width: max-content; min-height: 36px; padding: 0 12px; border-left: 0; border-bottom: 2px solid transparent; }
  .nav-item.active { border-bottom-color: #f5c45c; }
  .sidebar-status { display: none; }
  .main-content { padding: 0 14px 36px; }
  .topbar { min-height: 118px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 12px; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  h1 { font-size: 23px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { min-height: 105px; padding: 14px; }
  .metric-value { font-size: 24px; }
  .panel, .table-section { padding: 15px; }
  .issue-bar-row { grid-template-columns: minmax(110px, 1fr) minmax(90px, 1.3fr) 48px; gap: 8px; }
  .budget-form { grid-template-columns: 1fr 1fr; padding: 15px; }
  .budget-form .primary-button { min-height: 40px; }
  .issue-detail { grid-template-columns: 30px minmax(130px, 1fr) 72px; gap: 9px; padding: 13px 12px; }
  .issue-detail .issue-number:nth-of-type(4) { display: none; }
  .issue-question { grid-column: 2 / -1; }
  .lower-grid { grid-template-columns: 1fr; }
  .hotspot-topic-row { grid-template-columns: 28px minmax(130px, 1fr) 64px; }
  .hotspot-topic-bar { grid-column: 2 / -1; }
  .split-header { align-items: flex-start; }
  .split-actions { align-items: flex-end; flex-direction: column; }
  .dialog-fields { grid-template-columns: 1fr; }
  .dialog-fields .wide { grid-column: auto; }
}

@media (max-width: 460px) {
  .metric-grid { grid-template-columns: 1fr; }
  .budget-form { grid-template-columns: 1fr; }
  .segment button { min-width: 62px; }
  .command-button { padding-inline: 12px; }
  .section-heading { align-items: flex-start; }
  .issue-detail { grid-template-columns: 28px minmax(0, 1fr) 60px; }
}
