/* Bitácora de estudios */

:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --ink: #1b1b19;
  --ink-2: #52514e;
  --muted: #7a7873;
  --line: #e3e1db;
  --line-strong: #cfccc4;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --danger: #c73636;
  --ok: #0f7a3a;
  --warn: #9a6400;
  --focus: 0 0 0 3px rgba(42, 120, 214, .35);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 18, .05), 0 2px 8px rgba(20, 20, 18, .04);

  /* gráficas */
  --c-grid: #e8e6e0; --c-axis: #c3c2b7; --c-muted: #7a7873;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;

  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1b1b1a;
    --surface-2: #242422;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #96948d;
    --line: #2e2e2b;
    --line-strong: #44433f;
    --accent: #3987e5;
    --accent-soft: #1b2b40;
    --danger: #ec6b6b;
    --ok: #3ccf73;
    --warn: #f2b33d;
    --shadow: none;
    --c-grid: #2c2c2a; --c-axis: #44433f; --c-muted: #96948d;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #2a9a2a; --s7: #9085e9; --s8: #e66767;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b { font-weight: 650; }
small { font-size: .78rem; }
svg { flex: none; }
kbd { font: inherit; font-size: .75rem; padding: 0 .35em; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.page:focus, .page:focus-visible { box-shadow: none; }

/* ---------- Barra superior ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.brand svg rect { fill: var(--accent); }
.brand svg circle { fill: #fff; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; font-size: .92rem; overflow: hidden; }
.crumbs a, .crumbs span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--ink-2); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.crumbs__sep { color: var(--line-strong); }
.topbar__end { display: flex; align-items: center; gap: 12px; }
.sync { font-size: .82rem; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync[data-state="saving"]::before { background: var(--accent); animation: pulse 1s infinite; }
.sync[data-state="offline"] { color: var(--warn); }
.sync[data-state="offline"]::before { background: var(--warn); }
.sync[data-state="error"] { color: var(--danger); }
.sync[data-state="error"]::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Página ---------- */

.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.title-edit { display: flex; align-items: center; gap: 6px; }
.actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger-text:hover { color: var(--danger); }
.btn--sm { height: 30px; padding: 0 10px; font-size: .82rem; }
.btn--lg { height: 44px; padding: 0 22px; font-size: 1rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn svg { width: 17px; height: 17px; }
[data-act$="borrar"].icon-btn:hover { color: var(--danger); }

/* ---------- Tarjetas ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card__head { margin-bottom: 14px; }
.card__head p { margin-top: 2px; font-size: .85rem; }
.card__head--row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card--link { display: flex; flex-direction: column; gap: 6px; color: var(--ink); transition: border-color .15s, transform .15s; }
.card--link:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.card--link .muted { font-size: .88rem; }
.card__meta { display: flex; gap: 16px; margin-top: auto; padding-top: 10px; font-size: .85rem; color: var(--ink-2); }

.empty { text-align: center; max-width: 460px; margin: 48px auto; display: grid; gap: 12px; justify-items: center; }
.empty p { color: var(--ink-2); }
.empty--inline { margin: 24px auto; }
.empty__icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.empty__icon svg { width: 28px; height: 28px; }

.loading { display: grid; place-items: center; padding: 80px 0; }
.loading span { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---------- Formularios ---------- */

.field { display: grid; gap: 5px; min-width: 0; border: 0; margin: 0; padding: 0; }
.field > span, .field > legend { font-size: .82rem; font-weight: 600; color: var(--ink-2); padding: 0; }
.field small { color: var(--muted); }
input:not([type=radio]):not([type=checkbox]), select {
  width: 100%; height: 40px; padding: 0 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
}
input::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[aria-invalid="true"] { border-color: var(--danger); }
.radio, .check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: .92rem; }
input[type=radio], input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.form-error { color: var(--danger); font-size: .9rem; font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.wizard { display: grid; gap: 16px; max-width: 760px; }
.step { display: flex; gap: 18px; }
.step__num {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.step__body { flex: 1; display: grid; gap: 12px; min-width: 0; }
.step__body > p { margin-top: -6px; font-size: .9rem; }
.var-row { display: grid; grid-template-columns: 1fr 180px 32px; gap: 10px; align-items: end; }
.var-row--single { grid-template-columns: 1fr 180px; }
.deps { display: grid; gap: 10px; }
.wizard__foot { display: flex; justify-content: flex-end; gap: 8px; }
.step .btn--ghost { justify-self: start; color: var(--accent); }

/* ---------- Pestañas y barras ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab {
  border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted);
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar p { max-width: 640px; font-size: .9rem; }
.section-title { margin: 32px 0 2px; }
.section-sub { font-size: .9rem; margin-bottom: 14px; }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th { font-size: .8rem; font-weight: 650; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.table thead small { display: block; font-weight: 500; color: var(--muted); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.num small { display: block; color: var(--muted); }
.pm { color: var(--muted); }
.table--click tbody tr { cursor: pointer; }
.table--click tbody tr:hover { background: var(--surface-2); }
.table--click td:first-child a { font-weight: 600; color: var(--ink); }
.table--click td:first-child { white-space: nowrap; }

.table--capture th, .table--capture td { padding: 4px 6px; }
.table--capture thead th { padding: 8px 10px; }
.num-col { width: 44px; text-align: center !important; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.del-col { width: 40px; }
.cell {
  height: 36px !important; border-color: transparent !important; background: transparent !important;
  text-align: right; font-variant-numeric: tabular-nums; min-width: 96px; transition: background .3s;
}
.cell:hover { background: var(--surface-2) !important; }
.cell:focus { border-color: var(--accent) !important; background: var(--surface) !important; }
.cell.is-pending { background: color-mix(in srgb, var(--accent) 8%, transparent) !important; }
.cell.is-saved { background: color-mix(in srgb, var(--ok) 14%, transparent) !important; }
.cell.is-invalid { border-color: var(--danger) !important; color: var(--danger); }
.table--capture tfoot td, .table--capture tfoot th { padding: 7px 18px 7px 10px; background: var(--surface-2); border-bottom: 0; font-size: .85rem; }
.table--capture tfoot tr:first-child > * { border-top: 2px solid var(--line-strong); }
.foot-label { text-align: left !important; white-space: nowrap; width: auto; color: var(--ink-2); }
.add-row { margin-top: 12px; }

/* ---------- Objeto ---------- */

.obj-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pill {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: .85rem; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.pill[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; display: grid; gap: 2px; }
.tile span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.tile b { font-size: 1.05rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart-note { font-size: .8rem; margin-top: 8px; }

/* ---------- Gráficas ---------- */

.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.chart-card { display: grid; gap: 12px; padding: 16px; }
.chart-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.chart-card__head p { font-size: .82rem; margin-top: 2px; }
.chart { width: 100%; min-height: 280px; }
.chart-empty { padding: 48px 12px; text-align: center; color: var(--muted); background: var(--surface-2); border-radius: 8px; font-size: .9rem; }
.chart-svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.c-grid { stroke: var(--c-grid); stroke-width: 1; }
.c-grid--x { stroke-dasharray: 2 4; }
.c-axis { stroke: var(--c-axis); stroke-width: 1; }
.c-tick { fill: var(--c-muted); font-variant-numeric: tabular-nums; }
.c-label { fill: var(--ink-2); font-weight: 600; }
.c-text2 { fill: var(--ink-2); }
.c-halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.c-pt > * { stroke: var(--surface); stroke-width: 2px; transition: transform .12s; transform-box: fill-box; transform-origin: center; }
.c-pt:hover > :not(.c-hit) { transform: scale(1.35); }
.c-pt > .c-hit { fill: transparent !important; stroke: none; }
.c-err { fill: none; stroke-width: 1.5; opacity: .75; }
.c-firstlast { stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 6 4; }
.c-mean { stroke: var(--ink); stroke-width: 1.5; }
.c-trend { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 2 3; }
.c-band { fill: var(--s1); fill-opacity: .14; }
.c-s1 .c-pt > * { fill: var(--s1); } .c-s1 .c-err { stroke: var(--s1); }
.c-s2 .c-pt > * { fill: var(--s2); } .c-s2 .c-err { stroke: var(--s2); }
.c-s3 .c-pt > * { fill: var(--s3); } .c-s3 .c-err { stroke: var(--s3); }
.c-s4 .c-pt > * { fill: var(--s4); } .c-s4 .c-err { stroke: var(--s4); }
.c-s5 .c-pt > * { fill: var(--s5); } .c-s5 .c-err { stroke: var(--s5); }
.c-s6 .c-pt > * { fill: var(--s6); } .c-s6 .c-err { stroke: var(--s6); }
.c-s7 .c-pt > * { fill: var(--s7); } .c-s7 .c-err { stroke: var(--s7); }
.c-s8 .c-pt > * { fill: var(--s8); } .c-s8 .c-err { stroke: var(--s8); }
/* Líneas que pertenecen a una serie (agrupar por secundaria): toman el color de la serie */
.c-s1.c-ln { stroke: var(--s1); } .c-s2.c-ln { stroke: var(--s2); } .c-s3.c-ln { stroke: var(--s3); } .c-s4.c-ln { stroke: var(--s4); }
.c-s5.c-ln { stroke: var(--s5); } .c-s6.c-ln { stroke: var(--s6); } .c-s7.c-ln { stroke: var(--s7); } .c-s8.c-ln { stroke: var(--s8); }

/* Botones para mostrar u ocultar cada serie */
.toggles { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.toggles__label { font-size: .78rem; font-weight: 600; color: var(--muted); margin-right: 2px; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .82rem; padding: 3px 10px 3px 8px; border-radius: 999px; cursor: pointer;
}
.toggle__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: currentColor; }
.toggle__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle[aria-pressed="false"] { color: var(--muted); border-style: dashed; }
.toggle[aria-pressed="false"] .toggle__dot { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.toggle[aria-pressed="false"] .toggle__name { text-decoration: line-through; }
.toggle--all { border-color: transparent; color: var(--accent); font-weight: 600; padding-left: 10px; }
.toggle.c-s1 .toggle__dot { color: var(--s1); } .toggle.c-s2 .toggle__dot { color: var(--s2); }
.toggle.c-s3 .toggle__dot { color: var(--s3); } .toggle.c-s4 .toggle__dot { color: var(--s4); }
.toggle.c-s5 .toggle__dot { color: var(--s5); } .toggle.c-s6 .toggle__dot { color: var(--s6); }
.toggle.c-s7 .toggle__dot { color: var(--s7); } .toggle.c-s8 .toggle__dot { color: var(--s8); }
.chart-opts { display: grid; gap: 8px; }
.chart-opts .pills { margin-bottom: 0; }
.badge--sec { background: var(--accent-soft); color: var(--accent); opacity: .85; }

.tip {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; white-space: pre-line;
  background: var(--ink); color: var(--bg); font-size: .8rem; line-height: 1.45; padding: 7px 10px; border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18); max-width: 260px;
}

/* ---------- Variables ---------- */

.var-list { list-style: none; margin: 0; padding: 4px 0; max-width: 760px; }
.var-item { display: grid; grid-template-columns: 120px 1fr 1fr 124px; gap: 12px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.var-item:last-child { border-bottom: 0; }
.var-item__name { font-weight: 600; }
.var-item__unit { color: var(--ink-2); }
.badge { justify-self: start; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.badge--ind { background: var(--accent-soft); color: var(--accent); }

/* ---------- Modal y avisos ---------- */

.modal { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--ink); width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal::backdrop { background: rgba(10, 10, 9, .45); }
.modal__box { display: grid; gap: 16px; padding: 20px; }
.modal__head { display: flex; justify-content: space-between; align-items: center; }
.modal__body { display: grid; gap: 14px; }
.modal__body p { color: var(--ink-2); }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: .9rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); animation: in .2s ease-out; transition: opacity .3s, transform .3s; }
.toast--ok { border-left: 4px solid var(--ok); }
.toast--warn { border-left: 4px solid var(--warn); }
.toast--error { border-left: 4px solid var(--danger); }
.toast.is-out { opacity: 0; transform: translateY(6px); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Depuración ---------- */

.empty--error { max-width: 760px; }
.debug { width: 100%; text-align: left; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.debug summary { cursor: pointer; padding: 8px 12px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.debug pre {
  margin: 0; padding: 10px 12px; border-top: 1px solid var(--line); max-height: 360px; overflow: auto;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; color: var(--ink);
}
.toast--debug { max-width: min(640px, calc(100vw - 32px)); }
.toast .debug { margin-top: 8px; background: transparent; border-color: rgba(127,127,127,.4); }
.toast .debug summary, .toast .debug pre { color: inherit; }

/* ---------- Acceso ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login__card { width: min(360px, 100%); display: grid; gap: 16px; }

/* ---------- Pantallas chicas ---------- */

@media (max-width: 960px) {
  .obj-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .brand span { display: none; }
  .sync { font-size: 0; gap: 0; }
  .sync::before { width: 10px; height: 10px; }
  .page { padding: 20px 16px 64px; }
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .step { gap: 12px; }
  .step__num { width: 28px; height: 28px; }
  .var-row { grid-template-columns: 1fr 1fr 32px; }
  .var-row--single, .two { grid-template-columns: 1fr 1fr; }
  .var-item { grid-template-columns: 1fr auto; }
  .var-item .badge { grid-column: 1 / -1; }
  .chart-card__head { flex-direction: column; }
  .cell { min-width: 70px; }
  .table--capture th, .table--capture td { padding: 3px 2px; }
  .num-col { width: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Asistente: independiente secundaria opcional */
.sec-toggle { margin-top: 14px; }
.sec-box { margin-top: 10px; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); display: grid; gap: 10px; }
.sec-box[hidden] { display: none; }

/* Cualquier elemento con hidden se oculta aunque su clase le dé display */
[hidden] { display: none !important; }

/* Decimales a mostrar */
.dec-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.field .dec-row input[name=decimales] { width: 84px; flex: none; }
.pill--sm { font-size: .78rem; padding: 3px 10px; }

/* Conversor de unidades */
.conv { display: grid; gap: 14px; }
.conv fieldset.field { display: grid; gap: 8px; }
.conv__nombre { margin-left: 26px; }
.conv__preview { display: grid; gap: 8px; padding: 12px; border-radius: 8px; background: var(--surface-2); }
.conv__preview:empty { display: none; }
.conv__formula { font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.conv__tabla { font-size: .82rem; }
.conv__tabla td, .conv__tabla th { padding: 4px 8px; }
.conv__tabla td:first-child { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv__stats { font-size: .85rem; font-variant-numeric: tabular-nums; }
.conv__mas { font-size: .8rem; }
.conv__msg { color: var(--danger); font-size: .88rem; font-weight: 600; }
.conv__msg--warn { color: var(--warn); }
.conv__bad { color: var(--danger); font-weight: 600; }
.conv__confirm { border: 1px solid var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); padding: 10px 12px; border-radius: 8px; font-size: .9rem; }
.conv__aviso { font-size: .8rem; }

/* Historial de conversiones */
.conv-list { list-style: none; margin: 0; padding: 4px 0; max-width: 760px; }
.conv-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.conv-item:last-child { border-bottom: 0; }
.conv-item__body { display: grid; gap: 2px; min-width: 0; }
.conv-item__body p { margin: 0; overflow-wrap: anywhere; }
.conv-item small { font-size: .78rem; }
.conv-item.is-undone .conv-item__body p { color: var(--muted); text-decoration: line-through; }
.conv-item__undone { color: var(--warn); font-weight: 600; }
.modal { max-height: calc(100dvh - 32px); overflow: auto; }
.modal:has(.conv) { width: min(680px, calc(100vw - 32px)); }

.var-item > .actions { justify-content: flex-end; }
.conv .radio { align-items: flex-start; }
.conv .radio input { margin-top: 3px; flex: none; }

/* Notas */
.notas-obj { display: grid; gap: 6px; padding: 12px 16px; margin-bottom: 20px; }
.notas-obj__label { display: flex; gap: 8px; align-items: baseline; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
textarea.nota {
  width: 100%; resize: vertical; min-height: 38px; font: inherit; font-size: .9rem; line-height: 1.45; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px;
}
textarea.nota:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
textarea.nota::placeholder { color: var(--muted); opacity: .75; }
.notas-obj textarea.nota { min-height: 54px; }
.nota-estado { font-size: .75rem; font-weight: 500; color: var(--muted); margin-left: auto; }
.nota-estado[data-estado="offline"], .nota-estado[data-estado="error"] { color: var(--warn); }
.nota-row td { padding-top: 0 !important; border-top: 0; }
.nota-row .nota-estado { display: block; text-align: right; }
.nota-row .nota-estado:empty { display: none; }
.nota-col { width: 40px; }
.btn-nota { opacity: .45; }
.btn-nota.has-note, .btn-nota[aria-expanded="true"] { opacity: 1; color: var(--accent); }
.obj-nota { display: flex; gap: 4px; align-items: center; color: var(--muted); font-size: .78rem; margin-top: 2px; max-width: 320px; }
.obj-nota span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.obj-nota svg { width: 12px; height: 12px; flex: none; }

/* Botón de la línea de tendencia (se enciende/apaga) */
.pills__sep { width: 1px; align-self: stretch; background: var(--line-strong); margin: 2px 4px; }
.pill--toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
