/* Terminal de Bonos · estética Dark Liquid Glass */
:root {
  --bg-0: #15171b; --bg-1: #1d2025; --bg-2: #282c33;
  --ink: #f1f3f5; --ink-2: rgba(241, 243, 245, .68); --ink-3: rgba(241, 243, 245, .42);
  --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .14);
  --pos: #8fe3c0; --neg: #ff4d55;
  --iri: conic-gradient(from 210deg, #7cf3ff, #9d8cff, #ff9ecf, #ffd08a, #b6ffcf, #7cf3ff);
  --r-lg: 30px; --r-md: 24px; --r-sm: 16px; --pill: 999px;
  --font: "Inter Tight", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: linear-gradient(180deg, var(--bg-2), var(--bg-1) 40%, var(--bg-0)) fixed; }
body {
  margin: 0; font: 14px/1.45 var(--font); color: var(--ink);
  background: transparent; /* el fondo lo pone html + el paisaje fijo */
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
a { color: var(--ink); text-decoration-color: var(--ink-3); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Paisaje fijo detrás del vidrio ---------- */
.landscape { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.landscape svg { width: 100%; height: 100%; display: block; }

/* ---------- Vidrio líquido ---------- */
.lg {
  position: relative; isolation: isolate; border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, .035));
  backdrop-filter: blur(14px) saturate(160%); -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: inset 1.5px 1.5px 0 -0.5px rgba(255, 255, 255, .55), inset -1px -1px 0 -0.5px rgba(255, 255, 255, .25),
    inset 0 0 18px rgba(255, 255, 255, .06), 0 18px 40px -18px rgba(0, 0, 0, .55);
}
.lg::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; z-index: 2;
  background: linear-gradient(135deg, rgba(255, 255, 255, .75), rgba(255, 255, 255, .08) 30%, rgba(255, 255, 255, .04) 65%, rgba(255, 255, 255, .45));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.lg::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background: radial-gradient(120% 60% at 20% -10%, rgba(255, 255, 255, .16), transparent 55%);
}
.lg.dark { background: linear-gradient(180deg, rgba(18, 21, 26, .42), rgba(10, 12, 15, .30)); }
.lg.light { background: linear-gradient(180deg, rgba(255, 255, 255, .20), rgba(255, 255, 255, .08)); }
.lg.iri::before { background: var(--iri); opacity: .7; }
.lg > * { position: relative; z-index: 1; }
/* Paneles de datos: vidrio más denso para que las tablas se lean sobre el cielo claro */
.panel.lg { background: linear-gradient(180deg, rgba(20, 23, 28, .66), rgba(12, 14, 17, .58)); }
.panel.lg::after { background: radial-gradient(90% 40% at 15% -8%, rgba(255, 255, 255, .10), transparent 60%); }

/* ---------- Encabezado ---------- */
.hero { padding: 22px 24px 0; max-width: 1500px; margin: 0 auto; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; min-height: 150px; }
.eyebrow { font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 10px; }
.hero h1 { margin: 0 0 10px; font-weight: 500; font-size: clamp(36px, 6vw, 64px); letter-spacing: -0.04em; line-height: .98; color: var(--ink); }
.hero h1 span { color: var(--ink-3); }
.hero-obj { position: relative; width: 168px; height: 168px; flex: none; margin-right: 6px; }
.hero-obj .render { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); object-fit: contain; filter: drop-shadow(0 20px 30px rgba(0, 0, 0, .35)); }

#controls { margin-top: 10px; padding: 16px 18px 16px 22px; }
#controls.lg.dark { background: linear-gradient(180deg, rgba(18, 21, 26, .58), rgba(10, 12, 15, .46)); }
#controls .field-label { color: var(--ink-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; }
.toolbar-end { margin-left: auto; display: flex; gap: 14px; align-items: center; }

.tabs-wrap { position: sticky; top: 10px; z-index: 20; padding: 14px 24px 0; max-width: 1500px; margin: 0 auto; }
.tabs { display: flex; gap: 4px; padding: 6px; border-radius: var(--pill); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 9px 16px; color: var(--ink-2); text-decoration: none; white-space: nowrap; border-radius: var(--pill); font-weight: 500; transition: color .15s, background .15s; }
.tab:hover { color: var(--ink); background: rgba(255, 255, 255, .07); }
.tab.on { background: #f5f7f8; color: #15171b; }

/* ---------- Campos y controles ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.hint { font-size: 11px; color: var(--ink-3); }
.inline { display: flex; gap: 8px; align-items: center; }
.unit { color: var(--ink-3); font-size: 12px; font-family: var(--mono); }

input[type=date], input[type=number], select {
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2); border-radius: 14px;
  padding: 7px 12px; min-height: 36px; color: var(--ink);
}
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--bg-1); }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .6; }
input:focus-visible, select:focus-visible, button:focus-visible, .tab:focus-visible { outline: 2px solid rgba(255, 255, 255, .8); outline-offset: 2px; }
.num-input { width: 112px; font-family: var(--mono); text-align: right; font-size: 13px; }
.num-input.xs { width: 72px; }
input:disabled { opacity: .4; }

.seg { display: inline-flex; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); border-radius: var(--pill); padding: 3px; }
.seg button { background: none; border: 0; padding: 6px 13px; border-radius: var(--pill); cursor: pointer; color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: #f5f7f8; color: #15171b; }
.seg-sm button { padding: 5px 11px; font-size: 13px; }

.btn { background: #f5f7f8; color: #15171b; border: 0; border-radius: var(--pill); padding: 9px 18px; font-weight: 600; cursor: pointer; transition: transform .15s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); }
.btn.ghost { background: rgba(255, 255, 255, .07); color: var(--ink); border: 1px solid var(--line-2); font-weight: 500; }
.icon-btn { background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2); color: var(--ink-2); border-radius: 50%; width: 28px; height: 28px; cursor: pointer; line-height: 1; }
.icon-btn:hover { color: var(--neg); border-color: var(--neg); }

.status { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status.ok::before { background: var(--pos); box-shadow: 0 0 10px var(--pos); }
.status.error::before { background: var(--neg); box-shadow: 0 0 10px var(--neg); }
.status.loading::before { background: var(--ink); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- Contenido ---------- */
main { padding: 18px 24px 34px; max-width: 1500px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { padding: 22px 22px 20px; min-width: 0; }
.panel-head { margin-bottom: 14px; }
.panel h2 { margin: 0; font-size: 21px; font-weight: 500; letter-spacing: -0.025em; line-height: 1.1; }
.panel .sub { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; max-width: 92ch; }
.mini { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); font-weight: 400; margin: 18px 0 10px; text-transform: uppercase; letter-spacing: .08em; }
.note { color: var(--ink-2); font-size: 12.5px; margin: 0 0 12px; }
.empty, .muted { color: var(--ink-3); padding: 14px 0; margin: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; margin-bottom: 14px; }
.inline-kpi { font-family: var(--mono); font-size: 12px; color: var(--ink-2); padding-bottom: 9px; }
.row-end { display: flex; justify-content: flex-end; margin-top: 14px; }
.chart { position: relative; width: 100%; }

.kpis { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.kpi { background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 20px; padding: 10px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 130px; }
.kpi.lg { border: 0; border-radius: var(--r-md); }
.kpis.big .kpi { flex: 1; padding: 18px 22px; min-width: 220px; }
.kpis.big .kpi-value { font-size: 44px; font-family: var(--font); font-weight: 500; letter-spacing: -0.035em; line-height: 1.05; }
.kpi-label { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.kpi-value { font-family: var(--mono); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.kpi-sub { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.kpi.pos .kpi-value { color: var(--pos); }
.kpi.neg .kpi-value { color: var(--neg); }
.kpi.warn { border-color: rgba(255, 255, 255, .45); }
.kpi.alert { border-color: var(--neg); background: linear-gradient(180deg, rgba(255, 255, 255, .04) 10%, rgba(255, 60, 70, .22)); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: 18px; border: 1px solid var(--line); background: rgba(0, 0, 0, .14); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th, .grid td { padding: 8px 12px; border-bottom: 1px solid rgba(255, 255, 255, .055); white-space: nowrap; }
.grid th { position: sticky; top: 0; background: rgba(28, 31, 37, .96); color: var(--ink-3); font-family: var(--mono); font-weight: 400; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; text-align: left; cursor: pointer; user-select: none; }
.grid th:hover { color: var(--ink); }
.grid td.num, .grid th.num { text-align: right; }
.grid td.num { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.grid tbody tr:hover td { background: rgba(255, 255, 255, .035); }
.grid tbody tr:last-child td { border-bottom: 0; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.strong { font-weight: 600; }
.tk { font-family: var(--mono); font-weight: 500; letter-spacing: .02em; }
sup.edited { color: var(--ink); margin-left: 3px; opacity: .7; }

.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.price-cell { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .045); border: 1px solid var(--line); border-radius: var(--pill); padding: 5px 6px 5px 14px; }
.price-cell .tk { width: 52px; font-size: 12.5px; }
.price-cell .num-input { flex: 1; width: auto; min-width: 0; border-radius: var(--pill); }
.price-cell .unit { padding-right: 6px; }
.price-cell.edited { border-color: rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .09); }

.toast { position: fixed; right: 18px; bottom: 18px; padding: 12px 18px; border-radius: var(--pill); z-index: 50; font-weight: 500; }
.toast.error { color: var(--neg); }

.foot { color: var(--ink-3); font-size: 12px; text-align: center; padding: 22px 16px 34px; font-family: var(--mono); }
.foot a { color: var(--ink-2); }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .toolbar-end { margin-left: 0; width: 100%; justify-content: space-between; }
}
@media (max-width: 560px) {
  .hero { padding: 16px 16px 0; }
  .hero-row { min-height: 110px; }
  .hero-obj { width: 104px; height: 104px; }
  #controls { padding: 14px 16px; border-radius: var(--r-md); }
  .tabs-wrap { padding: 12px 16px 0; }
  main { padding: 14px 16px 26px; }
  .panel { padding: 16px 14px; border-radius: var(--r-md); }
  .panel h2 { font-size: 18px; }
  .kpis.big .kpi { min-width: 100%; }
  .kpis.big .kpi-value { font-size: 34px; }
  .price-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .price-cell { padding-left: 10px; }
  .price-cell .tk { width: 44px; font-size: 11.5px; }
  .price-cell .unit { display: none; }
}

/* ---------- Curva pesos ---------- */
#pesos .ps-no { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 10px; border-radius: 50%; background: rgba(255, 255, 255, .1); border: 1px solid var(--line-2); font-family: var(--mono); font-size: 12px; vertical-align: 3px; }
#pesos .ps-chart { height: 580px; margin-top: 4px; }
#pesos .ps-kn { margin: 8px 0 14px; color: var(--ink-3); font-family: var(--mono); font-size: 11.5px; }
#pesos .ps-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
#pesos .ps-sum .kpi { padding: 16px 20px; border-radius: var(--r-md); gap: 6px; }
#pesos .ps-sum .kpi-value { font-family: var(--font); font-size: 32px; letter-spacing: -0.03em; }
#pesos .ps-sum .kpi-sub { white-space: normal; line-height: 1.4; }
#pesos table.ps td.nt { text-align: left; white-space: normal; color: var(--ink-3); font-size: 12px; min-width: 200px; font-family: var(--font); }
#pesos table.ps th { line-height: 1.25; vertical-align: bottom; }
#pesos table.ps td.tk { font-family: var(--mono); font-weight: 500; }
#pesos .tag { display: inline-block; padding: 2px 9px; border-radius: var(--pill); background: rgba(255, 255, 255, .08); font-family: var(--font); font-size: 12px; }
#pesos .tag.up { background: rgba(143, 227, 192, .16); color: var(--pos); }
#pesos .vdsup { color: var(--ink-3); font-size: 11px; margin-left: 4px; font-weight: 400; }
#pesos .ps-fwd { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
#pesos details > summary { cursor: pointer; font-weight: 500; color: var(--ink); font-size: 15px; list-style: none; display: flex; align-items: center; gap: 10px; }
#pesos details > summary::-webkit-details-marker { display: none; }
#pesos details > summary::before { content: "▸"; color: var(--ink-2); transition: transform .15s; }
#pesos details[open] > summary::before { transform: rotate(90deg); }
#pesos tr.fwx td { background: rgba(143, 227, 192, .09); }
#pesos tr.fwx td.fwv { color: var(--pos); font-weight: 700; }
#pesos td.fwc { color: var(--ink-3); }
#pesos .bemsg { min-height: 90px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 24px; color: var(--ink-3); font-size: 15px; line-height: 1.5; }
#pesos #psPath input { width: 88px; }
#pesos .controls .btn { align-self: flex-end; }
@media (max-width: 700px) { #pesos .ps-chart { height: 420px; } }
