:root {
  color-scheme: dark;
  --bg: #071014;
  --bg-soft: #0c171b;
  --panel: #101d21;
  --panel-strong: #14272b;
  --ink: #edf7f5;
  --muted: #9db4af;
  --line: rgba(203, 229, 222, 0.16);
  --accent: #42d19b;
  --accent-2: #f2c14e;
  --danger: #ff6b5e;
  --orange: #f49c45;
  --blue: #67b7ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  --font: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef4f1;
  --bg-soft: #f7faf8;
  --panel: #ffffff;
  --panel-strong: #eaf2ee;
  --ink: #17231f;
  --muted: #61736e;
  --line: rgba(18, 52, 43, 0.15);
  --shadow: 0 24px 60px rgba(35, 76, 64, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(66, 209, 155, 0.16), transparent 30%),
    linear-gradient(135deg, var(--bg), var(--bg-soft));
  font-family: var(--font);
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0 18px;
}

.brand-block {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  display: block;
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

h1 span {
  color: var(--accent-2);
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
}

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

.primary-button,
.ghost-button,
.key-entry button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: none;
}

.primary-button {
  border-color: transparent;
  color: #071014;
  background: var(--accent);
  font-weight: 800;
}

.ghost-button:hover,
.key-entry button:hover,
.segmented-control button:hover {
  border-color: rgba(66, 209, 155, 0.55);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.hero-panel,
.map-panel,
.signals-panel,
.markets-panel,
.watchlist-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 29, 33, 0.88);
  box-shadow: var(--shadow);
}

:root[data-theme="light"] .hero-panel,
:root[data-theme="light"] .map-panel,
:root[data-theme="light"] .signals-panel,
:root[data-theme="light"] .markets-panel,
:root[data-theme="light"] .watchlist-panel {
  background: rgba(255, 255, 255, 0.92);
}

.hero-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(520px, 0.9fr);
  gap: 18px;
  padding: 18px;
}

.overview-copy {
  min-width: 0;
}

.overview-copy h2 {
  margin-bottom: 8px;
  max-width: 780px;
  font-size: 30px;
}

.overview-copy p:last-child {
  max-width: 740px;
  margin-bottom: 0;
  color: var(--muted);
}

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

.metric-card,
.market-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: var(--panel-strong);
}

.metric-card span,
.market-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong,
.market-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 28px;
  line-height: 1.05;
}

.metric-card small,
.market-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-card.critical strong {
  color: var(--danger);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 0;
}

.panel-heading.compact {
  align-items: center;
}

.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--panel-strong);
  font-size: 12px;
  font-weight: 700;
}

.map-panel {
  min-height: 650px;
}

.map-canvas {
  position: relative;
  margin: 14px 16px 0;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #071014;
}

.map-canvas svg {
  display: block;
  width: 100%;
  height: 430px;
}

.land {
  fill: rgba(181, 215, 205, 0.28);
  stroke: rgba(222, 242, 236, 0.34);
  stroke-width: 1.2;
}

.grid-line {
  fill: none;
  stroke: rgba(226, 242, 238, 0.12);
  stroke-width: 1;
}

.route {
  fill: none;
  stroke: rgba(242, 193, 78, 0.72);
  stroke-width: 3;
  stroke-dasharray: 7 10;
}

.map-marker {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transform: translate(-50%, -50%);
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  padding: 5px 9px 5px 7px;
  color: #f7fffd;
  background: rgba(10, 20, 24, 0.74);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.map-marker span {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(66, 209, 155, 0.16);
}

.map-marker.high span {
  background: var(--danger);
  box-shadow: 0 0 0 8px rgba(255, 107, 94, 0.18);
  animation: pulse 1.6s infinite;
}

.map-marker.medium span {
  background: var(--accent-2);
  box-shadow: 0 0 0 7px rgba(242, 193, 78, 0.17);
}

.map-marker.low span {
  background: var(--blue);
  box-shadow: 0 0 0 6px rgba(103, 183, 255, 0.16);
}

@keyframes pulse {
  0% {
    filter: drop-shadow(0 0 0 rgba(255, 107, 94, 0));
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(255, 107, 94, 0.85));
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(255, 107, 94, 0));
  }
}

.map-detail {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  margin: 12px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-strong);
}

.map-detail strong {
  color: var(--accent-2);
}

.map-detail span {
  color: var(--muted);
}

.signals-panel {
  min-height: 650px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-width: 178px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented-control button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  color: #071014;
  background: var(--accent);
}

.news-list {
  display: grid;
  gap: 10px;
  max-height: 580px;
  overflow: auto;
  padding: 14px 16px 16px;
}

.news-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: var(--panel-strong);
}

.news-score {
  display: grid;
  place-items: center;
  align-self: start;
  min-height: 42px;
  border-radius: var(--radius);
  color: #071014;
  background: var(--accent);
  font-size: 17px;
  font-weight: 900;
}

.news-score.high {
  background: var(--danger);
}

.news-score.medium {
  background: var(--accent-2);
}

.news-content {
  min-width: 0;
}

.news-meta {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.news-content a {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
  text-decoration: none;
}

.news-content a:hover {
  color: var(--accent);
}

.news-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tag.priority {
  color: #071014;
  border-color: transparent;
  background: var(--accent-2);
}

.markets-panel,
.watchlist-panel {
  grid-column: 2;
}

.api-row {
  margin: 14px 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-strong);
}

.api-row label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.api-row p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.key-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px;
  gap: 8px;
}

.key-entry input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--ink);
  background: var(--bg-soft);
}

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

.market-card.emphasis {
  border-color: rgba(242, 193, 78, 0.4);
}

.market-card.emphasis strong {
  color: var(--accent-2);
}

.quote-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px 16px;
}

.quote-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--panel-strong);
}

.quote-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.quote-tile strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
}

.quote-tile small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

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

.chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px 0;
}

.watch-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--panel-strong);
  font-size: 12px;
  font-weight: 800;
}

.watch-chip.core {
  color: #071014;
  border-color: transparent;
  background: var(--accent-2);
}

.source-notes {
  display: grid;
  gap: 10px;
  padding: 12px 16px 16px;
}

.source-notes article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: var(--panel-strong);
}

.source-notes strong,
.source-notes span {
  display: block;
}

.source-notes span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  background: var(--panel-strong);
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .markets-panel,
  .watchlist-panel {
    grid-column: auto;
  }

  .hero-panel {
    gap: 14px;
  }

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

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1680px);
    padding-top: 10px;
  }

  .topbar,
  .panel-heading,
  .panel-heading.compact {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .segmented-control {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .overview-copy h2 {
    font-size: 24px;
  }

  .score-strip,
  .market-grid,
  .quote-strip {
    grid-template-columns: 1fr;
  }

  .map-canvas,
  .map-canvas svg {
    min-height: 330px;
    height: 330px;
  }

  .map-marker {
    justify-content: center;
    width: 28px;
    min-height: 28px;
    padding: 0;
    font-size: 11px;
  }

  .map-marker {
    font-size: 0;
  }

  .map-marker span {
    width: 10px;
    height: 10px;
  }

  .map-detail,
  .news-item {
    grid-template-columns: 1fr;
  }

  .news-score {
    width: 54px;
  }

  .key-entry {
    grid-template-columns: 1fr;
  }
}
