/* Kairos · tinta azul, hueso y latón. Siempre oscuro; primero móvil. */
:root {
  --tabbar: 62px;
  --ink: #0f1622; --panel: #172132; --line: #26344b; --bone: #e8e2d4; --mute: #8d9bb0;
  --brass: #d6a756; --gain: #57b894; --loss: #e2675d;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--bone); font: 400 16px/1.5 var(--sans); font-variant-numeric: tabular-nums;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + var(--tabbar) + 16px) env(safe-area-inset-left); }
h1, h2, h3, p, dl, dd, ol, figure { margin: 0; }
ol { padding: 0; list-style: none; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.brand { display: flex; align-items: center; gap: .45rem; font-weight: 800; font-stretch: 118%; font-size: 1.3rem; letter-spacing: -0.01em; }
.brand img { display: block; width: 30px; height: 30px; margin-left: -4px; }
.brand-lg { font-size: 2.6rem; gap: .6rem; }
.brand-lg img { width: 52px; height: 52px; margin-left: -8px; }

/* ---- acceso ---- */
.login { max-width: 22rem; margin: max(8vh, 3rem) auto 0; padding: 0 1.25rem; display: grid; gap: 1rem; }
.login-sub { color: var(--mute); }
label { display: grid; gap: .3rem; font-size: .9rem; color: var(--mute); }
input, select { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .6rem .7rem; color: var(--bone); min-height: 44px; }
.err { color: var(--loss); min-height: 1.5em; }

/* ---- cabecera y pestañas ---- */
.top { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem .6rem; }
.chip { font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--line); color: var(--mute); }
.chip.paper { color: var(--brass); border-color: var(--brass); }
.chip.live { background: var(--loss); border-color: var(--loss); color: #1a0d0b; }
.beat { width: 9px; height: 9px; border-radius: 50%; background: var(--mute); margin-left: auto; }
.beat.ok { background: var(--gain); }
.beat.bad { background: var(--loss); }
.tabs { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel);
  border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.tabs button { background: none; border: 0; height: var(--tabbar); display: grid; place-items: center; align-content: center; gap: .2rem;
  font-size: .74rem; color: var(--mute); border-top: 2px solid transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tabs svg { width: 22px; height: 22px; }
.tabs button.on { color: var(--brass); border-top-color: var(--brass); font-weight: 600; }
.tabs button.on span { color: var(--bone); }
.banner { margin: 0 1rem .6rem; padding: .6rem .8rem; border-left: 3px solid var(--loss); background: var(--panel); font-size: .92rem; }
.banner.info { border-left-color: var(--brass); }

main { padding: 0 1rem; max-width: 60rem; margin: 0 auto; }
h3 { font-size: .95rem; font-weight: 600; color: var(--mute); margin: 1.8rem 0 .6rem; }

/* ---- veredicto del día: lo primero que se lee ---- */
.verdict { padding: .6rem 0 1rem; }
.kicker { color: var(--mute); font-size: .9rem; }
.verdict h2 { font-size: clamp(1.7rem, 7vw, 2.9rem); line-height: 1.08; font-weight: 700; font-stretch: 92%; letter-spacing: -0.015em; margin: .15rem 0 .5rem; text-wrap: balance; }
.verdict h2 .k { color: var(--brass); white-space: nowrap; }
.why { color: var(--mute); max-width: 44rem; }

/* ---- figura de la sesión ---- */
.session { margin: .4rem -1rem 0; }
.session svg { display: block; width: 100%; height: 44vh; max-height: 340px; min-height: 220px; }
#equity { height: 30vh; min-height: 180px; }
.session figcaption { padding: .4rem 1rem 0; color: var(--mute); font-size: .88rem; }
svg text { font-family: var(--sans); font-size: 11px; fill: var(--mute); }
svg .px { fill: none; stroke: var(--bone); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
svg .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg .or { fill: var(--line); opacity: .45; }
svg .win { fill: var(--brass); opacity: .12; }
svg .short { stroke: var(--brass); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
svg .long { stroke: var(--mute); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
svg .zone { fill: var(--gain); opacity: .09; }
svg .mk { fill: var(--brass); }
svg .now { fill: var(--bone); }
svg .eq { fill: none; stroke: var(--brass); stroke-width: 1.8; vector-effect: non-scaling-stroke; }
svg .eq-area { fill: var(--brass); opacity: .08; }
svg .zero { stroke: var(--mute); stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }

/* ---- posición ---- */
.position { margin-top: 1rem; padding: .9rem 1rem; background: var(--panel); border-left: 3px solid var(--brass); display: grid; gap: .5rem; }
.position .legs { font-weight: 600; font-size: 1.05rem; }
.position .row { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; color: var(--mute); font-size: .92rem; }
.position .row b { color: var(--bone); font-weight: 600; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 1rem 1.2rem; margin-top: 1.3rem; }
.figures dt { color: var(--mute); font-size: .82rem; }
.figures dd { font-size: 1.35rem; font-weight: 600; font-stretch: 92%; }
.pos { color: var(--gain); } .neg { color: var(--loss); }

.controls, .cfg-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.4rem; align-items: center; }
.cfg-actions { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 4; background: var(--ink);
  padding: .7rem 0; margin-top: 1rem; border-top: 1px solid var(--line); }
.controls .btn { flex: 1 1 9rem; }
.cfg-actions .btn { flex: 1 1 0; white-space: nowrap; }
.cfg-actions .msg { flex-basis: 100%; }
.cfg-actions .msg:empty { display: none; }
.position .btn { justify-self: start; }
.btn { background: none; border: 1px solid var(--line); border-radius: 6px; padding: .65rem 1rem; min-height: 44px; cursor: pointer; }
.btn:hover { border-color: var(--mute); }
.btn.primary { background: var(--brass); border-color: var(--brass); color: #1b1408; font-weight: 600; }
.btn.danger { border-color: var(--loss); color: var(--loss); }
.btn.danger.on { background: var(--loss); color: #1a0d0b; font-weight: 600; }
.link { background: none; border: 0; padding: 0; color: var(--brass); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.log li { display: grid; grid-template-columns: 3.4rem 1fr; gap: .6rem; padding: .5rem 0; border-top: 1px solid var(--line); font-size: .92rem; }
.log time { color: var(--mute); }
.log .did { color: var(--brass); }
.log .empty, .empty { color: var(--mute); padding: .8rem 0; }
.daypick, .tools { margin-top: 1.4rem; color: var(--mute); font-size: .9rem; }
.daypick label, .tools label { display: inline-flex; align-items: center; gap: .6rem; }

/* ---- operaciones ---- */
.trades { margin-top: .8rem; }
.trade { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.trade .what { font-weight: 600; }
.trade .pnl { font-weight: 700; font-size: 1.1rem; text-align: right; }
.trade .meta { grid-column: 1 / -1; color: var(--mute); font-size: .88rem; }

/* ---- rendimiento ---- */
table { width: 100%; border-collapse: collapse; margin-top: .4rem; font-size: .9rem; }
th, td { text-align: right; padding: .45rem .3rem; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--mute); font-weight: 500; }
th:first-child, td:first-child { text-align: left; }
td.name { font-weight: 600; }
@media (max-width: 619px) {
  .scroll { overflow: visible; margin: 0; padding: 0; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem 1rem; padding: .8rem 0; border-top: 1px solid var(--line); }
  td { border: 0; padding: .15rem 0; text-align: right; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; white-space: nowrap; }
  td::before { content: attr(data-label); color: var(--mute); font-size: .8rem; white-space: normal; text-align: left; }
  td.name { grid-column: 1 / -1; font-size: 1rem; justify-content: flex-start; order: -2; }
  td.name::before { content: none; }
  td.big { grid-column: 1 / -1; font-size: 1.25rem; font-weight: 700; order: -1; }
  td.big::before { font-size: .82rem; font-weight: 400; align-self: center; }
}
.scroll { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; }

/* ---- ajustes ---- */
.live-box { margin-top: .6rem; padding: .9rem 1rem; background: var(--panel); border-left: 3px solid var(--line); display: grid; gap: .6rem; }
.live-box.on { border-left-color: var(--loss); }
.live-box .row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.live-box input { width: 7rem; }
fieldset { border: 0; padding: 0; margin: 1.6rem 0 0; display: grid; gap: .9rem; }
legend { font-weight: 700; font-size: 1.05rem; padding: 0; margin-bottom: .2rem; }
.field { display: grid; grid-template-columns: 1fr 6.5rem; gap: .8rem; align-items: center; font-size: .92rem; color: var(--bone); }
.field input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; justify-self: end; accent-color: var(--brass); }
.field input.changed { border-color: var(--brass); }
.dates { display: grid; gap: .3rem; font-size: .92rem; color: var(--bone); }
.dates textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; color: var(--bone); font: inherit; padding: .6rem .7rem; min-height: 4.5rem; }
.msg { color: var(--mute); font-size: .9rem; }
.foot { margin: 2rem 0 1rem; color: var(--mute); font-size: .85rem; display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; }

@media (max-width: 359px) {
  .chip { display: none; }
  .tabs span { font-size: .68rem; }
  .field { grid-template-columns: 1fr 5.5rem; }
}
/* Móvil en horizontal: la barra inferior robaría media pantalla */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --tabbar: 0px; }
  body { padding-bottom: calc(env(safe-area-inset-bottom) + 1rem); }
  .tabs { position: static; display: flex; margin-left: auto; background: none; border: 0; padding: 0; gap: .2rem; }
  .tabs button { height: auto; display: flex; gap: .35rem; padding: .35rem .55rem; border-top: 0; border-bottom: 2px solid transparent; font-size: .82rem; }
  .tabs button.on { border-bottom-color: var(--brass); }
  .tabs svg { width: 16px; height: 16px; }
  .beat { margin-left: 0; }
  .session svg { height: 60vh; min-height: 180px; }
  .verdict h2 { font-size: 1.7rem; }
  .cfg-actions { bottom: 0; }
}
@media (min-width: 760px) {
  :root { --tabbar: 0px; }
  body { padding-bottom: 2rem; }
  .top { max-width: 72rem; margin: 0 auto; padding: 1.1rem 1rem; }
  .beat { margin-left: 0; }
  .tabs { position: static; margin-left: auto; background: none; border: 0; display: flex; gap: .3rem; padding: 0; }
  .tabs button { height: auto; display: flex; gap: .4rem; padding: .45rem .8rem; border-top: 0; border-bottom: 2px solid transparent; font-size: .9rem; }
  .tabs button.on { border-bottom-color: var(--brass); }
  .tabs svg { width: 17px; height: 17px; }
  main { max-width: 72rem; }
  .banner { max-width: 70rem; margin: 0 auto .6rem; }
  .session { margin-left: 0; margin-right: 0; }
  .session figcaption { padding-left: 0; }
  .controls .btn { flex: 0 0 auto; }
  .field { grid-template-columns: 1fr 8rem; max-width: 44rem; }
  .dates { max-width: 44rem; }
  .cfg-actions { bottom: 0; }
  .cfg-actions .btn { flex: 0 0 auto; }
  .trades { display: grid; grid-template-columns: 1fr 1fr; column-gap: 2.5rem; }
}
/* Pantallas anchas: el registro del día pasa a una columna lateral */
@media (min-width: 1100px) {
  #tab-hoy:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 2.5rem; align-items: start; }
  .side { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
  .side h3 { margin-top: .9rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .beat.ok { animation: beat 2.4s ease-in-out infinite; }
  @keyframes beat { 50% { opacity: .35; } }
}
