:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-soft: #eef2ea;
  --line: #d9ded4;
  --text: #17201a;
  --muted: #657167;
  --muted-2: #8b958d;
  --green: #0f766e;
  --green-soft: #dbeeea;
  --amber: #b66b16;
  --amber-soft: #f4ead7;
  --blue: #315f8c;
  --blue-soft: #e1ebf3;
  --red: #b42318;
  --shadow: 0 14px 42px rgba(31, 41, 34, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcf8;
}

.brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

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

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.nav-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-toolbar,
.tile-header,
.event-head,
.event-meta,
.source-row,
.calendar-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.tile-header p,
.section-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--green);
  font-weight: 800;
}

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

h1 {
  font-size: 34px;
  line-height: 1.12;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 16px;
  line-height: 1.28;
}

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

.sync-state {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.sync-state.offline {
  background: var(--amber-soft);
  color: var(--amber);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(32, 41, 34, 0.05);
}

.icon-button:hover {
  border-color: var(--green);
  color: var(--green);
}

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

.metric-block,
.tile,
.search-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-block {
  min-height: 118px;
  padding: 18px;
}

.metric-block span {
  color: var(--muted);
  font-size: 13px;
}

.metric-block strong {
  display: block;
  margin-top: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 30px;
  line-height: 1;
}

.metric-block small {
  display: block;
  margin-top: 10px;
  color: var(--muted-2);
}

.view {
  display: none;
  margin-top: 18px;
}

.view.active {
  display: block;
}

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

.tile {
  min-width: 0;
  min-height: 220px;
  padding: 18px;
}

.tile-large {
  grid-column: span 2;
  grid-row: span 2;
  min-height: 520px;
}

.tile-wide {
  grid-column: 1 / -1;
}

.accent-tile {
  background: linear-gradient(180deg, #fff, #fff9ef);
}

.tile-header {
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.warm {
  background: var(--amber-soft);
  color: var(--amber);
}

.topic-list,
.event-list,
.sector-list,
.mini-list,
.source-list,
.report-grid,
.calendar-grid,
.news-feed {
  display: grid;
  gap: 10px;
}

.topic-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 74px;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdf9;
}

.clickable-card {
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.clickable-card:hover,
.clickable-card:focus-visible {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 12px 30px rgba(15, 118, 110, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.compact .topic-row {
  min-height: 64px;
}

.rank {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--green);
  font-weight: 800;
}

.topic-body {
  min-width: 0;
}

.topic-body strong,
.source-row strong,
.mini-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-body p,
.event-row p,
.report-card p,
.calendar-card p,
.mini-row span {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.score {
  min-width: 0;
  text-align: right;
}

.score strong {
  display: block;
  font-size: 19px;
}

.score small {
  color: var(--muted-2);
}

.event-row,
.news-row,
.mini-row,
.source-row,
.report-card,
.calendar-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

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

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

.news-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 44px;
  gap: 12px;
  align-items: start;
  background: #fcfdf9;
}

.news-row time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.news-row div {
  min-width: 0;
}

.news-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-row p {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.news-row span {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  color: var(--muted-2);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-row b {
  color: var(--blue);
  font-size: 18px;
  text-align: right;
}

.event-head {
  color: var(--muted);
  font-size: 12px;
}

.event-type {
  color: var(--amber);
  font-weight: 800;
}

.event-row h3 {
  margin-top: 8px;
}

.event-meta {
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.event-meta strong {
  color: var(--amber);
  font-size: 20px;
}

.sector-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: center;
  min-height: 30px;
  font-size: 13px;
}

.sector-row div {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.sector-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.section-toolbar {
  align-items: center;
  margin-bottom: 16px;
}

.search-box {
  display: grid;
  grid-template-columns: 22px minmax(190px, 320px);
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  color: var(--muted);
  box-shadow: none;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.market-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.market-topics {
  grid-column: 1 / -1;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(12px, 1fr));
  align-items: end;
  gap: 8px;
  height: 180px;
  padding-top: 8px;
}

.bar {
  min-height: 10px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #315f8c, #8fb5d4);
}

.source-row {
  align-items: center;
}

.source-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.source-row span:last-child {
  color: var(--green);
  font-weight: 800;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 999px;
  background: #2f9e44;
}

.status-dot.warn {
  background: var(--amber);
}

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

.report-card {
  min-height: 190px;
}

.report-card span,
.calendar-card span,
.calendar-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.report-card h3 {
  margin-top: 14px;
}

.report-card strong {
  display: block;
  margin-top: 18px;
  color: var(--blue);
  font-size: 24px;
}

.calendar-grid {
  grid-template-columns: 1fr;
}

.calendar-card {
  align-items: center;
}

.calendar-card > span {
  display: grid;
  width: 74px;
  min-height: 54px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.calendar-card div {
  min-width: 0;
  flex: 1;
}

.calendar-card em {
  min-width: 72px;
  text-align: right;
}

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.detail-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(31, 41, 34, 0.22);
}

.detail-dialog::backdrop {
  background: rgba(23, 32, 26, 0.34);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-head span {
  display: block;
  margin-bottom: 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.dialog-head h2 {
  max-width: 560px;
}

#detailSummary {
  padding: 18px 20px 0;
  color: var(--muted);
  line-height: 1.65;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 20px 0;
}

.detail-stats span {
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.detail-links {
  display: grid;
  gap: 10px;
  max-height: 340px;
  margin-top: 16px;
  padding: 0 20px 20px;
  overflow: auto;
}

.detail-links a {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.detail-links a:hover {
  border-color: var(--green);
}

.detail-links a strong,
.detail-links a span {
  display: block;
}

.detail-links a span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .bento-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tile-large {
    grid-column: span 1;
  }

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

  .news-feed,
  .event-list-dense {
    grid-template-columns: 1fr;
  }
}

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

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

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 16px;
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 58px;
    text-align: center;
  }

  .metric-strip,
  .market-layout {
    grid-template-columns: 1fr 1fr;
  }

  .market-topics {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  h1 {
    font-size: 28px;
  }

  .metric-strip,
  .bento-grid,
  .market-layout,
  .report-grid,
  .news-feed,
  .event-list-dense,
  .nav-list {
    grid-template-columns: 1fr;
  }

  .tile-large {
    min-height: auto;
  }

  .search-box {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .topic-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .score {
    grid-column: 2;
    text-align: left;
  }

  .calendar-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-card em {
    text-align: left;
  }

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

  .news-row b {
    text-align: left;
  }
}
