:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #12161d;
  --muted: #657080;
  --soft: #8c97a5;
  --line: #dce3ec;
  --line-strong: #c7d1dc;
  --red: #d8272f;
  --red-soft: #fff1f2;
  --blue: #155ea8;
  --blue-soft: #eef6ff;
  --green: #18785d;
  --green-soft: #eaf8f2;
  --amber: #a76513;
  --amber-soft: #fff7e8;
  --slate: #263241;
  --shadow: 0 18px 42px rgba(21, 32, 43, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "SF Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(216, 39, 47, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 94, 168, 0.03) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1,
h2,
h3 {
  letter-spacing: 0;
  line-height: 1.22;
  text-wrap: balance;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 22px;
  padding: 20px;
  color: #eef4fb;
  background: #172131;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand,
.nav-list a,
.topbar-actions,
.status-row,
.panel-head,
.search-box,
.segmented,
.alert-meta,
.alert-tags,
.alert-footer,
.source-row,
.sector-meta,
.company-top,
.company-meta,
.channel-row,
.footer {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  min-height: 44px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  background: var(--red);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 850;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  margin-top: 2px;
  color: #aeb9c7;
  font-family: var(--mono);
  font-size: 0.7rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  min-height: 38px;
  padding: 0 10px;
  color: #c8d2df;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 760;
}

.nav-list a:hover,
.nav-list a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.side-card {
  margin-top: auto;
  padding: 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.side-card span,
.side-card p {
  color: #b7c1ce;
}

.side-card span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.74rem;
  font-weight: 760;
}

.side-card strong {
  display: block;
  color: #fff;
  font-size: 1.16rem;
}

.side-card p {
  margin: 8px 0 0;
  font-size: 0.8rem;
  line-height: 1.55;
}

.workspace {
  width: min(1500px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 22px clamp(16px, 3vw, 34px) 34px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 18px 18px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.55rem, 2.3vw, 2.35rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.topbar-lede {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.primary-button,
.secondary-button,
.ghost-button,
.segmented button {
  min-height: 36px;
  border-radius: 7px;
  font-weight: 780;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 0 13px;
  border: 1px solid var(--line-strong);
}

.primary-button {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.secondary-button {
  color: var(--blue);
  background: #fff;
}

.ghost-button {
  color: var(--slate);
  background: var(--surface-2);
}

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

.status-row article {
  min-width: 0;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-row span,
.status-row em {
  display: block;
  color: var(--muted);
  font-style: normal;
}

.status-row span {
  font-size: 0.78rem;
  font-weight: 760;
}

.status-row strong {
  display: block;
  margin: 6px 0 4px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.status-row em {
  font-size: 0.78rem;
  line-height: 1.35;
}

.command-center {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box {
  gap: 10px;
  min-width: 0;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.search-box label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.segmented {
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  white-space: nowrap;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 7px rgba(16, 24, 40, 0.08);
}

.grid-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.36fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(21, 32, 43, 0.05);
}

.panel-head {
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
  text-align: right;
}

.alert-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.alert-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: 8px;
}

.alert-card.risk-high {
  border-left-color: var(--red);
}

.alert-card.risk-mid {
  border-left-color: var(--amber);
}

.alert-card.risk-low {
  border-left-color: var(--green);
}

.alert-meta,
.alert-tags,
.alert-footer {
  flex-wrap: wrap;
  gap: 6px;
}

.alert-meta span,
.alert-tags span,
.alert-footer span,
.badge {
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 780;
  line-height: 1.25;
}

.alert-meta span {
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
}

.badge.high {
  color: var(--red);
  background: var(--red-soft);
}

.badge.mid {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.low {
  color: var(--green);
  background: var(--green-soft);
}

.alert-card h3 {
  margin: 0;
}

.alert-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.9rem;
}

.impact-box {
  display: grid;
  gap: 6px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.impact-box strong {
  color: var(--slate);
  font-size: 0.78rem;
}

.alert-tags span {
  color: var(--blue);
  background: var(--blue-soft);
}

.alert-footer {
  justify-content: space-between;
  color: var(--soft);
  font-size: 0.78rem;
}

.right-rail {
  display: grid;
  align-content: start;
  gap: 14px;
}

.judgement-panel ol {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 12px 16px 16px 34px;
}

.judgement-panel li {
  color: var(--slate);
  line-height: 1.62;
  font-size: 0.9rem;
}

.source-list,
.channel-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.source-row,
.channel-row {
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.source-row strong,
.channel-row strong {
  display: block;
  font-size: 0.86rem;
}

.source-row span,
.channel-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.source-bar {
  width: 88px;
  height: 8px;
  overflow: hidden;
  background: #e8edf3;
  border-radius: 999px;
}

.source-bar i {
  display: block;
  width: var(--value);
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.sector-panel,
.portfolio-panel,
.delivery-grid {
  margin-top: 14px;
}

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

.sector-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sector-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.62;
  font-size: 0.88rem;
}

.sector-meta {
  flex-wrap: wrap;
  gap: 6px;
}

.meter {
  display: grid;
  gap: 8px;
}

.meter-row {
  display: grid;
  grid-template-columns: 52px 1fr 36px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.meter-track {
  height: 8px;
  overflow: hidden;
  background: #e8edf3;
  border-radius: 999px;
}

.meter-track i {
  display: block;
  width: var(--value);
  height: 100%;
  background: var(--red);
}

.meter-track.heat i {
  background: var(--blue);
}

.sector-keywords,
.company-meta {
  flex-wrap: wrap;
  gap: 6px;
}

.sector-keywords span,
.company-meta span {
  padding: 4px 7px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 760;
}

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

.company-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.company-top {
  justify-content: space-between;
  gap: 8px;
}

.company-logo {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.company-logo img {
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
}

.company-card h3 {
  margin: 0 0 3px;
  font-size: 0.98rem;
}

.company-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.82rem;
}

.score-line {
  display: grid;
  grid-template-columns: 1fr 36px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.score-line i {
  height: 8px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--red));
  border-radius: 999px;
  transform-origin: left;
}

.delivery-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(320px, 1fr);
  gap: 14px;
}

.brief-card {
  margin: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brief-card h3 {
  margin-bottom: 10px;
}

.brief-card p {
  margin: 0;
  color: var(--slate);
  line-height: 1.78;
  white-space: pre-line;
}

.footer {
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 14px 2px 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  padding: 10px 12px;
  color: #fff;
  background: rgba(23, 33, 49, 0.94);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 14px 18px;
  }

  .nav-list {
    display: flex;
    flex-wrap: wrap;
  }

  .side-card {
    display: none;
  }

  .command-center,
  .grid-layout,
  .delivery-grid {
    grid-template-columns: 1fr;
  }

  .sector-grid,
  .company-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .sidebar,
  .topbar,
  .topbar-actions,
  .footer {
    align-items: stretch;
  }

  .sidebar,
  .topbar {
    flex-direction: column;
  }

  .workspace {
    padding: 14px 12px 24px;
  }

  .status-row,
  .sector-grid,
  .company-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-head > span {
    text-align: left;
  }

  .segmented button {
    flex: 1;
  }
}
