/* ==========================================================================
   Xoord Suite — Sistema de diseño
   Tema claro/oscuro · mobile-first · accesible (WCAG AA) · sin dependencias
   ========================================================================== */

/* ── 1. Tokens ─────────────────────────────────────────────────────────── */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', var(--font);
  --radius-sm: 8px; --radius: 12px; --radius-lg: 18px; --radius-xl: 24px; --pill: 999px;
  --sidebar-w: 264px; --sidebar-w-mini: 76px; --topbar-h: 64px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --accent: #06b6d4; --accent-2: #2563eb; --accent-3: #8b5cf6;
  --grad: linear-gradient(135deg, #22d3ee 0%, #3b82f6 55%, #6366f1 100%);
  --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --info: #3b82f6; --violet: #8b5cf6; --teal: #14b8a6; --orange: #f97316;

  /* Claro */
  --bg: #f4f6fb; --bg-elev: #ffffff; --bg-sunken: #eef1f7; --bg-hover: #f1f4fa;
  --text: #0f172a; --text-2: #475569; --text-3: #94a3b8;
  --border: #e2e8f0; --border-strong: #cbd5e1;
  --sidebar-bg: #0b1120; --sidebar-text: #cbd5e1; --sidebar-muted: #64748b; --sidebar-active: rgba(34,211,238,.12);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 4px 16px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow-lg: 0 20px 50px rgba(15,23,42,.14);
  --focus: 0 0 0 3px rgba(6,182,212,.35);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #020617; --bg-elev: #0b1222; --bg-sunken: #070d1a; --bg-hover: #111a2e;
  --text: #f1f5f9; --text-2: #a3b1c6; --text-3: #64748b;
  --border: #1c2840; --border-strong: #2a3a58;
  --sidebar-bg: #050a17; --sidebar-active: rgba(34,211,238,.14);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #020617; --bg-elev: #0b1222; --bg-sunken: #070d1a; --bg-hover: #111a2e;
    --text: #f1f5f9; --text-2: #a3b1c6; --text-3: #64748b;
    --border: #1c2840; --border-strong: #2a3a58; --sidebar-bg: #050a17;
    --shadow: 0 6px 24px rgba(0,0,0,.35); --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

/* ── 2. Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font: 400 15px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; min-height: 100vh; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem); font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; } h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: var(--accent-2); text-decoration: none; } a:hover { text-decoration: underline; }
:root[data-theme="dark"] a { color: #67e8f9; }
img { max-width: 100%; display: block; }
small, .small { font-size: .82rem; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: .86em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
::selection { background: rgba(6,182,212,.25); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ── 3. Layout app ─────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns .25s var(--ease); }
.app.is-mini { grid-template-columns: var(--sidebar-w-mini) 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 40; border-right: 1px solid rgba(255,255,255,.04); }
.sidebar::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(600px 300px at -10% -10%, rgba(34,211,238,.10), transparent 60%), radial-gradient(500px 300px at 120% 110%, rgba(99,102,241,.10), transparent 60%); }
.brand { display: flex; align-items: center; gap: .7rem; padding: 0 1.1rem; height: var(--topbar-h); font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none !important; position: relative; }
.brand-logo { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; font-weight: 800; color: #fff; box-shadow: 0 6px 20px rgba(34,211,238,.35); flex: none; }
.brand small { display: block; font: 500 .68rem var(--font); color: var(--sidebar-muted); letter-spacing: .08em; text-transform: uppercase; }
.nav { flex: 1; overflow-y: auto; padding: .5rem .7rem 1rem; position: relative; scrollbar-width: thin; scrollbar-color: #1e293b transparent; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--sidebar-muted); padding: 1rem .7rem .4rem; font-weight: 600; }
.nav a, .nav summary { display: flex; align-items: center; gap: .75rem; padding: .58rem .75rem; border-radius: 10px; color: var(--sidebar-text); text-decoration: none; font-weight: 500; font-size: .92rem; cursor: pointer; list-style: none; position: relative; transition: background .15s, color .15s; }
.nav summary::-webkit-details-marker { display: none; }
.nav a:hover, .nav summary:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -.7rem; top: 20%; bottom: 20%; width: 3px; border-radius: 3px; background: var(--grad); }
.nav i.bi { font-size: 1.1rem; width: 1.25rem; text-align: center; flex: none; opacity: .9; }
.nav details > summary .chev { margin-left: auto; transition: transform .2s; font-size: .8rem; }
.nav details[open] > summary .chev { transform: rotate(90deg); }
.nav details .sub { padding-left: .6rem; margin: .15rem 0 .35rem; border-left: 1px dashed rgba(255,255,255,.08); margin-left: 1.3rem; }
.nav details .sub a { font-size: .87rem; padding: .45rem .7rem; }
.sidebar-foot { padding: .8rem; border-top: 1px solid rgba(255,255,255,.06); position: relative; }
.app.is-mini .brand span, .app.is-mini .nav-section, .app.is-mini .nav a span, .app.is-mini .nav summary span, .app.is-mini .nav .chev, .app.is-mini .sidebar-foot .label { display: none; }
.app.is-mini .nav details .sub { margin-left: 0; padding-left: 0; border: 0; }
.app.is-mini .nav a, .app.is-mini .nav summary { justify-content: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--border); }
.search-trigger { flex: 1; max-width: 460px; display: flex; align-items: center; gap: .6rem; height: 40px; padding: 0 .9rem; border: 1px solid var(--border); background: var(--bg-elev); border-radius: var(--pill); color: var(--text-3); cursor: pointer; font: inherit; text-align: left; }
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger kbd { margin-left: auto; }
kbd { font: 600 .7rem var(--font); padding: .15rem .45rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-sunken); color: var(--text-2); }
.topbar .spacer { flex: 1; }
.icon-btn { position: relative; width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-size: 1.15rem; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font: 700 .64rem/17px var(--font); text-align: center; border: 2px solid var(--bg); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font: 700 .8rem var(--font-display); background: var(--accent-2); flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; } .avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .25rem; border-radius: var(--pill); border: 1px solid var(--border); background: var(--bg-elev); cursor: pointer; color: var(--text); font: inherit; }
.user-chip .who { line-height: 1.1; text-align: left; } .user-chip .who small { color: var(--text-3); display: block; }
.content { padding: 1.5rem clamp(1rem, 2.5vw, 2rem) 5rem; max-width: 1480px; width: 100%; margin: 0 auto; }
.menu-toggle { display: none; }

@media (max-width: 1024px) {
  .app, .app.is-mini { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 35; backdrop-filter: blur(2px); }
  .menu-toggle { display: inline-grid; }
  .user-chip .who, .search-trigger kbd, .collapse-btn { display: none; }
  .topbar { padding: 0 .75rem; }
}
@media (max-width: 560px) { .search-trigger span { display: none; } .search-trigger { flex: 0 0 40px; padding: 0; justify-content: center; } }

/* ── 4. Encabezado de página ───────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-head .title-wrap { min-width: 0; }
.page-head p { margin: .2rem 0 0; color: var(--text-2); }
.crumbs { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .8rem; color: var(--text-3); margin-bottom: .35rem; }
.crumbs a { color: var(--text-2); } .crumbs i { font-size: .65rem; align-self: center; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ── 5. Botones ────────────────────────────────────────────────────────── */
.btn { --b: var(--bg-elev); --c: var(--text); --bd: var(--border); display: inline-flex; align-items: center; justify-content: center; gap: .5rem; height: 40px; padding: 0 1rem; border-radius: var(--pill); border: 1px solid var(--bd); background: var(--b); color: var(--c); font: 600 .9rem var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: transform .1s, box-shadow .2s, background .15s, border-color .15s; user-select: none; }
.btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn i.bi { font-size: 1.05em; }
.btn-primary { --b: var(--grad); --c: #fff; --bd: transparent; background: var(--grad); box-shadow: 0 8px 22px -8px rgba(37,99,235,.65); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.07); box-shadow: 0 10px 26px -8px rgba(37,99,235,.8); }
.btn-danger { --b: transparent; --c: var(--danger); --bd: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: var(--danger); }
.btn-success { background: var(--success); --c: #fff; --bd: transparent; }
.btn-success:hover { background: #0ea371; }
.btn-ghost { --b: transparent; --bd: transparent; --c: var(--text-2); }
.btn-sm { height: 32px; padding: 0 .75rem; font-size: .82rem; }
.btn-lg { height: 52px; padding: 0 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; } .btn-sm.btn-icon { width: 32px; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn.is-loading::after { content: ''; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--pill); padding: 3px; background: var(--bg-elev); }
.btn-group a, .btn-group button { border: 0; background: transparent; padding: .35rem .8rem; border-radius: var(--pill); color: var(--text-2); font: 600 .82rem var(--font); cursor: pointer; text-decoration: none !important; }
.btn-group .on { background: var(--bg-sunken); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── 6. Tarjetas y grillas ─────────────────────────────────────────────── */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-foot { padding: .85rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.card.flush .card-body { padding: 0; }
.card.glow { position: relative; overflow: hidden; }
.card.glow::before { content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: .55; pointer-events: none; }
.grid { display: grid; gap: 1.1rem; }
.grid > * { min-width: 0; } /* evita que tablas/pestañas anchas desborden la pantalla en móvil */
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.span-2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; }
@media (max-width: 1100px) { .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .g-2, .g-3, .g-4 { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }
.stack > * + * { margin-top: 1.1rem; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; } .row.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }

/* KPI */
.kpi { padding: 1.1rem 1.2rem; display: flex; gap: .9rem; align-items: flex-start; position: relative; overflow: hidden; }
.kpi .ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 1.25rem; flex: none; background: color-mix(in srgb, var(--tone, var(--accent)) 14%, transparent); color: var(--tone, var(--accent)); }
.kpi .val { font: 700 1.6rem/1.1 var(--font-display); letter-spacing: -.02em; }
.kpi .lbl { color: var(--text-2); font-size: .84rem; font-weight: 500; }
.kpi .delta { font-size: .78rem; font-weight: 600; margin-top: .25rem; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); }
.tone-cyan { --tone: #06b6d4; } .tone-blue { --tone: #3b82f6; } .tone-violet { --tone: #8b5cf6; } .tone-success { --tone: #10b981; } .tone-warning { --tone: #f59e0b; } .tone-danger { --tone: #ef4444; } .tone-teal { --tone: #14b8a6; }
.gauge { --p: 0; width: 120px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--tone, var(--accent)) calc(var(--p) * 1%), var(--bg-sunken) 0); position: relative; }
.gauge::before { content: ''; position: absolute; inset: 12px; border-radius: 50%; background: var(--bg-elev); }
.gauge b { position: relative; font: 700 1.35rem var(--font-display); }

/* ── 7. Badges, chips, progreso ───────────────────────────────────────── */
.badge { --t: var(--text-2); display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: var(--pill); font: 600 .74rem/1.4 var(--font); color: var(--t); background: color-mix(in srgb, var(--t) 12%, transparent); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { --t: var(--success); } .badge-warning { --t: #d97706; } .badge-danger { --t: var(--danger); } .badge-info { --t: var(--info); }
.badge-violet { --t: var(--violet); } .badge-teal { --t: var(--teal); } .badge-orange { --t: var(--orange); } .badge-neutral { --t: var(--text-2); } .badge-dark { --t: var(--text); }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border: 1px solid var(--border); border-radius: var(--pill); font-size: .8rem; color: var(--text-2); background: var(--bg-elev); text-decoration: none !important; }
a.chip:hover, .chip.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev)); }
.chip .n { font-weight: 700; color: var(--text); }
.progress { height: 8px; background: var(--bg-sunken); border-radius: var(--pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--grad); border-radius: inherit; transition: width .4s var(--ease); }
.dot-status { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--t, var(--text-3)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--t, var(--text-3)) 18%, transparent); }

/* ── 8. Tablas (responsive → tarjetas en móvil) ───────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th { text-align: left; font: 600 .74rem var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg-sunken); position: sticky; top: 0; white-space: nowrap; }
.table th a { color: inherit; } .table th a:hover { color: var(--text); text-decoration: none; }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .t-title { font-weight: 600; color: var(--text); } .table .t-sub { font-size: .8rem; color: var(--text-3); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
tr[data-href] { cursor: pointer; }
@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
  .table.responsive td { border: 0; padding: .2rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table.responsive td::before { content: attr(data-label); font-weight: 600; font-size: .78rem; color: var(--text-3); text-align: left; }
  .table.responsive td.t-main { display: block; text-align: left; } .table.responsive td.t-main::before { display: none; }
  .table.responsive .num { text-align: right; }
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: .85rem; color: var(--text-2); }
.pager nav { display: flex; gap: .3rem; }
.pager a, .pager span.cur { min-width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); color: var(--text-2); text-decoration: none !important; padding: 0 .5rem; }
.pager span.cur { background: var(--grad); color: #fff; border-color: transparent; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.toolbar .search input { padding-left: 2.3rem; }
.filters-scroll { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }

/* ── 9. Formularios ────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.form-grid > .f { grid-column: span 12; }
@media (min-width: 720px) { .f-6 { grid-column: span 6 !important; } .f-4 { grid-column: span 4 !important; } .f-3 { grid-column: span 3 !important; } .f-8 { grid-column: span 8 !important; } }
.f label, .label { display: flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .86rem; margin-bottom: .4rem; color: var(--text); }
.f label .req { color: var(--danger); }
.f .hint { font-size: .78rem; color: var(--text-3); margin-top: .35rem; }
.f .counter { float: right; font-size: .72rem; color: var(--text-3); font-weight: 500; }
.input, select.input, textarea.input, .f input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), .f select, .f textarea {
  width: 100%; min-height: 44px; padding: .6rem .9rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg-elev); color: var(--text); font: 400 .95rem var(--font); transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none;
}
.f select, select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2394a3b8' d='M8 11 3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .85rem center; padding-right: 2.2rem; }
.f textarea, textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:hover, .f input:hover, .f select:hover, .f textarea:hover { border-color: var(--text-3); }
.input:focus, .f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.f input[type=color] { width: 56px; height: 44px; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 4px; background: var(--bg-elev); }
.f.invalid input, .f.invalid select, .f.invalid textarea, .input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.field-error, .f .err { color: var(--danger); font-size: .8rem; margin-top: .35rem; display: flex; gap: .3rem; align-items: center; }
.f.valid input, .f.valid select { border-color: color-mix(in srgb, var(--success) 60%, var(--border-strong)); }
.f.ai-filled input, .f.ai-filled select, .f.ai-filled textarea { border-color: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 18%, transparent); background: color-mix(in srgb, var(--violet) 5%, var(--bg-elev)); }
.f.ai-filled label::after { content: 'IA'; font: 700 .62rem var(--font); color: #fff; background: var(--violet); border-radius: 5px; padding: .05rem .35rem; }
.input-group { display: flex; align-items: stretch; } .input-group > :first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; } .input-group > :last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.input-addon { display: grid; place-items: center; padding: 0 .85rem; border: 1px solid var(--border-strong); background: var(--bg-sunken); color: var(--text-2); border-radius: var(--radius); font-size: .88rem; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin: 0 0 1.2rem; background: var(--bg-elev); }
.fieldset > legend, .fieldset .legend { font: 600 1rem var(--font-display); padding: 0 .4rem; display: flex; align-items: center; gap: .5rem; }
.fieldset .legend-sub { color: var(--text-3); font-size: .82rem; margin: -.2rem 0 1rem; }
/* Switch accesible */
.switch { display: inline-flex; align-items: center; gap: .65rem; cursor: pointer; font-weight: 500; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 26px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--accent); } .switch input:checked::after { transform: translateX(18px); }
/* Opciones grandes tipo tarjeta (táctil) */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .8rem .6rem; border: 1.5px solid var(--border); border-radius: var(--radius); text-align: center; font-weight: 600; font-size: .86rem; cursor: pointer; transition: all .15s; background: var(--bg-elev); }
.choice span i { font-size: 1.3rem; color: var(--text-3); }
.choice input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev)); box-shadow: var(--focus); }
.choice input:checked + span i { color: var(--accent); }
.choice input:focus-visible + span { box-shadow: var(--focus); }
/* Dropzone */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 1.4rem; text-align: center; color: var(--text-2); cursor: pointer; transition: all .15s; background: var(--bg-sunken); position: relative; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg-sunken)); color: var(--text); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone i { font-size: 1.8rem; color: var(--accent); display: block; margin-bottom: .35rem; }
/* Barra de acciones fija del formulario */
.form-actions { position: sticky; bottom: 0; z-index: 20; display: flex; gap: .6rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: .9rem 1.25rem; margin: 1.2rem -1px -1px; background: color-mix(in srgb, var(--bg-elev) 88%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.form-actions .status { margin-right: auto; font-size: .8rem; color: var(--text-3); display: flex; gap: .35rem; align-items: center; }
@media (max-width: 720px) { .form-actions { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); } .form-actions .btn { flex: 1; } .form-actions .status { display: none; } .has-fixed-actions { padding-bottom: 80px; } }
/* Asistente por pasos */
.steps { display: flex; gap: .4rem; margin-bottom: 1.2rem; overflow-x: auto; scrollbar-width: none; counter-reset: s; }
.steps button { flex: 1; min-width: 120px; display: flex; align-items: center; gap: .55rem; padding: .65rem .85rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); color: var(--text-2); font: 600 .85rem var(--font); cursor: pointer; text-align: left; counter-increment: s; }
.steps button::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-sunken); font-size: .75rem; flex: none; }
.steps button.on { border-color: var(--accent); color: var(--text); box-shadow: var(--focus); } .steps button.on::before { background: var(--grad); color: #fff; }
.steps button.done::before { content: '✓'; background: var(--success); color: #fff; }
.step-panel[hidden] { display: none; }
/* Repetidor de filas (checklist, repuestos…) */
.repeater-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: .6rem; align-items: start; padding: .7rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .55rem; background: var(--bg-elev); }
.repeater-row .handle { color: var(--text-3); cursor: grab; padding-top: .7rem; text-align: center; }
.repeater-row .inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; }
.repeater-row .inner .wide { grid-column: 1 / -1; }

/* Combobox con búsqueda */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow-y: auto; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .3rem; }
.combo-list [role=option] { padding: .55rem .7rem; border-radius: 8px; cursor: pointer; font-size: .9rem; }
.combo-list [role=option][aria-selected=true], .combo-list [role=option]:hover { background: var(--bg-hover); }
.combo-list .empty { padding: .7rem; color: var(--text-3); font-size: .86rem; }

/* ── 10. Pestañas, menús, diálogos ───────────────────────────────────── */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: 1.2rem; }
.tabs a, .tabs button { padding: .7rem 1rem; border: 0; background: none; color: var(--text-2); font: 600 .88rem var(--font); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none !important; display: flex; gap: .45rem; align-items: center; }
.tabs .on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font-size: .72rem; padding: .05rem .45rem; border-radius: var(--pill); background: var(--bg-sunken); color: var(--text-2); }
.tab-panel[hidden] { display: none; }
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .35rem; z-index: 70; display: none; }
.dropdown.open > .menu { display: block; animation: pop .14s var(--ease); }
.menu a, .menu button { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .7rem; border-radius: 8px; border: 0; background: none; color: var(--text); font: 500 .9rem var(--font); cursor: pointer; text-align: left; text-decoration: none !important; }
.menu a:hover, .menu button:hover { background: var(--bg-hover); }
.menu hr { margin: .35rem 0; } .menu .danger { color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
dialog.modal { border: 0; padding: 0; border-radius: var(--radius-xl); background: var(--bg-elev); color: var(--text); width: min(560px, calc(100vw - 2rem)); box-shadow: var(--shadow-lg); }
dialog.modal.lg { width: min(860px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(2,6,23,.55); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop .18s var(--ease); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); } .modal-head h3 { margin: 0; }
.modal-body { padding: 1.3rem 1.4rem; max-height: 70vh; overflow-y: auto; } .modal-foot { padding: 1rem 1.4rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 560px) { dialog.modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; } }

/* ── 11. Feedback ──────────────────────────────────────────────────────── */
.alert { display: flex; gap: .75rem; padding: .9rem 1rem; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--t, var(--info)) 30%, transparent); background: color-mix(in srgb, var(--t, var(--info)) 8%, var(--bg-elev)); font-size: .9rem; }
.alert i.bi { color: var(--t, var(--info)); font-size: 1.15rem; } .alert-success { --t: var(--success); } .alert-danger { --t: var(--danger); } .alert-warning { --t: var(--warning); }
.toasts { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .55rem; width: min(380px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; background: var(--bg-elev); border: 1px solid var(--border); border-left: 4px solid var(--t, var(--info)); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: slide .25s var(--ease); font-size: .9rem; }
.toast i.bi { color: var(--t, var(--info)); font-size: 1.1rem; } .toast .x { margin-left: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; }
.toast.exito { --t: var(--success); } .toast.peligro { --t: var(--danger); } .toast.alerta { --t: var(--warning); }
@keyframes slide { from { opacity: 0; transform: translateY(10px); } }
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-2); }
.empty .ico { width: 64px; height: 64px; margin: 0 auto .9rem; border-radius: 20px; display: grid; place-items: center; font-size: 1.8rem; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.skeleton { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 50%, var(--bg-sunken) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; min-height: 1em; }
@keyframes sk { to { background-position: -200% 0; } }

/* ── 12. Componentes de dominio ───────────────────────────────────────── */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: .45rem; top: .3rem; bottom: .3rem; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 1rem; }
.tl-item::before { content: ''; position: absolute; left: -1.29rem; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: var(--bg-elev); border: 3px solid var(--t, var(--accent)); }
.tl-item .meta { font-size: .76rem; color: var(--text-3); }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: 1rem; scroll-snap-type: x mandatory; }
.kcol { background: var(--bg-sunken); border-radius: var(--radius-lg); padding: .75rem; min-height: 60vh; scroll-snap-align: start; border: 1px solid var(--border); }
.kcol h3 { display: flex; justify-content: space-between; font-size: .85rem; padding: .25rem .35rem .7rem; margin: 0; }
.kcard { display: block; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .9rem; margin-bottom: .6rem; color: var(--text) !important; text-decoration: none !important; box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s; border-left: 3px solid var(--t, var(--border)); }
.kcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kcard .code { font: 600 .74rem var(--font); color: var(--text-3); }
.kcard .ttl { font-weight: 600; font-size: .9rem; margin: .2rem 0 .45rem; }
.tree ul { list-style: none; margin: 0; padding-left: 1.2rem; border-left: 1px dashed var(--border); }
.tree > ul { padding-left: 0; border: 0; }
.tree li { margin: .15rem 0; }
.tree .node { display: flex; align-items: center; gap: .55rem; padding: .5rem .65rem; border-radius: 10px; }
.tree .node:hover { background: var(--bg-hover); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--border); gap: 1px; }
.cal .dow { background: var(--bg-sunken); padding: .5rem; font: 600 .72rem var(--font); text-transform: uppercase; color: var(--text-3); text-align: center; }
.cal .day { background: var(--bg-elev); min-height: 116px; padding: .35rem; font-size: .78rem; overflow: hidden; }
.cal .day.out { background: var(--bg-sunken); color: var(--text-3); } .cal .day.today .n { background: var(--grad); color: #fff; }
.cal .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 600; margin-bottom: .2rem; }
.cal .ev { display: block; padding: .15rem .4rem; border-radius: 6px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text) !important; text-decoration: none !important; background: color-mix(in srgb, var(--t, var(--info)) 14%, transparent); border-left: 3px solid var(--t, var(--info)); }
.cal .ev.proj { border-left-style: dashed; opacity: .75; }
@media (max-width: 760px) { .cal .day { min-height: 72px; } .cal .ev { font-size: 0; height: 6px; padding: 0; } }
.checklist-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .8rem; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .55rem; background: var(--bg-elev); transition: border-color .2s, background .2s; }
.checklist-item.done { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: color-mix(in srgb, var(--success) 5%, var(--bg-elev)); }
.checklist-item.out { border-color: var(--danger); }
.checklist-item .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-sunken); font: 700 .8rem var(--font); }
.checklist-item.done .num { background: var(--success); color: #fff; }
.big-check { width: 28px; height: 28px; accent-color: var(--success); cursor: pointer; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--pill); overflow: hidden; }
.segmented label { padding: .45rem 1rem; cursor: pointer; font-weight: 600; font-size: .85rem; } .segmented input { display: none; }
.segmented input:checked + label { background: var(--accent); color: #fff; }
.qr-label { display: inline-grid; grid-template-columns: 110px 1fr; gap: .7rem; align-items: center; border: 1px solid #000; padding: .6rem; width: 340px; page-break-inside: avoid; margin: 4px; font-family: Arial, sans-serif; color: #000; background: #fff; }
.qr-label canvas, .qr-label img, .qr-label svg { width: 110px; height: 110px; }
.fab { position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 50; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; font-size: 1.5rem; display: grid; place-items: center; box-shadow: 0 14px 30px -10px rgba(37,99,235,.8); cursor: pointer; }
.fab.listening { animation: pulse 1.2s infinite; background: linear-gradient(135deg, #ef4444, #f97316); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); } 100% { box-shadow: 0 0 0 22px rgba(239,68,68,0); } }
.palette-results { max-height: 55vh; overflow-y: auto; }
.palette-results .grp { font: 600 .7rem var(--font); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: .7rem .8rem .3rem; }
.palette-results a { display: flex; gap: .75rem; align-items: center; padding: .6rem .8rem; border-radius: 10px; color: var(--text) !important; text-decoration: none !important; }
.palette-results a.on, .palette-results a:hover { background: var(--bg-hover); }
.palette-results a i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-sunken); color: var(--accent); flex: none; }

/* ── 13. Autenticación ─────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--bg); }
.auth-hero { position: relative; overflow: hidden; background: #020617; color: #e2e8f0; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(700px 420px at 10% 0%, rgba(6,182,212,.25), transparent 60%), radial-gradient(600px 400px at 100% 100%, rgba(99,102,241,.25), transparent 60%); }
.auth-hero::after { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%); }
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero h1 { font-size: clamp(2rem, 1.4rem + 2vw, 3rem); color: #fff; max-width: 14ch; }
.auth-hero .feat { display: flex; gap: .8rem; align-items: center; margin: .7rem 0; color: #cbd5e1; }
.auth-hero .feat i { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); color: #67e8f9; }
.auth-panel { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { padding: 0; height: auto; margin-bottom: 2rem; color: var(--text); }
.otp-input { font: 700 1.8rem var(--font-display) !important; letter-spacing: .5em; text-align: center; }
.qr-box { background: #fff; padding: 12px; border-radius: 14px; display: inline-block; border: 1px solid var(--border); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; font: 600 1rem ui-monospace, Consolas, monospace; }
.codes span { padding: .5rem; border: 1px dashed var(--border-strong); border-radius: 8px; text-align: center; background: var(--bg-sunken); }
.pw-meter { height: 6px; border-radius: 6px; background: var(--bg-sunken); overflow: hidden; margin-top: .5rem; } .pw-meter span { display: block; height: 100%; width: 0; transition: width .3s, background .3s; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ── 14. Chat IA ───────────────────────────────────────────────────────── */
.chat { display: grid; grid-template-rows: 1fr auto; height: calc(100vh - var(--topbar-h) - 9rem); min-height: 420px; }
.chat-log { overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: .9rem; }
.msg { max-width: min(760px, 88%); padding: .8rem 1rem; border-radius: 16px; line-height: 1.55; font-size: .93rem; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bg-sunken); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .tools { font-size: .74rem; color: var(--text-3); margin-top: .4rem; }
.chat-input { display: flex; gap: .5rem; padding: .9rem; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-input textarea { min-height: 48px !important; max-height: 160px; }
.suggestions { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; }
.voice-panel { position: fixed; z-index: 90; left: 50%; bottom: 1.2rem; transform: translateX(-50%); width: min(640px, calc(100vw - 1.5rem)); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 1rem 1.1rem; }
.voice-panel .transcript { min-height: 2.6em; font-size: 1.02rem; padding: .6rem .8rem; border-radius: 12px; background: var(--bg-sunken); margin: .6rem 0; }
.voice-panel .wave { display: flex; gap: 3px; align-items: center; height: 22px; } .voice-panel .wave i { width: 3px; background: var(--accent); border-radius: 3px; animation: wave 1s infinite ease-in-out; }
.voice-panel .wave i:nth-child(2) { animation-delay: .1s } .voice-panel .wave i:nth-child(3) { animation-delay: .2s } .voice-panel .wave i:nth-child(4) { animation-delay: .3s } .voice-panel .wave i:nth-child(5) { animation-delay: .4s }
@keyframes wave { 0%, 100% { height: 4px } 50% { height: 20px } }

/* ── 15. Impresión ─────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .actions, .form-actions, .toasts, .fab, .no-print { display: none !important; }
  .app { display: block; } body { background: #fff; color: #000; } .card { box-shadow: none; border-color: #ccc; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.g-chat { grid-template-columns: minmax(0, 1fr) 260px; }
@media (max-width: 900px) { .g-chat { grid-template-columns: minmax(0, 1fr); } .g-chat > aside { order: 2; } }
