:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --subtle: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --green: #11845b;
  --green-bg: #e8f6ef;
  --red: #c9342f;
  --red-bg: #fff0ef;
  --amber: #9a6a00;
  --amber-bg: #fff7db;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.05);
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 420px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(251, 251, 253, 0.84);
  backdrop-filter: saturate(180%) blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
}

.brand-mark {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0)),
    conic-gradient(from 220deg, #0071e3, #34c759, #ff3b30, #0071e3);
}

.topnav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  color: var(--muted);
  font-size: 14px;
}

.topnav a {
  transition: color 160ms ease;
}

.topnav a:hover {
  color: var(--text);
}

.refresh-button {
  justify-self: end;
  height: 36px;
  padding: 0 18px;
  border: 1px solid rgba(0, 113, 227, 0.2);
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 160ms ease, transform 160ms ease;
}

.refresh-button:hover,
.primary-action:hover {
  background: var(--blue-hover);
}

.refresh-button:active,
.primary-action:active {
  transform: scale(0.98);
}

.secondary-action,
.quiet-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.secondary-action:hover,
.quiet-button:hover {
  border-color: var(--border-strong);
  background: #ffffff;
}

.secondary-action.active,
.quiet-button.active {
  border-color: rgba(0, 113, 227, 0.18);
  background: rgba(0, 113, 227, 0.1);
  color: var(--blue);
}

main {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.8fr);
  gap: 32px;
  align-items: center;
  min-height: 360px;
  padding: 52px 0 36px;
}

.hero-copy {
  max-width: 680px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 14px;
  max-width: 760px;
  font-size: clamp(38px, 4vw, 56px);
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.16;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.hero-subtitle {
  max-width: 620px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.primary-action {
  height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 650;
  transition: background-color 160ms ease, transform 160ms ease;
}

.auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
}

.auto-refresh input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.hero-panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(154, 106, 0, 0.1);
}

.status-dot.ready {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(17, 132, 91, 0.1);
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(201, 52, 47, 0.1);
}

.hero-metric {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.hero-metric.primary {
  margin-bottom: 12px;
}

.metric-label {
  display: block;
  margin-bottom: 6px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 650;
}

.hero-metric strong {
  display: block;
  overflow: hidden;
  font-size: 22px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-detail {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.toolbar-section {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 56px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.75);
}

.insight-section {
  margin-bottom: 48px;
}

.control-section {
  scroll-margin-top: 82px;
}

.compact-heading {
  margin-bottom: 16px;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.25fr) repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.control-card,
.table-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.035);
}

.control-card {
  min-width: 0;
  padding: 14px;
}

.control-head,
.table-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.control-head {
  margin-bottom: 10px;
}

.control-head span,
.table-panel-head span {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.control-head small,
.table-panel-head small {
  display: block;
  margin-top: 2px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 650;
}

.focus-list {
  display: grid;
  gap: 8px;
}

.focus-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid rgba(0, 0, 0, 0.055);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.focus-row strong,
.focus-row span,
.focus-values b {
  display: block;
}

.focus-row strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-row span {
  overflow: hidden;
  margin-top: 2px;
  color: var(--subtle);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-row-expanded {
  align-items: flex-start;
  min-height: 64px;
}

.focus-row-expanded strong,
.focus-row-expanded span {
  white-space: normal;
}

.session-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.session-breakdown span {
  margin-top: 0;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.045);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
}

.focus-values {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 76px;
}

.focus-values b {
  max-width: 104px;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.value-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.045);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.value-chip.positive {
  background: var(--red-bg);
  color: var(--red);
}

.value-chip.negative {
  background: var(--green-bg);
  color: var(--green);
}

.value-chip.neutral,
.value-chip.flat {
  background: rgba(0, 0, 0, 0.045);
  color: var(--muted);
}

.status-dot-mini {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot-mini.ok {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(17, 132, 91, 0.1);
}

.status-dot-mini.warn {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(154, 106, 0, 0.12);
}

.focus-empty {
  min-height: 48px;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.control-grid + .insight-grid {
  margin-top: 14px;
}

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

.insight-card {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
}

.insight-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 750;
}

.insight-card strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.alert-banner {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.alert-banner.active {
  display: flex;
}

.alert-banner span {
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--amber-bg);
  color: var(--amber);
  font-size: 12px;
  font-weight: 750;
}

.alert-panel {
  margin: -32px 0 56px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
}

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

.alert-rule {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.alert-rule strong,
.alert-rule small {
  display: block;
}

.alert-rule strong {
  font-size: 14px;
}

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

.alert-rule input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.alert-rule input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.history-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.history-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.history-form label {
  min-width: 0;
}

.history-form label span {
  display: block;
  margin: 0 0 7px 4px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 750;
}

.history-form .search-input,
.history-form .select-input {
  width: 100%;
}

.history-form .primary-action {
  min-width: 92px;
  height: 40px;
}

.history-result {
  min-height: 118px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.history-result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.history-result-card strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.2;
}

.history-result-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-result-values {
  text-align: right;
}

.history-result-values b {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
}

.history-mini-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.history-mini-grid span {
  min-width: 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.86);
  color: var(--subtle);
  font-size: 11px;
  font-weight: 750;
}

.history-mini-grid strong {
  overflow: hidden;
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-error {
  min-height: 88px;
  padding: 28px;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segment {
  min-height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 160ms ease, color 160ms ease;
}

.segment:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.segment.active {
  background: var(--text);
  color: #ffffff;
}

.toolbar-right {
  display: grid;
  grid-template-columns: auto minmax(150px, 210px) auto minmax(128px, 150px) auto;
  gap: 10px;
  align-items: center;
}

.field-label {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
}

.search-input,
.select-input {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.search-input {
  padding: 0 14px;
}

.select-input {
  padding: 0 34px 0 14px;
}

.search-input:focus,
.select-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.content-section {
  margin-bottom: 72px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.section-note {
  max-width: 420px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.period-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.period-button {
  min-height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.period-button.active {
  background: var(--text);
  color: #ffffff;
}

.table-panel {
  overflow: hidden;
  margin-bottom: 16px;
}

.table-panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(251, 251, 253, 0.86);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.055);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  background: var(--surface-soft);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background-color 160ms ease;
}

.data-table tbody tr[data-detail-market-id],
.data-table tbody tr[data-detail-fx-code] {
  cursor: pointer;
}

.data-table tbody tr[data-detail-market-id]:hover,
.data-table tbody tr[data-detail-market-id]:focus-visible,
.data-table tbody tr[data-detail-fx-code]:hover,
.data-table tbody tr[data-detail-fx-code]:focus-visible {
  background: rgba(0, 113, 227, 0.055);
  outline: none;
}

.data-table td strong,
.data-table td span {
  display: block;
}

.data-table td strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
}

.data-table td span {
  margin-top: 2px;
  color: var(--subtle);
  font-size: 11px;
}

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

.market-card,
.fx-card,
.fx-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.035);
}

.market-card {
  display: flex;
  flex-direction: column;
  min-height: 258px;
  padding: 18px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.market-card:hover,
.market-card:focus-visible,
.fx-card[data-detail-fx-code]:hover,
.fx-card[data-detail-fx-code]:focus-visible {
  border-color: var(--border-strong);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.06);
  outline: none;
  transform: translateY(-2px);
}

.card-top,
.quote-row,
.range-row,
.fx-card-top,
.fx-rate-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.card-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  flex: none;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.open {
  background: var(--red-bg);
  color: var(--red);
}

.status-pill.closed {
  background: rgba(0, 0, 0, 0.045);
  color: var(--muted);
}

.card-actions {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 8px;
}

.watch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  color: var(--subtle);
  font-size: 17px;
  line-height: 1;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.watch-button:hover {
  border-color: var(--border-strong);
  transform: scale(1.03);
}

.watch-button.active {
  border-color: rgba(0, 113, 227, 0.18);
  background: rgba(0, 113, 227, 0.1);
  color: var(--blue);
}

.quote-row {
  align-items: end;
  margin-top: 22px;
}

.quote-value {
  font-size: 33px;
  font-weight: 750;
  line-height: 1;
  letter-spacing: 0;
}

.change-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 750;
}

.positive .change-badge,
.positive .direction-pill {
  background: var(--red-bg);
  color: var(--red);
}

.negative .change-badge,
.negative .direction-pill {
  background: var(--green-bg);
  color: var(--green);
}

.flat .change-badge,
.flat .direction-pill {
  background: rgba(0, 0, 0, 0.045);
  color: var(--muted);
}

.market-status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.sparkline-panel {
  margin: 18px 0 16px;
}

.sparkline-caption,
.sparkline-axis {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sparkline-caption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.sparkline-caption strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.sparkline-axis {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 650;
}

.chart-stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.chart-stat-row span {
  min-width: 0;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  color: var(--subtle);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.2;
}

.chart-stat-row strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--text);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sparkline-wrap {
  height: 72px;
  margin: 8px 0 4px;
}

.sparkline {
  display: block;
  width: 100%;
  height: 72px;
}

.sparkline .area {
  opacity: 0.12;
}

.positive .sparkline .line,
.positive .sparkline .area {
  stroke: var(--red);
  fill: var(--red);
}

.negative .sparkline .line,
.negative .sparkline .area {
  stroke: var(--green);
  fill: var(--green);
}

.flat .sparkline .line,
.flat .sparkline .area {
  stroke: var(--muted);
  fill: var(--muted);
}

.sparkline-panel.positive .sparkline .line,
.sparkline-panel.positive .sparkline .area {
  stroke: var(--red);
  fill: var(--red);
}

.sparkline-panel.negative .sparkline .line,
.sparkline-panel.negative .sparkline .area {
  stroke: var(--green);
  fill: var(--green);
}

.sparkline-panel.flat .sparkline .line,
.sparkline-panel.flat .sparkline .area {
  stroke: var(--muted);
  fill: var(--muted);
}

.sparkline-panel.positive .sparkline-caption strong {
  color: var(--red);
}

.sparkline-panel.negative .sparkline-caption strong {
  color: var(--green);
}

.sparkline .line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.range-row {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--muted);
  font-size: 12px;
}

.range-row strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 13px;
}

.card-detail-hint {
  margin-top: 12px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 750;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 40px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
}

.skeleton {
  overflow: hidden;
  position: relative;
  min-height: 258px;
}

.skeleton::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: shimmer 1.5s infinite;
  content: "";
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

.fx-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.fx-summary {
  min-height: 210px;
  padding: 24px;
}

.fx-summary strong {
  display: block;
  margin-bottom: 18px;
  font-size: 28px;
  line-height: 1.15;
}

.fx-summary p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.fx-card {
  display: flex;
  flex-direction: column;
  min-height: 196px;
  padding: 18px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.fx-card-top {
  align-items: center;
  margin-bottom: 20px;
}

.currency-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 34px;
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.08);
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.fx-card h3 {
  font-size: 16px;
}

.fx-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.fx-rate-row {
  align-items: end;
}

.fx-rate {
  font-size: 25px;
  font-weight: 750;
  line-height: 1.1;
}

.fx-reverse {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.fx-sparkline-panel {
  margin-top: 16px;
  margin-bottom: 0;
}

.fx-sparkline-wrap {
  height: 58px;
  margin: 8px 0 4px;
}

.fx-sparkline-wrap .sparkline {
  height: 58px;
}

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

.fx-change {
  min-width: 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.045);
  color: var(--muted);
}

.fx-change span {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 700;
}

.fx-change strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fx-change.positive {
  background: var(--red-bg);
  color: var(--red);
}

.fx-change.negative {
  background: var(--green-bg);
  color: var(--green);
}

body.detail-open {
  overflow: hidden;
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(245, 245, 247, 0.76);
  backdrop-filter: saturate(180%) blur(18px);
}

.detail-backdrop[hidden] {
  display: none;
}

.detail-panel {
  position: relative;
  width: min(960px, 100%);
  max-height: min(840px, calc(100vh - 48px));
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.14);
}

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.detail-close:hover,
.detail-close:focus-visible {
  border-color: var(--border-strong);
  background: rgba(0, 0, 0, 0.07);
  color: var(--text);
  outline: none;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 48px;
  align-items: flex-start;
  padding-right: 42px;
}

.detail-head h2 {
  margin-bottom: 6px;
}

.detail-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.detail-quote-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin: 24px 0 16px;
}

.detail-quote-row strong {
  display: block;
  font-size: 42px;
  line-height: 1;
}

.detail-change {
  min-width: 128px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.045);
  color: var(--muted);
  text-align: right;
}

.detail-change span,
.detail-change b {
  display: block;
}

.detail-change span {
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 750;
}

.detail-change b {
  font-size: 20px;
  line-height: 1.15;
}

.detail-change.positive {
  background: var(--red-bg);
  color: var(--red);
}

.detail-change.negative {
  background: var(--green-bg);
  color: var(--green);
}

.detail-period-control {
  width: fit-content;
  margin-bottom: 16px;
}

.detail-chart {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.chart-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.detail-sparkline-wrap {
  height: 132px;
  margin: 12px 0 6px;
}

.detail-sparkline-wrap .sparkline {
  height: 132px;
}

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

.detail-stat {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
}

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

.detail-stat span {
  margin-bottom: 6px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 750;
}

.detail-stat strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insurance-context {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(0, 113, 227, 0.04);
}

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

.insurance-grid article {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(0, 113, 227, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
}

.insurance-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.insurance-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.page-footer {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 10px 0 40px;
  color: var(--subtle);
  font-size: 12px;
  text-align: center;
}

.compact-mode .hero-section {
  min-height: auto;
  padding: 48px 0 40px;
}

.compact-mode h1 {
  font-size: clamp(36px, 4vw, 52px);
}

.compact-mode .hero-subtitle {
  margin-bottom: 18px;
}

.compact-mode .content-section {
  margin-bottom: 48px;
}

.compact-mode .market-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-mode .market-card {
  min-height: 218px;
  padding: 16px;
}

.compact-mode .quote-value {
  font-size: 27px;
}

.compact-mode .sparkline-wrap {
  height: 54px;
  margin: 6px 0 4px;
}

.compact-mode .sparkline {
  height: 54px;
}

.compact-mode .fx-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-mode .fx-card {
  min-height: 184px;
}

@media (max-width: 1040px) {
  .hero-section {
    grid-template-columns: 1fr;
    gap: 32px;
    align-items: stretch;
    min-height: auto;
    padding-top: 64px;
  }

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

  .toolbar-right {
    grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto;
  }

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

  .compact-mode .market-grid,
  .compact-mode .fx-grid,
  .control-grid,
  .insight-grid,
  .alert-rule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fx-layout {
    grid-template-columns: 1fr;
  }

  .history-panel {
    grid-template-columns: 1fr;
  }

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

  .history-form .primary-action {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 0 18px;
  }

  .topnav {
    display: none;
  }

  main,
  .page-footer {
    width: min(100% - 28px, 1180px);
  }

  .hero-section {
    gap: 18px;
    padding: 24px 0 24px;
  }

  h1 {
    font-size: 34px;
  }

  h2 {
    font-size: 27px;
  }

  .hero-subtitle {
    margin-bottom: 16px;
    font-size: 15px;
  }

  .hero-actions {
    gap: 8px;
  }

  .primary-action {
    height: 38px;
    padding: 0 14px;
    font-size: 13px;
  }

  .secondary-action,
  .quiet-button,
  .auto-refresh {
    min-height: 38px;
    padding: 0 12px;
    font-size: 13px;
  }

  .hero-panel {
    padding: 14px;
  }

  .status-line {
    margin-bottom: 10px;
  }

  .hero-metric {
    padding: 10px;
  }

  .hero-metric.primary {
    margin-bottom: 8px;
  }

  .hero-metrics-grid {
    gap: 8px;
  }

  .hero-metric strong {
    font-size: 16px;
  }

  .metric-detail {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .hero-panel,
  .market-card,
  .fx-card,
  .fx-summary,
  .control-card,
  .table-panel {
    border-radius: var(--radius-md);
  }

  .toolbar-right {
    grid-template-columns: 1fr;
  }

  .period-control {
    width: 100%;
    justify-content: space-between;
  }

  .period-button {
    flex: 1;
  }

  .history-form,
  .history-result-card,
  .history-mini-grid {
    grid-template-columns: 1fr;
  }

  .history-panel {
    padding: 14px;
  }

  .history-result-values {
    text-align: left;
  }

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

  .field-label {
    margin-top: 6px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-note {
    text-align: left;
  }

  .detail-backdrop {
    align-items: end;
    padding: 12px;
  }

  .detail-panel {
    max-height: calc(100vh - 24px);
    padding: 18px;
  }

  .detail-head {
    flex-direction: column;
    gap: 10px;
    padding-right: 42px;
  }

  .detail-quote-row,
  .detail-stat-grid,
  .insurance-grid {
    grid-template-columns: 1fr;
  }

  .detail-quote-row {
    align-items: start;
  }

  .detail-quote-row strong {
    font-size: 34px;
  }

  .detail-change {
    width: 100%;
    text-align: left;
  }

  .detail-period-control {
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
  }

  .detail-period-control .period-button {
    flex: 0 0 auto;
  }

  .detail-sparkline-wrap,
  .detail-sparkline-wrap .sparkline {
    height: 104px;
  }

  .market-grid,
  .fx-grid {
    grid-template-columns: 1fr;
  }

  .compact-mode .market-grid,
  .compact-mode .fx-grid,
  .control-grid,
  .insight-grid,
  .alert-rule-grid {
    grid-template-columns: 1fr;
  }

  .quote-value {
    font-size: 30px;
  }

  .card-top,
  .quote-row {
    gap: 12px;
  }
}

@media (max-width: 420px) {
  .brand span:last-child {
    max-width: 144px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .refresh-button {
    padding: 0 14px;
  }

  h1 {
    font-size: 32px;
  }

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

  .quote-row,
  .fx-rate-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .change-badge,
  .fx-reverse {
    align-items: flex-start;
    text-align: left;
  }
}
