:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --glass: rgba(245, 245, 247, 0.78);
  --border: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --text-2: #424245;
  --muted: #86868b;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --grid: #ececf0;
  --good: #1f8a3b;
  --bad: #d70015;
  --warn-bg: #fff4d6;
  --warn-text: #7a5300;
  --bad-bg: #ffe5e7;
  --bad-text: #b0000f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --neg: #e34948;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --glass: rgba(22, 22, 23, 0.72);
    --border: rgba(255, 255, 255, 0.1);
    --text: #f5f5f7;
    --text-2: #d1d1d6;
    --muted: #98989d;
    --accent: #2997ff;
    --accent-soft: rgba(41, 151, 255, 0.16);
    --grid: #2c2c2e;
    --good: #30d158;
    --bad: #ff453a;
    --warn-bg: #3a2e0c;
    --warn-text: #f5cf73;
    --bad-bg: #3b1616;
    --bad-text: #ff8a80;
    --shadow: none;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --neg: #e66767;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 32px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { font: 13px ui-monospace, "SF Mono", Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ---------- controls ---------- */
button {
  font: inherit; font-weight: 500; cursor: pointer; border: 0; border-radius: 980px;
  padding: 8px 16px; background: var(--accent); color: #fff; transition: opacity .15s, background .15s;
}
button:hover { opacity: .88; }
button:disabled { opacity: .4; cursor: default; }
button.secondary { background: var(--surface-2); color: var(--text); }
button.plain { background: none; color: var(--accent); padding: 6px 4px; border-radius: 6px; }
button.plain.strong { font-weight: 600; }
button.round { width: 36px; height: 36px; padding: 0; font-size: 20px; line-height: 36px; }
button.pill-btn { padding: 4px 12px; font-size: 13px; background: var(--accent-soft); color: var(--accent); }
button.danger-link { background: none; color: var(--bad); width: 100%; padding: 12px; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid transparent; border-radius: 10px; padding: 9px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2386868b' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center; }
.login-card h1 { font-size: 28px; }
.login-card p { margin: 0 0 8px; }
.login-card button[type=submit] { padding: 11px; }
.logo { width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, #0071e3, #5e5ce6); color: #fff; font-weight: 700; font-size: 22px; }
.logo.small { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; margin: 0; }
.msg { margin: 0; font-size: 13px; color: var(--text-2); }
.msg.error { color: var(--bad-text); background: var(--bad-bg); padding: 10px 12px; border-radius: 10px; text-align: left; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px;
  padding: 20px 12px; border-right: 1px solid var(--border); background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 0 8px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a, .tabbar a { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; border-radius: 8px; padding: 7px 10px; }
.sidebar nav a:hover { background: var(--surface-2); }
.sidebar nav a[aria-current=page] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar-foot { margin-top: auto; display: grid; gap: 4px; padding: 0 8px; justify-items: start; overflow-wrap: anywhere; }
.main { min-width: 0; --gutter: max(32px, calc((100% - 1240px) / 2)); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 24px var(--gutter) 10px; background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.add-wrap { position: relative; display: flex; gap: 10px; align-items: center; }
.menu { position: absolute; right: 0; top: 44px; z-index: 20; min-width: 210px; padding: 6px; border-radius: 14px;
  background: var(--surface); box-shadow: 0 10px 40px rgba(0,0,0,.18); border: 1px solid var(--border); display: grid; }
.menu button { background: none; color: var(--text); text-align: left; border-radius: 8px; padding: 8px 12px; font-weight: 400; }
.menu button:hover { background: var(--accent); color: #fff; opacity: 1; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 4px var(--gutter) 16px; }
.filterbar:empty { display: none; }
.custom-range { display: contents; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 980px; padding: 0 0 0 12px; font-size: 13px; color: var(--muted); box-shadow: var(--shadow); }
.pill.on { border-color: var(--accent); background: var(--accent-soft); }
.pill.on select { color: var(--accent); }
.pill select { background-color: transparent; border: 0; padding: 6px 28px 6px 2px; font-size: 13px; font-weight: 500; width: auto; border-radius: 980px; }
.view { padding: 0 var(--gutter) 48px; display: grid; gap: 20px; }
.subtitle { margin: -6px 0 0; color: var(--muted); font-size: 13px; }
.tabbar { display: none; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); min-width: 0; border: 1px solid var(--border); }
.card.flush { padding: 4px 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head.wrap { flex-wrap: wrap; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: 3fr 2fr; } }
.empty { color: var(--muted); text-align: center; padding: 24px 0; margin: 0; }

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.kpi.accent { background: linear-gradient(135deg, #0071e3, #5e5ce6); color: #fff; border: 0; }
.kpi.accent .kpi-label, .kpi.accent .delta { color: rgba(255,255,255,.8); }
.delta { font-size: 12px; color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.spark { width: 100%; height: 32px; margin-top: 8px; }
.spark .line { stroke-width: 1.5; }
.kpis.small { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.kpis.small .kpi { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.kpis.small .kpi-value { font-size: 19px; }

/* segmented & chips */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 2px; }
.segmented button { background: none; color: var(--text); border-radius: 7px; padding: 4px 12px; font-size: 13px; }
.segmented button[aria-pressed=true] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
@media (prefers-color-scheme: dark) { .segmented button[aria-pressed=true] { background: #636366; } }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chips button { background: var(--surface-2); color: var(--muted); font-size: 13px; padding: 4px 12px; display: inline-flex; align-items: center; gap: 6px; }
.chips button[aria-pressed=true] { color: var(--text); background: var(--accent-soft); }
.chips button[aria-pressed=false] .swatch { opacity: .35; }
select.mini { width: auto; padding: 5px 30px 5px 10px; font-size: 13px; border-radius: 9px; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list li > span:first-child { flex: 1; min-width: 0; display: grid; }
.list small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row { cursor: pointer; border-radius: 8px; }
.link-row:hover { background: var(--surface-2); }

.badge { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge.confirmado { background: rgba(31,138,59,.12); color: var(--good); }
.badge.provisional { background: var(--warn-bg); color: var(--warn-text); }
.badge.sin_definir { background: var(--bad-bg); color: var(--bad-text); }
.badge.off { background: var(--surface-2); color: var(--muted); }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 420px; background-color: var(--surface); border-color: var(--border); }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
.th-btn { background: none; color: inherit; padding: 0; font: inherit; border-radius: 0; }
.th-btn .arrow { margin-left: 4px; color: var(--accent); }
th.num .th-btn { text-align: right; }
td.num, th.num { text-align: right; }
td.neg { color: var(--bad); }
td.note { white-space: normal; color: var(--muted); min-width: 200px; font-size: 13px; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover td { background: var(--surface-2); }
tfoot td, tr.total td { font-weight: 600; border-bottom: 0; }
td.ok { color: var(--good); }
tr.bad td { color: var(--bad-text); background: var(--bad-bg); white-space: normal; }

/* ---------- charts ---------- */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis-label { fill: var(--muted); font-size: 12px; }
.chart .rank-label { fill: var(--text); font-size: 13px; }
.chart .rank-value { fill: var(--text-2); font-size: 13px; font-weight: 500; }
.chart .rank-value.neg { fill: var(--bad); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; }
.bar { transition: opacity .15s; }
.bar.dim { opacity: .35; }
.bar.s1 { fill: var(--s1); } .bar.s2 { fill: var(--s2); } .bar.s3 { fill: var(--s3); } .bar.s4 { fill: var(--s4); }
.bar.neg { fill: var(--neg); }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.s1 { stroke: var(--s1); } .line.s2 { stroke: var(--s2); } .line.s3 { stroke: var(--s3); } .line.s4 { stroke: var(--s4); }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot.s1 { fill: var(--s1); } .dot.s2 { fill: var(--s2); } .dot.s3 { fill: var(--s3); } .dot.s4 { fill: var(--s4); }
.kpi.accent .spark .line { stroke: rgba(255,255,255,.85); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.s1 { background: var(--s1); } .swatch.s2 { background: var(--s2); } .swatch.s3 { background: var(--s3); } .swatch.s4 { background: var(--s4); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; list-style: none; padding: 0; margin: 0 0 10px; font-size: 13px; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }

.tooltip { position: fixed; z-index: 50; pointer-events: none; min-width: 160px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,.16); font-size: 13px; padding: 8px 12px; border-radius: 10px; }
.tip-title { font-weight: 600; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row b { margin-left: auto; padding-left: 12px; }

/* ---------- sheet (dialog) ---------- */
.sheet { border: 0; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 32px)); max-height: 88vh;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.sheet:has(.wide) { width: min(820px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(0,0,0,.32); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.sheet[open] { animation: rise .28s cubic-bezier(.2,.9,.3,1); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-body { padding: 0 20px 20px; display: grid; gap: 14px; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  margin: 0 -20px; padding: 14px 16px; background: var(--glass); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.sheet-head h2 { font-size: 17px; text-align: center; }
.sheet-head button:first-child { justify-self: start; }
.sheet-head button:last-child { justify-self: end; }
.fields { display: flex; flex-wrap: wrap; gap: 12px; }
.field { display: grid; gap: 4px; flex: 1 1 100%; font-size: 13px; color: var(--muted); }
.field.half { flex: 1 1 calc(50% - 6px); min-width: 140px; }
.field.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.field.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.suffix { position: relative; }
.suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.preview { margin: 0; font-size: 14px; color: var(--text-2); }
.preview:empty { display: none; }
.contact { color: var(--text-2); font-size: 14px; }

/* ---------- console ---------- */
textarea.console { font: 14px/1.6 ui-monospace, "SF Mono", Menlo, monospace; resize: vertical; margin-bottom: 12px; }
.row-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-bottom: 12px; }
.row-actions .muted { margin-right: auto; font-size: 13px; }
.help { background: var(--surface-2); border-radius: 12px; padding: 4px 16px 12px; margin-bottom: 14px; font-size: 14px; }
.help pre { font: 13px/1.6 ui-monospace, "SF Mono", Menlo, monospace; overflow-x: auto; margin: 8px 0; }
.ref-list { columns: 2 260px; font-size: 13px; padding-left: 18px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 980px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: rise .25s; }
.toast.error { background: var(--bad); color: #fff; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { --gutter: 16px; }
  .topbar { padding: 16px 16px 8px; }
  h1 { font-size: 28px; }
  .filterbar { flex-wrap: nowrap; overflow-x: auto; padding: 4px 16px 12px; scrollbar-width: none; }
  .filterbar::-webkit-scrollbar { display: none; }
  .pill { flex: none; }
  .view { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); gap: 16px; }
  .card { padding: 16px; border-radius: 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi.accent { grid-column: 1 / -1; }
  .kpi-value { font-size: 21px; }
  .toolbar-actions { margin-left: 0; }
  .toolbar .search { max-width: none; }
  .tabbar { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; inset: auto 0 0 0; z-index: 10;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--glass); border-top: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
  .tabbar a { flex-direction: column; gap: 2px; font-size: 10px; padding: 4px 0; color: var(--muted); }
  .tabbar a[aria-current=page] { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .sheet:has(.wide) { width: 100vw; }
}

/* ================= v3 polish ================= */
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.ico.dim { color: var(--muted); }
button .ico { margin-right: 2px; }
button.round .ico { width: 18px; height: 18px; margin: 0; vertical-align: -4px; }
.mono, code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.warn-text { color: var(--warn-text); }
@media (prefers-color-scheme: light) { .warn-text { color: #9a6700; } }
.hint { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--text-2); font-size: 14px; }
.hint .ico { color: var(--accent); margin-top: 2px; }

/* identity marks */
.room-icon { --c: #888; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(145deg, color-mix(in srgb, var(--c) 82%, #fff), var(--c)); color: #fff;
  font: 700 9px/1 -apple-system, system-ui, sans-serif; letter-spacing: -0.02em; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,.15); }
.room-icon.lg { width: 34px; height: 34px; border-radius: 9px; font-size: 12px; }
.avatar { --h: 210; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: hsl(var(--h) 60% 92%); color: hsl(var(--h) 45% 32%); font: 600 10px/1 -apple-system, system-ui, sans-serif; }
@media (prefers-color-scheme: dark) { .avatar { background: hsl(var(--h) 35% 26%); color: hsl(var(--h) 70% 82%); } }
.avatar.lg { width: 38px; height: 38px; font-size: 14px; }
.room-tag, .player-tag { display: inline-flex; align-items: center; gap: 8px; }
.row-main { display: flex !important; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.row-main > span:last-child { display: grid; min-width: 0; }
.list li { gap: 12px; padding: 11px 4px; }
.sheet-head h2.with-avatar { display: flex; align-items: center; gap: 8px; justify-content: center; }
.chart .rank-icon { fill: #fff; font: 700 8px -apple-system, system-ui, sans-serif; }
.kpi-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.kpi-dot.s1 { background: var(--s1); } .kpi-dot.s2 { background: var(--s2); } .kpi-dot.s3 { background: var(--s3); } .kpi-dot.s4 { background: var(--s4); }
.plain-link { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.card { transition: box-shadow .2s; }
.kpi:hover { box-shadow: 0 2px 6px rgba(0,0,0,.05), 0 10px 28px rgba(0,0,0,.07); }
table td { vertical-align: middle; }

/* topbar search */
.search-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  padding: 7px 10px 7px 12px; font-weight: 400; box-shadow: var(--shadow); }
.search-btn kbd, .palette kbd { font: 11px -apple-system, system-ui; background: var(--surface-2); border-radius: 5px; padding: 2px 6px; color: var(--muted); }

/* skeleton */
.sk { min-height: 120px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.sk.tall { min-height: 300px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* buttons */
button.big { padding: 12px 22px; font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
button.big .ico { width: 18px; height: 18px; }
button.secondary.danger { color: var(--bad); }
.icon-btn { background: var(--surface-2); color: var(--text-2); width: 32px; height: 32px; padding: 0; border-radius: 9px; display: inline-grid; place-items: center; flex: none; }
.icon-btn .ico { margin: 0; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); opacity: 1; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.segmented.big-seg button { padding: 7px 16px; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.page-seg { margin-bottom: 4px; }
.view-inner { display: grid; gap: 20px; }

/* hero */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.hero > div:first-child { display: grid; gap: 2px; }
.hero-value { font-size: 40px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; }
.net-summary { display: flex; gap: 10px; flex-wrap: wrap; }
.net-summary > div { display: grid; background: var(--surface-2); border-radius: 12px; padding: 10px 14px; min-width: 140px; }
.net-summary b { font-size: 18px; }

/* wallets & batches */
.wallet-chip { display: block; background: none; color: var(--text-2); padding: 2px 0; font-size: 13px; text-align: left; border-radius: 0; font-weight: 400; }
.wallet-chip:hover { color: var(--accent); opacity: 1; }
.wallet-chip code { background: none; padding: 0; font-size: 12px; color: var(--muted); }
.wallet-ico, .batch-ico { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); flex: none; }
.batch-ico.done { background: rgba(31,138,59,.12); color: var(--good); }
.pay-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.pay-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px; display: grid; gap: 12px; box-shadow: var(--shadow); transition: opacity .2s, border-color .2s; }
.pay-card.sent { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.pay-card.sent .pay-amount, .pay-card.sent .pay-addr { opacity: .55; }
.pay-head { display: flex; align-items: center; gap: 12px; }
.pay-head > div { display: grid; flex: 1; }
.pay-amount { display: flex; align-items: center; gap: 10px; }
.pay-amount > span { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.pay-amount > span small { font-size: 15px; font-weight: 600; color: var(--muted); }
.pay-amount > small { margin-left: auto; }
.pay-addr { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 8px 8px 8px 12px; }
.pay-addr code { flex: 1; background: none; padding: 0; font-size: 13px; word-break: break-all; }
.pay-foot { display: flex; gap: 8px; }
.pay-foot input { flex: 1; font-size: 13px; }
.confirm-bar button { white-space: nowrap; flex: none; }
.confirm-bar { position: sticky; bottom: 16px; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 20px; border-radius: 16px; background: var(--glass); border: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 8px 30px rgba(0,0,0,.1); }

/* generator */
.gen-top { display: flex; gap: 12px; flex-wrap: wrap; }
.gen-actions { display: flex; gap: 12px; }
.gen-list { display: grid; gap: 6px; }
.gen-row { display: grid; grid-template-columns: auto auto 1fr minmax(160px, 230px) 120px; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); transition: opacity .15s; }
.gen-row.off { opacity: .45; }
.gen-row.below { display: none; }
.gen-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.gen-name { display: grid; min-width: 0; }
.gen-row .g-amount { text-align: right; padding-right: 26px; background: var(--surface); }
.gen-row select { background-color: var(--surface); }
.gen-total { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.net-chip { font-size: 12px; background: var(--surface-2); padding: 3px 10px; border-radius: 999px; color: var(--text-2); }

/* data loading */
.load-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.load-ctx { display: flex; gap: 12px; flex-wrap: wrap; }
.load-ctx .field { flex: none; width: 220px; }
.grid-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.mg { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 0 20px 6px; box-shadow: var(--shadow); margin-bottom: 16px; }
.mg-room { display: flex; align-items: center; gap: 10px; margin: 0 -20px; padding: 10px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 14px; }
.mg-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 64px 150px 220px; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mg-row:last-child { border-bottom: 0; }
.mg-head { position: sticky; top: 0; padding: 12px 0 10px; font-size: 12px; font-weight: 500; color: var(--muted); }
.mg-head .r { text-align: right; padding-right: 12px; }
.mg-head .mg-out, .mg-head .mg-out span { color: var(--muted); font-weight: 500; font-size: 12px; }
.mg-name { display: grid; min-width: 0; }
.mg-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-input { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.mg-row.saved .mg-input { background: transparent; border-color: var(--border); }
.mg-row.dirty .mg-input { border-color: var(--accent); background: var(--accent-soft); }
.mg-row.neg .mg-input { color: var(--bad); }
.mg-row.nodeal .mg-name { opacity: .6; }
.mg-fix { grid-column: 3 / -1; text-align: right; }
.mg-out { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mg-out b { color: var(--text); }
.mg-out .wide { grid-column: 1 / -1; }
.mg-row .cur { justify-self: center; min-width: 52px; }
.cur { background: var(--surface-2); color: var(--text-2); padding: 5px 10px; font-size: 12px; font-weight: 600; border-radius: 7px; }
.cur:hover { background: var(--accent-soft); color: var(--accent); opacity: 1; }
.paste-result { display: grid; gap: 4px; font-size: 14px; }
.ok-line { color: var(--good); } .ok-line b { color: var(--text); margin-left: 6px; }
.bad-line { color: var(--bad-text); }

/* quick text */
.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.example { background: var(--surface-2); color: var(--text-2); font: 12px ui-monospace, "SF Mono", Menlo, monospace; padding: 5px 10px; }
.example:hover { background: var(--accent-soft); color: var(--accent); opacity: 1; }
.editor { position: relative; }
.suggest { position: absolute; left: 12px; right: 12px; top: 100%; margin-top: -6px; z-index: 10; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 6px; display: grid; }
.suggest button { display: flex; align-items: center; gap: 10px; background: none; color: var(--text); text-align: left; padding: 8px 10px; border-radius: 8px; font-weight: 400; }
.suggest button:hover { background: var(--accent-soft); opacity: 1; }
.preview-cards { display: grid; gap: 8px; }
.pcard { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.pcard > div:not(.amt) { display: grid; flex: 1; min-width: 0; }
.pcard.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-bg); }
.pcard.bad b { color: var(--bad-text); }
.pcard-n { font: 12px ui-monospace, monospace; color: var(--muted); width: 18px; }
.pcard .amt { display: grid; text-align: right; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* palette */
.palette-dlg { border: 0; padding: 0; background: transparent; width: min(620px, calc(100vw - 32px)); margin-top: 12vh; }
.palette-dlg::backdrop { background: rgba(0,0,0,.25); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.palette { background: var(--surface); color: var(--text); border-radius: 16px; overflow: hidden; box-shadow: 0 24px 80px rgba(0,0,0,.35); border: 1px solid var(--border); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input .ico { width: 20px; height: 20px; }
.palette-input input { border: 0; background: none; font-size: 18px; padding: 0; }
.palette-input input:focus { background: none; }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palette-list li { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.palette-list li span { flex: 1; }
.palette-list li small { color: var(--muted); font-size: 12px; }
.palette-list li[aria-selected=true] { background: var(--accent); color: #fff; }
.palette-list li[aria-selected=true] small { color: rgba(255,255,255,.8); }

@media (max-width: 860px) {
  .search-btn span, .search-btn kbd { display: none; }
  .hero-value { font-size: 32px; }
  .pay-list { grid-template-columns: 1fr; }
  .gen-row { grid-template-columns: auto auto 1fr; }
  .gen-row select, .gen-row .g-amount-wrap { grid-column: 1 / -1; }
  .mg-row { grid-template-columns: 28px minmax(0, 1fr) 56px 110px; gap: 10px; }
  .mg-row > .mg-out { grid-column: 2 / -1; }
  .mg-head > .mg-out { display: none; }
  .load-ctx, .load-ctx .field { width: 100%; flex: 1 1 100%; }
  .big-seg { display: flex; width: 100%; }
  .big-seg button { flex: 1; justify-content: center; white-space: nowrap; padding: 7px 8px; font-size: 13px; }
  .confirm-bar { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .pay-foot { flex-wrap: wrap; }
}
.g-new-addr { font-size: 12px; background: var(--surface); }
.g-new-addr.invalid { border-color: var(--bad); }

/* room logos as app icons */
.room-icon { position: relative; overflow: hidden; }
.room-icon > span { position: relative; }
.room-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.room-icon.has-logo { background: #fff; }
.room-icon.has-logo > span { visibility: hidden; }
.room-icon::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,.14); pointer-events: none; }
@media (prefers-color-scheme: dark) { .room-icon::after { box-shadow: inset 0 0 0 0.5px rgba(255,255,255,.16); } }
.room-icon { border-radius: 27%; }
.room-icon.lg { border-radius: 26%; }
.room-icon.xl { width: 48px; height: 48px; font-size: 15px; }
.chart .icon-ring { fill: none; stroke: rgba(0,0,0,.14); stroke-width: .5; }

/* ===== Resumen v2 ===== */
.hero-chart { padding: 24px; }
.hero-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 14px; }
.hero-head > div:first-child { display: grid; gap: 2px; }
.hero-value { font-size: 44px; }
.hero-value.neg { color: var(--bad); }
.hero-sub { font-size: 14px; color: var(--text-2); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.hero-stats > div { display: grid; background: var(--surface-2); border-radius: 12px; padding: 10px 14px; min-width: 120px; }
.hero-stats span { font-size: 12px; color: var(--muted); }
.hero-stats b { font-size: 18px; letter-spacing: -0.02em; }
.hero-stats small { font-size: 12px; color: var(--muted); }
.cum-chips { margin-bottom: 8px; }
.line.thick { stroke-width: 2.5; }
.stop-s1 { stop-color: var(--s1); } .stop-s2 { stop-color: var(--s2); } .stop-s3 { stop-color: var(--s3); } .stop-s4 { stop-color: var(--s4); }
.end-dot { stroke-width: 3; }
.tip-sub { font-size: 12px; color: var(--muted); margin: -2px 0 4px 16px; }
.delta { display: inline-flex; align-items: center; gap: 2px; }
.delta .ico { width: 12px; height: 12px; stroke-width: 2.5; }
.kpi-foot { min-height: 18px; }
a.kpi.accent { text-decoration: none; }
a.kpi.accent:hover { filter: brightness(1.05); }
.count-pill { min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 13px; font-weight: 600; background: var(--warn-bg); color: var(--warn-text); }
.count-pill.ok { background: rgba(31,138,59,.12); color: var(--good); }
.count-pill .ico { width: 14px; height: 14px; }
.task-ico { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex: none; }
.task-ico.warn { background: var(--warn-bg); color: var(--warn-text); }
.task-ico.accent { background: var(--accent-soft); color: var(--accent); }
.task-ico.bad { background: var(--bad-bg); color: var(--bad-text); }
.task-ico.muted { background: var(--surface-2); color: var(--muted); }
.tasks small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.all-good { display: grid; justify-items: center; gap: 4px; padding: 28px 0; }
.all-good .ico { width: 34px; height: 34px; color: var(--good); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.compare > div { display: grid; gap: 2px; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.compare b { font-size: 22px; letter-spacing: -0.02em; }
.mini-title { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 4px; }
.movers .delta { font-weight: 600; font-size: 14px; }
.plain-link.more { display: block; text-align: center; margin-top: 10px; }
@media (max-width: 860px) {
  .hero-chart { padding: 18px; }
  .hero-value { font-size: 34px; }
  .hero-stats { width: 100%; }
  .hero-stats > div { flex: 1; min-width: 0; padding: 8px 10px; }
  .hero-stats b { font-size: 15px; }
}
.warn-text { color: var(--warn-text); }
.card-head > button, .card-head > a { white-space: nowrap; flex: none; }
.card-head h2 { min-width: 0; }

/* API y registro */
.small-text { font-size: 13px; margin: 0 0 12px; }
.key-fresh { display: grid; gap: 8px; padding: 12px; margin-bottom: 12px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-text); }
.list li.revoked { opacity: .55; }
.audit li { align-items: flex-start; }
.audit li > span:nth-child(2) { flex: 1; min-width: 0; display: block; font-size: 14px; }
.audit li > span:nth-child(2) small { display: block; white-space: normal; overflow-wrap: anywhere; margin-top: 2px; }
.audit-act { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; font-size: 13px; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.audit-act.insert { background: rgba(31,138,59,.12); color: var(--good); }
.audit-act.delete { background: var(--bad-bg); color: var(--bad-text); }
.nowrap { white-space: nowrap; }
.audit li > span.audit-act { flex: none; width: 24px; display: grid; }
