:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border: #d9dde3;
  --text: #111418;
  --text-muted: #5f6672;
  --accent: #1f3a5f;
  --up: #15803d;
  --up-bg: #e8f5ec;
  --down: #b91c1c;
  --down-bg: #fbeaea;
  --flat: #6b7280;
  --flat-bg: #eef0f3;
  --warn: #a16207;
  --warn-bg: #fdf3d7;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

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

button,
input,
select {
  font: inherit;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--flat-bg);
  padding: 0 3px;
  border-radius: 2px;
}

.is-hidden {
  display: none !important;
}

/* Top bar */
.topbar {
  background: var(--accent);
  color: #fff;
  border-bottom: 2px solid #15293f;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 12px;
  max-width: 1400px;
  margin: 0 auto;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 11px;
  color: #c7d2e0;
}

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

.clock {
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-alt);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-small {
  padding: 3px 8px;
  font-size: 12px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #2a4d7d;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.45);
  color: inherit;
}

.topbar .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.dialog .btn-ghost {
  border-color: var(--border);
  color: var(--text);
}

.dialog .btn-ghost:hover {
  background: var(--surface-alt);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-muted {
  background: var(--flat-bg);
  color: var(--flat);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-ok {
  background: var(--up-bg);
  color: var(--up);
}

.badge-platform {
  background: #e3e8ef;
  color: var(--accent);
  font-weight: 600;
}

/* Ticker */
.ticker {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.ticker-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px dashed var(--border);
  flex-wrap: wrap;
}

.ticker-label {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.ticker-viewport {
  overflow: hidden;
  white-space: nowrap;
  padding: 7px 0;
  background: var(--surface-alt);
}

.ticker-track {
  display: inline-flex;
  gap: 36px;
  padding-left: 100%;
  animation: ticker-scroll 60s linear infinite;
  will-change: transform;
}

.ticker-track[data-size="xs"] {
  animation-duration: 36s;
}

.ticker-track[data-size="s"] {
  animation-duration: 72s;
}

.ticker-track[data-size="m"] {
  animation-duration: 120s;
}

.ticker-track[data-size="l"] {
  animation-duration: 180s;
}

.ticker-viewport:hover .ticker-track,
.ticker-track.is-paused {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.ticker-item .ticker-title {
  font-weight: 700;
}

.ticker-item .ticker-summary {
  color: var(--text-muted);
}

.ticker-item .ticker-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.ticker-empty {
  color: var(--text-muted);
  padding-left: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track {
    animation: none;
    padding-left: 12px;
    flex-wrap: wrap;
    white-space: normal;
    gap: 8px 24px;
  }
}

/* Layout */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    gap: 12px;
  }

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

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.card-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.source-label {
  font-weight: 600;
  color: var(--text);
}

.updated {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.sub-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-size: 12.5px;
  font-weight: 700;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.sub-head .source-label {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Status / states */
.status {
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  border: 1px solid transparent;
}

.status-error {
  background: var(--down-bg);
  border-color: #efc1c1;
  color: var(--down);
}

.status-warn {
  background: var(--warn-bg);
  border-color: #efdca1;
  color: var(--warn);
}

.status-info {
  background: var(--flat-bg);
  border-color: var(--border);
  color: var(--text-muted);
}

.state {
  padding: 14px 8px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

.state-error {
  color: var(--down);
  font-style: normal;
}

.state-waiting {
  color: var(--warn);
  font-style: normal;
}

.state-loading::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 8px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
}

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

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

.data-table th,
.data-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table thead th {
  background: var(--surface-alt);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}

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

.data-table tbody tr:hover td {
  background: #fbfcfd;
}

.data-table .num,
.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.data-table td.state {
  text-align: left;
  white-space: normal;
  font-family: var(--sans);
}

.data-table td.state .state-inner {
  display: inline-block;
  position: sticky;
  left: 8px;
  max-width: calc(100vw - 64px);
}

/* Kalender: kolom tetap terbaca, tanpa gulir horizontal yang menutupi angka. */
.cal-board {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.cal-head,
.cal-row {
  display: grid;
  grid-template-columns: 4.2rem 4.6rem 4.4rem minmax(8rem, 1.6fr) minmax(5.5rem, 0.8fr) minmax(5.5rem, 0.8fr) minmax(5.5rem, 0.9fr) minmax(7.5rem, 0.9fr);
  gap: 6px 10px;
  align-items: center;
  padding: 8px 12px;
}

.cal-head {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.cal-head span:nth-child(n + 5) {
  text-align: right;
}

.cal-row + .cal-row {
  border-top: 1px solid var(--border);
}

.cal-time,
.cal-ccy,
.cal-num-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.cal-time {
  font-weight: 700;
}

.cal-stars {
  letter-spacing: 0.08em;
  font-size: 13px;
  line-height: 1;
}

.cal-stars-3 {
  color: var(--warn);
}

.cal-stars-2 {
  color: #c4a15a;
}

.cal-ccy {
  font-weight: 700;
}

.cal-title {
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cal-num {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 0;
}

.cal-num-label {
  display: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--sans);
}

.cal-num-value {
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: right;
}

.cal-num.up .cal-num-value {
  color: var(--up);
  font-weight: 700;
}

.cal-num.down .cal-num-value {
  color: var(--down);
  font-weight: 700;
}

.cal-row .pill {
  justify-self: start;
}

.cal-empty {
  margin: 0;
  padding: 14px 12px;
  color: var(--text-muted);
}

@media (max-width: 860px) {
  .cal-head {
    display: none;
  }

  .cal-row {
    grid-template-columns: auto auto auto minmax(0, 1fr);
    grid-template-areas:
      "time stars ccy title"
      "konsensus previous aktual aktual"
      "status status status status";
    align-items: start;
  }

  .cal-time { grid-area: time; }
  .cal-stars { grid-area: stars; }
  .cal-ccy { grid-area: ccy; }
  .cal-title { grid-area: title; }
  .cal-row .cal-num:nth-child(5) { grid-area: konsensus; }
  .cal-row .cal-num:nth-child(6) { grid-area: previous; }
  .cal-row .cal-num:nth-child(7) { grid-area: aktual; }
  .cal-row .pill { grid-area: status; }

  .cal-num {
    align-items: flex-start;
    background: var(--surface-alt);
    border-radius: var(--radius);
    padding: 6px 8px;
  }

  .cal-num-label {
    display: block;
  }

  .cal-num-value {
    text-align: left;
  }
}

.coin-name {
  font-weight: 600;
}

.coin-symbol {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  margin-left: 4px;
}

.pair {
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
}

.event-name {
  white-space: normal;
  min-width: 160px;
}

.ccy {
  font-family: var(--mono);
  font-weight: 700;
}

/* Semantic colors */
.up {
  color: var(--up);
}

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

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

.pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-up {
  background: var(--up-bg);
  color: var(--up);
}

.pill-down {
  background: var(--down-bg);
  color: var(--down);
}

.pill-flat {
  background: var(--flat-bg);
  color: var(--flat);
}

.pill-wait {
  background: var(--warn-bg);
  color: var(--warn);
}

/* Key-value blocks (snapshot, fed) */
.kv-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 640px) {
  .kv-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .kv-grid.kv-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.kv-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  padding: 8px 10px;
  min-width: 0;
}

.kv-block h4 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  border-bottom: 1px dotted var(--border);
}

.kv-row:last-child {
  border-bottom: none;
}

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

.kv-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}

.note {
  border-left: 3px solid var(--accent);
  background: var(--surface-alt);
  padding: 8px 10px;
  font-size: 12.5px;
}

.note-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.note ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.note li {
  margin: 2px 0;
}

.fine-print {
  font-size: 11px;
  color: var(--text-muted);
}

.fed-event {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 6px 0;
  border-bottom: 1px dotted var(--border);
}

.fed-event:last-child {
  border-bottom: none;
}

.fed-event-name {
  font-weight: 600;
}

.fed-event-nums {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.fed-sentence {
  font-size: 14px;
  font-weight: 600;
}

.fed-meeting {
  font-size: 13px;
  margin-top: 2px;
}

.fed-bar {
  display: flex;
  width: 100%;
  height: 28px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.fed-bar > .fed-seg {
  display: block;
  height: 100%;
  line-height: 28px;
  text-align: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

.fed-seg-cut {
  background: #15803d;
}

.fed-seg-hike {
  background: #b91c1c;
}

.fed-seg-other {
  background: #6b7280;
}

.fed-nums {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fed-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.fed-key {
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
}

.fed-later {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

.fed-later-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fed-later-date {
  font-size: 12px;
  font-weight: 700;
}

/* Footer */
.footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 12px 20px;
  color: var(--text-muted);
  font-size: 11.5px;
}

/* Dialog */
.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  width: min(92vw, 460px);
  color: var(--text);
}

.dialog::backdrop {
  background: rgba(17, 20, 24, 0.45);
}

.dialog-form {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog-form h2 {
  font-size: 15px;
  color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-weight: 600;
  font-size: 12px;
}

.field input,
.field select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.field-help {
  font-size: 11px;
  color: var(--text-muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
