:root {
  --ground:#f2f3ee; --surface:#ffffff; --surface-2:#fafaf7; --line:#e1e2da;
  --ink:#1e211d; --muted:#6c7069; --accent:#2e4a58; --accent-ink:#ffffff;
  --danger:#97402f; --focus:#2e4a58;
  --winter:#4c6fa5; --spring:#4e8c57; --summer:#a8761f; --fall:#a9552f;
  --shadow:0 1px 1px rgba(30,33,29,.04), 0 6px 20px rgba(30,33,29,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground:#16181a; --surface:#1d2023; --surface-2:#232729; --line:#32373b;
    --ink:#e9eae5; --muted:#9aa09b; --accent:#8fbecb; --accent-ink:#10222a;
    --danger:#e08670; --focus:#8fbecb;
    --winter:#8fb0e0; --spring:#87c091; --summer:#dcb463; --fall:#dd9070;
    --shadow:0 1px 1px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.28);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.brand { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 26px; letter-spacing: -.015em; line-height: 1; margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: 9px; padding: 10px 18px; font-weight: 600; cursor: pointer; }
.primary:hover { filter: brightness(1.08); }

/* Puerta de entrada */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: min(360px, 100%); padding: 26px 22px; display: flex; flex-direction: column; gap: 14px; }
.gate-note { margin: -6px 0 4px; color: var(--muted); font-size: 14px; }
.gate-error { margin: 0; color: var(--danger); font-size: 13.5px; }

.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f label, .f > span { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.f input, .f select { width: 100%; min-width: 0; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); font-size: 16px; }
.f input[type="number"] { font-family: "IBM Plex Mono", ui-monospace, monospace; }

.shell { max-width: 1080px; margin: 0 auto; padding: 0 16px 72px; }

header.bar { position: sticky; top: 0; z-index: 5; background: var(--ground); padding: 18px 0 12px; border-bottom: 1px solid var(--line); }
.brandrow { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tally { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.state { margin-left: auto; font-size: 12.5px; color: var(--muted); letter-spacing: .02em; }
.state.busy { color: var(--accent); }
.state.bad { color: var(--danger); font-weight: 600; }

.searchrow { display: flex; gap: 8px; margin-top: 12px; }
.search { position: relative; flex: 1 1 auto; }
.search input { width: 100%; padding: 12px 38px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.search .mag { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; line-height: 0; }
.search .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px 8px; font-size: 15px; }
.search .clear[hidden] { display: none; }

.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 12px 0 0; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.filters select { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 10px; font-size: 13px; max-width: 190px; }
.spacer { flex: 1 1 auto; }
.ghost { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--muted); text-decoration: none; display: inline-block; }
.ghost:hover { color: var(--ink); border-color: var(--muted); }

form.entry { margin-top: 16px; padding: 14px; }
.entry .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }
.f.wide { grid-column: 1 / -1; }
.entry .foot, dialog .foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.keep { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; }
.keep input { accent-color: var(--accent); }

.listwrap { margin-top: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 12px 10px; white-space: nowrap; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
thead th.plain { cursor: default; }
thead th .car { font-size: 9px; opacity: .6; }
tbody td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.thing { font-weight: 600; }
.note { color: var(--muted); font-size: 12.5px; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
td.num { text-align: right; }
td.when { color: var(--muted); white-space: nowrap; font-size: 12.5px; }
td.ops { text-align: right; white-space: nowrap; }
.op { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; }
.op:hover { border-color: var(--muted); }
.op.kill { color: var(--danger); }
.season { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.season.Winter { color: var(--winter); background: color-mix(in srgb, var(--winter) 15%, transparent); }
.season.Spring { color: var(--spring); background: color-mix(in srgb, var(--spring) 15%, transparent); }
.season.Summer { color: var(--summer); background: color-mix(in srgb, var(--summer) 15%, transparent); }
.season.Fall   { color: var(--fall);   background: color-mix(in srgb, var(--fall) 15%, transparent); }
.blank { color: var(--muted); opacity: .5; }
.nothing { padding: 36px 16px; text-align: center; color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20,22,20,.5); }
dialog form { padding: 16px; }
dialog h2 { margin: 0 0 14px; font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 19px; }

@media (max-width: 760px) {
  .shell { padding: 0 12px 64px; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  .listwrap { overflow-x: visible; }
  tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
  tbody td { border: 0; padding: 1px 0; }
  td:empty { display: none; }
  td::before { content: attr(data-k) " "; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
  td.thingcell { grid-column: 1 / -1; font-size: 16px; }
  td.thingcell::before { content: none; }
  td.num { text-align: left; }
  td.ops { grid-column: 1 / -1; text-align: left; display: flex; gap: 8px; margin-top: 9px; }
  td.ops::before { content: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
