:root {
  --blue: #0B53A4; --blue-soft: #e7f0fb; --navy: #0F2A4A; --orange: #FF8200; --orange-soft: #fff1e3;
  --bg: #F4F7FB; --card: #ffffff; --line: #dfe6ef; --text: #0F2A4A; --muted: #5d6d82;
  --hot: #d92d20; --hot-bg: #fdecea; --warm: #b54708; --warm-bg: #fef3e2; --cold: #3a6ea5; --cold-bg: #e8f0fa;
  --ok: #127a3a; --ok-bg: #e5f6ec; --shadow: 0 6px 24px rgba(15, 42, 74, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #5b9be6; --blue-soft: #16304f; --navy: #e6edf6; --orange: #ff9a33; --orange-soft: #3a2611;
    --bg: #0b1626; --card: #122135; --line: #23364f; --text: #e6edf6; --muted: #9db0c6;
    --hot: #ff7a6e; --hot-bg: #3b1714; --warm: #f5b35c; --warm-bg: #3a2610; --cold: #8db8ec; --cold-bg: #142a45;
    --ok: #59d08b; --ok-bg: #0f3020; --shadow: 0 6px 24px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --blue: #5b9be6; --blue-soft: #16304f; --navy: #e6edf6; --orange: #ff9a33; --orange-soft: #3a2611;
  --bg: #0b1626; --card: #122135; --line: #23364f; --text: #e6edf6; --muted: #9db0c6;
  --hot: #ff7a6e; --hot-bg: #3b1714; --warm: #f5b35c; --warm-bg: #3a2610; --cold: #8db8ec; --cold-bg: #142a45;
  --ok: #59d08b; --ok-bg: #0f3020; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, sans-serif; }
a { color: var(--blue); }
h1, h2, h3 { font-family: Poppins, Inter, sans-serif; margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: .98rem; }
.muted { color: var(--muted); } .err { color: var(--hot); min-height: 1.2em; } .small { font-size: 12px; }
[hidden] { display: none !important; }

.brand { display: flex; align-items: center; gap: 10px; font: 700 17px Poppins, sans-serif; color: var(--blue); }
.logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--blue), var(--orange)); flex: none; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--hot); border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.inline input { width: auto; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.top nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.top nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
.top nav a.on { background: var(--blue-soft); color: var(--blue); }
.view { padding: 20px; max-width: 1400px; margin: 0 auto; outline: none; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.bar .grow { flex: 1 1 220px; }
.bar select { width: auto; }
.spacer { flex: 1; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(150px, 1.4fr) 140px 120px 70px 90px; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--blue-soft); }
.row.head { cursor: default; background: transparent; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.chip.caliente { background: var(--hot-bg); color: var(--hot); }
.chip.tibio { background: var(--warm-bg); color: var(--warm); }
.chip.frio { background: var(--cold-bg); color: var(--cold); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.gray { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.src { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.src i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.late { color: var(--hot); font-weight: 600; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; min-height: 200px; }
.col.drop { outline: 2px dashed var(--blue); }
.col-h { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 4px 10px; }
.col-h b { font-family: Poppins, sans-serif; }
.cardl { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: grab; }
.cardl:hover { border-color: var(--blue); }
.cardl .t { font-weight: 600; margin-bottom: 4px; }
.cardl .m { display: flex; justify-content: space-between; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .v { font: 700 1.6rem Poppins, sans-serif; margin-top: 2px; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.hbar .track { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 6px; background: var(--blue); }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
table.t th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }

.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.source-card { display: grid; gap: 10px; align-content: start; }
.source-card .h { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.steps { margin: 0; padding-left: 18px; color: var(--muted); }
.steps li { margin: 3px 0; }
pre.code { margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto; }
.copy-row { display: flex; gap: 6px; } .copy-row input { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.qr { width: 160px; height: 160px; background: #fff; padding: 8px; border-radius: 8px; }
.qr img, .qr canvas { width: 100% !important; height: 100% !important; }

.drawer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.drawer-bg { position: absolute; inset: 0; background: rgba(8, 20, 36, .45); opacity: 0; transition: opacity .2s; }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(640px, 100%); background: var(--card); box-shadow: -10px 0 30px rgba(0, 0, 0, .2); transform: translateX(100%); transition: transform .22s ease; overflow-y: auto; padding: 20px 22px 40px; }
.drawer.open { pointer-events: auto; } .drawer.open .drawer-bg { opacity: 1; } .drawer.open .drawer-panel { transform: none; }
.d-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fields .full { grid-column: 1 / -1; }
.section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 16px; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.timeline .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft); font-size: 13px; }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .txt { white-space: pre-wrap; word-break: break-word; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--card); color: var(--text); width: min(440px, calc(100% - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 20, 36, .5); }
#dlgForm { padding: 18px; display: grid; gap: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(120%); background: var(--navy); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; transition: transform .2s; z-index: 80; max-width: calc(100% - 32px); }
.toast.show { transform: translateX(-50%); }
.progress { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; } .progress > div { height: 100%; background: var(--orange); width: 0; transition: width .2s; }
.stage-list { display: grid; gap: 6px; } .stage-list .copy-row input:first-child { max-width: 140px; }

@media (max-width: 860px) {
  .row { grid-template-columns: 1fr auto; }
  .row > :nth-child(n+2):not(.score) { display: none; }
  .row.head { display: none; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; padding: 10px 16px; gap: 8px; } .top nav { order: 3; flex-basis: 100%; }
  .view { padding: 14px 16px; } .fields { grid-template-columns: 1fr; } dl.kv { grid-template-columns: 110px 1fr; }
  .hbar { grid-template-columns: 96px 1fr 36px; } .grid2, .sources { grid-template-columns: 1fr; }
}
