/* ctsitsa-assets 2.0 — paleta CTS SA IT con predominio de azules. */

@font-face { font-family: "Carlito"; src: url("../fonts/Carlito-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("../fonts/Carlito-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light dark;
  --blue: #0081CC;
  --blue-600: #0A6FB0;
  --blue-700: #1F4E78;
  --blue-500: #2E73B4;
  --blue-400: #3A78C4;
  --blue-200: #C9DDF0;
  --blue-100: #E3EEF8;
  --blue-50: #F2F7FC;
  --green: #3EB135;
  --navy: #0B2540;

  --bg: light-dark(#F4F8FC, #08131F);
  --surface: light-dark(#FFFFFF, #0E1E30);
  --surface-2: light-dark(var(--blue-50), #122840);
  --border: light-dark(#D6E3F0, #1E3A57);
  --text: light-dark(#1E2B38, #E6F0FA);
  --text-2: light-dark(#52657A, #9DB4CC);
  --heading: light-dark(var(--blue-700), #CFE3F7);
  --accent: light-dark(var(--blue), #3BA7E8);
  --accent-ink: #FFFFFF;
  --accent-soft: light-dark(var(--blue-100), rgba(59, 167, 232, .14));
  --focus: light-dark(#0A6FB0, #6CC0F2);

  --ok: light-dark(#2E8F27, #5CCB53);
  --warn: light-dark(#9A6A00, #F2C14E);
  --bad: light-dark(#C0352B, #FF8A80);
  --info: var(--accent);

  --sidebar: light-dark(var(--blue-700), #071425);
  --sidebar-ink: #E3EEF8;
  --sidebar-active: rgba(255, 255, 255, .12);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(11, 37, 64, .06), 0 4px 16px rgba(11, 37, 64, .06);
  --font: "Carlito", Calibri, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 1rem/1.5 var(--font); color: var(--text); background: var(--bg); min-height: 100dvh; }
h1, h2, h3 { color: var(--heading); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; text-wrap: balance; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; text-wrap: pretty; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: .92em; }
img, svg, canvas { max-width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ───── Layout ───── */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
.sidebar .brand { padding: 18px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { display: block; width: 100%; height: auto; }
.sidebar .bar { height: 4px; background: linear-gradient(90deg, var(--blue) 0 72%, var(--green) 72% 100%); }
.nav { list-style: none; margin: 8px 0; padding: 0 8px; display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--sidebar-ink); text-decoration: none; font-weight: 700; font-size: .95rem; opacity: .86; }
.nav a:hover { background: rgba(255,255,255,.06); opacity: 1; }
.nav a[aria-current="page"] { background: var(--sidebar-active); opacity: 1; box-shadow: inset 3px 0 0 #6CC0F2; }
.nav .group { margin: 14px 12px 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; opacity: .55; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .foot { margin-top: auto; padding: 12px 16px; font-size: .78rem; opacity: .6; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .spacer { flex: 1; }
.topbar select { max-width: 280px; }

/* Filtro de alcance: País → Entidad → Sucursal */
.scope { min-width: 0; flex: 0 1 auto; display: flex; }
.topbar .prefs, .topbar > .btn { flex: none; }
.scope-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; max-width: min(560px, 100%); padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font: 700 .92rem var(--font); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.scope-btn:hover { border-color: var(--accent); }
.scope-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.scope-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.scope-btn > svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.scope-trail { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.scope-part { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.scope-part.muted { color: var(--text-2); font-weight: 400; }
.scope-sep { color: var(--text-2); font-weight: 400; }
.scope-flag-sm { line-height: 1; }
.scope-caret { width: 8px; height: 8px; flex: none; border: solid var(--text-2); border-width: 0 2px 2px 0; rotate: 45deg; translate: 0 -2px; margin-inline-start: 2px; }
.scope-pop { margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 12px 40px rgba(11, 37, 64, .18); width: min(760px, calc(100vw - 24px)); max-height: min(70dvh, 520px); overflow: hidden;
  inset: auto; position-area: block-end span-inline-end; position-try-fallbacks: flip-inline; margin-block-start: 6px; }
.scope-pop:popover-open { display: flex; flex-direction: column; }
@supports not (position-area: block-end) {
  .scope-pop { position: fixed; inset: 64px auto auto 50%; translate: -50% 0; }
}
.scope-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.scope-head strong { margin-inline-end: auto; }
.scope-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-height: 0; flex: 1; }
.scope-cols.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.scope-col { display: flex; flex-direction: column; min-height: 0; padding: 10px 8px; }
.scope-col + .scope-col { border-inline-start: 1px solid var(--border); }
.scope-col h3 { margin: 0 8px 8px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.scope-search { margin: 0 4px 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: inherit; }
.scope-list { display: grid; gap: 2px; align-content: start; overflow-y: auto; overscroll-behavior: contain; }
.scope-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text);
  font: inherit; text-align: start; cursor: pointer; }
.scope-opt:hover { background: var(--accent-soft); }
.scope-opt:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.scope-opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.scope-opt[aria-pressed="true"] .scope-opt-sub { color: inherit; opacity: .85; }
.scope-opt-main { display: grid; min-width: 0; }
.scope-opt-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-opt-sub { font-size: .8rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-flag { font-size: 1.15rem; line-height: 1; width: 1.4em; text-align: center; flex: none; }
.scope-dot { width: 1.4em; height: 1.4em; flex: none; border-radius: 50%; border: 2px dashed currentColor; opacity: .45; scale: .7; }
.scope-empty { margin: 4px 10px; color: var(--text-2); font-size: .85rem; }
@media (max-width: 600px) {
  .scope-btn { padding: 6px 10px; gap: 6px; }
  .scope-btn > svg, .scope-caret, .p-country, .s-country, .s-branch, .p-branch.muted { display: none; }
  .scope-trail:has(.p-branch:not(.muted)) .p-entity { display: none; }
}
@media (max-width: 700px) {
  .scope-pop { width: calc(100vw - 16px); max-height: 80dvh; overflow-y: auto; }
  .scope-pop:popover-open { display: block; }
  .scope-cols, .scope-cols.n2 { grid-template-columns: 1fr; }
  .scope-col + .scope-col { border-inline-start: 0; border-block-start: 1px solid var(--border); }
  .scope-list { max-height: 34dvh; }
}
@media (prefers-reduced-motion: reduce) { .scope-btn { transition: none; } }
.menu-btn { display: none; }
.content { padding: 24px; display: grid; gap: 20px; align-content: start; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.page-head h1 { margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--text-2); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; translate: -100% 0; transition: translate .2s; }
  .shell.nav-open .sidebar { translate: 0 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
}

/* ───── Componentes ───── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; border-top: 3px solid var(--accent); }
.kpi .v { font-size: 1.9rem; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { color: var(--text-2); font-size: .85rem; }
.kpi.green { border-top-color: var(--green); }
.kpi.warn { border-top-color: var(--warn); }
.kpi.bad { border-top-color: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 700 .92rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--blue-600); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

label { display: grid; gap: 4px; align-content: start; font-size: .88rem; font-weight: 700; color: var(--text-2); }
input, select, textarea { font: 400 .95rem var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; min-height: 38px; width: 100%; }
textarea { min-height: 80px; resize: vertical; field-sizing: content; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--bad); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid > label { align-self: start; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-error { color: var(--bad); font-weight: 700; margin: 0; }
.hint { color: var(--text-2); font-size: .85rem; font-weight: 400; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 0; }
legend { padding: 0 6px; font-weight: 700; color: var(--heading); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filters > * { flex: 1 1 160px; }
.filters .grow { flex: 3 1 240px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 700; color: var(--heading); background: light-dark(var(--blue-200), #15304C); padding: 9px 10px; white-space: nowrap; position: sticky; top: 0; }
td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: top; }
tbody tr:nth-child(even) td { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--text-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.in_stock { color: var(--blue-500); background: light-dark(#E3EEF8, rgba(46,115,180,.2)); }
.badge.assigned { color: var(--ok); background: light-dark(#E6F4E4, rgba(92,203,83,.15)); }
.badge.in_repair { color: var(--warn); background: light-dark(#FFF6D6, rgba(242,193,78,.15)); }
.badge.in_transit { color: #6B4FB8; background: light-dark(#EEE9FA, rgba(150,120,230,.18)); }
.badge.lost, .badge.rejected { color: var(--bad); background: light-dark(#FBE7E5, rgba(255,138,128,.15)); }
.badge.retired, .badge.disposed, .badge.closed, .badge.cancelled { color: var(--text-2); background: var(--surface-2); }
.badge.pending, .badge.open { color: var(--warn); background: light-dark(#FFF6D6, rgba(242,193,78,.15)); }
.badge.approved, .badge.done { color: var(--ok); background: light-dark(#E6F4E4, rgba(92,203,83,.15)); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { border: 0; background: none; font: 700 .92rem var(--font); color: var(--text-2); padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

dl.props { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: 6px 16px; margin: 0; }
dl.props dt { color: var(--text-2); font-size: .88rem; }
dl.props dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--border); }
.tree li > .node { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); }
.tree li > .node:hover { background: var(--surface-2); }
.tree .kind { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.tree .count { margin-left: auto; color: var(--text-2); font-size: .85rem; font-variant-numeric: tabular-nums; }

.bars { display: grid; gap: 8px; }
.bars .b { display: grid; grid-template-columns: 140px 1fr 48px; gap: 8px; align-items: center; font-size: .88rem; }
.bars .track { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bars .fill { height: 100%; border-radius: 5px; background: var(--accent); }

/* ───── Diálogos y avisos ───── */
dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(8, 19, 31, .55); }
html:has(dialog:modal) { overflow: hidden; scrollbar-gutter: stable; }
dialog .dlg-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog .dlg-head h2 { margin: 0; font-size: 1.1rem; flex: 1; }
dialog .dlg-body { padding: 18px; display: grid; gap: 14px; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
dialog.wide { width: min(1000px, calc(100vw - 24px)); }

#toast { position: fixed; inset: auto 16px 16px auto; margin: 0; border: 0; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--navy); color: #fff; font-weight: 700; box-shadow: var(--shadow); max-width: min(420px, calc(100vw - 32px)); }
#toast.bad { background: var(--bad); }

/* ───── Acceso ───── */
.auth-body { display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 600px at 10% -10%, light-dark(#D6E8F7, #0E2A47) 0%, transparent 60%),
  radial-gradient(900px 500px at 110% 110%, light-dark(#DDEFF9, #0A2238) 0%, transparent 60%), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.auth-card .auth-logo { width: 260px; height: auto; justify-self: center; }
.auth-card .bar { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--blue) 0 72%, var(--green) 72% 100%); }
.auth-card h1 { font-size: 1.2rem; margin: 0; text-align: center; }
.otp { font-family: var(--mono); letter-spacing: .3em; font-size: 1.3rem; text-align: center; }

/* ───── QR y etiquetas ───── */
.qr { background: #fff; padding: 8px; border-radius: var(--radius-sm); display: inline-block; line-height: 0; }
.qr svg { width: 140px; height: 140px; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(62mm, 1fr)); gap: 4mm; }
.label { border: 1px solid #999; border-radius: 2mm; padding: 3mm; display: grid; grid-template-columns: 22mm 1fr; gap: 3mm; align-items: center; background: #fff; color: #111; break-inside: avoid; }
.label svg { width: 22mm; height: 22mm; }
.label .t { font: 700 11pt var(--mono); }
.label .n { font-size: 8pt; line-height: 1.2; }
.label .e { font-size: 7pt; color: #0081CC; font-weight: 700; }

/* ───── Almacén 3D ───── */
.scene-wrap { position: relative; height: calc(100dvh - 190px); min-height: 420px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: light-dark(#EAF2FA, #06101B); }
.scene-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.scene-tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 2; }
.scene-legend { position: absolute; bottom: 12px; left: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-size: .8rem; display: grid; gap: 4px; z-index: 2; }
.scene-tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; padding: 4px 8px; border-radius: 4px; font-size: .82rem; font-weight: 700; z-index: 3; translate: -50% -130%; white-space: nowrap; }
.scene-panel { position: absolute; inset: 12px 12px 12px auto; width: min(380px, calc(100% - 24px)); margin: 0; max-height: none; overflow-y: auto; z-index: 4; }
.scene-crumb { position: absolute; top: 12px; right: 12px; z-index: 2; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; font-size: .85rem; font-weight: 700; }

/* ───── Reportes e impresión ───── */
.report-head { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: .88rem; }
.report-head strong { color: var(--heading); }
.print-only { display: none; }

@media print {
  .sidebar, .topbar, .no-print, .page-head .actions, .filters { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #111; }
  .content { padding: 0; }
  .card, .table-wrap { box-shadow: none; border-color: #bbb; }
  .print-only { display: block; }
  th { background: #C9DDF0 !important; color: #1F4E78 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table { font-size: 8.5pt; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { rotate: 360deg; } }

/* ───── Idioma y tema ───── */
.prefs { display: flex; align-items: center; gap: 6px; }
.auth-card .prefs { justify-self: end; margin: -12px -12px 0 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; color: var(--text-2); font: 700 .8rem var(--font); padding: 5px 9px; cursor: pointer; min-height: 30px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.btn svg { flex: none; max-width: none; }
@media (max-width: 600px) {
  .topbar { padding: 8px 10px; gap: 6px; }
  .topbar .user-name { display: none; }
  .topbar select { max-width: 130px; }
  .seg button { padding: 4px 6px; }
}

/* ───── Dashboard y gráficos ───── */
:root {
  --series-1: light-dark(#0081CC, #338ced);
  --series-2: light-dark(#f47230, #e76624);
  --series-3: light-dark(#00b894, #00a888);
  --series-4: light-dark(#f2a600, #d28e05);
  --series-5: light-dark(#ee7fac, #e24d8b);
  --series-6: light-dark(#008a17, #0aac23);
  --series-7: light-dark(#6a4ce2, #9887ef);
}
.dash-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-card.full { grid-column: 1 / -1; }
.dash-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dash-head h2 { margin: 0; flex: 1; font-size: 1.05rem; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-custom { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.dash-custom li { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dash-custom .grow { flex: 1; font-weight: 700; }
.dash-custom select { width: auto; min-height: 30px; padding: 2px 6px; }
.chart { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .axis-label { fill: var(--text-2); font: 400 11px var(--font); }
.chart-svg .value-label { fill: var(--text); font: 700 11px var(--font); }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .crosshair { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .mark:hover rect:first-of-type { opacity: .85; }
.chart-tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; padding: 4px 8px; border-radius: 4px; font-size: .8rem; font-weight: 700; white-space: nowrap; z-index: 3; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--text); margin-top: 6px; }
.plan2d { width: 100%; height: auto; max-height: 520px; display: block; }
.plan-floor { fill: light-dark(#F2F7FC, #0F2238); stroke: var(--border); stroke-width: .08; }
.plan-area { fill: light-dark(#E3EEF8, #14304D); stroke: var(--blue-400); stroke-width: .06; }
.plan-area.warehouse, .plan-area.office, .plan-area.site { fill: light-dark(#FFFFFF, #0E1E30); stroke: var(--blue-700); stroke-width: .1; }
.plan-rack { fill: light-dark(#C9DDF0, #1E3A57); stroke: var(--blue-700); stroke-width: .05; }
.plan-label { fill: var(--heading); font-family: var(--font); font-weight: 700; }
.plan-link { cursor: pointer; text-decoration: underline; }
.plan-asset { cursor: pointer; stroke: var(--surface); stroke-width: .03; }
.plan-asset:focus-visible { outline: none; stroke: var(--focus); stroke-width: .08; }
.scene-wrap.embed { height: 460px; min-height: 0; }
.scene-embed { min-height: 460px; }

/* ───── Zetti ───── */
.zetti-fab { position: fixed; left: calc(100vw - 152px); top: calc(100dvh - 160px); z-index: 30; border: 0; background: none; padding: 0; cursor: pointer; filter: drop-shadow(0 6px 12px rgba(11,37,64,.25)); }
.zetti-fab:focus-visible { outline: 3px solid var(--focus); border-radius: 50%; }
.zetti-svg .zetti-body { transform-origin: 50px 90px; animation: zetti-bounce 3.2s ease-in-out infinite; }
.zetti-svg .zetti-eyes { transform-origin: 50px 42px; animation: zetti-blink 5s infinite; }
.zetti-fab.thinking .zetti-body { animation: zetti-think .8s ease-in-out infinite; }
@keyframes zetti-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes zetti-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes zetti-think { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.zetti-panel { position: fixed; inset: auto 40px 140px auto; margin: 0; width: min(400px, calc(100vw - 24px)); max-height: min(70dvh, 620px); display: none; flex-direction: column; padding: 0; z-index: 31; }
.zetti-panel[open] { display: flex; }
.zetti-panel .dlg-head h2 { flex: 1; }
.zetti-log { flex: 1; overflow-y: auto; padding: 12px; display: grid; gap: 8px; align-content: start; min-height: 220px; }
.zetti-msg { padding: 8px 12px; border-radius: 12px; max-width: 92%; font-size: .92rem; }
.zetti-msg p { margin: 0 0 6px; }
.zetti-msg.bot { background: var(--accent-soft); justify-self: start; border-bottom-left-radius: 4px; }
.zetti-msg.me { background: var(--accent); color: var(--accent-ink); justify-self: end; border-bottom-right-radius: 4px; }
.zetti-items { margin: 4px 0 8px; padding-left: 18px; font-size: .85rem; max-height: 180px; overflow-y: auto; }
.zetti-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.live-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 60dvh; overflow-y: auto; font-size: .9rem; }
.live-feed li { padding: 6px 8px; border-bottom: 1px solid var(--border); }
@media print { .zetti-fab, .zetti-panel { display: none !important; } }

/* ───── Bóveda ───── */
.scene-wrap.vault { background: #050d18; border-color: #10304f; }
.scene-wrap.vault .scene-crumb, .scene-wrap.vault .scene-legend { background: rgba(8, 24, 41, .88); color: #e3eef8; border-color: #1e3a57; }
.scene-wrap.vault .scene-crumb a { color: #6cc0f2; }
.scene-wrap.vault .scene-tools .btn { background: rgba(8, 24, 41, .88); color: #e3eef8; border-color: #1e3a57; }
.scene-wrap.vault .scene-tools .btn-primary { background: var(--blue); border-color: var(--blue); }
.scene-search { width: 260px; min-height: 30px; padding: 4px 10px; font-size: .85rem; }
.scene-wrap.vault .scene-search { background: rgba(8, 24, 41, .88); color: #e3eef8; border-color: #1e3a57; }
.scene-tools select.btn { width: auto; padding-right: 26px; }
@media (max-width: 700px) { .scene-search { width: 160px; } }

/* Logo según el tema */
.logo-on-dark { display: none; }
:root[data-theme="dark"] .logo-on-light { display: none; }
:root[data-theme="dark"] .logo-on-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block; }
}

/* Zetti: brazos, halo al caer y botón para volver a su lugar */
.zetti-svg .zetti-arm { transform-box: fill-box; }
.zetti-svg .zetti-arm.r { transform-origin: 0% 100%; animation: zetti-wave 2.6s ease-in-out infinite; }
.zetti-svg .zetti-arm.l { transform-origin: 100% 100%; animation: zetti-wave 2.6s ease-in-out infinite reverse; }
@keyframes zetti-wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-14deg); } }
.zetti-halo { position: fixed; z-index: 29; width: 20px; height: 8px; margin: -4px 0 0 -10px; border: 3px solid var(--accent); border-radius: 50%; pointer-events: none; animation: zetti-halo 1s ease-out forwards; }
@keyframes zetti-halo { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(7, 4); } }
.zetti-boing { position: fixed; z-index: 29; pointer-events: none; font: 800 1.15rem/1 Carlito, Calibri, sans-serif; color: var(--accent); -webkit-text-stroke: 1px var(--surface, #fff); text-shadow: 0 2px 0 rgba(11,37,64,.25); transform: rotate(var(--tilt, 0deg)); animation: zetti-boing 1s ease-out forwards; }
@keyframes zetti-boing { 0% { opacity: 0; transform: translateY(6px) rotate(var(--tilt)) scale(.6); } 25% { opacity: 1; transform: translateY(-6px) rotate(var(--tilt)) scale(1.15); } 100% { opacity: 0; transform: translateY(-26px) rotate(var(--tilt)) scale(1); } }
.zetti-home { position: fixed; right: 24px; bottom: 24px; z-index: 30; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 12px rgba(11,37,64,.2); }
.zetti-home:focus-visible { outline: 3px solid var(--focus); }
@media (prefers-reduced-motion: reduce) {
  .zetti-svg .zetti-body, .zetti-svg .zetti-arm, .zetti-svg .zetti-eyes { animation: none; }
  .zetti-halo, .zetti-boing { display: none; }
}
@media print { .zetti-home, .zetti-halo, .zetti-boing, .zetti-say, .zetti-fx { display: none !important; } }
/* Lo que Zetti dice al saltar */
.zetti-say { position: fixed; z-index: 31; max-width: 220px; pointer-events: none; background: var(--surface); color: var(--text); border: 2px solid var(--accent); border-radius: 14px; padding: 6px 10px; font: 600 .85rem/1.25 Carlito, Calibri, sans-serif; box-shadow: 0 6px 16px rgba(11,37,64,.2); animation: zetti-pop .25s ease-out; transition: opacity .25s; }
.zetti-say::after { content: ''; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px; margin-left: -6px; background: var(--surface); border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.zetti-say.below::after { bottom: auto; top: -8px; transform: rotate(-135deg); }
.zetti-say.out { opacity: 0; }
/* Efectos del salto: estrellitas, viento y polvo */
.zetti-fx { position: fixed; z-index: 29; pointer-events: none; line-height: 1; }
.zetti-fx.star { margin: -10px 0 0 -10px; font-size: 20px; color: #F5C542; text-shadow: 0 0 6px rgba(245,197,66,.7); animation: zetti-star .9s ease-out forwards; }
.zetti-fx.star.alt { color: #5BC0F5; text-shadow: 0 0 6px rgba(91,192,245,.7); font-size: 15px; }
@keyframes zetti-star { 0% { opacity: 0; transform: scale(.3) rotate(0); } 20% { opacity: 1; transform: scale(1.2) rotate(var(--rot, 45deg)); } 100% { opacity: 0; transform: translateY(14px) scale(.4) rotate(calc(var(--rot, 45deg) * 2)); } }
.zetti-fx.wind { width: 34px; height: 3px; margin-top: -1px; border-radius: 3px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 70%, transparent), transparent); opacity: 0; animation: zetti-wind .55s ease-out var(--d, 0ms) forwards; }
@keyframes zetti-wind { 0% { opacity: 0; transform: translateX(0) scaleX(.4); } 30% { opacity: .9; } 100% { opacity: 0; transform: translateX(var(--dx)) scaleX(1.3); } }
.zetti-fx.puff { width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: color-mix(in srgb, var(--text) 18%, transparent); animation: zetti-puff .7s ease-out forwards; }
@keyframes zetti-puff { from { opacity: .8; transform: translate(0, 0) scale(calc(var(--s, 1) * .4)); } to { opacity: 0; transform: translate(var(--dx), -10px) scale(calc(var(--s, 1) * 1.4)); } }
.zetti-fx.spark { margin: -7px 0 0 -7px; font-size: 14px; color: #3EB135; animation: zetti-spark .7s ease-out forwards; }
@keyframes zetti-spark { 0% { opacity: 0; transform: translate(0, 10px) scale(.4); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), -22px) scale(1); } }
.zetti-tip { max-width: min(320px, calc(100vw - 24px)); }
/* Cara y gestos de Zetti */
.zetti-svg .zetti-pupils { transform: translate(var(--lx, 0px), var(--ly, 0px)); transition: transform .18s ease-out; }
.zetti-svg .zetti-brows, .zetti-svg .m-grin, .zetti-svg .m-o, .zetti-svg .m-sleep { display: none; }
.zetti-svg .zetti-eyes, .zetti-svg .zetti-mouth, .zetti-svg .zetti-brows { transform-box: fill-box; transform-origin: center; }
.zetti-svg .zetti-cheek { transition: fill .2s; }
.zetti-fab.thinking .zetti-pupils { transform: translate(1.8px, -2.4px); }
.zetti-fab.mood-happy .m-smile, .zetti-fab.mood-surprised .m-smile, .zetti-fab.mood-sleepy .m-smile { display: none; }
.zetti-fab.mood-happy .m-grin { display: inline; }
.zetti-fab.mood-happy .zetti-eyes { animation: none; transform: scaleY(.6) translateY(-1px); }
.zetti-fab.mood-happy .zetti-cheek { fill: rgba(255,140,170,.75); }
.zetti-fab.mood-surprised .m-o, .zetti-fab.mood-surprised .zetti-brows { display: inline; }
.zetti-fab.mood-surprised .zetti-eyes { animation: none; transform: scale(1.12); }
.zetti-fab.mood-surprised .zetti-brows { transform: translateY(-1.5px); }
.zetti-fab.mood-sleepy .m-sleep { display: inline; }
.zetti-fab.mood-sleepy .zetti-eyes { animation: none; transform: scaleY(.12) translateY(4px); }
.zetti-fab.mood-sleepy .zetti-body { animation: zetti-breathe 3.6s ease-in-out infinite; }
.zetti-fab.mood-sleepy .zetti-arm { animation: none; }
@keyframes zetti-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.03, .97); } }
.zetti-fab.waving .zetti-arm.r { animation: zetti-bigwave .4s ease-in-out 4; }
@keyframes zetti-bigwave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-38deg); } }
.zetti-fab.talking .zetti-mouth { animation: zetti-talk .16s ease-in-out infinite alternate; }
@keyframes zetti-talk { from { transform: scaleY(.55); } to { transform: scaleY(1.25); } }
.zetti-fx.zzz { margin: -8px 0 0 0; font: 700 15px/1 Carlito, Calibri, sans-serif; color: var(--accent); animation: zetti-zzz 2.2s ease-out forwards; }
@keyframes zetti-zzz { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(18px, -34px) scale(1.4); } }
@media (prefers-reduced-motion: reduce) {
  .zetti-svg .zetti-pupils { transition: none; }
  .zetti-fab.waving .zetti-arm.r, .zetti-fab.talking .zetti-mouth, .zetti-fab.mood-sleepy .zetti-body { animation: none; }
}
.zetti-tip .zetti-tip-head { justify-content: space-between; align-items: center; margin-bottom: 4px; }
@media (prefers-reduced-motion: reduce) { .zetti-say { animation: none; transition: none; } .zetti-fx { display: none; } }

/* Saludo de Zetti */
.zetti-bubble { position: fixed; z-index: 31; max-width: min(340px, calc(100vw - 24px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px 14px 4px 14px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(11,37,64,.25); animation: zetti-pop .35s ease-out; }
.zetti-bubble p { margin: 0 0 8px; }
.zetti-bubble .row { gap: 6px; flex-wrap: wrap; }
@keyframes zetti-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }

/* Recorrido guiado */
.tour-layer { position: fixed; inset: 0; z-index: 40; }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(6,18,32,.62); outline: 3px solid var(--accent); transition: all .25s ease; pointer-events: none; }
.tour-card { position: fixed; width: min(360px, calc(100vw - 24px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: 0 12px 34px rgba(0,0,0,.35); transition: left .25s ease, top .25s ease; }
.tour-head { display: flex; align-items: center; gap: 10px; }
.tour-head h2 { margin: 0; font-size: 1.1rem; }
.tour-card p { margin: 10px 0 14px; line-height: 1.45; }
.tour-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tour-count { color: var(--muted, #6b7c8f); font-size: .85rem; }
body.tour-on .sidebar { transform: none !important; visibility: visible !important; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-card, .zetti-bubble { transition: none; animation: none; } }

.human-check.ok { border-color: var(--ok, #2bb673); color: var(--ok, #2bb673); }

/* Firma */
.sidebar .foot { display: grid; gap: 2px; }
.sidebar .foot strong, .powered strong { color: var(--accent); font-weight: 700; }
.sidebar .foot .ver { opacity: .7; font-size: .78rem; }
.powered { margin: 18px 0 0; text-align: center; font-size: .8rem; color: var(--muted, #6b7c8f); }

/* Fotos */
img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.kpi-link { text-decoration: none; color: inherit; cursor: pointer; }
.kpi-link:hover { outline: 2px solid var(--accent); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; }
.gallery figcaption { display: flex; gap: 4px; justify-content: space-between; align-items: center; padding: 6px; font-size: .8rem; }
.gallery .primary { position: absolute; top: 6px; left: 6px; }
.photo-hero { width: 100%; max-height: 320px; object-fit: contain; border-radius: 10px; background: var(--surface-2); }
.photo-pick { display: grid; gap: 10px; }
.photo-pick .preview { max-width: 220px; max-height: 220px; border-radius: 8px; border: 1px solid var(--border); }
.photo-pick .suggest { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-pick .suggest button { padding: 0; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; }
.photo-pick .suggest button[aria-pressed="true"] { border-color: var(--accent); }
.photo-pick .suggest img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; display: block; }
progress.bar { width: 100%; height: 10px; accent-color: var(--accent); }
.global-load { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: gl 1.1s linear infinite; pointer-events: none; }
@keyframes gl { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) { .global-load { animation: none; background: var(--accent); opacity: .6; } }

.mission-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 35; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px 12px; box-shadow: 0 10px 30px rgba(11,37,64,.3); min-width: min(440px, calc(100vw - 24px)); }
.mission-bar .stack { flex: 1; gap: 2px; }

/* Atlas */
.atlas-wrap { position: relative; }
.atlas-svg { width: 100%; height: auto; display: block; background: light-dark(#eef4fa, #0b1a2a); border-radius: 10px; }
.atlas-c { fill: light-dark(#dfe7ef, #1c3047); stroke: light-dark(#ffffff, #0b1a2a); stroke-width: .5; transition: fill .2s; }
.atlas-c.on { stroke: light-dark(#ffffff, #0e2236); }
.atlas-c:hover { stroke: var(--accent); stroke-width: 1.5; }
.atlas-tip { position: absolute; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font-size: .82rem; box-shadow: 0 6px 18px rgba(0,0,0,.25); white-space: nowrap; }
.atlas-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.atlas-ramp { display: inline-flex; border-radius: 4px; overflow: hidden; }
.atlas-ramp i { width: 22px; height: 10px; display: block; }
.seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Aprobaciones y carga masiva */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-weight: 600; }
dl.kv dd { margin: 0; }
ul.msgs { margin: 0; padding-left: 1.1rem; }
.kpi.warn .v { color: var(--warn, #b26a00); }
.kpi.bad .v { color: var(--bad, #b42318); }

/* Alcance por tarjetas */
.scope-wizard h3 { margin: .6rem 0 .2rem; font-size: 1rem; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; }
.pick-card { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; text-align: left; padding: .65rem .8rem;
  border: 1.5px solid var(--line, #cfd8e3); border-radius: 10px; background: var(--surface, #fff); color: inherit; cursor: pointer; font: inherit; }
.pick-card:hover { border-color: var(--accent, #0B5CAD); }
.pick-card:focus-visible { outline: 3px solid var(--accent, #0B5CAD); outline-offset: 2px; }
.pick-card[aria-pressed="true"] { border-color: var(--accent, #0B5CAD); background: color-mix(in srgb, var(--accent, #0B5CAD) 10%, var(--surface, #fff)); box-shadow: inset 0 0 0 1px var(--accent, #0B5CAD); }
.pick-card[aria-pressed="true"] strong::before { content: "✓ "; color: var(--accent, #0B5CAD); }
.pick-card .sub { font-size: .85rem; color: var(--muted, #5b6b7f); }
.pick-card .meta { font-size: .8rem; font-weight: 600; color: var(--brand-orange, #E8711C); }
.scope-sum { position: sticky; bottom: 0; margin: .4rem 0 0; padding: .55rem .8rem; border-radius: 8px; background: var(--surface-2, #eef3f8); font-weight: 600; }
