:root {
  color-scheme: dark;
  --bg: #080d12;
  --surface: #101822;
  --surface-2: #131f2c;
  --surface-3: #0d141c;
  --text: #eef4fb;
  --muted: #8fa1b7;
  --border: #263445;
  --accent: #f5b642;
  --accent-2: #4ab8ff;
  --positive: #32d27c;
  --negative: #ff5d73;
  --neutral: #a9b6c6;
  --shadow: rgba(0, 0, 0, 0.28);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #edf2f7;
  --surface-3: #e7edf4;
  --text: #182331;
  --muted: #607083;
  --border: #d3dce7;
  --accent: #b97800;
  --accent-2: #006fbf;
  --positive: #087a46;
  --negative: #c93650;
  --neutral: #516073;
  --shadow: rgba(36, 48, 64, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(245, 182, 66, 0.08), transparent 240px),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .topbar,
body.auth-locked .terminal-shell,
body.auth-locked .footer-bar {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

body:not(.auth-locked) .auth-gate {
  display: none;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 52px var(--shadow);
}

.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  box-shadow: 0 14px 32px rgba(0, 98, 255, 0.28);
}

.auth-panel h2 {
  font-size: 1.28rem;
}

.auth-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.auth-input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  outline: none;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-button {
  min-width: 72px;
  height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 720;
  cursor: pointer;
}

.auth-button:hover {
  filter: brightness(1.05);
}

.auth-error {
  min-height: 20px;
  color: var(--negative);
  font-size: 0.88rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
}

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

.brand-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 98, 255, 0.22);
}

.brand-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.terminal-kicker,
.panel-label,
.data-badge,
.status-pill,
.date-label,
.ticker-tag,
.news-meta,
.footer-bar {
  font-family: var(--mono);
  letter-spacing: 0;
}

.terminal-kicker,
.panel-label {
  color: var(--accent);
  font-size: 0.72rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.6rem;
  font-weight: 760;
}

h2 {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 720;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.status-pill,
.data-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  background: var(--surface-3);
  font-size: 0.72rem;
  white-space: nowrap;
}

.date-label {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

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

.icon-button:active {
  transform: translateY(1px);
}

.app-menu {
  position: relative;
  flex: 0 0 auto;
}

.app-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  width: 190px;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 42px var(--shadow);
}

.app-menu-panel[hidden],
.modal-backdrop[hidden] {
  display: none;
}

.menu-item {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.menu-item:hover,
.menu-item:focus-visible {
  outline: none;
  background: var(--surface-2);
  color: var(--accent);
}

.menu-switch {
  font-family: var(--sans);
}

.menu-state {
  min-width: 36px;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.72rem;
  text-align: right;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(8px);
}

.modal-panel {
  width: min(560px, 100%);
  max-height: min(680px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 60px var(--shadow);
}

.modal-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-header h2 {
  margin-top: 0;
}

.modal-content {
  display: grid;
  gap: 14px;
  padding: 16px;
  color: var(--text);
  font-size: 0.94rem;
}

.modal-content p,
.modal-content li {
  color: var(--text);
}

.modal-content .modal-note,
.modal-content .copyright-line {
  color: var(--muted);
  font-size: 0.86rem;
}

.version-block {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.version-block strong {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.86rem;
}

.version-block ul {
  margin: 0;
  padding-left: 18px;
}

.terminal-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto;
}

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

.metric-panel,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 40px var(--shadow);
}

.metric-panel {
  min-height: 112px;
  display: grid;
  gap: 10px;
  padding: 16px;
}

.metric-panel strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.3rem;
}

.metric-panel small {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.86rem;
}

.board-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 12px;
}

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

.rates-panel,
.text-panel {
  grid-column: span 1;
}

.rates-panel {
  grid-column: span 2;
}

.focus-panel,
.events-panel,
.risk-panel,
.news-panel {
  grid-column: span 1;
}

.strategy-panel {
  grid-column: span 2;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

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

.rate-card {
  min-width: 0;
  min-height: 178px;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.rate-pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.rate-pair strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.95rem;
}

.ticker-tag {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.68rem;
}

.rate-value {
  font-family: var(--mono);
  font-size: 1.72rem;
  font-weight: 780;
  line-height: 1;
  overflow-wrap: anywhere;
}

.rate-change {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.84rem;
}

.up {
  color: var(--positive);
}

.down {
  color: var(--negative);
}

.flat {
  color: var(--neutral);
}

.rate-range,
.rate-comment {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.rate-range {
  font-family: var(--mono);
}

.stack-list,
.news-list {
  display: grid;
  gap: 10px;
}

.driver-item,
.news-item,
.event-item,
.focus-item,
.risk-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.item-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
}

.impact {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 4px;
  color: var(--bg);
  background: var(--accent);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.driver-item p,
.news-item p,
.event-item p,
.focus-item p,
.risk-item p,
.brief-text {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.source-link {
  width: fit-content;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.75rem;
  text-decoration: none;
}

.source-link:hover {
  color: var(--accent);
}

.news-link-card {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.news-link-card:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--surface-2) 78%, var(--accent) 10%);
  transform: translateY(-1px);
}

.news-link-card:hover .source-link {
  color: var(--accent);
}

.news-link-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.focus-grid,
.risk-list {
  display: grid;
  gap: 10px;
}

.focus-value {
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 720;
}

.news-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--accent-2);
  font-size: 0.74rem;
}

.brief-text {
  color: var(--text);
  font-size: 0.98rem;
}

.text-panel {
  min-height: 232px;
}

.footer-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 0.72rem;
}

.error-state {
  border-color: color-mix(in srgb, var(--negative) 45%, var(--border));
}

@media (max-width: 980px) {
  .headline-grid,
  .board-grid,
  .rates-grid {
    grid-template-columns: 1fr;
  }

  .rates-panel,
  .news-panel,
  .strategy-panel {
    grid-column: span 1;
    grid-row: span 1;
  }
}

@media (max-width: 640px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }

  .topbar-meta {
    width: 100%;
    justify-content: space-between;
  }

  .app-menu-panel {
    right: 0;
  }

  .terminal-shell,
  .footer-bar {
    width: calc(100% - 20px);
  }

  .terminal-shell {
    margin-top: 10px;
  }

  .footer-bar {
    flex-direction: column;
  }

  .rate-value {
    font-size: 1.65rem;
  }
}
