:root {
  --bg: #0b0d18;
  --bg-2: #111427;
  --panel: rgba(25, 29, 52, .78);
  --panel-solid: #191d34;
  --panel-2: #232847;
  --line: rgba(140, 150, 210, .18);
  --text: #eef0fa;
  --muted: #9aa1bf;
  --brand: #7c6cff;
  --claude: #d97757;
  --ok: #3ccf91;
  --warn: #ffb547;
  --bad: #ff6b7a;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body {
  background:
    radial-gradient(900px 500px at 110% -10%, rgba(217, 119, 87, .18), transparent 60%),
    radial-gradient(800px 500px at -20% 10%, rgba(124, 108, 255, .22), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
  min-height: 100vh;
  overflow-x: hidden;
}
button, textarea { font: inherit; color: inherit; }
h2 { font-size: .78rem; margin: 24px 0 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
h3 { font-size: .95rem; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Cabecera */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: rgba(11, 13, 24, .78); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .22em; display: flex; align-items: center; gap: 6px; }
.brand small { font-weight: 500; letter-spacing: .02em; color: var(--muted); }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--claude)); color: #fff; font-size: 14px; letter-spacing: 0; box-shadow: 0 4px 14px rgba(124, 108, 255, .4); }
.sync { font-size: .76rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(60, 207, 145, .2); }
.demo { margin: 12px 16px 0; padding: 10px 12px; border-radius: var(--radius); background: rgba(255, 181, 71, .12); border: 1px solid rgba(255, 181, 71, .3); color: #ffd99a; font-size: .84rem; }

main { padding: 4px 16px 16px; max-width: 900px; margin: 0 auto; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi { position: relative; overflow: hidden; background: var(--panel); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi::after { content: ""; position: absolute; right: -24px; top: -24px; width: 70px; height: 70px; border-radius: 50%; background: radial-gradient(circle, rgba(124, 108, 255, .35), transparent 70%); }
.kpi:nth-child(2)::after, .kpi:nth-child(3)::after { background: radial-gradient(circle, rgba(217, 119, 87, .4), transparent 70%); }
.kpi b { display: block; font-size: 1.45rem; margin-top: 4px; letter-spacing: -.01em; }
.kpi span { color: var(--muted); font-size: .78rem; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; }
.list li .meta { display: flex; gap: 8px; align-items: center; font-size: .76rem; color: var(--muted); margin-bottom: 3px; flex-wrap: wrap; }
.list .empty { color: var(--muted); text-align: center; }
.tag { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: .72rem; }
.tag--alta { background: rgba(255, 107, 122, .18); color: #ffb3bc; }
.tag--media { background: rgba(255, 181, 71, .16); color: #ffd99a; }
.tag--baja, .tag--ok { background: rgba(60, 207, 145, .16); color: #9ff0cc; }

.chips { display: flex; gap: 8px; margin: 16px 0; overflow-x: auto; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 15px; cursor: pointer; white-space: nowrap; }
.chip.is-on { background: linear-gradient(135deg, var(--brand), #9b6cff); border-color: transparent; color: #fff; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.card .row { display: flex; justify-content: space-between; font-size: .88rem; padding: 4px 0; border-top: 1px dashed var(--line); }
.card .row:first-of-type { border-top: 0; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

/* Oficina 3D */
.view--office { padding: 0; }
.office { position: relative; height: 68vh; min-height: 360px; margin: 0 -16px; overflow: hidden; touch-action: none; border-bottom: 1px solid var(--line); }
#office-canvas { width: 100%; height: 100%; display: block; }
.office__hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; margin: 0; font-size: .78rem; color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, .7); pointer-events: none; }
.office__labels { position: absolute; inset: 0; pointer-events: none; }
.office__label { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; background: rgba(255, 255, 255, .92); color: #1b1e2e; border: 0; border-top: 3px solid var(--c, var(--claude)); padding: 3px 9px 4px; border-radius: 10px; font-size: .7rem; font-weight: 700; white-space: nowrap; pointer-events: auto; cursor: pointer; box-shadow: 0 4px 12px rgba(0, 0, 0, .25); will-change: transform; }
.office__label em { font-style: normal; font-weight: 500; font-size: .62rem; color: #5b6078; }
.office__label i[hidden] { display: none; }
.office__label i { position: absolute; right: -7px; top: -9px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--claude); color: #fff; font-style: normal; font-size: .68rem; line-height: 18px; text-align: center; }
.office__zone { position: absolute; left: 0; top: 0; padding: 2px 8px; border-radius: 6px; background: rgba(255, 255, 255, .75); color: #6b5d4a; font-size: .58rem; font-weight: 800; letter-spacing: .12em; white-space: nowrap; will-change: transform; }
.office__hud { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; align-items: center; pointer-events: auto; }
.office__clock { background: rgba(11, 13, 24, .7); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-variant-numeric: tabular-nums; }
.office__mode { background: rgba(255, 255, 255, .85); color: #1b1e2e; border: 0; padding: 4px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600; cursor: pointer; }
.roles { display: grid; gap: 8px; padding: 14px 16px 0; max-width: 900px; margin: 0 auto; }
.role-btn { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; cursor: pointer; }
.role-btn .dot { width: 30px; height: 26px; border-radius: 5px; flex: none; background: var(--claude) !important; position: relative; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.role-btn .dot::before, .role-btn .dot::after { content: ""; position: absolute; top: 8px; width: 4px; height: 7px; background: #141414; }
.role-btn .dot::before { left: 8px; }
.role-btn .dot::after { right: 8px; }
.role-btn small { display: block; color: var(--muted); }

/* Hoja del rol */
.sheet { width: min(640px, 100vw); max-height: 88vh; margin: auto auto 0; border: 1px solid var(--line); border-radius: 22px 22px 0 0; background: var(--panel-solid); color: var(--text); padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet[open] { animation: up .25s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.sheet h2 { margin-top: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.2rem; }
.sheet__close { position: absolute; right: 10px; top: 10px; }
.sheet__close button { background: var(--panel-2); border: 0; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
.chat { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.chat li { padding: 9px 12px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; }
.chat .me { background: linear-gradient(135deg, var(--brand), #9b6cff); color: #fff; justify-self: end; border-bottom-right-radius: 4px; }
.chat .bot { background: var(--panel-2); border-bottom-left-radius: 4px; border-left: 3px solid var(--claude); }
.chat .wait { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.ask { display: flex; gap: 8px; margin-top: 12px; }
.ask textarea { flex: 1; resize: none; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.ask button { background: var(--claude); border: 0; border-radius: 12px; padding: 0 16px; color: #fff; font-weight: 700; cursor: pointer; }
.ask button:disabled { opacity: .5; }

/* Navegación inferior */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(11, 13, 24, .86); backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { position: relative; background: none; border: 0; padding: 13px 2px; font-size: .76rem; color: var(--muted); cursor: pointer; }
.tabs button.is-on { color: var(--text); font-weight: 600; }
.tabs button.is-on::before { content: ""; position: absolute; left: 30%; right: 30%; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: linear-gradient(90deg, var(--brand), var(--claude)); }

/* Claude mensajero */
.buddy { position: fixed; left: 0; top: 0; z-index: 7; pointer-events: none; transition-property: transform; transition-timing-function: linear; will-change: transform; }
.buddy__bot { pointer-events: auto; position: relative; display: block; width: 54px; height: 52px; padding: 0; border: 0; background: none; cursor: pointer; transform: scaleX(var(--dir, 1)); filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .35)); }
.buddy__body { position: absolute; left: 9px; top: 6px; width: 36px; height: 28px; background: var(--claude); border-radius: 3px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12); animation: bob 2.4s ease-in-out infinite; }
.buddy__body i { position: absolute; top: 8px; width: 4px; height: 8px; background: #141414; animation: blink 4s infinite; }
.buddy__body i:first-child { left: 9px; }
.buddy__body i:last-child { right: 9px; }
.buddy__arm { position: absolute; top: 16px; width: 7px; height: 7px; background: var(--claude); animation: bob 2.4s ease-in-out infinite; }
.buddy__arm--l { left: 2px; }
.buddy__arm--r { right: 2px; }
.buddy__legs { position: absolute; left: 12px; top: 34px; width: 30px; height: 12px; display: flex; justify-content: space-between; }
.buddy__legs i { width: 4px; height: 12px; background: var(--claude); transform-origin: top; }
.buddy__bag { position: absolute; right: -2px; top: 24px; width: 12px; height: 10px; background: #f5efe4; border-radius: 2px; box-shadow: inset 0 3px 0 #c79a5b; }
.is-walking .buddy__legs i:nth-child(odd) { animation: step .35s ease-in-out infinite alternate; }
.is-walking .buddy__legs i:nth-child(even) { animation: step .35s ease-in-out infinite alternate-reverse; }
.is-walking .buddy__body, .is-walking .buddy__arm { animation: hop .35s ease-in-out infinite alternate; }
.is-spin .buddy__bot { animation: spin .9s ease; }
@keyframes bob { 50% { transform: translateY(-2px); } }
@keyframes hop { to { transform: translateY(-3px); } }
@keyframes step { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }
@keyframes blink { 0%, 94%, 100% { height: 8px; } 96% { height: 1px; } }
@keyframes spin { 0% { transform: scaleX(var(--dir, 1)) rotate(0); } 50% { transform: scaleX(var(--dir, 1)) translateY(-14px) rotate(180deg); } 100% { transform: scaleX(var(--dir, 1)) rotate(360deg); } }
.buddy__bubble { pointer-events: auto; position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(260px, 80vw); background: #fff; color: #1b1e2e; padding: 8px 11px; border-radius: 12px; font-size: .8rem; line-height: 1.35; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.buddy__bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
.buddy__bubble.is-link { cursor: pointer; }
.buddy__bubble.is-link::before { content: "Toca para ver →"; display: block; font-size: .68rem; color: var(--claude); font-weight: 700; margin-bottom: 2px; }
@media (prefers-reduced-motion: reduce) { .buddy, .buddy *, .view, .sheet[open] { animation: none !important; transition: none !important; } }

/* Inicio de sesión */
.login { border: 1px solid var(--line); border-radius: 22px; background: var(--panel-solid); color: var(--text); padding: 26px 22px; width: min(380px, 92vw); }
.login::backdrop { background: rgba(5, 6, 14, .8); backdrop-filter: blur(6px); }
.login form { display: grid; gap: 10px; }
.login h2 { margin: 6px 0 6px; text-align: center; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.15rem; }
.login label { font-size: .82rem; color: var(--muted); }
.login input { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--text); font: inherit; }
.login button[type=submit] { background: var(--claude); border: 0; border-radius: 12px; padding: 12px; color: #fff; font-weight: 700; cursor: pointer; }
.login__demo { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 4px; }
.login__err { margin: 0; color: var(--bad); font-size: .85rem; }
.login__bot { justify-self: center; position: relative; width: 56px; height: 44px; background: var(--claude); border-radius: 4px; box-shadow: inset 0 -5px 0 rgba(0,0,0,.15); }
.login__bot span { position: absolute; top: 13px; width: 6px; height: 12px; background: #141414; animation: blink 4s infinite; }
.login__bot span:first-child { left: 13px; }
.login__bot span:last-child { right: 13px; }
