/* =====================================================================
   DASHBOARD · Control de OC y Cartera — hoja de estilos
   Tema oscuro (por defecto) inspirado en la referencia azul marino;
   tema claro opcional. Todos los colores son tokens en :root.
   ===================================================================== */
:root{
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --r-xl: 16px; --r-lg: 14px; --r-md: 10px; --r-sm: 8px; --r-xs: 6px; --r-pill: 999px;
  --sidebar-w: 248px; --panel-w: 340px;
  --accent: #2f6fe8;
  --accent-2: #6c5cf2;
  --accent-soft: rgba(47,111,232,.16);
  --accent-ink: #ffffff;
  --grad: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 100%);
  --grad-soft: linear-gradient(120deg, rgba(47,111,232,.9) 0%, rgba(108,92,242,.9) 100%);
  --ease: cubic-bezier(.16,1,.3,1);
  --t-fast: 140ms; --t-med: 240ms; --t-slow: 420ms;

  /* ---------- tema oscuro (default) ---------- */
  color-scheme: dark;
  --bg-app: #0f1430;
  --sidebar: #121832;
  --sidebar-line: rgba(255,255,255,.06);
  --nav-fg: #8f9bbf;
  --nav-fg-hover: #ffffff;
  --nav-bg-hover: rgba(255,255,255,.04);
  --nav-bg-active: #1b2447;
  --nav-fg-active: #46db89;
  --main-bg: radial-gradient(1100px 520px at 28% -8%, rgba(88,112,178,.42) 0%, rgba(88,112,178,0) 62%),
             linear-gradient(180deg, #2e3d64 0%, #28365b 42%, #222e51 100%);
  --card: #202b4b;
  --card-2: #26335a;
  --card-3: #2f3e65;
  --card-line: rgba(255,255,255,.06);
  --card-line-2: rgba(255,255,255,.11);
  --panel: #1c2743;
  --panel-card: #18223c;
  --panel-head: #151e37;
  --panel-line: rgba(255,255,255,.07);
  --input: #1a2442;
  --input-line: rgba(255,255,255,.12);
  --text: #ffffff;
  --text-2: #b3bdd8;
  --text-3: #8d99bf;
  --text-label: #dfe5f5;
  --link: #6f9cf5;
  --grid: rgba(255,255,255,.07);
  --axis: rgba(255,255,255,.16);
  --good: #45d98a;   --good-bg: rgba(69,217,138,.14);
  --warning: #ffc14d; --warning-bg: rgba(255,193,77,.15);
  --serious: #ff9459; --serious-bg: rgba(255,148,89,.15);
  --critical: #ff6b6b; --critical-bg: rgba(255,107,107,.15);
  --info: #5b9bff;   --info-bg: rgba(91,155,255,.15);
  --muted: #8d99bf;  --muted-bg: rgba(141,153,191,.15);
  --series-1: #4a8cf0; --series-2: #e0662f; --series-3: #1fa37a;
  --series-muted: #56648f;
  --shadow-sm: 0 2px 8px -2px rgba(4,8,24,.45);
  --shadow: 0 14px 34px -14px rgba(4,8,24,.65);
  --shadow-lg: 0 30px 70px -20px rgba(3,6,20,.8);
  --overlay: rgba(6,10,26,.62);
  --scroll-thumb: rgba(255,255,255,.14);
  --focus-ring: 0 0 0 3px rgba(91,155,255,.5);
  --tooltip-bg: #0f1731;
  --skeleton: rgba(255,255,255,.05);
}
:root[data-theme="light"]{
  color-scheme: light;
  --bg-app: #e9edf6;
  --sidebar: #121832;
  --main-bg: radial-gradient(1100px 520px at 28% -8%, rgba(47,111,232,.08) 0%, rgba(47,111,232,0) 62%),
             linear-gradient(180deg, #f2f5fb 0%, #eef1f8 50%, #eaeef7 100%);
  --card: #ffffff;
  --card-2: #f5f7fc;
  --card-3: #e8edf7;
  --card-line: rgba(16,24,40,.08);
  --card-line-2: rgba(16,24,40,.14);
  --panel: #ffffff;
  --panel-card: #f6f8fd;
  --panel-head: #eef2fa;
  --panel-line: rgba(16,24,40,.08);
  --input: #ffffff;
  --input-line: rgba(16,24,40,.16);
  --text: #141b34;
  --text-2: #4b5675;
  --text-3: #6b7593;
  --text-label: #29324f;
  --link: #2563eb;
  --grid: rgba(16,24,40,.07);
  --axis: rgba(16,24,40,.18);
  --good: #0c8a4c;   --good-bg: rgba(12,138,76,.1);
  --warning: #b7791f; --warning-bg: rgba(250,178,25,.16);
  --serious: #c2571b; --serious-bg: rgba(236,131,90,.14);
  --critical: #d63b3b; --critical-bg: rgba(214,59,59,.1);
  --info: #2563eb;   --info-bg: rgba(37,99,235,.1);
  --muted: #6b7593;  --muted-bg: rgba(107,117,147,.12);
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --series-muted: #b6bfd6;
  --shadow-sm: 0 1px 3px rgba(16,24,40,.08);
  --shadow: 0 10px 28px -14px rgba(16,24,40,.22);
  --shadow-lg: 0 30px 70px -24px rgba(16,24,40,.35);
  --overlay: rgba(16,24,40,.42);
  --scroll-thumb: rgba(16,24,40,.18);
  --tooltip-bg: #141b34;
  --skeleton: rgba(16,24,40,.05);
}

/* ---------------- base ---------------- */
*,*::before,*::after{ box-sizing:border-box; }
html,body{ margin:0; padding:0; height:100%; }
html{ -webkit-text-size-adjust:100%; }
body{
  font-family: var(--font); font-size:14px; line-height:1.5; color: var(--text);
  background: var(--bg-app); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
button, input, select, textarea{ font: inherit; color: inherit; }
button{ cursor:pointer; }
button:disabled{ cursor:not-allowed; opacity:.55; }
a{ color: var(--link); }
img{ max-width:100%; }
svg{ flex:none; }
[hidden]{ display:none !important; }
:focus{ outline:none; }
:focus-visible{ box-shadow: var(--focus-ring); border-radius: 6px; }
input:focus-visible, select:focus-visible, textarea:focus-visible{ box-shadow: var(--focus-ring); }
::selection{ background: rgba(91,155,255,.35); }
.tnum{ font-variant-numeric: tabular-nums; }
.sr-only{ position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.muted{ color: var(--text-3); }
.nowrap{ white-space:nowrap; }
.grow{ flex:1; min-width:0; }
.row{ display:flex; align-items:center; gap:10px; }
.row.wrap{ flex-wrap:wrap; }
.stack{ display:flex; flex-direction:column; gap:12px; }
.spacer{ flex:1; }
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
*::-webkit-scrollbar{ width:8px; height:8px; }
*::-webkit-scrollbar-thumb{ background: var(--scroll-thumb); border-radius:8px; }
*::-webkit-scrollbar-track{ background: transparent; }

/* ---------------- app shell ---------------- */
.app{ display:flex; height:100vh; height:100dvh; width:100%; overflow:hidden; background: var(--bg-app); }
.sidebar{
  width: var(--sidebar-w); flex:none; background: var(--sidebar); color: var(--nav-fg);
  display:flex; flex-direction:column; padding: 26px 14px 16px; gap: 6px; overflow-y:auto; z-index: 40;
  border-right: 1px solid var(--sidebar-line);
}
.brand{ display:flex; align-items:center; gap:10px; padding: 0 10px 22px; min-height:36px; }
.brand-logo{ width:30px; height:30px; border-radius:8px; object-fit:cover; background:#fff; flex:none; }
.brand-name{ font-size:18px; font-weight:700; letter-spacing:.06em; color:#fff; text-transform:uppercase; line-height:1.1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.brand-name .first{ color: var(--accent-brand, #3d86ff); }
.brand-sub{ font-size:10.5px; color: var(--nav-fg); letter-spacing:.04em; margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.nav-label{ font-size:12px; color:#6f7ba3; padding: 14px 12px 8px; letter-spacing:.02em; }
.nav{ display:flex; flex-direction:column; gap:3px; }
.nav-btn{
  display:flex; align-items:center; gap:11px; width:100%; text-align:left; background:transparent; border:0;
  color: var(--nav-fg); font-size:13.5px; font-weight:500; padding: 10px 12px; border-radius: var(--r-sm);
  transition: background var(--t-fast) ease, color var(--t-fast) ease; position:relative; min-height:40px;
}
.nav-btn svg{ width:18px; height:18px; opacity:.9; }
.nav-btn:hover{ background: var(--nav-bg-hover); color: var(--nav-fg-hover); }
.nav-btn.active{ background: var(--nav-bg-active); color: var(--nav-fg-active); }
.nav-btn.active svg{ opacity:1; }
.nav-btn .badge{ margin-left:auto; flex:none; }
.nav-btn > span:not(.badge){ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.badge{
  display:inline-flex; align-items:center; justify-content:center; min-width:22px; height:20px; padding:0 6px;
  border-radius:6px; font-size:11px; font-weight:600; background:#2c3760; color:#c9d2ec; line-height:1;
}
.badge.good{ background: rgba(69,217,138,.18); color:#5ee49b; }
.badge.critical{ background: rgba(255,107,107,.2); color:#ff8a8a; }
.badge.warning{ background: rgba(255,193,77,.18); color:#ffcf73; }
.sidebar-foot{ margin-top:auto; padding-top:14px; border-top: 1px solid var(--sidebar-line); display:flex; flex-direction:column; gap:8px; }
.ws-switch{
  display:flex; align-items:center; gap:10px; width:100%; background: rgba(255,255,255,.03); border:1px solid rgba(255,255,255,.06);
  border-radius: var(--r-md); padding: 9px 10px; color:#dfe5f5; text-align:left; overflow:hidden; min-width:0;
}
.ws-switch:hover{ background: rgba(255,255,255,.06); }
.ws-switch > svg{ width:16px; height:16px; opacity:.7; }
.ws-avatar{ width:28px; height:28px; border-radius:8px; display:grid; place-items:center; font-size:12px; font-weight:700; color:#fff; background: var(--grad); flex:none; overflow:hidden; }
.ws-avatar img{ width:100%; height:100%; object-fit:cover; background:#fff; }
.ws-meta{ min-width:0; flex:1; display:block; }
.ws-name{ display:block; font-size:12.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ws-sub{ display:block; font-size:10.5px; color:#8f9bbf; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.form-grid.two{ grid-template-columns: 1fr 1fr; }
@media (max-width: 520px){ .form-grid.two{ grid-template-columns: 1fr; } }
.version{ font-size:10.5px; color:#58658f; padding: 0 4px; }

.main{
  flex:1; min-width:0; display:flex; flex-direction:column; background: var(--main-bg); position:relative;
  overflow-y:auto; overflow-x:hidden; scroll-behavior:smooth;
}
.main-inner{ width:100%; max-width: 1240px; margin: 0 auto; padding: 26px 30px 60px; container-type: inline-size; container-name: main; }
.main-head{ display:flex; align-items:flex-start; gap:14px; margin-bottom: 18px; }
.page-title{ margin:0; font-size:19px; font-weight:400; letter-spacing:.14em; text-transform:uppercase; color: var(--text); line-height:1.25; }
.page-title b{ font-weight:600; }
.page-sub{ margin:4px 0 0; font-size:12.5px; color: var(--text-3); }
.head-tools{ margin-left:auto; display:flex; align-items:center; gap:8px; }
.icon-btn{
  width:38px; height:38px; border-radius: 50%; display:inline-grid; place-items:center; flex:none;
  background: transparent; border:1px solid var(--card-line-2); color: var(--text-2); position:relative;
  transition: background var(--t-fast) ease, color var(--t-fast) ease, border-color var(--t-fast) ease;
}
.icon-btn:hover{ background: rgba(255,255,255,.06); color: var(--text); }
:root[data-theme="light"] .icon-btn:hover{ background: rgba(16,24,40,.05); }
.icon-btn.sq{ border-radius: var(--r-sm); width:34px; height:34px; }
.icon-btn.ghost{ border-color: transparent; }
.icon-btn .dot{
  position:absolute; top:-3px; right:-3px; min-width:18px; height:18px; border-radius:9px; padding:0 5px;
  background: var(--critical); color:#fff; font-size:10.5px; font-weight:700; display:grid; place-items:center; border:2px solid var(--panel);
}
.hamburger{ display:none; }
.mobile-only{ display:none !important; }

/* pills (acciones principales, como la referencia) */
.pills{ display:flex; flex-wrap:wrap; gap:10px; margin-bottom: 18px; align-items:center; }
.pill{
  height:38px; padding: 0 18px; border-radius: var(--r-pill); border:0; font-size:13px; font-weight:500;
  display:inline-flex; align-items:center; gap:8px; white-space:nowrap;
  background: var(--card-3); color: var(--text-2); transition: transform var(--t-fast) var(--ease), filter var(--t-fast) ease, background var(--t-fast) ease;
}
.pill svg{ width:16px; height:16px; }
.pill:hover{ color: var(--text); filter: brightness(1.12); }
.pill:active{ transform: scale(.97); }
.pill.primary{ background: var(--grad); color: var(--accent-ink); box-shadow: 0 10px 22px -8px rgba(47,111,232,.65); }
.pill.primary:hover{ filter: brightness(1.08); }
.pill.danger{ background: var(--critical-bg); color: var(--critical); }
.pill.sm{ height:32px; padding:0 14px; font-size:12.5px; }
.pill.xs{ height:28px; padding:0 11px; font-size:12px; gap:6px; }
.pill.ghost{ background: transparent; border:1px solid var(--card-line-2); }
.pill.good{ background: var(--good-bg); color: var(--good); }

/* barra de filtros */
.filterbar{
  display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-bottom: 20px;
  padding: 10px 12px; border-radius: var(--r-md); background: rgba(255,255,255,.025); border:1px solid var(--card-line);
}
:root[data-theme="light"] .filterbar{ background: rgba(255,255,255,.7); }
.filterbar label{ font-size:12px; color: var(--text-3); }
.fsel{
  height:34px; border-radius: var(--r-pill); border:1px solid var(--input-line); background: var(--input); color: var(--text);
  padding: 0 30px 0 14px; font-size:12.5px; appearance:none; -webkit-appearance:none; min-width:130px; max-width: 240px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px, 5px 5px; background-repeat:no-repeat;
}
.fsel.on{ border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent) inset; }
.chip{
  display:inline-flex; align-items:center; gap:6px; height:28px; padding: 0 6px 0 12px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--text); font-size:12px; font-weight:500;
}
.chip button{ width:20px; height:20px; border-radius:50%; border:0; background: rgba(255,255,255,.12); color: inherit; display:grid; place-items:center; padding:0; }
.chip button svg{ width:12px; height:12px; }

/* banner demo / avisos */
.banner{
  display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 18px;
  background: linear-gradient(120deg, rgba(47,111,232,.22), rgba(108,92,242,.18)); border:1px solid rgba(111,156,245,.3); font-size:13px;
}
.banner svg{ width:20px; height:20px; color: var(--link); }
.banner.warn{ background: var(--warning-bg); border-color: rgba(255,193,77,.3); }
.banner.warn svg{ color: var(--warning); }
.banner.ok{ background: var(--good-bg); border-color: rgba(69,217,138,.3); }
.banner.ok svg{ color: var(--good); }
.modal .banner{ margin-bottom: 0; }
.banner b{ font-weight:600; }

/* ---------------- cards ---------------- */
.grid{ display:grid; gap:18px; }
.g-kpi{ grid-template-columns: repeat(4, minmax(0,1fr)); gap:16px; margin-bottom:18px; }
.g-2{ grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-3{ grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-12{ grid-template-columns: 1.25fr 1fr; }
.g-21{ grid-template-columns: 1fr 1.25fr; }
.grid > *{ min-width:0; }
.mt{ margin-top:18px; }
.card{
  background: var(--card); border:1px solid var(--card-line); border-radius: var(--r-lg); padding: 18px 20px 20px;
  box-shadow: var(--shadow-sm); position:relative; min-width:0;
}
.card.flat{ background: rgba(255,255,255,.02); box-shadow:none; }
:root[data-theme="light"] .card.flat{ background:#fff; }
.card-head{ display:flex; align-items:center; gap:10px; margin-bottom: 14px; min-height:28px; }
.card-title{ font-size:12.5px; letter-spacing:.12em; text-transform:uppercase; color: var(--text-2); font-weight:400; margin:0; }
.card-title b{ font-weight:600; color: var(--text); }
.card-note{ font-size:12px; color: var(--text-3); margin: -8px 0 14px; }
.card-tools{ margin-left:auto; display:flex; gap:6px; align-items:center; }
.seg{ display:inline-flex; background: var(--card-2); border-radius: var(--r-pill); padding:3px; gap:2px; }
.seg button{ border:0; background:transparent; color: var(--text-3); font-size:11.5px; padding: 4px 10px; border-radius: var(--r-pill); }
.seg button.on{ background: var(--card-3); color: var(--text); }
.kebab{ width:28px; height:28px; border-radius:8px; border:0; background:transparent; color: var(--text-3); display:grid; place-items:center; }
.kebab:hover{ background: rgba(255,255,255,.06); color: var(--text); }

/* KPI tiles (como "10 · 03 · 06" de la referencia) */
.kpi{
  background: var(--card); border:1px solid var(--card-line); border-radius: var(--r-md); padding: 18px 18px 14px;
  min-height: 128px; display:flex; flex-direction:column; position:relative; overflow:hidden; box-shadow: var(--shadow-sm);
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) ease;
}
.kpi:hover{ transform: translateY(-3px); box-shadow: var(--shadow); }
.kpi.alt{ background: var(--card-3); }
:root[data-theme="light"] .kpi.alt{ background: #fff; }
.kpi.hero{ background: var(--grad); border-color: transparent; box-shadow: 0 18px 38px -16px rgba(47,111,232,.75); }
.kpi.hero::after{
  content:''; position:absolute; inset:0; pointer-events:none;
  background: radial-gradient(420px 160px at 90% 110%, rgba(255,255,255,.18), transparent 60%),
              repeating-radial-gradient(circle at 20% 20%, rgba(255,255,255,.03) 0 2px, transparent 2px 7px);
}
.kpi-value{ font-size: clamp(26px, 2.5vw, 36px); font-weight:300; line-height:1.05; letter-spacing:-.01em; margin-top:2px; white-space:nowrap; position:relative; z-index:1; }
.kpi.hero .kpi-value{ font-size: clamp(30px, 3vw, 44px); color:#fff; }
.kpi-value.critical{ color: var(--critical); }
.kpi-value.good{ color: var(--good); }
.kpi-label{ font-size:12.5px; color: var(--text-2); margin-top:auto; padding-top:10px; display:flex; align-items:center; gap:8px; }
.kpi.hero .kpi-label{ color: rgba(255,255,255,.92); }
.kpi-sub{ font-size:11.5px; color: var(--text-3); margin-top:2px; }
.kpi.hero .kpi-sub{ color: rgba(255,255,255,.8); }
.kpi-ico{ position:absolute; right:14px; bottom:14px; width:22px; height:22px; color: var(--text-2); opacity:.9; }
.kpi.hero .kpi-ico{ color:#fff; }
.kpi-ico.critical{ color: var(--critical); }
.kpi-spark{ position:absolute; left:0; right:0; bottom:0; width:100%; height:48px; opacity:.32; pointer-events:none; }
.kpi-label, .kpi-sub{ position:relative; z-index:1; padding-right:30px; }
.delta{ display:inline-flex; align-items:center; gap:3px; font-size:11.5px; font-weight:500; }
.delta.up{ color: var(--good); } .delta.down{ color: var(--critical); }
.kpi.hero .delta{ color:#fff; }
.mini-stats{ display:flex; flex-wrap:wrap; gap:8px 22px; font-size:12.5px; color: var(--text-3); margin: -4px 0 18px; }
.mini-stats b{ color: var(--text); font-weight:600; }

/* ---------------- charts ---------------- */
.chart{ position:relative; width:100%; }
.chart svg{ display:block; overflow:visible; }
.chart text{ font-family: var(--font); }
.ax-label{ fill: var(--text-3); font-size:11px; }
.ax-label.strong{ fill: var(--text-2); }
.grid-line{ stroke: var(--grid); stroke-width:1; shape-rendering: crispEdges; }
.axis-line{ stroke: var(--axis); stroke-width:1; shape-rendering: crispEdges; }
.val-label{ fill: var(--text-2); font-size:11.5px; font-weight:500; }
.val-label.strong{ fill: var(--text); font-weight:600; }
.legend{ display:flex; flex-wrap:wrap; gap:8px 18px; font-size:12px; color: var(--text-2); margin-bottom: 10px; }
.legend-item{ display:inline-flex; align-items:center; gap:7px; }
.lk-line{ width:16px; height:3px; border-radius:2px; display:inline-block; }
.lk-rect{ width:10px; height:10px; border-radius:3px; display:inline-block; }
.lk-ring{ width:12px; height:12px; border-radius:50%; border:2.5px solid currentColor; display:inline-block; }
.crosshair{ stroke: var(--axis); stroke-width:1; }
.hit{ fill: transparent; cursor: crosshair; }
.bar-hit{ fill: transparent; cursor: pointer; }
.mark{ transition: opacity var(--t-fast) ease, filter var(--t-fast) ease; }
.mark.hover{ filter: brightness(1.18); }
.chart-empty{ display:grid; place-items:center; text-align:center; color: var(--text-3); font-size:12.5px; min-height: 160px; padding: 20px; gap:8px; }
.chart-empty svg{ width:34px; height:34px; opacity:.6; }
.tooltip{
  position:fixed; z-index: 9999; pointer-events:none; min-width: 120px; max-width: 260px;
  background: var(--tooltip-bg); color:#fff; border-radius: var(--r-sm); padding: 9px 12px; font-size:12px;
  box-shadow: 0 16px 34px -10px rgba(0,0,0,.6); border:1px solid rgba(255,255,255,.08);
  opacity:0; transform: translate(-50%, calc(-100% - 12px)) scale(.96); transition: opacity 120ms ease, transform 120ms ease;
}
.tooltip.show{ opacity:1; transform: translate(-50%, calc(-100% - 14px)) scale(1); }
.tooltip .tt-title{ font-size:11px; color: rgba(255,255,255,.7); margin-bottom:5px; }
.tooltip .tt-row{ display:flex; align-items:center; gap:8px; }
.tooltip .tt-row + .tt-row{ margin-top:4px; }
.tooltip .tt-key{ width:12px; height:3px; border-radius:2px; flex:none; }
.tooltip .tt-val{ font-weight:600; font-size:13px; white-space:nowrap; }
.tooltip .tt-lab{ color: rgba(255,255,255,.72); font-size:11.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ring-wrap{ display:flex; justify-content:space-around; gap:14px; flex-wrap:wrap; }
.ring-box{ display:flex; flex-direction:column; align-items:center; gap:12px; min-width:150px; }
.ring-legend{ display:flex; gap:14px; font-size:12px; color: var(--text-2); flex-wrap:wrap; justify-content:center; }
.ring-legend span{ display:inline-flex; align-items:center; gap:6px; white-space:nowrap; }
.ring-center-l{ fill: var(--text-2); font-size:11px; }
.ring-center-v{ fill: var(--text); font-size:26px; font-weight:400; }
.gauge-box{ display:flex; flex-direction:column; align-items:center; gap:10px; }
.donut-box{ display:flex; align-items:center; gap:22px; flex-wrap:wrap; }
.donut-legend{ flex:1; min-width: 230px; display:flex; flex-direction:column; gap:4px; }
.dl-row > span:nth-child(2){ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.dl-row{
  display:grid; grid-template-columns: auto 1fr auto auto; align-items:center; gap:10px; padding: 6px 8px; border-radius: 8px;
  font-size:12.5px; border:0; background:transparent; color: var(--text); text-align:left; width:100%;
}
.dl-row:hover, .dl-row.on{ background: rgba(255,255,255,.05); }
:root[data-theme="light"] .dl-row:hover, :root[data-theme="light"] .dl-row.on{ background: rgba(16,24,40,.04); }
.dl-row .n{ color: var(--text-2); font-variant-numeric: tabular-nums; }
.dl-row .m{ color: var(--text-3); font-variant-numeric: tabular-nums; font-size:12px; min-width: 70px; text-align:right; }
.st-ico{ width:16px; height:16px; }

/* ---------------- tablas ---------------- */
.table-tools{ display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-bottom: 12px; }
.search{
  position:relative; flex:1; min-width: 200px; max-width: 380px;
}
.search input{
  width:100%; height:36px; border-radius: var(--r-pill); border:1px solid var(--input-line); background: var(--input);
  padding: 0 14px 0 36px; font-size:13px; color: var(--text);
}
.search svg{ position:absolute; left:12px; top:10px; width:16px; height:16px; color: var(--text-3); }
.count{ font-size:12px; color: var(--text-3); margin-left:auto; }
.table-wrap{ overflow-x:auto; border:1px solid var(--card-line); border-radius: var(--r-md); }
table.t{ width:100%; border-collapse:collapse; font-size:12.5px; min-width: 640px; }
.ell{ display:block; max-width:180px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ell.w-con{ max-width:230px; }
.sub-line{ display:block; font-size:11.5px; color: var(--text-3); white-space:nowrap; }
table.t th{
  position:sticky; top:0; z-index:1; background: var(--card-2); color: var(--text-3); font-size:11.5px; font-weight:500;
  text-transform:uppercase; letter-spacing:.05em; text-align:left; padding: 10px 12px; white-space:nowrap; border-bottom:1px solid var(--card-line);
}
table.t th.sortable{ cursor:pointer; user-select:none; }
table.t th.sortable:hover{ color: var(--text); }
table.t th .sort{ display:inline-block; width:10px; opacity:.8; }
table.t td{ padding: 9px 10px; border-bottom: 1px solid var(--card-line); vertical-align: middle; white-space:nowrap; }
table.t td.wrap{ white-space:normal; }
table.t tr:last-child td{ border-bottom: 0; }
table.t tbody tr{ transition: background var(--t-fast) ease; }
table.t tbody tr.clickable{ cursor:pointer; }
table.t tbody tr:hover{ background: rgba(255,255,255,.028); }
:root[data-theme="light"] table.t tbody tr:hover{ background: rgba(16,24,40,.025); }
table.t tbody tr.sel{ background: var(--accent-soft); }
table.t td.num, table.t th.num{ text-align:right; font-variant-numeric: tabular-nums; white-space:nowrap; }
table.t td.c, table.t th.c{ text-align:center; }
table.t td.strong{ font-weight:500; }
table.t .clip{ display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; color: var(--text-2); max-width: 280px; }
table.t tfoot td{ font-weight:600; background: var(--card-2); border-top:1px solid var(--card-line-2); }
table.t .actions{ white-space:nowrap; text-align:right; }
.mono{ font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size:12.5px; }
.pager{ display:flex; align-items:center; gap:8px; justify-content:flex-end; margin-top: 12px; font-size:12px; color: var(--text-3); flex-wrap:wrap; }
.pager button{ height:30px; min-width:30px; border-radius:8px; border:1px solid var(--card-line-2); background:transparent; color: var(--text-2); padding: 0 10px; }
.pager button.on{ background: var(--accent); border-color: var(--accent); color:#fff; }
.empty{
  text-align:center; padding: 38px 20px; color: var(--text-3); font-size:13px; display:flex; flex-direction:column; align-items:center; gap:10px;
}
.empty svg{ width:40px; height:40px; opacity:.55; }
.empty b{ color: var(--text); font-weight:600; font-size:14px; }

/* estado (pills de estado con ícono: nunca solo color) */
.st{
  display:inline-flex; align-items:center; gap:6px; padding: 3px 10px 3px 8px; border-radius: var(--r-pill);
  font-size:11.5px; font-weight:500; white-space:nowrap; line-height:1.5;
}
.st svg{ width:13px; height:13px; }
.st.good{ background: var(--good-bg); color: var(--good); }
.st.warning{ background: var(--warning-bg); color: var(--warning); }
.st.serious{ background: var(--serious-bg); color: var(--serious); }
.st.critical{ background: var(--critical-bg); color: var(--critical); }
.st.info{ background: var(--info-bg); color: var(--info); }
.st.muted{ background: var(--muted-bg); color: var(--muted); }
.yes{ color: var(--good); } .no{ color: var(--text-3); }
.row-btn{
  height:28px; padding: 0 10px; border-radius: 8px; border:1px solid var(--card-line-2); background: transparent; color: var(--text-2);
  font-size:12px; display:inline-flex; align-items:center; gap:6px;
}
.row-btn:hover{ color: var(--text); border-color: var(--accent); }
.row-btn svg{ width:14px; height:14px; }
.row-btn.good:hover{ border-color: var(--good); color: var(--good); }

/* alertas / hallazgos */
.alert-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap:12px; }
.alert{
  text-align:left; border-radius: var(--r-md); border:1px solid var(--card-line); background: var(--card-2); padding: 13px 14px;
  display:flex; flex-direction:column; gap:6px; color: var(--text); transition: transform var(--t-med) var(--ease), border-color var(--t-fast) ease, box-shadow var(--t-med) ease;
}
.alert:hover{ transform: translateY(-2px); border-color: var(--card-line-2); box-shadow: var(--shadow); }
.alert.on{ border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.alert-top{ display:flex; align-items:center; gap:8px; }
.alert-n{ font-size:22px; font-weight:400; }
.alert-t{ font-size:13px; font-weight:500; }
.alert-d{ font-size:11.5px; color: var(--text-3); line-height:1.4; }
.alert .st{ margin-left:auto; }
.notes{ margin:0; padding-left: 18px; color: var(--text-2); font-size:12.5px; line-height:1.7; }

/* ---------------- panel derecho ---------------- */
.rpanel{
  width: var(--panel-w); flex:none; background: var(--panel); display:flex; flex-direction:column; border-left:1px solid var(--panel-line);
  z-index: 30; min-height:0;
}
.rp-top{ display:flex; align-items:center; gap:12px; padding: 22px 18px 16px; }
.avatar{
  width:40px; height:40px; border-radius:50%; flex:none; display:grid; place-items:center; font-weight:600; font-size:14px; color:#fff;
  background: var(--grad); box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px rgba(111,156,245,.45); overflow:hidden;
}
.avatar img{ width:100%; height:100%; object-fit:cover; background:#fff; }
.rp-user{ min-width:0; flex:1; }
.rp-name{ font-size:13.5px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rp-role{ font-size:11.5px; color: var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rp-tabs{ display:flex; gap:4px; margin: 0 16px 12px; background: var(--panel-card); padding:4px; border-radius: var(--r-pill); border:1px solid var(--panel-line); }
.rp-tab{ flex:1; border:0; background:transparent; color: var(--text-3); font-size:12.5px; font-weight:500; height:32px; border-radius: var(--r-pill); display:inline-flex; align-items:center; justify-content:center; gap:7px; }
.rp-tab svg{ width:15px; height:15px; }
.rp-tab.on{ background: var(--grad); color:#fff; box-shadow: 0 8px 18px -8px rgba(47,111,232,.7); }
.rp-body{ flex:1; min-height:0; display:flex; flex-direction:column; margin: 0 16px 16px; border-radius: var(--r-lg); background: var(--panel-card); border:1px solid var(--panel-line); overflow:hidden; }
.rp-scroll{ flex:1; overflow-y:auto; min-height:0; scrollbar-color: #46db89 transparent; }
.rp-scroll::-webkit-scrollbar{ width:4px; }
.rp-scroll::-webkit-scrollbar-thumb{ background:#46db89; border-radius:4px; }

/* detalle (como "DEAL NUMBER D189810") */
.det-head{ background: var(--panel-head); padding: 18px 18px 16px; display:flex; align-items:flex-start; gap:10px; border-bottom:1px solid var(--panel-line); }
.det-kicker{ font-size:10.5px; letter-spacing:.12em; text-transform:uppercase; color: var(--text-3); }
.det-id{ font-size:22px; font-weight:400; margin-top:4px; word-break: break-word; line-height:1.2; }
.det-body{ padding: 6px 18px 18px; }
.det-grid{ display:grid; grid-template-columns: 1fr 1fr; }
.det-f{ padding: 12px 0; border-bottom: 1px solid var(--panel-line); min-width:0; }
.det-f.full{ grid-column: 1 / -1; }
.det-grid .det-f:nth-child(odd):not(.full){ padding-right: 10px; }
.det-k{ font-size:11.5px; font-weight:600; color: var(--text-label); margin-bottom:4px; }
.det-v{ font-size:13.5px; color: var(--link); word-break: break-word; }
.det-v.plain{ color: var(--text-2); }
.det-actions{ display:flex; flex-wrap:wrap; gap:8px; padding: 14px 18px 18px; border-top:1px solid var(--panel-line); }
.det-empty{ padding: 34px 22px; text-align:center; color: var(--text-3); font-size:13px; display:flex; flex-direction:column; align-items:center; gap:10px; }
.det-empty svg{ width:38px; height:38px; opacity:.6; }
.det-mini{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; padding: 14px 18px 4px; }
.det-mini .mbox{ background: var(--card-2); border-radius: var(--r-sm); padding: 10px 12px; }
.det-mini .mbox .k{ font-size:11px; color: var(--text-3); }
.det-mini .mbox .v{ font-size:16px; font-weight:500; }

/* chat del asistente */
.chat{ display:flex; flex-direction:column; min-height:0; flex:1; }
.chat-head{ display:flex; align-items:center; gap:10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--panel-line); }
.ai-orb{
  width:34px; height:34px; border-radius:11px; display:grid; place-items:center; color:#fff; flex:none;
  background: conic-gradient(from 210deg, #2f6fe8, #6c5cf2, #46db89, #2f6fe8); box-shadow: 0 8px 18px -8px rgba(108,92,242,.8);
}
.ai-orb svg{ width:18px; height:18px; }
.chat-title{ font-size:13.5px; font-weight:600; }
.chat-sub{ font-size:11px; color: var(--text-3); display:flex; align-items:center; gap:6px; }
.live-dot{ width:7px; height:7px; border-radius:50%; background: var(--good); display:inline-block; box-shadow: 0 0 0 3px rgba(69,217,138,.18); }
.live-dot.pro{ background: #b39bff; box-shadow: 0 0 0 3px rgba(179,155,255,.2); }
.msgs{ flex:1; overflow-y:auto; padding: 14px 12px 10px; display:flex; flex-direction:column; gap:12px; min-height:0; }
.msg{ max-width: 92%; font-size:13px; line-height:1.55; animation: msgIn var(--t-med) var(--ease) both; }
@keyframes msgIn{ from{ opacity:0; transform: translateY(6px); } to{ opacity:1; transform:none; } }
.msg.bot{ align-self:flex-start; }
.msg.user{ align-self:flex-end; }
.bubble{ padding: 10px 12px; border-radius: 14px; }
.msg.bot .bubble{ background: var(--card); border:1px solid var(--card-line); border-top-left-radius: 5px; color: var(--text); }
:root[data-theme="light"] .msg.bot .bubble{ background:#fff; }
.msg.user .bubble{ background: var(--grad); color:#fff; border-top-right-radius: 5px; }
.bubble p{ margin: 0 0 6px; } .bubble p:last-child{ margin-bottom:0; }
.bubble ul{ margin: 4px 0 6px; padding-left: 18px; } .bubble li{ margin: 2px 0; }
.bubble strong{ font-weight:600; }
.bubble .mt-tab{ width:100%; border-collapse:collapse; font-size:12px; margin: 6px 0; }
.bubble .mt-tab td, .bubble .mt-tab th{ padding: 5px 4px; border-bottom:1px solid var(--card-line); text-align:left; }
.bubble .mt-tab th{ color: var(--text-3); font-weight:500; font-size:11px; }
.bubble .mt-tab td.num{ text-align:right; font-variant-numeric: tabular-nums; white-space:nowrap; }
.bubble .mkpis{ display:grid; grid-template-columns: 1fr 1fr; gap:6px; margin: 6px 0; }
.bubble .mkpi{ background: var(--card-2); border-radius:8px; padding: 7px 9px; }
.bubble .mkpi .k{ font-size:10.5px; color: var(--text-3); }
.bubble .mkpi .v{ font-size:14px; font-weight:500; }
.bubble .mkpi .v.critical{ color: var(--critical); } .bubble .mkpi .v.good{ color: var(--good); }
.msg-actions{ display:flex; flex-wrap:wrap; gap:6px; margin-top: 8px; }
.msg-actions button{
  border:1px solid var(--card-line-2); background: transparent; color: var(--link); border-radius: var(--r-pill);
  font-size:11.5px; padding: 4px 10px; display:inline-flex; align-items:center; gap:5px;
}
.msg-actions button:hover{ border-color: var(--link); }
.msg-actions button svg{ width:13px; height:13px; }
.msg-meta{ font-size:10.5px; color: var(--text-3); margin-top:4px; padding: 0 4px; display:flex; gap:6px; align-items:center; }
.typing{ display:inline-flex; gap:4px; padding: 12px 14px; }
.typing i{ width:6px; height:6px; border-radius:50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2){ animation-delay: .15s; } .typing i:nth-child(3){ animation-delay: .3s; }
@keyframes blink{ 0%,80%,100%{ opacity:.25; transform: translateY(0); } 40%{ opacity:1; transform: translateY(-3px); } }
.sugs{ display:flex; gap:6px; overflow-x:auto; padding: 8px 12px 2px; scrollbar-width:none; }
.sugs::-webkit-scrollbar{ display:none; }
.sug{
  flex:none; border:1px solid var(--card-line-2); background: var(--card); color: var(--text-2); border-radius: var(--r-pill);
  font-size:11.5px; padding: 6px 11px; white-space:nowrap;
}
.sug:hover{ color: var(--text); border-color: var(--accent); }
.composer{ display:flex; align-items:flex-end; gap:8px; padding: 10px 12px 12px; }
.composer textarea{
  flex:1; resize:none; min-height:40px; max-height:120px; border-radius: 12px; border:1px solid var(--input-line);
  background: var(--input); color: var(--text); padding: 10px 12px; font-size:13px; line-height:1.4;
}
.send-btn{ width:40px; height:40px; border-radius: 12px; border:0; background: var(--grad); color:#fff; display:grid; place-items:center; flex:none; box-shadow: 0 8px 18px -8px rgba(47,111,232,.8); }
.send-btn svg{ width:18px; height:18px; }
.mic-btn{ width:40px; height:40px; border-radius:12px; border:1px solid var(--input-line); background: transparent; color: var(--text-2); display:grid; place-items:center; flex:none; }
.mic-btn.rec{ color: var(--critical); border-color: var(--critical); animation: pulse 1.2s infinite; }
@keyframes pulse{ 0%{ box-shadow: 0 0 0 0 rgba(255,107,107,.45);} 100%{ box-shadow: 0 0 0 10px rgba(255,107,107,0);} }
.ai-note{ font-size:10.5px; color: var(--text-3); padding: 0 14px 10px; }

/* ---------------- formularios ---------------- */
.form-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; }
.form-grid .full{ grid-column: 1 / -1; }
.field{ display:flex; flex-direction:column; gap:6px; min-width:0; }
.field > label, .field > .flabel{ font-size:12px; font-weight:500; color: var(--text-2); }
.field .hint{ font-size:11px; color: var(--text-3); }
.field .err{ font-size:11.5px; color: var(--critical); }
.inp, .field input[type=text], .field input[type=number], .field input[type=date], .field input[type=password], .field input[type=email], .field input[type=tel], .field input[type=search], .field select, .field textarea{
  width:100%; min-height:40px; border-radius: var(--r-sm); border:1px solid var(--input-line); background: var(--input); color: var(--text);
  padding: 8px 12px; font-size:13.5px;
}
.field textarea{ min-height:80px; resize:vertical; }
.field input[type=color]{ width:52px; height:40px; border-radius: var(--r-sm); border:1px solid var(--input-line); background: var(--input); padding: 4px; }
.field.invalid input, .field.invalid select{ border-color: var(--critical); }
.fsec{ border-top: 1px dashed var(--card-line-2); padding-top: 16px; margin-top: 16px; }
.fsec:first-child{ border-top:0; padding-top:0; margin-top:0; }
.fsec-t{ font-size:11.5px; letter-spacing:.1em; text-transform:uppercase; color: var(--text-3); margin-bottom: 12px; display:flex; align-items:center; gap:8px; }
.check{ display:inline-flex; align-items:center; gap:10px; font-size:13px; color: var(--text-2); cursor:pointer; }
.check input{ width:18px; height:18px; accent-color: var(--accent); }
.switch{ position:relative; display:inline-flex; align-items:center; gap:10px; cursor:pointer; font-size:13px; color: var(--text-2); }
.switch input{ position:absolute; opacity:0; width:1px; height:1px; }
.switch .sw{ width:40px; height:22px; border-radius: 11px; background: var(--card-3); position:relative; transition: background var(--t-fast) ease; flex:none; }
.switch .sw::after{ content:''; position:absolute; top:3px; left:3px; width:16px; height:16px; border-radius:50%; background:#fff; transition: transform var(--t-med) var(--ease); }
.switch input:checked + .sw{ background: var(--accent); }
.switch input:checked + .sw::after{ transform: translateX(18px); }
.switch input:focus-visible + .sw{ box-shadow: var(--focus-ring); }
.swatches{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.swatch-btn{ width:30px; height:30px; border-radius:50%; border:2px solid transparent; padding:0; box-shadow: 0 0 0 1px var(--card-line-2); }
.swatch-btn.on{ border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.dropzone{
  border: 1.5px dashed var(--card-line-2); border-radius: var(--r-md); padding: 22px; text-align:center; color: var(--text-3);
  display:flex; flex-direction:column; align-items:center; gap:10px; transition: border-color var(--t-fast) ease, background var(--t-fast) ease; cursor:pointer;
}
.dropzone:hover, .dropzone.drag{ border-color: var(--accent); background: var(--accent-soft); color: var(--text-2); }
.dropzone svg{ width:34px; height:34px; color: var(--link); }
.dropzone b{ color: var(--text); font-weight:500; }
.logo-prev{ width:64px; height:64px; border-radius:14px; background: var(--card-2); display:grid; place-items:center; overflow:hidden; border:1px solid var(--card-line); flex:none; }
.logo-prev img{ width:100%; height:100%; object-fit:contain; background:#fff; }

/* tarjetas de opción (cargar datos, configuración) */
.opt-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap:14px; }
.opt{
  text-align:left; background: var(--card); border:1px solid var(--card-line); border-radius: var(--r-lg); padding: 18px; color: var(--text);
  display:flex; flex-direction:column; gap:8px; transition: transform var(--t-med) var(--ease), border-color var(--t-fast) ease, box-shadow var(--t-med) ease;
}
.opt:hover{ transform: translateY(-3px); border-color: var(--card-line-2); box-shadow: var(--shadow); }
.opt-ico{ width:40px; height:40px; border-radius: 12px; display:grid; place-items:center; background: var(--accent-soft); color: var(--link); }
.opt-ico svg{ width:20px; height:20px; }
.opt-ico.g{ background: var(--good-bg); color: var(--good); }
.opt-ico.w{ background: var(--warning-bg); color: var(--warning); }
.opt-ico.c{ background: var(--critical-bg); color: var(--critical); }
.opt-t{ font-size:14px; font-weight:500; }
.opt-d{ font-size:12px; color: var(--text-3); line-height:1.5; }
.tabs{ display:flex; gap:2px; flex-wrap:nowrap; overflow-x:auto; margin-bottom: 18px; border-bottom: 1px solid var(--card-line); scrollbar-width:none; }
.tabs::-webkit-scrollbar{ display:none; }
.tab{ border:0; background:transparent; color: var(--text-3); font-size:13px; font-weight:500; padding: 10px 12px; border-bottom: 2px solid transparent; margin-bottom:-1px; display:inline-flex; gap:7px; align-items:center; white-space:nowrap; flex:none; }
.tab svg{ width:16px; height:16px; }
.tab:hover{ color: var(--text); }
.tab.on{ color: var(--text); border-bottom-color: var(--accent); }
.kv{ display:grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size:13px; }
.kv .k{ color: var(--text-3); }
.code-box{ font-family: ui-monospace, Consolas, monospace; background: var(--card-2); border:1px dashed var(--card-line-2); border-radius: var(--r-sm); padding: 12px 14px; font-size:15px; letter-spacing:.08em; text-align:center; user-select:all; }
.hist{ display:flex; flex-direction:column; gap:8px; }
.hist-item{ background: var(--card-2); border-radius: var(--r-sm); padding: 9px 12px; font-size:12.5px; }
.hist-date{ font-size:10.5px; color: var(--link); text-transform:uppercase; letter-spacing:.04em; margin-bottom:2px; }
.file-row{ display:flex; align-items:center; gap:10px; background: var(--card-2); border-radius: var(--r-sm); padding: 8px 10px; font-size:12.5px; }
.file-row svg{ width:16px; height:16px; color: var(--link); }
.file-row .fn{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.file-row .fm{ color: var(--text-3); font-size:11.5px; white-space:nowrap; }
.pay-row{ display:grid; grid-template-columns: 1fr 1fr 1.2fr auto; gap:8px; align-items:center; background: var(--card-2); border-radius: var(--r-sm); padding: 8px 10px; font-size:12.5px; }
.progress{ height:6px; background: var(--card-3); border-radius:6px; overflow:hidden; }
.progress > i{ display:block; height:100%; background: var(--grad); border-radius:6px; transition: width var(--t-slow) var(--ease); }

/* ---------------- modal / drawer / toast ---------------- */
.overlay{ position:fixed; inset:0; background: var(--overlay); z-index: 900; display:flex; align-items:center; justify-content:center; padding: 20px; animation: fadeIn var(--t-med) ease both; backdrop-filter: blur(3px); }
@keyframes fadeIn{ from{ opacity:0; } to{ opacity:1; } }
.modal{
  width:100%; max-width: 520px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display:flex; flex-direction:column;
  background: var(--panel); border:1px solid var(--panel-line); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); animation: popIn var(--t-med) var(--ease) both;
}
.modal.lg{ max-width: 860px; } .modal.xl{ max-width: 1080px; } .modal.sm{ max-width: 420px; }
@keyframes popIn{ from{ opacity:0; transform: translateY(12px) scale(.98); } to{ opacity:1; transform:none; } }
.modal-head{ display:flex; align-items:center; gap:12px; padding: 18px 20px 14px; border-bottom:1px solid var(--panel-line); }
.modal-title{ font-size:15px; font-weight:500; margin:0; }
.modal-sub{ font-size:12px; color: var(--text-3); margin-top:2px; }
.modal-body{ padding: 18px 20px; overflow-y:auto; min-height:0; flex:1; }
.modal-foot{ display:flex; align-items:center; gap:10px; justify-content:flex-end; padding: 14px 20px 18px; border-top:1px solid var(--panel-line); flex-wrap:wrap; }
.drawer-ov{ position:fixed; inset:0; background: var(--overlay); z-index: 800; animation: fadeIn var(--t-med) ease both; }
.drawer{
  position:fixed; top:0; right:0; bottom:0; width: min(640px, 100vw); background: var(--panel); z-index: 801; display:flex; flex-direction:column;
  box-shadow: var(--shadow-lg); border-left:1px solid var(--panel-line); animation: slideIn var(--t-slow) var(--ease) both;
}
.drawer.sm{ width: min(420px, 100vw); }
@keyframes slideIn{ from{ transform: translateX(40px); opacity:0; } to{ transform:none; opacity:1; } }
.toasts{ position:fixed; left:50%; bottom: 22px; transform: translateX(-50%); z-index: 1000; display:flex; flex-direction:column; gap:8px; align-items:center; pointer-events:none; width: min(520px, calc(100vw - 32px)); }
.toast{
  pointer-events:auto; display:flex; align-items:center; gap:10px; background: var(--tooltip-bg); color:#fff; border-radius: 12px; padding: 11px 14px;
  font-size:13px; box-shadow: 0 18px 40px -12px rgba(0,0,0,.6); border:1px solid rgba(255,255,255,.08); animation: toastIn var(--t-med) var(--ease) both; max-width:100%;
}
.toast svg{ width:18px; height:18px; flex:none; }
.toast.ok svg{ color: #45d98a; } .toast.warn svg{ color:#ffc14d; } .toast.error svg{ color:#ff6b6b; } .toast.info svg{ color:#6f9cf5; }
.toast button{ margin-left:6px; border:0; background: rgba(255,255,255,.12); color:#fff; border-radius: 8px; padding: 5px 10px; font-size:12px; font-weight:500; }
.toast.out{ animation: toastOut 200ms ease forwards; }
@keyframes toastIn{ from{ opacity:0; transform: translateY(10px); } to{ opacity:1; transform:none; } }
@keyframes toastOut{ to{ opacity:0; transform: translateY(6px); } }
.menu{
  position:fixed; z-index: 950; min-width: 210px; background: var(--panel); border:1px solid var(--panel-line); border-radius: 12px; padding: 6px;
  box-shadow: var(--shadow-lg); animation: popIn 160ms var(--ease) both;
}
.menu button{ display:flex; align-items:center; gap:10px; width:100%; border:0; background:transparent; color: var(--text); padding: 9px 10px; border-radius: 8px; font-size:13px; text-align:left; }
.menu button:hover{ background: rgba(255,255,255,.06); }
:root[data-theme="light"] .menu button:hover{ background: rgba(16,24,40,.05); }
.menu button svg{ width:16px; height:16px; color: var(--text-3); }
.menu hr{ border:0; border-top:1px solid var(--panel-line); margin: 5px 4px; }
.menu .danger{ color: var(--critical); } .menu .danger svg{ color: var(--critical); }

/* ---------------- login / asistente de configuración ---------------- */
.auth{ position:fixed; inset:0; background: var(--main-bg), var(--bg-app); display:flex; align-items:center; justify-content:center; padding: 24px; overflow-y:auto; z-index: 500; }
.auth-card{ width:100%; max-width: 440px; background: var(--panel); border:1px solid var(--panel-line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 30px 28px; animation: popIn var(--t-slow) var(--ease) both; }
.auth-card.wide{ max-width: 620px; }
.auth-brand{ display:flex; align-items:center; gap:12px; margin-bottom: 18px; }
.auth-brand .brand-name{ font-size:20px; }
.auth-title{ font-size:20px; font-weight:500; margin: 0 0 6px; }
.auth-sub{ font-size:13px; color: var(--text-3); margin: 0 0 18px; line-height:1.55; }
.steps{ display:flex; gap:6px; margin-bottom: 20px; }
.steps i{ flex:1; height:4px; border-radius:4px; background: var(--card-3); }
.steps i.on{ background: var(--grad); }
.btn-block{ width:100%; justify-content:center; height:44px; font-size:14px; }
.auth-foot{ font-size:11.5px; color: var(--text-3); margin-top: 16px; line-height:1.5; }
.choice-grid{ display:grid; grid-template-columns: 1fr; gap:10px; }
.choice{ display:flex; gap:14px; align-items:flex-start; text-align:left; border:1px solid var(--card-line-2); border-radius: var(--r-md); background: var(--card); padding: 14px; color: var(--text); }
.choice:hover{ border-color: var(--accent); }
.choice.on{ border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--accent-soft); }
.choice .opt-ico{ flex:none; }

/* ---------------- botón flotante del asistente + panel plegable ---------------- */
.ai-fab{
  position:fixed; right:22px; bottom:22px; width:58px; height:58px; border-radius:18px; border:0; color:#fff; z-index:650;
  background: conic-gradient(from 210deg, #2f6fe8, #6c5cf2, #46db89, #2f6fe8); box-shadow: 0 16px 34px -10px rgba(108,92,242,.85);
  display:none; place-items:center; transition: transform var(--t-med) var(--ease);
}
.ai-fab:hover{ transform: translateY(-3px) scale(1.04); }
.ai-fab svg{ width:26px; height:26px; }
.ai-fab .fab-dot{ position:absolute; top:-4px; right:-4px; min-width:20px; height:20px; border-radius:10px; background: var(--critical); color:#fff; font-size:11px; font-weight:700; display:grid; place-items:center; padding:0 5px; border:2px solid var(--bg-app); }
.rp-collapse{ display:none !important; }
@media (min-width: 1360px){
  .rp-collapse{ display:inline-grid !important; }
  .app.panel-collapsed .rpanel{ display:none; }
  .app.panel-collapsed .ai-fab{ display:grid; }
}
@media (max-width: 1359px){ .ai-fab{ display:grid; } }

/* ---------------- ajustes por ancho real del contenido (container queries) ---------------- */
@container main (max-width: 1000px){
  .g-12, .g-21{ grid-template-columns: 1fr; }
}
@container main (max-width: 720px){
  .g-2, .g-3{ grid-template-columns: 1fr; }
  .g-kpi{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
/* tablas: columnas secundarias y textos de botones se ocultan cuando falta espacio */
@container main (max-width: 1000px){
  table.t .col-md{ display:none; }
  table.t .ell{ max-width:150px; }
  .row-btn .lbl{ display:none; }
  .row-btn{ padding: 0 8px; }
}
@container main (max-width: 700px){
  table.t .col-sm{ display:none; }
}

/* ---------------- responsive ---------------- */
@media (max-width: 1359px){
  .rpanel{ position:fixed; top:0; right:0; bottom:0; transform: translateX(105%); transition: transform var(--t-slow) var(--ease); box-shadow: var(--shadow-lg); z-index: 700; width: min(380px, 100vw); }
  .rpanel.open{ transform:none; }
  .panel-toggle{ display:inline-grid !important; }
  .rp-close{ display:inline-grid !important; }
}
@media (min-width: 1360px){
  .panel-toggle{ display:none !important; }
  .rp-close{ display:none !important; }
}
@media (max-width: 1023px){
  .sidebar{ position:fixed; top:0; left:0; bottom:0; transform: translateX(-105%); transition: transform var(--t-slow) var(--ease); box-shadow: var(--shadow-lg); z-index: 720; }
  .scrim{ z-index: 690; }
  .sidebar.open{ transform:none; }
  .hamburger{ display:inline-grid; }
  .mobile-only{ display:inline-grid !important; }
  .main-inner{ padding: 18px 18px 60px; }
  .g-2, .g-3{ grid-template-columns: 1fr; }
}
@media (max-width: 640px){
  body{ font-size:14px; }
  .main-inner{ padding: 14px 16px 70px; }
  .page-title{ font-size:16px; letter-spacing:.1em; }
  .g-kpi{ grid-template-columns: repeat(2, minmax(0,1fr)); gap:10px; }
  .kpi{ min-height: 108px; padding: 14px 14px 12px; }
  .card{ padding: 14px 14px 16px; }
  .pill{ height:40px; }
  .pills{ gap:8px; }
  .filterbar .fsel{ flex:1 1 40%; min-width: 0; max-width:none; }
  .filterbar #f-cliente{ flex-basis: 100%; }
  .banner > .grow{ flex-basis: 100%; }
  .rpanel{ width: 100vw; }
  .modal{ max-height: 100dvh; border-radius: 16px; }
  .overlay{ padding: 10px; }
  .det-grid{ grid-template-columns: 1fr; }
  .pay-row{ grid-template-columns: 1fr 1fr; }
  .donut-box{ justify-content:center; }
}
@media (max-width: 380px){ .g-kpi{ grid-template-columns: 1fr; } }
.scrim{ position:fixed; inset:0; background: var(--overlay); z-index: 39; display:none; }
.scrim.on{ display:block; }

/* ---------------- versión nube: sincronización, esperas y accesos ---------------- */
.sync-chip{ display:flex; align-items:center; gap:7px; font-size:11px; padding: 0 4px; color:#8f9bbf; min-width:0; }
.sync-chip svg{ width:14px; height:14px; flex:none; }
.sync-chip span:last-child{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sync-chip.ok svg{ color:#5ee49b; }
.sync-chip.saving{ color:#aab6d8; }
.sync-chip.offline{ color:#ffcf73; }
.sync-chip.error{ color:#ff8a8a; }
.spin{ width:12px; height:12px; border-radius:50%; border:2px solid currentColor; border-right-color:transparent; display:inline-block; flex:none; animation: spin .8s linear infinite; opacity:.85; }
.spin.lg{ width:22px; height:22px; border-width:3px; }
@keyframes spin{ to{ transform: rotate(360deg); } }
.busy{ position:fixed; inset:0; z-index: 1100; background: var(--overlay); display:flex; align-items:center; justify-content:center; padding:20px; animation: fadeIn var(--t-med) ease both; backdrop-filter: blur(2px); }
.busy-box{ display:flex; align-items:center; gap:12px; background: var(--panel); border:1px solid var(--panel-line); border-radius:14px; padding: 16px 20px; font-size:13.5px; color: var(--text); box-shadow: var(--shadow-lg); }
.busy-box .spin, .splash-row .spin, .empty .spin{ color: var(--accent-brand, var(--accent)); }
.splash{ min-height:100vh; min-height:100dvh; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:22px; padding:24px; background: var(--main-bg), var(--bg-app); }
.splash .auth-brand{ margin:0; }
.splash-row{ display:flex; align-items:center; gap:12px; color: var(--text-3); font-size:13px; }
.auth-err{ color: var(--critical); font-size:12.5px; min-height:18px; line-height:1.45; }
.kv.cred{ background: var(--card-2); border-radius: var(--r-sm); padding: 12px 14px; align-items:center; }
.kv.cred .mono{ font-size:13px; word-break: break-all; user-select: all; }
.kv.cred .strong{ font-weight:600; font-size:14.5px; letter-spacing:.04em; color: var(--text); }
.progress.sm{ height:4px; width:64px; flex:none; }
.use{ display:flex; align-items:center; gap:8px; white-space:nowrap; font-size:12px; color: var(--text-3); }
a.pill{ text-decoration:none; }

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .spin{ animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}

/* ---------------- impresión (Informe PDF) ---------------- */
@media print{
  :root, :root[data-theme="dark"], :root[data-theme="light"]{
    color-scheme: light;
    --card:#ffffff; --card-2:#f3f5fa; --card-3:#e6eaf3; --card-line: rgba(16,24,40,.12); --card-line-2: rgba(16,24,40,.18);
    --panel:#ffffff; --panel-card:#f6f8fd; --input:#ffffff; --input-line: rgba(16,24,40,.18);
    --text:#111827; --text-2:#374151; --text-3:#4b5563; --text-label:#1f2937; --link:#1d4ed8;
    --grid: rgba(16,24,40,.1); --axis: rgba(16,24,40,.25);
    --good:#0c8a4c; --good-bg: rgba(12,138,76,.1); --warning:#b7791f; --warning-bg: rgba(250,178,25,.16);
    --serious:#c2571b; --serious-bg: rgba(236,131,90,.14); --critical:#d63b3b; --critical-bg: rgba(214,59,59,.1);
    --info:#2563eb; --info-bg: rgba(37,99,235,.1); --muted:#6b7593; --muted-bg: rgba(107,117,147,.12);
    --series-1:#2a78d6; --series-2:#eb6834; --series-3:#1baf7a;
  }
  .alert{ background:#fff !important; border-color:#d9deea !important; }
  .ring-center-v, .ring-center-l{ fill:#111827 !important; }
  body{ overflow: visible; background:#fff !important; color:#111 !important; }
  .app{ display:block; height:auto; overflow:visible; background:#fff; }
  .sidebar, .rpanel, .pills, .filterbar .chip, .no-print, .toasts, .card-tools, .pager, .table-tools .search, .banner, .scrim, .hamburger{ display:none !important; }
  .main{ overflow:visible; background:#fff !important; }
  .main-inner{ max-width:none; padding: 0; }
  .card, .kpi{ break-inside: avoid; background:#fff !important; border:1px solid #d9deea !important; box-shadow:none !important; color:#111 !important; }
  .kpi.hero{ background:#fff !important; } .kpi.hero .kpi-value, .kpi.hero .kpi-label, .kpi.hero .kpi-sub, .kpi.hero .kpi-ico{ color:#111 !important; }
  .page-title, .card-title, .card-title b, .kpi-label, .kpi-value{ color:#111 !important; }
  .ax-label, .val-label{ fill:#333 !important; }
  table.t th{ background:#eef1f7 !important; color:#333 !important; }
  table.t td{ color:#111; }
  .print-head{ display:block !important; }
}
.print-head{ display:none; margin-bottom: 16px; }
