:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --soft: #f4f7fb;
  --paper: #ffffff;
  --brand: #1f7a8c;
  --brand-strong: #0f5f6e;
  --accent: #c47f2d;
  --ok: #16815d;
  --warn: #bd7b00;
  --bad: #b42318;
  --shadow: 0 18px 45px rgba(26, 39, 58, .12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #f5f7fa;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body.auth-loading .login-screen,
body.auth-loading .app-shell {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #102932;
}

.login-screen.hidden {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .24);
}

.login-panel h1 {
  font-size: 24px;
}

.login-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.login-panel label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.login-panel button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.login-error {
  min-height: 20px;
  color: var(--bad);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 18px;
  background: #102932;
  color: #eef8f9;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 8px;
  background: #eaf6f7;
  display: grid;
  place-items: center;
}

.brand-mark img {
  width: 32px;
  height: 32px;
  display: block;
}

.brand strong,
.brand span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand span {
  color: #a8c4ca;
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.ai-primary-nav {
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: #eaf6f7;
  color: #0f5f6e;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
}

.ai-primary-nav:hover,
.ai-primary-nav.active {
  background: #fff;
  color: #0f5f6e;
}

.ai-primary-nav span:last-child {
  display: grid;
  gap: 1px;
}

.ai-primary-nav strong,
.ai-primary-nav small {
  display: block;
}

.ai-primary-nav small {
  font-size: 12px;
  color: #4f7e86;
}

.nav-group,
.nav-subgroup {
  display: grid;
  gap: 6px;
}

.nav-group summary,
.nav-subgroup summary {
  cursor: pointer;
  list-style: none;
  color: #a8c4ca;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 4px;
}

.nav-group summary::-webkit-details-marker,
.nav-subgroup summary::-webkit-details-marker {
  display: none;
}

.nav-subgroup {
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, .12);
}

.nav-subgroup summary {
  color: #cde4e8;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  color: #cde4e8;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.side-status {
  margin-top: auto;
  display: flex;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
}

.side-status strong,
.side-status span {
  display: block;
}

.side-status span {
  color: #a8c4ca;
  font-size: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(189, 123, 0, .18);
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(22, 129, 93, .18);
}

.dot.bad {
  background: var(--bad);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, .18);
}

.main {
  min-width: 0;
  padding: 30px;
  max-width: 1480px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.ai-rail-tab {
  position: fixed;
  right: 0;
  top: 42%;
  z-index: 20;
  min-height: 132px;
  width: 44px;
  border: 0;
  border-radius: 8px 0 0 8px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 30px rgba(26, 39, 58, .22);
  writing-mode: vertical-rl;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ai-rail-tab .icon {
  transform: rotate(90deg);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 3px;
  font-size: 20px;
}

h3 {
  margin-bottom: 0;
  font-size: 15px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px 0 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.user-menu-wrap {
  position: relative;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.avatar.large {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

.user-meta {
  display: grid;
  gap: 1px;
  text-align: left;
}

.user-meta strong {
  font-size: 13px;
}

.user-meta small {
  color: var(--muted);
  font-size: 11px;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(26, 39, 58, .16);
  padding: 6px;
}

.user-menu button {
  width: 100%;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  justify-content: flex-start;
  padding: 0 10px;
}

.user-menu button:hover {
  background: var(--soft);
}

.icon-button,
.top-actions > button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  display: grid;
  place-items: center;
}

.ask-panel {
  display: grid;
  grid-template-columns: minmax(280px, 430px) minmax(360px, 1fr);
  gap: 24px;
  align-items: center;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
}

#view-overview {
  min-height: calc(100vh - 112px);
}

.chat-layout {
  min-height: calc(100vh - 112px);
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 18px;
}

.ai-history {
  min-height: 0;
  max-height: calc(100vh - 112px);
  position: sticky;
  top: 30px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  align-self: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(26, 39, 58, .08);
}

.ai-history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.ai-history-head span,
.ai-history-head small {
  display: block;
}

.ai-history-head span {
  font-weight: 700;
}

.ai-history-head small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.ai-history-head button {
  min-height: 32px;
  border: 1px solid #b8dadd;
  border-radius: 8px;
  background: #e9f5f6;
  color: var(--brand-strong);
  padding: 0 10px;
  white-space: nowrap;
}

.chat-workspace {
  min-height: calc(100vh - 112px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.examples {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.examples button,
.small-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: #f8fafc;
  color: var(--brand-strong);
}

.examples button:hover,
.small-action:hover {
  background: #e9f5f6;
  border-color: #b8dadd;
}

#openDashboardBtn {
  align-items: center;
  background: linear-gradient(180deg, #23899d 0%, #126477 100%);
  border-color: #0f5f6e;
  box-shadow: 0 14px 28px rgba(15, 95, 110, .28), inset 0 1px 0 rgba(255, 255, 255, .28);
  color: #fff;
  display: inline-flex;
  gap: 8px;
  font-weight: 800;
  min-height: 40px;
  padding: 0 20px;
  transform: translateY(-1px);
}

#openDashboardBtn:hover {
  background: linear-gradient(180deg, #2b98ad 0%, #0f5f6e 100%);
  border-color: var(--brand-strong);
  box-shadow: 0 18px 34px rgba(15, 95, 110, .34), inset 0 1px 0 rgba(255, 255, 255, .32);
}

#openDashboardBtn .icon {
  width: 17px;
  height: 17px;
}

.ask-copy {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ask-copy h2 {
  font-size: 22px;
  line-height: 1.25;
}

.ask-copy p,
.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.ask-form,
.filters,
.workshop-toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
}

.ask-form input,
.filters input,
.filters select,
.workshop-toolbar select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 0 12px;
  color: var(--ink);
}

.ask-form button,
.filters button,
.workshop-toolbar button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.ask-form input {
  min-height: 52px;
  font-size: 16px;
  background: #fff;
}

.ask-form button {
  min-height: 52px;
  padding: 0 20px;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
  opacity: .82;
}

.chat-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  overflow: auto;
  padding: 10px 0 22px;
  margin: 0;
}

.chat-empty {
  border: 1px dashed #b8c7d5;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  background: rgba(255, 255, 255, .72);
  max-width: 960px;
}

.chat-empty .examples {
  grid-column: auto;
  margin-top: 14px;
}

.composer {
  position: sticky;
  bottom: 0;
  padding: 14px 0 0;
  background: linear-gradient(180deg, rgba(245, 247, 250, 0), #f5f7fa 32%);
}

.recent-prompts {
  max-width: 920px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
}

.recent-prompts span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.recent-prompts button {
  flex: 0 0 auto;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
}

.composer .ask-form {
  max-width: 920px;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(26, 39, 58, .12);
}

.composer .ask-form input {
  border: 0;
  background: transparent;
}

.composer .ask-form button {
  width: 44px;
  padding: 0;
  justify-content: center;
}

.chat-empty strong,
.chat-empty span {
  display: block;
}

.chat-empty strong {
  color: var(--ink);
  margin-bottom: 4px;
}

.chat-row {
  display: flex;
}

.chat-row.user {
  justify-content: flex-end;
}

.chat-row.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: min(920px, 100%);
  border-radius: 8px;
  padding: 15px 17px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(26, 39, 58, .08);
}

.chat-row.user .bubble {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.assistant-bubble {
  min-width: min(840px, 100%);
}

.assistant-bubble.failed {
  border-color: #f3b5af;
  background: #fff7f6;
}

.assistant-bubble.failed .answer-text {
  color: var(--bad);
}

.bubble.error {
  border-color: #f3b5af;
  color: var(--bad);
  background: #fff7f6;
}

.answer-text {
  font-size: 16px;
  line-height: 1.75;
  color: #263241;
}

.agent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.agent-meta span {
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.answer-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #fff;
  color: var(--brand-strong);
}

.answer-actions button:hover {
  background: #e9f5f6;
  border-color: #b8dadd;
}

.agent-steps {
  margin-top: 12px;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}

.agent-steps summary {
  cursor: pointer;
  color: var(--brand-strong);
  font-weight: 700;
}

.agent-steps ol {
  margin: 10px 0 0;
  padding-left: 20px;
}

.agent-steps li {
  margin: 6px 0;
}

.agent-steps li span {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.agent-sources {
  margin-top: 10px;
  color: var(--muted);
}

.agent-sources summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.agent-sources div,
.followups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.agent-sources span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: #fff;
  font-size: 12px;
}

.agent-sources em {
  margin-left: 6px;
  font-style: normal;
  color: var(--brand-strong);
}

.followups {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.followups button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 11px;
  color: var(--brand-strong);
  cursor: pointer;
}

.chat-result {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.echart {
  width: 100%;
  height: 360px;
}

.mini-insight {
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.mini-insight.risk-medium {
  border-left-color: var(--warn);
}

.mini-insight.risk-high {
  border-left-color: var(--bad);
}

.mini-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.mini-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mini-facts span,
.mini-card-grid div {
  display: block;
  border-radius: 8px;
  background: var(--soft);
  padding: 9px;
}

.mini-facts em,
.mini-card-grid span {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.chart-list {
  display: grid;
  gap: 10px;
}

.progress-chart {
  display: grid;
  gap: 12px;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 2fr) 110px;
  gap: 12px;
  align-items: center;
}

.progress-label strong,
.progress-label span,
.progress-value strong,
.progress-value span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-label span,
.progress-value span {
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 18px;
  border-radius: 999px;
  background: #e8eef4;
  overflow: hidden;
}

.progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #63a8a6);
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 2fr) 70px;
  gap: 10px;
  align-items: center;
}

.bar-row strong,
.bar-row span {
  display: block;
  overflow-wrap: anywhere;
}

.bar-row span {
  color: var(--muted);
  font-size: 12px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e8eef4;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ok);
}

.bar-track i.risk-medium {
  background: var(--warn);
}

.bar-track i.risk-high {
  background: var(--bad);
}

.mini-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric,
.panel,
.entity-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.metric {
  padding: 15px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 7px 0 2px;
  font-size: 28px;
  line-height: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr);
  gap: 14px;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 14px;
  margin-bottom: 14px;
}

.decision-hero,
.decision-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 22px rgba(26, 39, 58, .08);
}

.decision-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 18px;
  border-left: 5px solid var(--ok);
}

.decision-hero.risk-medium,
.decision-card.risk-medium {
  border-left-color: var(--warn);
}

.decision-hero.risk-high,
.decision-card.risk-high {
  border-left-color: var(--bad);
}

.decision-hero strong {
  display: block;
  margin-bottom: 4px;
  font-size: 20px;
}

.decision-hero p,
.decision-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.radar-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.radar-metrics.compact {
  margin-bottom: 0;
}

.radar-metrics span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--muted);
}

.radar-metrics strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  margin-bottom: 5px;
}

.decision-list {
  display: grid;
  gap: 12px;
}

.decision-card {
  border-left: 5px solid var(--ok);
  padding: 16px;
}

.decision-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.decision-card header strong,
.decision-card header small {
  display: block;
}

.decision-card header small {
  color: var(--muted);
  margin-top: 2px;
}

.decision-card .facts {
  margin-top: 12px;
}

.decision-card .reason-block {
  margin-top: 12px;
}

.decision-card > button {
  min-height: 34px;
  margin-top: 12px;
  border: 1px solid #b8dadd;
  border-radius: 8px;
  padding: 0 12px;
  background: #e9f5f6;
  color: var(--brand-strong);
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.insight-panel {
  overflow: visible;
}

.insight-panel.compact {
  margin-bottom: 14px;
}

.inline-diagnose {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.inline-diagnose input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfcfe;
}

.inline-diagnose button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-head {
  min-height: 50px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f8fafc;
}

td {
  color: #263241;
}

.filters {
  flex-wrap: wrap;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.filters label {
  flex: 1 1 210px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filters input,
.filters select {
  display: block;
  margin-top: 6px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.entity-card {
  padding: 15px;
}

.entity-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.entity-card strong {
  display: block;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.entity-card small {
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.fact {
  padding: 8px;
  border-radius: 8px;
  background: var(--soft);
}

.fact span,
.fact strong {
  display: block;
}

.fact span {
  color: var(--muted);
  font-size: 12px;
}

.fact strong {
  margin-top: 2px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #e8f4f5;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.warn {
  background: #fff2d9;
  color: var(--warn);
}

.badge.done {
  background: #e6f5ee;
  color: var(--ok);
}

.badge.bad {
  background: #feeceb;
  color: var(--bad);
}

.muted-box {
  padding: 18px;
  color: var(--muted);
}

.insight-result {
  min-height: 140px;
}

.ai-card {
  padding: 16px;
  border-left: 4px solid var(--ok);
}

.ai-card.risk-medium {
  border-left-color: var(--warn);
}

.ai-card.risk-high {
  border-left-color: var(--bad);
}

.ai-card header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.ai-card header strong {
  display: block;
  font-size: 18px;
}

.ai-card header p {
  margin: 5px 0 0;
  color: var(--muted);
}

.ai-facts {
  margin-bottom: 14px;
}

.reason-block {
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
  margin-top: 10px;
}

.reason-block strong {
  display: block;
  margin-bottom: 6px;
}

.reason-block ul {
  margin: 0;
  padding-left: 18px;
  color: #394556;
}

.risk-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.history-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 6px;
}

.history-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px 2px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  align-items: center;
  border-radius: 8px;
}

.history-item.pinned {
  background: #f8fbfd;
}

.history-item > button:first-child {
  min-width: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 9px 8px;
  text-align: left;
}

.history-item:hover,
.history-item > button:first-child:hover {
  background: #f4f8fb;
}

.history-item strong,
.history-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item strong {
  font-size: 13px;
}

.history-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 6px 7px;
}

.history-actions button,
.history-delete {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 5px 6px;
  font-size: 12px;
}

.history-actions button:hover {
  background: #f4f8fb;
  color: var(--brand-strong);
}

.history-delete:hover {
  background: #f4f8fb;
  color: var(--bad);
}

.risk-item {
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  padding: 11px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.risk-item.risk-medium {
  border-left-color: var(--warn);
}

.risk-item.risk-high {
  border-left-color: var(--bad);
}

.risk-item strong,
.risk-item small {
  display: block;
  margin-top: 5px;
}

.risk-item small {
  color: var(--muted);
}

.workshop-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.workshop-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px;
  border-radius: 8px;
  background: var(--soft);
}

.workshop-item strong,
.workshop-item span {
  overflow-wrap: anywhere;
}

.workshop-item span {
  color: var(--muted);
  font-size: 12px;
}

.map-board {
  position: relative;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(#e1e8ef 1px, transparent 1px),
    linear-gradient(90deg, #e1e8ef 1px, transparent 1px),
    #f7fafc;
  background-size: 34px 34px;
}

.point {
  position: absolute;
  width: 136px;
  min-height: 54px;
  transform: translate(-50%, -50%);
  padding: 8px;
  border: 1px solid #b8c7d5;
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 18px rgba(31, 45, 61, .1);
}

.point strong,
.point span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.point span {
  color: var(--muted);
  font-size: 12px;
}

.empty,
.loading {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  display: none;
  padding: 13px 15px;
  border-radius: 8px;
  background: #102932;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast.show {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .36);
}

.modal-backdrop[hidden] {
  display: none;
}

.profile-modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(15, 23, 42, .28);
  padding: 22px;
}

.profile-modal header,
.profile-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.profile-user {
  justify-content: flex-start;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.profile-user div {
  display: grid;
  gap: 3px;
}

.profile-user span,
.profile-user small {
  color: var(--muted);
}

.profile-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-tabs button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  cursor: pointer;
}

.profile-tabs button.active {
  border-color: var(--brand);
  background: #e9f5f6;
  color: var(--brand-strong);
  font-weight: 800;
}

.profile-token-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fbfcfe;
}

.profile-token-card span,
.profile-token-card small {
  display: block;
  color: var(--muted);
}

.profile-token-card strong {
  display: block;
  margin: 6px 0;
  font-size: 34px;
}

.profile-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.profile-feature-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.profile-feature-grid span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.profile-export {
  margin-top: 10px;
}

.subscription-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.subscription-panel h3 {
  margin-bottom: 10px;
}

.subscription-panel label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 14px 8px 0;
  color: var(--ink);
  font-size: 13px;
}

.subscription-status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.suggest-box {
  position: absolute;
  z-index: 60;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(26, 39, 58, .18);
}

.suggest-box button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf1f6;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.suggest-box button:hover {
  background: #f4f8fb;
}

.suggest-box strong,
.suggest-box span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-box span,
.suggest-empty {
  color: var(--muted);
  font-size: 12px;
}

.suggest-empty {
  padding: 12px;
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex: 0 0 18px;
}

.icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon.xl {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.leader-dashboard {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.dashboard-backdrop {
  align-items: flex-start;
  overflow: auto;
  padding: 28px;
}

.dashboard-modal {
  width: min(1180px, 100%);
  max-height: none;
  margin: 0 auto;
  background: #f5f7fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
  padding: 18px;
}

.dashboard-modal > header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.dashboard-modal > header h2 {
  margin: 2px 0 0;
}

.leader-hero {
  align-items: center;
  background: linear-gradient(135deg, #153f4a, #1f7a8c);
  border-radius: 8px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
}

.leader-hero h2 {
  font-size: 28px;
  margin: 4px 0 8px;
}

.leader-hero p {
  color: rgba(255, 255, 255, .82);
  margin: 0;
}

.leader-actions,
.leader-item div,
.quick-questions,
.agent-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.leader-actions button,
.quick-questions button,
.agent-roles button,
.leader-item div button {
  border: 1px solid rgba(31, 122, 140, .22);
  border-radius: 8px;
  cursor: pointer;
}

.leader-actions button {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  padding: 10px 12px;
}

.leader-metrics {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.leader-metrics div,
.briefing-panel,
.leader-grid > section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.leader-metrics div {
  padding: 14px;
}

.leader-metrics strong {
  display: block;
  font-size: 26px;
}

.leader-metrics span,
.agent-roles span {
  color: var(--muted);
  font-size: 13px;
}

.briefing-panel,
.notification-panel,
.leader-grid > section {
  padding: 16px;
}

.briefing-text {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  line-height: 1.7;
  min-height: 74px;
  padding: 14px;
  white-space: pre-wrap;
}

.notification-list {
  display: grid;
  gap: 10px;
}

.notification-wrap {
  position: relative;
}

.notification-button {
  position: relative;
}

.notification-dot {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 8px;
  height: 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--bad);
}

.notification-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  width: min(420px, calc(100vw - 32px));
  max-height: 560px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .2);
}

.notification-popover[hidden] {
  display: none;
}

.notification-item {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 12px;
}

.notification-item.risk-high {
  border-left-color: var(--bad);
}

.notification-item.risk-medium {
  border-left-color: var(--warn);
}

.notification-item header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.notification-item small,
.notification-item p {
  color: var(--muted);
}

.notification-item p {
  margin: 8px 0 10px;
}

.notification-item div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notification-item button {
  border: 1px solid rgba(31, 122, 140, .22);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--brand-strong);
  padding: 6px 10px;
}

.agent-roles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.agent-roles button,
.quick-questions button {
  background: #fff;
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.agent-roles button strong {
  display: block;
  margin-bottom: 4px;
}

.quick-questions button {
  color: var(--accent);
}

.leader-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.leader-list {
  display: grid;
  gap: 10px;
}

.leader-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px;
}

.leader-item.risk-high {
  border-left-color: #dc2626;
}

.leader-item.risk-medium {
  border-left-color: #d97706;
}

.leader-item > button {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 6px;
  padding: 0 0 8px;
  text-align: left;
  width: 100%;
}

.leader-item small {
  color: var(--muted);
  line-height: 1.5;
}

.leader-item div button {
  background: #f8fafc;
  color: var(--accent);
  font-size: 12px;
  padding: 6px 8px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav {
    max-height: 320px;
  }

  .side-status {
    display: none;
  }

  .ask-panel,
  .chat-layout,
  .decision-hero,
  .dashboard-grid,
  .insight-grid,
  .leader-hero,
  .leader-grid,
  .agent-roles {
    grid-template-columns: 1fr;
  }

  .leader-hero {
    align-items: stretch;
    display: grid;
  }

  .ai-history {
    position: static;
    max-height: 240px;
  }

  .chat-workspace {
    min-height: calc(100vh - 352px);
  }

  .examples {
    grid-column: 1;
  }

  .metrics,
  .radar-metrics,
  .result-grid,
  .leader-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .main {
    padding: 16px;
  }

  .nav {
    max-height: 360px;
  }

  .ask-form,
  .filters,
  .workshop-toolbar,
  .inline-diagnose {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .radar-metrics,
    .result-grid,
    .leader-metrics,
    .facts,
    .mini-facts,
    .mini-card-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .progress-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 23px;
  }
}
