/* =========================================================================
   Cognivo Currency Center
   Tema claro y oscuro. El color de marca (#F1DC5E, tomado del logo) se usa
   como acento; el resto de la paleta es neutra para que manden los numeros.
   ========================================================================= */

:root {
  color-scheme: light;

  --brand: #F1DC5E;
  --brand-ink: #3d3413;

  --bg: #fafafa;
  --bg-subtle: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;

  --text: #18181b;
  --text-2: #52525b;
  --text-3: #a1a1aa;

  --accent: #2563eb;
  --accent-soft: #eff6ff;

  --up: #059669;
  --up-soft: #ecfdf5;
  --down: #dc2626;
  --down-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.06);
  --shadow-md: 0 2px 4px rgb(0 0 0 / 0.04), 0 8px 20px -6px rgb(0 0 0 / 0.10);
  --ring: 0 0 0 3px rgb(37 99 235 / 0.18);
}

/* El tema oscuro se aplica por preferencia del sistema en modo automatico... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --brand-ink: #2a250f;

    --bg: #0a0a0b;
    --bg-subtle: #131316;
    --surface: #17171a;
    --surface-2: #1d1d21;
    --border: #27272b;
    --border-strong: #3f3f46;

    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #71717a;

    --accent: #60a5fa;
    --accent-soft: #172033;

    --up: #34d399;
    --up-soft: #0c2620;
    --down: #f87171;
    --down-soft: #2a1516;
    --warn: #fbbf24;
    --warn-soft: #2a2110;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 16px -4px rgb(0 0 0 / 0.5);
    --ring: 0 0 0 3px rgb(96 165 250 / 0.25);
  }
}

/* ...y de forma explicita cuando el usuario elige oscuro en el selector. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --brand-ink: #2a250f;

  --bg: #0a0a0b;
  --bg-subtle: #131316;
  --surface: #17171a;
  --surface-2: #1d1d21;
  --border: #27272b;
  --border-strong: #3f3f46;

  --text: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #71717a;

  --accent: #60a5fa;
  --accent-soft: #172033;

  --up: #34d399;
  --up-soft: #0c2620;
  --down: #f87171;
  --down-soft: #2a1516;
  --warn: #fbbf24;
  --warn-soft: #2a2110;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 16px -4px rgb(0 0 0 / 0.5);
  --ring: 0 0 0 3px rgb(96 165 250 / 0.25);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

::selection { background: var(--brand); color: var(--brand-ink); }

/* --- barra superior ------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); }

.nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav a {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.nav a:hover { background: var(--bg-subtle); color: var(--text); }

.nav a.active {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--brand);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.theme-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-toggle:focus-visible { outline: none; box-shadow: var(--ring); }

.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  grid-area: 1 / 1;
}

/* El icono refleja el tema activo en cada momento. */
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-moon { display: block; }
}

/* --- estructura ---------------------------------------------------------- */

.container { max-width: 1240px; margin: 0 auto; padding: 28px 22px 64px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

h2 { margin: 0 0 14px; font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }

.page-head p { margin: 5px 0 0; font-size: 13.5px; color: var(--text-2); }

.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.align-end { display: flex; align-items: flex-end; }

.mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* --- tarjetas de moneda -------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 13px;
  margin-bottom: 8px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px 13px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }

.flag {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  line-height: 1;
  flex-shrink: 0;
  overflow: hidden;
}

/* La bandera SVG llena el circulo; el recorte redondo lo da .flag. */
.flag .fi {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  border-radius: 50%;
}

/* Cuando no hay bandera (XDR del FMI) se muestra el simbolo de la moneda. */
.flag.is-symbol {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
  letter-spacing: -0.02em;
}

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

.card-code {
  display: block;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.card-name {
  display: block;
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-subtle);
  color: var(--text-3);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.badge-compra { background: var(--up-soft); color: var(--up); border-color: transparent; }
.badge-venta { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Las dos equivalencias del panel: cuanto vale en dolares y en colones. */
.rates { display: grid; gap: 7px; margin-bottom: 11px; }

.rate-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.rate-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rate-value {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rate-value small { font-size: 11.5px; font-weight: 500; color: var(--text-3); margin-right: 2px; }
.rate-value.na { color: var(--text-3); font-weight: 500; font-size: 14px; }

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-3);
  margin-bottom: 9px;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.delta.up { background: var(--up-soft); color: var(--up); }
.delta.down { background: var(--down-soft); color: var(--down); }
.delta.flat { background: var(--bg-subtle); color: var(--text-3); }

.spark { display: block; width: 100%; height: 34px; margin-bottom: 4px; }

.spark path.line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spark path.area { fill: currentColor; opacity: 0.09; stroke: none; }
.spark.trend-up { color: var(--up); }
.spark.trend-down { color: var(--down); }
.spark.trend-flat { color: var(--text-3); }

.stale { margin: 2px 0 0; font-size: 11px; color: var(--warn); }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-3);
}

.card-foot a { color: var(--accent); text-decoration: none; font-weight: 550; }
.card-foot a:hover { text-decoration: underline; }

/* --- agrupacion y buscador ----------------------------------------------- */

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 30px 0 4px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.group-head .group-title { margin-bottom: 0; }

.group-title .count {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 10.5px;
  letter-spacing: 0;
  color: var(--text-2);
}

.group-note { margin: 8px 0 16px; }

.search-wrap { position: relative; }

.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--text-3);
  stroke-width: 2;
  pointer-events: none;
}

.search-input {
  width: 280px;
  max-width: 100%;
  padding-left: 33px;
  font-weight: 400;
}

.card[hidden] { display: none; }

/* --- paneles y tablas ---------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 19px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.panel.narrow { max-width: 660px; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-head h2 { margin: 0; }
.panel-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-2); }

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

.table th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 9px 11px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.table td { padding: 9px 11px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table th.right, .table td.right { text-align: right; }

.table-scroll { overflow: auto; max-height: 580px; border-radius: var(--radius-sm); }

.detail { max-width: 340px; font-size: 11.5px; color: var(--text-2); }

.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}

.status-ok { background: var(--up-soft); color: var(--up); }
.status-parcial { background: var(--warn-soft); color: var(--warn); }
.status-error { background: var(--down-soft); color: var(--down); }

/* --- formularios --------------------------------------------------------- */

.filters { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 15px;
}

/* Los nombres de moneda son largos: el select muestra el texto completo. */
.form-grid select { min-width: 0; text-overflow: ellipsis; }

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, select {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  font-weight: 450;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color 0.12s, box-shadow 0.12s;
}

input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

.inline-form { display: flex; gap: 9px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.12s, background 0.12s, border-color 0.12s;
}

.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgb(241 220 94 / 0.4); }

.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-subtle); border-color: var(--border-strong); }

/* display:inline-flex le gana al display:none implicito de [hidden], asi que
   hay que decirlo de forma explicita. */
.btn[hidden] { display: none; }

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgb(0 0 0 / 0.18);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }

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

/* --- avisos -------------------------------------------------------------- */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid transparent;
}

.banner-ok { background: var(--up-soft); color: var(--up); }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner-error { background: var(--down-soft); color: var(--down); }
.banner-muted { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.banner .detail { flex-basis: 100%; margin: 3px 0 0; }
.banner strong { font-weight: 650; }
.sync-report { margin-top: 14px; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 44px 26px;
  text-align: center;
  margin-bottom: 20px;
}

.empty h2 { margin-bottom: 7px; }
.empty p { color: var(--text-2); margin: 0 0 16px; }

code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

pre {
  display: inline-block;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  margin: 0;
  text-align: left;
  color: var(--text);
}

code { background: var(--bg-subtle); padding: 2px 6px; border-radius: 5px; }

/* --- grafico de series --------------------------------------------------- */

.chart-wrap { position: relative; }

.chart {
  display: block;
  width: 100%;
  height: 280px;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-2);
}

.chart path.line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart path.area { fill: currentColor; opacity: 0.08; stroke: none; }

.chart-axis {
  position: absolute;
  top: 12px;
  right: 16px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 11px;
  color: var(--text-3);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.chart-dates {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* --- convertidor --------------------------------------------------------- */

.conv-result {
  margin-top: 20px;
  padding: 18px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.conv-amount {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
  margin: 0 0 6px;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.conv-amount strong { font-size: 25px; font-weight: 650; letter-spacing: -0.02em; }
.conv-amount .arrow { color: var(--text-3); }
.conv-result p.muted { margin: 0; font-size: 12.5px; }

.conv-path {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
}

/* --- pie ----------------------------------------------------------------- */

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 22px 36px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}

.footer-brand { display: inline-flex; align-items: center; gap: 6px; }
.footer-brand img { border-radius: 4px; }

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .theme-toggle { margin-left: auto; }
}

@media (max-width: 620px) {
  .container { padding: 20px 16px 48px; }
  .grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .search-input { width: 100%; }
  .search-wrap { width: 100%; }
  h1 { font-size: 21px; }
  .detail { max-width: 200px; }

  /* En pantallas angostas la tabla se desplaza en vez de desbordarse. */
  .panel { padding: 15px; overflow-x: auto; }
  .panel > .table { min-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .card:hover { transform: none; }
}

/* =========================================================================
   Portada: el convertidor es el protagonista
   ========================================================================= */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

/* Un velo de marca muy tenue, para que la portada no sea una caja blanca mas. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 150px;
  background: linear-gradient(180deg, rgb(241 220 94 / 0.10), transparent);
  pointer-events: none;
}

.hero > * { position: relative; }

.hero-head { margin-bottom: 20px; }
.hero-head h1 { font-size: 27px; margin-bottom: 4px; }
.hero-head p { margin: 0; font-size: 13.5px; color: var(--text-2); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* --- convertidor --------------------------------------------------------- */

.converter { display: flex; flex-direction: column; gap: 14px; }

.conv-row {
  display: grid;
  /* Los selects llevan nombres largos ("Dolar Estadounidense"), asi que se
     les da mas ancho que al monto. */
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.15fr) auto minmax(0, 1.15fr);
  gap: 10px;
  align-items: end;
}

.conv-field { gap: 6px; }

.conv-label {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}

.conv-field input,
.conv-field select {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  font-weight: 550;
}

.conv-field input { font-variant-numeric: tabular-nums; }

.swap {
  display: grid;
  place-items: center;
  width: 38px;
  height: 40px;
  margin-bottom: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.swap:hover {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: var(--border-strong);
}

.swap svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.conv-out {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}

.conv-out.is-error {
  display: block;
  background: var(--down-soft);
  border-color: transparent;
  color: var(--down);
  font-size: 13.5px;
}

.conv-from {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: var(--text-2);
}

.conv-eq { color: var(--text-3); font-size: 18px; }

.conv-to {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

/* Bandera pequena dentro del resultado y de los atajos. */
.conv-from .fi, .conv-to .fi, .shortcut .fi {
  width: 20px;
  height: 15px;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.conv-to .fi { width: 26px; height: 19px; border-radius: 4px; }

.conv-note { margin: 0; font-size: 12.5px; color: var(--text-3); }

.conv-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- grafico del par ----------------------------------------------------- */

.hero-chart {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.hc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.hc-pair {
  display: block;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.hc-days { font-size: 11.5px; color: var(--text-3); }

.hc-svg { display: block; width: 100%; height: 150px; color: var(--accent); }

.hc-svg path.line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.hc-svg path.area { fill: currentColor; opacity: 0.10; stroke: none; }
.hc-svg.trend-up { color: var(--up); }
.hc-svg.trend-down { color: var(--down); }
.hc-svg.trend-flat { color: var(--text-3); }

.hc-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.hc-empty { display: grid; place-items: center; min-height: 190px; }
.hc-empty p { margin: 0; font-size: 13px; color: var(--text-3); text-align: center; }

/* --- atajos -------------------------------------------------------------- */

.shortcuts {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.shortcut {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 12.5px;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s;
}

.shortcut:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.shortcut.is-active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.sc-pair { font-weight: 600; color: var(--text-2); }
.sc-rate { font-weight: 650; font-variant-numeric: tabular-nums; }

/* =========================================================================
   Franja del dolar
   ========================================================================= */

.usd-strip {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.usd-title { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.usd-title strong { display: block; font-size: 14px; font-weight: 600; }
.usd-title span span { font-size: 11.5px; color: var(--text-3); }

.usd-box { display: flex; flex-direction: column; gap: 2px; }

.usd-label {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.usd-value {
  font-size: 23px;
  font-weight: 680;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.usd-box .delta { align-self: flex-start; margin-top: 2px; }

.usd-link { font-size: 12.5px; text-decoration: none; font-weight: 550; white-space: nowrap; }
.usd-link:hover { text-decoration: underline; }

/* =========================================================================
   Tabla de monedas
   ========================================================================= */

.rates-table td { padding: 10px 11px; vertical-align: middle; }
.rates-table tr[hidden] { display: none; }

.cell-currency { display: flex; align-items: center; gap: 10px; }
.cell-names { display: flex; flex-direction: column; line-height: 1.25; }
.cell-names strong { font-size: 13.5px; font-weight: 650; }
.cell-names small { font-size: 11.5px; color: var(--text-3); }

.flag-sm { width: 28px; height: 28px; }

.rates-table .strong { font-weight: 650; }

.spark-cell { display: inline-block; width: 92px; height: 26px; vertical-align: middle; }

.cell-link {
  font-size: 12px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
}

.rates-table tr:hover .cell-link { opacity: 1; }
.cell-link:hover { text-decoration: underline; }

/* =========================================================================
   Estado del servicio
   ========================================================================= */

.status-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 13px;
  margin-bottom: 18px;
}

.status-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.status-card.is-action { justify-content: center; align-items: flex-start; gap: 9px; }

.sc-label {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.sc-value {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

.sc-value.ok { color: var(--up); font-size: 15px; }
.sc-value.warn { color: var(--warn); font-size: 15px; }
.sc-meta { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sc-meta.link { text-decoration: none; color: var(--accent); }
.sc-meta.link:hover { text-decoration: underline; }

/* =========================================================================
   Responsive de la portada
   ========================================================================= */

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-chart { order: -1; }
}

@media (max-width: 640px) {
  .hero { padding: 18px; }
  .hero-head h1 { font-size: 22px; }

  /* En movil el convertidor se apila y el boton de invertir se centra. */
  .conv-row { grid-template-columns: 1fr; gap: 12px; }
  .swap { width: 100%; height: 34px; }
  .swap svg { transform: rotate(90deg); }

  .conv-to { font-size: 25px; }
  .usd-strip { gap: 18px; }
  .usd-title { width: 100%; margin-right: 0; }
  .spark-cell { display: none; }
}

/* Hora de la proxima carga en la pagina de actualizaciones. */
.usd-value.sched-time { font-size: 19px; }
.usd-value.warn { color: var(--warn); font-size: 17px; }

/* Los avisos de una carga pueden ser decenas: se colapsan en la tabla. */
.detail details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 550;
  white-space: nowrap;
}

.detail-list {
  margin: 8px 0 0;
  padding-left: 16px;
  max-height: 180px;
  overflow-y: auto;
}

.detail-list li { margin-bottom: 3px; }

/* Selector de fuente de datos, sobre el convertidor. */
.conv-provider {
  gap: 6px;
  max-width: 320px;
}

.conv-provider select {
  padding: 8px 11px;
  font-size: 13.5px;
  font-weight: 500;
}

@media (max-width: 640px) {
  .conv-provider { max-width: none; }
}

/* Aclara la zona horaria de la columna de fechas en la bitacora. */
.th-tz {
  margin-left: 5px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}
