:root {
  --bg: #0b0a0a;
  --surface: #141313;
  --surface-2: #1b1a1a;
  --surface-3: #252323;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #f6f3f2;
  --muted: #9c9594;
  --faint: #6a6363;
  --brand: #e0261d;
  --brand-deep: #a3160f;
  --in: #3ddc97;
  --out: #ffb020;
  --warn: #b89cff;
  --danger: #ff5a6a;
  --radius: 22px;
  --radius-sm: 14px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Inter Tight", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, select, textarea { outline: none; }
::selection { background: var(--brand); color: #fff; }

/* ---------- fondo animado ---------- */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-orbs span { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.35; animation: drift 22s var(--ease) infinite alternate; }
.bg-orbs span:nth-child(1) { width: 420px; height: 420px; background: var(--brand-deep); top: -140px; left: -120px; }
.bg-orbs span:nth-child(2) { width: 320px; height: 320px; background: #5c0d08; bottom: -120px; right: -80px; animation-duration: 28s; }
.bg-orbs span:nth-child(3) { width: 220px; height: 220px; background: #e0261d; top: 40%; left: 60%; opacity: 0.1; animation-duration: 34s; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }

#app { position: relative; z-index: 1; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; text-align: center; animation: rise 0.7s var(--ease) both; }
.login-logo { width: 76px; height: 76px; margin: 0 auto 22px; border-radius: 24px; box-shadow: 0 20px 60px -10px rgba(224, 38, 29, 0.5); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.login h1 { font-size: 30px; letter-spacing: -0.03em; margin: 0 0 6px; font-weight: 800; }
.login p { color: var(--muted); margin: 0 0 28px; font-size: 15px; }
.login form { display: grid; gap: 12px; }
.login .error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 0; }

.field { display: grid; gap: 6px; text-align: left; }
.field > span { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.input {
  width: 100%; height: 52px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03); padding: 0 16px; font-size: 16px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
textarea.input { height: auto; min-height: 84px; padding: 14px 16px; resize: vertical; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 22px) 23px, calc(100% - 17px) 23px; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus { border-color: var(--brand); background: rgba(224, 38, 29, 0.06); box-shadow: 0 0 0 4px rgba(224, 38, 29, 0.15); }

.btn {
  height: 52px; border-radius: var(--radius-sm); padding: 0 20px; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.25s var(--spring), background 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 10px 30px -10px rgba(224, 38, 29, 0.8); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line); }
.btn-danger { background: rgba(255, 90, 106, 0.12); color: var(--danger); }
.btn-sm { height: 40px; font-size: 14px; padding: 0 14px; border-radius: 12px; }

/* ---------- shell ---------- */
.shell { max-width: 1180px; margin: 0 auto; padding: calc(16px + var(--safe-t)) 16px calc(110px + var(--safe-b)); }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.topbar img { width: 38px; height: 38px; border-radius: 12px; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.topbar .title strong { font-size: 19px; letter-spacing: -0.02em; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); transition: transform 0.25s var(--spring), background 0.2s; flex: none; }
.icon-btn:active { transform: scale(0.9); }
.icon-btn svg { width: 20px; height: 20px; }

.view { animation: viewIn 0.5s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(0.98); } }
.stagger > * { animation: rise 0.6s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }

.h-section { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 2px 12px; }
.h-section h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0; }
.h-section button { color: var(--brand); font-weight: 600; font-size: 14px; }
.page-title { font-size: clamp(30px, 7vw, 44px); font-weight: 800; letter-spacing: -0.04em; margin: 4px 0 18px; line-height: 1; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); z-index: 20;
  display: flex; gap: 4px; padding: 6px; border-radius: 26px;
  background: rgba(27, 26, 26, 0.72); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--line-2); box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.7);
}
.tab { position: relative; width: 62px; height: 54px; border-radius: 20px; display: grid; place-items: center; color: var(--muted); transition: color 0.25s; }
.tab svg { width: 22px; height: 22px; position: relative; z-index: 1; transition: transform 0.35s var(--spring); }
.tab span { position: absolute; bottom: 5px; font-size: 10px; font-weight: 600; z-index: 1; opacity: 0.9; }
.tab.active { color: #fff; }
.tab.active svg { transform: translateY(-5px); }
.tab-pill { position: absolute; top: 6px; height: 54px; width: 62px; border-radius: 20px; background: var(--brand); box-shadow: 0 8px 24px -6px rgba(224, 38, 29, 0.8); transition: left 0.5s var(--spring); }
.tab-fab { width: 54px; height: 54px; border-radius: 20px; display: grid; place-items: center; background: #fff; color: var(--bg); margin-left: 4px; transition: transform 0.3s var(--spring); }
.tab-fab:active { transform: scale(0.88) rotate(90deg); }
.tab-fab svg { width: 24px; height: 24px; }

/* ---------- home ---------- */
.home-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .home-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
}
.card { background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

.codepad { position: relative; overflow: hidden; }
.codepad::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: linear-gradient(135deg, rgba(224, 38, 29, 0.7), transparent 40%, transparent 60%, rgba(61, 220, 151, 0.4)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.codepad h3 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.codepad p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.code-boxes { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.code-boxes input { position: absolute; inset: 0; opacity: 0; font-size: 16px; width: 100%; height: 100%; caret-color: transparent; z-index: 2; }
.code-box { height: 76px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-family: var(--mono); font-size: 36px; font-weight: 700; transition: border-color 0.2s, transform 0.3s var(--spring), background 0.2s; }
.code-box.filled { border-color: rgba(224, 38, 29, 0.6); background: rgba(224, 38, 29, 0.08); animation: pop 0.35s var(--spring); }
.code-box.caret::after { content: ""; width: 2px; height: 34px; background: var(--brand); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pop { 40% { transform: scale(1.08); } }
.code-boxes.shake { animation: shake 0.45s; }
.code-boxes.shake .code-box { border-color: var(--danger); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.code-hint { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 18px; }
.code-hint.err { color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { border-radius: 20px; padding: 16px 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; transition: transform 0.3s var(--spring), border-color 0.2s; position: relative; overflow: hidden; }
.stat:active { transform: scale(0.96); }
.stat b { display: block; font-size: 34px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat i { position: absolute; top: 14px; right: 14px; width: 8px; height: 8px; border-radius: 50%; }
.stat.in i { background: var(--in); box-shadow: 0 0 12px var(--in); }
.stat.out i { background: var(--out); box-shadow: 0 0 12px var(--out); animation: pulse 2s infinite; }
.stat.pend i { background: var(--warn); }
@keyframes pulse { 50% { opacity: 0.35; } }

.out-strip { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 6px; scroll-snap-type: x mandatory; }
.out-strip::-webkit-scrollbar { display: none; }
.out-card { flex: none; width: 200px; scroll-snap-align: start; text-align: left; padding: 14px; border-radius: 18px; background: linear-gradient(160deg, rgba(255, 176, 32, 0.16), rgba(255, 176, 32, 0.03)); border: 1px solid rgba(255, 176, 32, 0.25); transition: transform 0.3s var(--spring); }
.out-card:active { transform: scale(0.96); }
.out-card .code { font-family: var(--mono); font-weight: 700; color: var(--out); font-size: 13px; }
.out-card strong { display: block; margin: 6px 0 4px; font-size: 15px; line-height: 1.25; }
.out-card small { color: var(--muted); font-size: 12px; }
.empty { padding: 22px; text-align: center; color: var(--muted); font-size: 14px; border: 1px dashed var(--line-2); border-radius: 18px; }

/* ---------- lista ---------- */
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 14px; position: sticky; top: 0; z-index: 5; padding: 10px 0; margin-top: -10px; background: linear-gradient(var(--bg) 75%, transparent); }
.search { position: relative; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 46px; }
.segmented { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 4px; }
.segmented button { position: relative; z-index: 1; height: 38px; font-size: 13px; font-weight: 600; color: var(--muted); transition: color 0.25s; border-radius: 12px; }
.segmented button.active { color: #fff; }
.segmented .seg-pill { position: absolute; top: 4px; bottom: 4px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--line-2); transition: left 0.45s var(--spring), width 0.45s var(--spring); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); transition: all 0.25s var(--ease); white-space: nowrap; }
.chip.active { background: #fff; color: var(--bg); border-color: #fff; }
.chip:active { transform: scale(0.94); }

.list { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); text-align: left; width: 100%; transition: transform 0.3s var(--spring), border-color 0.2s, background 0.2s; }
.row:hover { border-color: var(--line-2); background: var(--surface-2); }
.row:active { transform: scale(0.98); }
.code-tag { flex: none; width: 62px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 16px; background: var(--surface-3); border: 1px solid var(--line-2); letter-spacing: 0.02em; }
.row .meta { flex: 1; min-width: 0; }
.row strong { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.in { color: var(--in); background: rgba(61, 220, 151, 0.1); }
.pill.out { color: var(--out); background: rgba(255, 176, 32, 0.12); }
.pill.pend { color: var(--warn); background: rgba(184, 156, 255, 0.1); }
.count-note { color: var(--muted); font-size: 13px; margin: 0 2px 10px; }

/* ---------- espacio (bento dinámico) ---------- */
.bento { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 118px; grid-auto-flow: dense; gap: 10px; }
@media (min-width: 900px) { .bento { grid-template-columns: repeat(6, 1fr); grid-auto-rows: 132px; } }
.tile { position: relative; overflow: hidden; border-radius: var(--radius); padding: 16px; text-align: left; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; transition: transform 0.35s var(--spring), border-color 0.25s; }
.tile:active { transform: scale(0.97); }
.tile:hover { border-color: var(--line-2); }
.tile.s-1 { grid-column: span 2; }
.tile.s-2 { grid-column: span 2; grid-row: span 2; }
.tile.s-3 { grid-column: span 4; grid-row: span 2; }
@media (min-width: 900px) { .tile.s-3 { grid-column: span 3; } .tile.s-2 { grid-column: span 3; } }
.tile .t-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; position: relative; z-index: 1; }
.tile .t-count { font-size: 40px; font-weight: 800; letter-spacing: -0.05em; line-height: 1; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.tile .t-count small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.tile .dots { position: absolute; right: 14px; bottom: 14px; display: grid; grid-template-columns: repeat(8, 7px); gap: 5px; direction: rtl; }
.tile .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); opacity: 0.8; animation: dotIn 0.4s var(--spring) both; animation-delay: calc(var(--d) * 18ms + 200ms); }
@keyframes dotIn { from { transform: scale(0); } }
.tile .glow { position: absolute; width: 180px; height: 180px; border-radius: 50%; right: -60px; top: -60px; background: radial-gradient(circle, var(--tile-c, var(--brand)), transparent 70%); opacity: 0.22; transition: transform 0.8s var(--ease); }
.tile:hover .glow { transform: scale(1.3); }
.tile.out-tile { --tile-c: var(--out); background: linear-gradient(160deg, rgba(255, 176, 32, 0.12), var(--surface) 60%); }
.tile.out-tile .dots i { background: var(--out); }
.tile.pend-tile { --tile-c: var(--warn); border-style: dashed; }
.tile.pend-tile .dots i { background: var(--warn); }
.tile .t-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tile .t-top svg { width: 20px; height: 20px; color: var(--muted); position: relative; z-index: 1; flex: none; }

.area-detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

/* ---------- actividad ---------- */
.timeline { display: grid; gap: 4px; }
.day-label { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin: 18px 4px 8px; }
.ev { display: flex; gap: 12px; align-items: flex-start; padding: 10px 6px; border-radius: 14px; text-align: left; width: 100%; transition: background 0.2s; }
.ev:hover { background: rgba(255, 255, 255, 0.03); }
.ev-ico { flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); }
.ev-ico svg { width: 17px; height: 17px; }
.ev-ico.in { background: rgba(61, 220, 151, 0.12); color: var(--in); }
.ev-ico.out { background: rgba(255, 176, 32, 0.12); color: var(--out); }
.ev-ico.move { background: rgba(224, 38, 29, 0.14); color: var(--brand); }
.ev .ev-body { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; }
.ev .ev-body b { font-weight: 600; }
.ev .ev-body .mono { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-right: 4px; }
.ev .ev-body small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.ev time { flex: none; font-size: 12px; color: var(--faint); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(8, 6, 6, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade 0.3s both; }
.sheet-backdrop.closing { animation: fade 0.25s reverse both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; margin: 0 auto; max-width: 560px;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-2); border-bottom: 0; border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(24px + var(--safe-b)); animation: sheetUp 0.55s var(--spring) both;
  box-shadow: 0 -30px 80px -20px rgba(0, 0, 0, 0.8);
}
.sheet.closing { animation: sheetDown 0.3s var(--ease) both; }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@media (min-width: 700px) {
  .sheet { bottom: auto; top: max(24px, 6vh); max-height: calc(100dvh - max(48px, 12vh)); border-radius: 28px; border-bottom: 1px solid var(--line-2); padding-bottom: 24px; animation: modalIn 0.45s var(--spring) both; }
  .sheet.closing { animation: modalOut 0.25s var(--ease) both; }
  .sheet .grabber { display: none; }
  @keyframes modalIn { from { opacity: 0; transform: translateY(30px) scale(0.96); } }
  @keyframes modalOut { to { opacity: 0; transform: translateY(20px) scale(0.97); } }
}
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.sheet-head .grow { flex: 1; min-width: 0; }
.sheet h3 { margin: 0; font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.big-code { font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: 0.25em; color: var(--brand); display: inline-flex; gap: 2px; margin-bottom: 6px; }
.big-code span { display: inline-block; animation: rise 0.5s var(--spring) both; animation-delay: calc(var(--i) * 60ms); }

.status-hero { border-radius: 20px; padding: 16px; display: flex; align-items: center; gap: 14px; margin-bottom: 14px; border: 1px solid var(--line); transition: background 0.4s, border-color 0.4s; }
.status-hero.in { background: rgba(61, 220, 151, 0.07); border-color: rgba(61, 220, 151, 0.2); }
.status-hero.out { background: rgba(255, 176, 32, 0.08); border-color: rgba(255, 176, 32, 0.25); }
.status-hero.pend { background: rgba(184, 156, 255, 0.06); border-color: rgba(184, 156, 255, 0.2); }
.status-hero .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: currentColor; box-shadow: 0 0 0 6px color-mix(in srgb, currentColor 18%, transparent); }
.status-hero.in .dot { color: var(--in); }
.status-hero.out .dot { color: var(--out); animation: pulse 2s infinite; }
.status-hero.pend .dot { color: var(--warn); }
.status-hero strong { display: block; font-size: 16px; }
.status-hero small { color: var(--muted); font-size: 13px; }

.io-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.io-btn { height: 88px; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 800; font-size: 17px; border: 1px solid transparent; transition: transform 0.3s var(--spring), opacity 0.25s, background 0.25s, box-shadow 0.25s; }
.io-btn svg { width: 26px; height: 26px; transition: transform 0.4s var(--spring); }
.io-btn:active { transform: scale(0.94); }
.io-btn.in { background: var(--in); color: #04140c; box-shadow: 0 14px 34px -14px var(--in); }
.io-btn.out { background: var(--out); color: #1d0c00; box-shadow: 0 14px 34px -14px var(--out); }
.io-btn.muted { background: var(--surface-2); color: var(--faint); box-shadow: none; border-color: var(--line); }
.io-btn.selected svg { transform: scale(1.15); }
.io-btn.in.selected { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--in); }
.io-btn.out.selected { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--out); }

.reveal { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.45s var(--ease), opacity 0.3s; opacity: 0; }
.reveal.open { grid-template-rows: 1fr; opacity: 1; }
.reveal > div { overflow: hidden; }
.reveal-inner { padding-bottom: 16px; display: grid; gap: 12px; }

.area-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.area-chip { height: 42px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; transition: all 0.3s var(--spring); }
.area-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; transform: scale(1.03); box-shadow: 0 8px 22px -8px rgba(224, 38, 29, 0.9); }
.area-chip:active { transform: scale(0.94); }

.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 4px 0 16px; }
.kv div { background: var(--surface-2); border-radius: 14px; padding: 12px; border: 1px solid var(--line); }
.kv small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.kv span { font-size: 14px; font-weight: 600; }
.kv .full { grid-column: 1 / -1; }
.kv .full span { font-weight: 500; line-height: 1.45; }

.label-mini { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }
.form-grid { display: grid; gap: 14px; }
.form-grid .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.code-field { position: relative; }
.code-field .input { font-family: var(--mono); font-size: 22px; letter-spacing: 0.3em; font-weight: 700; }
.code-field .regen { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); height: 36px; padding: 0 10px; border-radius: 10px; background: var(--surface-3); font-size: 12px; font-weight: 600; color: var(--muted); }

.area-edit-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; animation: rise 0.4s var(--ease) both; }
.area-edit-row .input { height: 46px; }
.area-edit-row .icon-btn { height: 46px; width: 46px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; left: 0; right: 0; top: calc(14px + var(--safe-t)); z-index: 60; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; background: rgba(37, 35, 35, 0.92); backdrop-filter: blur(16px); border: 1px solid var(--line-2); font-size: 14px; font-weight: 600; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8); animation: toastIn 0.5s var(--spring) both; max-width: 100%; }
.toast.leaving { animation: toastOut 0.3s var(--ease) both; }
.toast i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.toast.in i { background: var(--in); }
.toast.out i { background: var(--out); }
.toast.err i { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(0.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px) scale(0.95); } }

/* ---------- escritorio: barra lateral ---------- */
@media (min-width: 1100px) {
  .tabbar { left: 24px; top: 50%; bottom: auto; transform: translateY(-50%); flex-direction: column; }
  .tab-pill { left: 6px !important; transition: top 0.5s var(--spring); }
  .tab-fab { margin: 4px 0 0; }
  .shell { padding-left: 120px; padding-bottom: 40px; }
}

/* ---------- impresión de etiquetas ---------- */
#print-root { display: none; }
@media print {
  @page { size: letter; margin: 10mm; }
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; color: #000; }
  .labels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; }
  .label { border: 0.3mm dashed #999; border-radius: 3mm; padding: 3mm 4mm; height: 30mm; display: flex; flex-direction: column; justify-content: space-between; break-inside: avoid; font-family: var(--font); }
  .label .l-top { display: flex; justify-content: space-between; align-items: center; font-size: 7pt; font-weight: 700; letter-spacing: 0.12em; }
  .label .l-top img { width: 5mm; height: 5mm; }
  .label .l-code { font-family: var(--mono); font-size: 26pt; font-weight: 700; letter-spacing: 0.08em; line-height: 1; }
  .label .l-name { font-size: 7.5pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- fotos ---------- */
.thumb { position: relative; flex: none; width: 62px; height: 46px; border-radius: 12px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--line-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb em { position: absolute; left: 0; right: 0; bottom: 0; font-style: normal; font-family: var(--mono); font-size: 10.5px; font-weight: 700; text-align: center; padding: 1px 0; background: rgba(11, 10, 10, 0.72); backdrop-filter: blur(4px); }

.photo-hero { position: relative; margin-bottom: 14px; border-radius: 20px; overflow: hidden; background: var(--surface-2); animation: rise 0.5s var(--ease) both; }
.photo-img { display: block; width: 100%; }
.photo-img img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform 0.6s var(--ease); }
.photo-img:hover img { transform: scale(1.03); }
.photo-actions { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.photo-actions button { height: 36px; min-width: 36px; padding: 0 12px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; background: rgba(11, 10, 10, 0.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line-2); transition: transform 0.25s var(--spring); }
.photo-actions button:active { transform: scale(0.92); }
.photo-actions svg { width: 16px; height: 16px; }
.photo-actions button:last-child { padding: 0; color: var(--danger); }

.photo-add { width: 100%; height: 64px; margin-bottom: 14px; border-radius: 18px; border: 1.5px dashed var(--line-2); color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 15px; transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.25s var(--spring); }
.photo-add:hover { border-color: var(--brand); color: var(--text); background: rgba(224, 38, 29, 0.06); }
.photo-add:active { transform: scale(0.98); }
.photo-add svg { width: 22px; height: 22px; }
.photo-add.loading, .photo-actions button.loading { pointer-events: none; opacity: 0.6; }
.photo-add.loading span::after { content: " · subiendo…"; }

.photo-field { position: relative; width: 100%; height: 120px; border-radius: var(--radius-sm); border: 1.5px dashed var(--line-2); overflow: hidden; display: grid; place-items: center; color: var(--muted); transition: border-color 0.2s; }
.photo-field:hover { border-color: var(--brand); }
.photo-field.has { height: 180px; border-style: solid; }
.photo-field img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: fade 0.4s both; }
.photo-field .pf-label { position: relative; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.photo-field.has .pf-label { position: absolute; right: 10px; bottom: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(11, 10, 10, 0.7); backdrop-filter: blur(10px); color: var(--text); font-size: 13px; }
.photo-field svg { width: 20px; height: 20px; }

.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(8, 6, 6, 0.92); display: grid; place-items: center; padding: 16px; cursor: zoom-out; animation: fade 0.25s both; }
.lightbox.closing { animation: fade 0.2s reverse both; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 16px; animation: rise 0.45s var(--spring) both; }

/* ---------- personal ---------- */
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; letter-spacing: 0.02em; color: #fff; background: linear-gradient(135deg, hsl(var(--h) 80% 58%), hsl(calc(var(--h) + 40) 75% 42%)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.avatar.empty { background: var(--surface-3); color: var(--muted); }
.avatar.lg { width: 58px; height: 58px; font-size: 20px; transition: transform 0.4s var(--spring); }
.who-btn { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px 0 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; font-weight: 600; flex: none; max-width: 46vw; transition: transform 0.25s var(--spring), border-color 0.2s; }
.who-btn span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-btn:active { transform: scale(0.94); }
.who-btn:hover { border-color: var(--line-2); }
.people-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 520px) { .people-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.person { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 10px 16px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; font-size: 14px; text-align: center; line-height: 1.25; transition: transform 0.3s var(--spring), border-color 0.25s, background 0.25s; }
.person:hover .avatar { transform: scale(1.08) rotate(-4deg); }
.person:active { transform: scale(0.95); }
.person.active { border-color: var(--brand); background: rgba(224, 38, 29, 0.1); box-shadow: 0 0 0 3px rgba(224, 38, 29, 0.2); }
.person.active .avatar { transform: scale(1.08); }
