:root {
  --red: #e11d2a;
  --red-dark: #a30010;
  --ink: #1f2023;
  --ink-2: #4a4d55;
  --muted: #7a7e88;
  --line: #e3e5ea;
  --bg: #f4f5f7;
  --card: #ffffff;
  --side: #262626;
  --ok: #138a4b;
  --ok-bg: #e5f6ec;
  --warn: #a86200;
  --warn-bg: #fff3df;
  --bad: #b3141f;
  --bad-bg: #fde8ea;
  --info: #2a5bd7;
  --info-bg: #e8eefc;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--red); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.boot { padding: 40px; color: var(--muted); }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #ddd; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; border-bottom: 1px solid #3a3a3a; margin-bottom: 10px; }
.side .brand img { width: 46px; background: #fff; border-radius: 6px; padding: 3px; }
.side .brand b { color: #fff; display: block; font-size: 15px; }
.side .brand small { color: #aaa; }
.side a.nav { color: #ddd; text-decoration: none; padding: 9px 12px; border-radius: 8px; display: block; }
.side a.nav:hover { background: #333; }
.side a.nav.active { background: var(--red); color: #fff; }
.side .spacer { flex: 1; }
.side .who { font-size: 12px; color: #aaa; padding: 8px 12px; border-top: 1px solid #3a3a3a; }
.side .who b { color: #fff; display: block; font-size: 13px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { margin: 0; flex: 1; }
.menu-btn { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .main { padding: 16px 16px 60px; }
  .menu-btn { display: inline-flex; }
}

/* Cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.section { border-left: 4px solid var(--red); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
label, .label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #cfd3da; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(225, 29, 42, .25); border-color: var(--red); }
textarea { resize: vertical; min-height: 64px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--red); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid #cfd3da; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: #fff; color: var(--ink-2); padding: 8px 14px; }
.seg button.on { background: var(--ink); color: #fff; }

/* Buttons */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  background: var(--red); color: #fff; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
}
button:hover, .btn:hover { filter: brightness(.95); }
button:disabled { opacity: .5; cursor: default; }
.btn-dark { background: var(--ink); }
.btn-ghost { background: #fff; color: var(--ink); border-color: #cfd3da; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ok { background: var(--ok); }
.btn-bad { background: var(--bad); }
.btn-warn { background: #d98200; }
.btn-link { background: none; color: var(--red); padding: 4px 6px; border: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #fafbfc; font-size: 12px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td input { padding: 6px 8px; }
.calc-table th, .calc-table td { padding: 6px 8px; }
.out { font-weight: 700; color: var(--ink); white-space: nowrap; }
.out.muted { color: var(--muted); font-weight: 500; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-enviada { background: var(--info-bg); color: var(--info); }
.st-ganado { background: var(--ok-bg); color: var(--ok); }
.st-perdido { background: var(--bad-bg); color: var(--bad); }
.st-validacion { background: var(--warn-bg); color: var(--warn); }
.tag { display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11px; background: #eef0f3; color: var(--ink-2); margin: 1px; }

/* Label item blocks */
.item-block { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; background: #fcfcfd; }
.item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.item-head b { flex: 1; }
.kit-sum { background: #fff6f6; border: 1px solid #f3c9cc; border-radius: 8px; padding: 10px; margin-top: 10px; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #262626 0 55%, #e11d2a 55% 58%, #262626 58%); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .logo { display: block; width: 160px; margin: 0 auto 16px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth h1 { text-align: center; font-size: 19px; }
.qr { display: grid; place-items: center; margin: 8px 0; }
.qr img, .qr svg { width: 190px; height: 190px; }
.secret { font-family: Consolas, monospace; background: #f2f3f5; padding: 6px 8px; border-radius: 6px; word-break: break-all; font-size: 12px; text-align: center; }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 22px; }
.modal.lg { max-width: 820px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 360px; }
.toast.err { background: var(--bad); }
.error { color: var(--bad); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 860px) { .filters { grid-template-columns: 1fr 1fr; } }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.img-prev { max-width: 320px; max-height: 160px; border: 1px solid var(--line); border-radius: 8px; display: block; margin-bottom: 8px; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(244, 245, 247, .95); padding: 12px 0; border-top: 1px solid var(--line); z-index: 5; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
