:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --ink: #20231f;
  --muted: #68716b;
  --line: #dfe5df;
  --green: #16845c;
  --green-soft: #e4f3eb;
  --red: #b83b3b;
  --red-soft: #f8e8e5;
  --amber: #a46714;
  --amber-soft: #fff1d6;
  --teal: #0b7285;
  --teal-soft: #e0f2f5;
  --shadow: 0 12px 40px rgba(33, 39, 34, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid rgba(223, 229, 223, 0.9);
  background: #f6f7f5;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p,
pre {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1;
}

h2 {
  font-size: 19px;
  line-height: 1.25;
}

main {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 32px) 44px;
}

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

.status-pill,
.tag,
.news-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.ok,
.tag.positive,
.news-badge.bullish {
  border-color: rgba(22, 132, 92, 0.25);
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.warn,
.tag.negative,
.news-badge.bearish {
  border-color: rgba(184, 59, 59, 0.25);
  background: var(--red-soft);
  color: var(--red);
}

.tag.watch,
.news-badge.neutral {
  border-color: rgba(164, 103, 20, 0.25);
  background: var(--amber-soft);
  color: var(--amber);
}

.icon-button,
.text-button,
.primary-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
}

.icon-button:hover,
.text-button:hover,
.primary-button:hover {
  border-color: #b9c5bc;
}

.icon-button.loading span {
  animation: spin 900ms linear infinite;
}

.text-button,
.primary-button {
  min-height: 36px;
  padding: 0 14px;
  font-weight: 800;
}

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

.today-brief,
.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.today-brief {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  padding: clamp(18px, 3vw, 26px);
}

.summary-bullets {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

.overview-lines p {
  border-left: 3px solid var(--teal);
  padding: 9px 0 9px 12px;
  background: #fbfcfb;
  color: #303832;
}

.brief-side {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.brief-side > div {
  display: flex;
  min-height: 72px;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  border-left: 3px solid var(--teal);
  padding: 10px 0 10px 14px;
  background: #fbfcfb;
}

.brief-side span,
.metric-card span,
.metric-card small,
.panel-head p,
.news-meta,
.news-impact,
.form-message {
  color: var(--muted);
}

.brief-side strong {
  font-size: 22px;
}

.data-health-panel {
  margin-top: 14px;
}

.panel-head.compact {
  margin-bottom: 10px;
}

.data-health {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.health-card {
  min-width: 0;
  min-height: 82px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfcfb;
}

.health-card span,
.health-card small {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-card strong {
  display: block;
  margin: 7px 0 5px;
  font-size: 20px;
  line-height: 1.05;
}

.health-card.ok {
  border-left-color: var(--green);
}

.health-card.ok strong {
  color: var(--green);
}

.health-card.warn {
  border-left-color: var(--amber);
}

.health-card.warn strong {
  color: var(--amber);
}

.health-card.error {
  border-left-color: var(--red);
}

.health-card.error strong {
  color: var(--red);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.kpi-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
  box-shadow: var(--shadow);
}

.kpi-group-title {
  grid-column: 1 / -1;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.kpi-group .metric-card {
  box-shadow: none;
}

.metric-card {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
}

.metric-card span {
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
  word-break: break-word;
}

.metric-card small {
  font-size: 13px;
}

.core-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.15fr) minmax(420px, 0.85fr);
  align-items: start;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.flow-panel {
  min-height: 0;
}

.news-panel {
  grid-column: 1 / -1;
  min-height: 0;
}

.hype-panel {
  grid-column: 1 / -1;
  min-height: 0;
}

.hype-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

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

.hype-stats > div {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.hype-stats span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.hype-stats strong {
  font-size: 21px;
  line-height: 1.15;
  word-break: break-word;
}

.chart-shell {
  position: relative;
  min-width: 0;
}

.chart-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
}

.range-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1 1 auto;
  margin: 0 0 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.range-tabs::-webkit-scrollbar {
  display: none;
}

.range-tabs button {
  position: relative;
  flex: 0 0 auto;
  min-width: 68px;
  border: 0;
  border-right: 1px solid #d6ddd8;
  border-radius: 0;
  padding: 0 18px 11px;
  background: transparent;
  color: #5e6762;
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: 0;
  cursor: pointer;
}

.range-tabs button:first-child {
  padding-left: 0;
}

.range-tabs button:last-child {
  border-right: 0;
}

.range-tabs button.active {
  color: #1769e0;
}

.range-tabs button.active::after {
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 4px;
  border-radius: 4px 4px 0 0;
  background: #1769e0;
  content: "";
}

.range-tabs button:first-child.active::after {
  left: 0;
}

.range-tabs button:disabled {
  color: #a4aca7;
  cursor: default;
}

.range-tabs.compact {
  margin-bottom: 10px;
}

.range-tabs.compact button {
  min-width: 58px;
  padding-right: 14px;
  padding-left: 14px;
  font-size: 15px;
}

.range-tabs.compact button:first-child {
  padding-left: 0;
}

#hypeChart,
#btcMarketChart {
  display: block;
  width: 100%;
  height: 260px;
  border-radius: 6px;
  background: #fbfcfb;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  z-index: 4;
  min-width: 172px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 20px rgba(33, 39, 34, 0.14);
  color: var(--ink);
  font-size: 15px;
  pointer-events: none;
  text-align: left;
  white-space: nowrap;
}

.chart-toolbar .chart-tooltip[hidden] {
  display: block;
  visibility: hidden;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: inline;
}

.chart-tooltip strong {
  margin-right: 10px;
  color: var(--ink);
  font-weight: 850;
}

.chart-tooltip span {
  color: #5e6762;
  font-weight: 800;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head p {
  margin-top: 5px;
  font-size: 13px;
}

.flow-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.flow-stats > div {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfb;
}

.flow-stats span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.flow-stats strong {
  font-size: 20px;
}

#flowChart {
  display: block;
  width: 100%;
  height: 260px;
  border-radius: 6px;
  background: #fbfcfb;
  cursor: crosshair;
}

.breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.flow-row,
.sentiment-row,
.news-item,
.alert-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.flow-row {
  display: grid;
  grid-template-columns: 58px 1fr 84px;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 10px;
}

.flow-bar {
  height: 8px;
  border-radius: 999px;
  background: #e9ede8;
  overflow: hidden;
}

.flow-bar span {
  display: block;
  width: var(--w);
  height: 100%;
  margin-left: var(--ml);
  border-radius: 999px;
  background: var(--bar);
}

.value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.sentiment-board {
  display: grid;
  gap: 10px;
}

.sentiment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 11px 12px;
}

.sentiment-row div {
  display: grid;
  gap: 4px;
}

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

.sentiment-row b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f4f1;
}

.segmented button {
  min-width: 54px;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(31, 37, 32, 0.08);
}

.alert-list {
  max-height: 710px;
  overflow: auto;
  padding-right: 4px;
}

.news-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
  gap: 12px;
}

.topic-news-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.topic-news-section + .topic-news-section {
  margin-top: 0;
}

.topic-news-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f7faf8;
}

.topic-news-head strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
}

.topic-news-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.topic-news-list {
  display: grid;
  max-height: 680px;
  overflow: auto;
}

.news-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.topic-news-list .news-item:last-child {
  border-bottom: 0;
}

.news-item:hover {
  border-color: #b8c5bd;
  box-shadow: inset 3px 0 0 var(--teal);
  transform: translateY(-1px);
}

.news-title {
  display: block;
  color: var(--ink);
  font-weight: 900;
  line-height: 1.35;
}

.news-item:hover .news-title {
  color: var(--teal);
}

.news-meta,
.news-impact {
  margin-top: 6px;
  font-size: 12px;
}

.news-body p {
  margin-top: 8px;
  color: #404841;
  font-size: 13px;
  line-height: 1.45;
}

.news-impact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stock-panel {
  margin-top: 14px;
}

.stock-table {
  display: grid;
  gap: 8px;
}

.stock-header,
.stock-row.rich {
  display: grid;
  grid-template-columns: 96px 76px 96px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.stock-header {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.stock-row.rich {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: inherit;
  text-decoration: none;
}

.stock-row strong,
.stock-row b {
  font-variant-numeric: tabular-nums;
}

.quote-cell {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.quote-cell small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-news {
  display: grid;
  gap: 4px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
}

.stock-news-link,
.stock-news-title {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-news-link:hover {
  color: var(--teal);
  text-decoration: underline;
}

.stock-news small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.alert-item {
  display: block;
  padding: 12px;
  text-decoration: none;
}

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

.alert-item strong {
  display: block;
  margin-top: 5px;
  line-height: 1.35;
}

.alert-item p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.alert-item.critical {
  border-left: 4px solid var(--red);
}

.alert-item.warn {
  border-left: 4px solid var(--amber);
}

.alert-item.info {
  border-left: 4px solid var(--teal);
}

.daily-brief {
  min-height: 240px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
  color: #303832;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.positive-text {
  color: var(--green);
}

.negative-text {
  color: var(--red);
}

.neutral-text {
  color: var(--muted);
}

.empty,
.error {
  min-height: 76px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .today-brief,
  .core-grid,
  .hype-layout,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

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

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

  .data-health {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .news-list {
    grid-template-columns: 1fr;
  }

  .data-health {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
  }

  .metric-card {
    min-height: 104px;
    padding: 12px;
  }

  .metric-card span,
  .metric-card small {
    font-size: 11px;
    line-height: 1.25;
  }

  .metric-card strong {
    font-size: 22px;
  }

  .brief-side,
  .breakdown,
  .hype-stats,
  .flow-stats,
  .flow-stats {
    grid-template-columns: 1fr;
  }

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

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .stock-header {
    display: none;
  }

  .stock-row.rich {
    grid-template-columns: 76px minmax(0, 1fr) 88px;
  }

  .stock-news {
    grid-column: 1 / -1;
  }

  .stock-news-link,
  .stock-news-title,
  .stock-news small {
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .kpi-group {
    grid-template-columns: 1fr;
  }
}
