/* ───────────── CIRAM · Design tokens ───────────── */
:root {
  /* Default: gris muy claro neutro (resalta los módulos blancos).
     Se puede sobrescribir con [data-bg-tone="..."] para variantes. */
  --bg: oklch(0.965 0.004 260);
  --bg-2: oklch(0.945 0.006 260);
  --bg-elev: oklch(1 0 0);
  --ink: oklch(0.22 0.015 265);
  --ink-2: oklch(0.38 0.012 265);
  --ink-3: oklch(0.55 0.01 265);
  --ink-4: oklch(0.72 0.008 265);
  --line: oklch(0.92 0.005 265);
  --line-2: oklch(0.87 0.006 265);
  --accent: oklch(0.55 0.15 280);
  --accent-soft: oklch(0.94 0.03 280);
  --accent-ink: oklch(0.38 0.16 280);
  --ok: oklch(0.62 0.14 155);
  --warn: oklch(0.72 0.14 75);
  --danger: oklch(0.58 0.18 25);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-1: 0 1px 0 rgba(17,17,20,.04), 0 1px 2px rgba(17,17,20,.04);
  --shadow-2: 0 1px 0 rgba(17,17,20,.04), 0 8px 24px rgba(17,17,20,.06);
  --shadow-pop: 0 8px 30px rgba(17,17,20,.12), 0 2px 8px rgba(17,17,20,.08);
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "SF Pro Text", sans-serif;
  --font-display: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --pad-y: 14px;
  --pad-x: 16px;
  /* Alias usados por los módulos (mapeados a los tokens reales; se resuelven en cada
     elemento, así que siguen automáticamente el tema claro/oscuro). */
  --surface: var(--bg-elev);
  --surface-2: var(--bg-2);
  --text: var(--ink);
  --text-muted: var(--ink-3);
  --text-faint: var(--ink-4);
  --border: var(--line-2);
}
[data-density="compact"] { --pad-y: 8px; --pad-x: 12px; }
[data-density="comfy"]   { --pad-y: 18px; --pad-x: 20px; }

/* ────── Tonos de fondo (modo claro). En modo oscuro, las reglas de [data-theme="dark"]
   cargadas más abajo sobreescriben estas. --bg-elev (módulos) se mantiene blanco. ────── */
:root[data-bg-tone="white"]    { --bg: oklch(0.99 0.003 260);  --bg-2: oklch(0.975 0.004 260); }
:root[data-bg-tone="grey"]     { --bg: oklch(0.965 0.004 260); --bg-2: oklch(0.945 0.006 260); }
:root[data-bg-tone="beige"]    { --bg: oklch(0.965 0.014 82);  --bg-2: oklch(0.945 0.018 82);  }
:root[data-bg-tone="navy"]     { --bg: oklch(0.965 0.012 240); --bg-2: oklch(0.945 0.016 240); }
:root[data-bg-tone="sage"]     { --bg: oklch(0.965 0.012 155); --bg-2: oklch(0.945 0.016 155); }
:root[data-bg-tone="rose"]     { --bg: oklch(0.97 0.012 0);    --bg-2: oklch(0.95 0.016 0);    }
:root[data-bg-tone="lavender"] { --bg: oklch(0.965 0.013 290); --bg-2: oklch(0.945 0.017 290); }

:root[data-theme="dark"] {
  --bg: oklch(0.18 0.012 265);
  --bg-2: oklch(0.34 0.008 265);
  --bg-elev: oklch(0.40 0.008 265);
  --ink: oklch(1 0 0);
  --ink-2: oklch(1 0 0);
  --ink-3: oklch(0.94 0 0);
  --ink-4: oklch(0.88 0 0);
  --line: oklch(0.46 0.008 265);
  --line-2: oklch(0.54 0.008 265);
  --accent: oklch(0.72 0.14 280);
  --accent-soft: oklch(0.3 0.06 280);
  --accent-ink: oklch(0.85 0.1 280);
  --shadow-1: 0 1px 0 rgba(0,0,0,.2);
  --shadow-2: 0 1px 0 rgba(0,0,0,.25), 0 8px 24px rgba(0,0,0,.35);
  --shadow-pop: 0 12px 40px rgba(0,0,0,.5);
}

[data-font="display"] {
  --font-display: "Fraunces", "Inter", ui-serif, Georgia, serif;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ───── App shell ───── */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
[data-density="compact"] .app { grid-template-columns: 224px 1fr; }
.sidebar {
  background:
    linear-gradient(180deg,
      color-mix(in oklch, var(--accent) 8%, transparent) 0%,
      color-mix(in oklch, var(--accent) 4%, transparent) 60%,
      transparent 100%),
    var(--bg-2);
  border-right: 1px solid color-mix(in oklch, var(--accent) 14%, var(--line));
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
[data-theme="dark"] .sidebar {
  background:
    linear-gradient(180deg,
      color-mix(in oklch, var(--accent) 14%, transparent) 0%,
      color-mix(in oklch, var(--accent) 6%, transparent) 60%,
      transparent 100%),
    var(--bg-2);
}
.side-hd { padding: 14px 14px 10px; }
.ws-switch {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; cursor: default;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: border-color .15s, box-shadow .15s;
  position: relative;
}
.ws-switch:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.ws-logo {
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px; color: #fff;
  letter-spacing: .02em;
}
.ws-meta { flex: 1; min-width: 0; }
.ws-name { font-weight: 600; font-size: 13px; color: var(--ink); letter-spacing: -0.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-plan { font-size: 11px; color: var(--ink-3); }
.ws-chev { color: var(--ink-4); }

.ws-pop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-pop);
  z-index: 40; padding: 6px; overflow: hidden;
}
.ws-pop .hd { font-size: 10px; font-weight: 600; letter-spacing: .08em;
  color: var(--ink-4); text-transform: uppercase; padding: 8px 8px 4px; }
.ws-pop-item { display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 8px; cursor: default; }
.ws-pop-item:hover { background: var(--bg-2); }
.ws-pop-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.ws-pop-item .check { margin-left: auto; color: var(--accent); opacity: 0; }
.ws-pop-item[aria-selected="true"] .check { opacity: 1; }
.ws-pop-sep { height: 1px; background: var(--line); margin: 4px 0; }
.ws-pop-add { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 8px; }
.ws-pop-add:hover { background: var(--bg-2); color: var(--ink); }

.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-4); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500; font-size: 13px;
  cursor: default; border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-elev); color: var(--ink); }
.nav-item.active { background: var(--bg-elev); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-1); }
.nav-item.active .ic { color: var(--accent); }
.nav-item .count {
  margin-left: auto; font-size: 11px; color: var(--ink-4);
  background: var(--bg-2); padding: 0 6px; border-radius: 999px;
  border: 1px solid var(--line);
}
.nav-item.active .count { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.nav-item.locked { opacity: .5; cursor: not-allowed; }
.nav-item.locked::after { content: "Admin"; margin-left: auto; font-size: 10px; color: var(--ink-4); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }

.side-ft { border-top: 1px solid var(--line); padding: 10px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em; }
.user-role { font-size: 11px; color: var(--ink-3); }
.user-role .role-dot { display: inline-block; width: 6px; height: 6px; border-radius: 999px; background: var(--ok); margin-right: 5px; vertical-align: middle; }

/* ───── Topbar ───── */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 28px; background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13px; }
.crumbs .sep { color: var(--ink-4); }
.crumbs .cur { color: var(--ink); font-weight: 600; }
.search {
  flex: 1; max-width: 440px; margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink-3);
}
.search input { background: transparent; border: 0; outline: none; flex: 1; font-size: 13px; color: var(--ink); }
.search kbd { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3);
  padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px;
  color: var(--ink-2); cursor: default; position: relative; border: 1px solid transparent;
  background: transparent; }
.icon-btn:hover { background: var(--bg-2); border-color: var(--line); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 6px; height: 6px;
  border-radius: 999px; background: var(--accent); }

/* ───── Page container ───── */
.page { padding: 28px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
[data-density="compact"] .page { padding: 18px; gap: 16px; }
[data-density="comfy"] .page { padding: 36px; gap: 32px; }
.page-hd { display: flex; align-items: flex-end; gap: 18px; }
.page-hd h1 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em;
  font-size: 26px; margin: 0; line-height: 1.1; }
.page-hd .sub { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.page-hd-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── OvStrip: mini-KPIs de visión general junto al título ── */
.ov-slot { margin-left: auto; }
.ov-strip { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ov-chip { --ovc: var(--accent, #1D4ED8); background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 12px 7px; min-width: 84px; text-align: center;
  box-shadow: 0 1px 2px rgba(15,23,42,.05); position: relative; overflow: hidden; }
.ov-chip::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: color-mix(in srgb, var(--ovc) 55%, transparent); }
.ov-chip .l { font-size: 8.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); white-space: nowrap; }
.ov-chip .v { font-size: 15.5px; font-weight: 700; margin-top: 1px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 1100px) { .ov-chip { min-width: 70px; padding: 5px 9px 6px; } .ov-chip .v { font-size: 13.5px; } }

/* ───── Buttons ───── */
.btn { display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--ink); font-size: 13px; font-weight: 500;
  cursor: default; transition: border-color .15s, background .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
[data-theme="dark"] .btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { background: oklch(0.3 0.015 265); }
[data-theme="dark"] .btn.primary:hover { background: oklch(0.88 0.005 265); }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.accent:hover { background: oklch(0.5 0.16 280); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg-2); border-color: var(--line); }
.btn.sm { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--danger); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 500; background: var(--bg-2);
  color: var(--ink-2); border: 1px solid var(--line); }
.pill.ok { background: color-mix(in oklch, var(--ok) 14%, transparent); color: var(--ok); border-color: transparent; }
.pill.warn { background: color-mix(in oklch, var(--warn) 18%, transparent); color: oklch(0.5 0.14 75); border-color: transparent; }
.pill.danger { background: color-mix(in oklch, var(--danger) 14%, transparent); color: var(--danger); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* ───── Cards ───── */
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1); }
.card-hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.card-hd h3 { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card-hd .sub { color: var(--ink-3); font-size: 12px; }
.card-hd-actions { margin-left: auto; display: flex; gap: 6px; }
.card-bd { padding: 18px; }

/* ───── Metrics ───── */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric { padding: 18px 20px; border-radius: var(--radius-lg);
  background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.metric .lbl { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.metric .val { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.metric .delta { font-size: 12px; color: var(--ok); margin-top: 2px; display: inline-flex; align-items: center; gap: 4px; }
.metric .delta.neg { color: var(--danger); }
.metric .spark { height: 44px; margin-top: 10px; }
.metric.locked { opacity: .55; background: repeating-linear-gradient(135deg, var(--bg-elev) 0 10px, var(--bg-2) 10px 20px); }
.metric.locked .val { filter: blur(7px); }
.metric.locked::after { content: "Visible solo para Admin"; font-size: 11px; color: var(--ink-3); display: block; margin-top: 8px; }

/* ───── Table ───── */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table thead th { font-weight: 500; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); text-align: left; padding: 10px 14px;
  background: var(--bg-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--bg-2); }
.table tbody tr.selected { background: var(--accent-soft); }
.table .avatar-cell { display: flex; align-items: center; gap: 10px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--bg-elev); }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg-elev); border-radius: var(--radius-lg) var(--radius-lg) 0 0; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font-size: 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elev); cursor: default; }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .x { opacity: .6; }

/* ───── Kanban ───── */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(260px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.col { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 200px);
  box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.col-hd { padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line);
  background: var(--bg-elev); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.col-hd .dot { width: 9px; height: 9px; border-radius: 999px; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }
.col-hd .ttl { font-weight: 700; font-size: 13px; letter-spacing: -0.01em; }
.col-hd .count { color: var(--ink-3); font-size: 11px; font-weight: 700; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 1px 8px; }
.col-hd .amt { margin-left: auto; font-size: 12.5px; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.col-body.drop-target { background: color-mix(in oklch, var(--accent) 7%, var(--bg-2)); outline: 1px dashed var(--accent); outline-offset: -4px; }
.kcard { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: grab;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 18px -14px rgba(15,23,42,.25); transition: transform .12s ease, box-shadow .12s ease; }
.kcard:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 2px 4px rgba(15,23,42,.06), 0 14px 28px -14px rgba(15,23,42,.35); }
.kcard.dragging { opacity: .4; transform: scale(0.98); }
.kcard .top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .3px; }
.kcard .name { font-weight: 650; font-size: 13.5px; margin-top: 4px; letter-spacing: -0.005em; }
.kcard .amount { font-family: var(--font-display); font-weight: 700; font-size: 17px; margin-top: 6px; letter-spacing: -0.01em;
  color: var(--accent); font-variant-numeric: tabular-nums; }
.kcard .meta { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.kcard .tags { margin-top: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.kcard .tag { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--bg-2); color: var(--ink-3); }

/* ───── Gallery ───── */
.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.photo { aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
  background: var(--bg-2); position: relative; cursor: zoom-in; }
.photo .label { position: absolute; bottom: 6px; left: 6px; font-family: var(--font-mono); font-size: 10.5px;
  color: #fff; background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 4px; backdrop-filter: blur(4px); }
.photo .tag-top { position: absolute; top: 6px; left: 6px; font-size: 10.5px; color: #fff;
  background: rgba(0,0,0,.55); padding: 2px 6px; border-radius: 4px; backdrop-filter: blur(4px); }
.ph-placeholder {
  width: 100%; height: 100%;
  background:
    repeating-linear-gradient(135deg,
      color-mix(in oklch, currentColor 6%, transparent) 0 6px,
      color-mix(in oklch, currentColor 12%, transparent) 6px 12px);
  color: var(--ink-4);
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .02em;
}

/* Before/after comparator */
.ba { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16/10; background: var(--bg-2); user-select: none; }
.ba .layer { position: absolute; inset: 0; }
.ba .after { clip-path: inset(0 0 0 var(--ba,50%)); }
.ba .handle { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; left: var(--ba,50%); transform: translateX(-1px); box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.ba .grip { position: absolute; top: 50%; left: var(--ba,50%); width: 34px; height: 34px; border-radius: 999px; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.25); transform: translate(-50%,-50%); display: grid; place-items: center; color: #111; }
.ba .badge { position: absolute; top: 10px; left: 12px; font-family: var(--font-mono); font-size: 11px; color: #fff; background: rgba(0,0,0,.55); padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(4px); }
.ba .badge.r { left: auto; right: 12px; }

/* ───── Inbox ───── */
.inbox-layout { display: grid; grid-template-columns: 300px 1fr 320px; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-elev); min-height: calc(100vh - 200px); overflow: hidden; }
.inbox-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.inbox-item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: default; display: flex; gap: 10px; }
.inbox-item:hover { background: var(--bg-2); }
.inbox-item.active { background: var(--accent-soft); }
.inbox-item.unread .t { font-weight: 600; color: var(--ink); }
.inbox-item .meta { flex: 1; min-width: 0; }
.inbox-item .t { font-size: 13px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.inbox-item .t time { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.inbox-item .preview { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.inbox-item .badges { display: flex; gap: 4px; margin-top: 6px; }
.inbox-detail { display: flex; flex-direction: column; min-width: 0; }
.inbox-thread { flex: 1; padding: 20px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.5; }
.msg.them { background: var(--bg-2); border-top-left-radius: 4px; align-self: flex-start; }
.msg.me { background: var(--ink); color: var(--bg); border-top-right-radius: 4px; align-self: flex-end; }
.msg.system { align-self: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 11.5px; padding: 6px 12px; border-radius: 999px; }
.msg time { display: block; font-size: 10.5px; color: var(--ink-4); margin-top: 4px; }
.msg.me time { color: rgba(255,255,255,.55); }
.compose { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-end; }
.compose textarea { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; resize: none; background: var(--bg-2); outline: none; font-size: 13px; min-height: 40px; }
.compose textarea:focus { border-color: var(--line-2); background: var(--bg-elev); }
.inbox-ctx { border-left: 1px solid var(--line); padding: 20px; overflow-y: auto; background: var(--bg-2); }

/* ───── Integrations ───── */
.int-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.int-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-elev); display: flex; flex-direction: column; gap: 10px; }
.int-card .hdr { display: flex; align-items: center; gap: 10px; }
.int-card .mark { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; }
.int-card .ttl { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.int-card .sub { font-size: 12px; color: var(--ink-3); }
.int-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }

.webhook-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.webhook-row:last-child { border-bottom: 0; }
.webhook-row .url { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.webhook-row .evt { font-size: 11.5px; color: var(--ink-3); }

.event-log { font-family: var(--font-mono); font-size: 12px; }
.event-row { padding: 10px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 80px 110px 1fr auto; gap: 12px; align-items: center; }
.event-row time { color: var(--ink-4); }
.event-row .evt-name { color: var(--ink); }
.event-row .status-200 { color: var(--ok); }
.event-row .status-err { color: var(--danger); }

/* ───── Forms ───── */
.form-row { display: grid; grid-template-columns: 200px 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); align-items: start; }
.form-row:last-child { border-bottom: 0; }
.form-row .lbl { font-size: 13px; font-weight: 500; }
.form-row .lbl .sub { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-top: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--bg-elev); font-size: 13px; outline: none; }
.input:focus { border-color: var(--ink-3); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* ───── Module matrix (admin) ───── */
.mod-matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.mod-matrix th, .mod-matrix td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: center; }
.mod-matrix th:first-child, .mod-matrix td:first-child { text-align: left; }
.mod-matrix th { font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); background: var(--bg-2); }

/* ───── Toggle switch ───── */
.switch { width: 34px; height: 20px; background: var(--line-2); border-radius: 999px; position: relative; cursor: default; transition: background .15s; display: inline-block; border: 0; padding: 0; }
.switch[data-on="1"] { background: var(--accent); }
.switch i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch[data-on="1"] i { transform: translateX(14px); }

/* ───── Lightbox ───── */
.lightbox { position: fixed; inset: 0; background: rgba(10,10,15,.85); z-index: 100; display: grid; place-items: center; backdrop-filter: blur(20px); }
.lightbox .frame { width: min(1100px, 92vw); height: min(720px, 88vh); background: var(--bg-elev); border-radius: 16px; overflow: hidden; display: grid; grid-template-columns: 1fr 320px; }
.lightbox .lb-img { background: #0b0b10; display: grid; place-items: center; position: relative; }
.lightbox .lb-meta { padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; border-left: 1px solid var(--line); background: var(--bg-elev); }
.lightbox .lb-close { position: absolute; top: 14px; right: 14px; z-index: 2; width: 32px; height: 32px; border-radius: 999px; background: rgba(255,255,255,.15); color: #fff; display: grid; place-items: center; border: 0; backdrop-filter: blur(8px); cursor: default; }

/* ───── Utilities ───── */
.row { display: flex; align-items: center; gap: 10px; }
.col2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.col3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grow { flex: 1; }
.muted { color: var(--ink-3); }
.hr { height: 1px; background: var(--line); margin: 12px 0; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; left: -9999px; }

/* Focus ring */
:where(button,a,input,select,textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; border: 2px solid transparent; }

/* Tiny charts (SVG) */
.sparkline path.line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.sparkline path.area { fill: var(--accent); opacity: .1; }
.funnel-bar { height: 36px; border-radius: 8px; background: linear-gradient(90deg, var(--accent) 0%, color-mix(in oklch, var(--accent) 60%, transparent) 100%); display: flex; align-items: center; padding: 0 12px; color: #fff; font-weight: 500; font-size: 12.5px; }

/* Doc list */
.doc-row { display: grid; grid-template-columns: 32px 1fr auto auto auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-row:hover { background: var(--bg-2); }
.doc-icon { width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; color: #fff; letter-spacing: .02em; }
.doc-icon.pdf { background: oklch(0.55 0.18 25); }
.doc-icon.xls { background: oklch(0.55 0.14 155); }
.doc-icon.img { background: oklch(0.55 0.13 220); }
.doc-icon.doc { background: oklch(0.55 0.13 250); }
.doc-name { font-size: 13px; font-weight: 500; }
.doc-meta { font-size: 11.5px; color: var(--ink-3); }

/* Dropzone */
.drop { border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 20px; text-align: center; color: var(--ink-3); font-size: 13px; background: var(--bg-2); }
.drop.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ─── Modal flotante centrado (CIRAM) ────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  z-index: 1000;
  display: grid; place-items: center;
  padding: 24px;
  background: color-mix(in oklch, oklch(0.1 0.01 260) 45%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: ciram-modal-fade .18s ease-out;
}
@keyframes ciram-modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal {
  width: 100%; max-width: 540px; max-height: 90vh;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow:
    0 32px 80px -16px color-mix(in oklch, oklch(0.05 0.01 260) 65%, transparent),
    0 12px 28px -8px color-mix(in oklch, oklch(0.05 0.01 260) 35%, transparent),
    0 0 0 1px color-mix(in oklch, var(--accent) 8%, transparent);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: ciram-modal-pop .22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes ciram-modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1);   }
}
.modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 22px 14px;
  border-bottom: 1px solid color-mix(in oklch, oklch(0.6 0.14 240) 25%, var(--line));
  background: linear-gradient(180deg,
    oklch(0.96 0.024 240) 0%,
    oklch(0.965 0.018 240) 100%);
}
.modal-hd h3 {
  margin: 0;
  font-family: var(--font-display, "Inter");
  font-size: 17px; font-weight: 700;
  color: oklch(0.32 0.08 240);
  letter-spacing: -0.005em;
}
.modal-bd {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
  /* Fondo gris claro para que los inputs blancos resalten */
  background: oklch(0.965 0.004 260);
}
.modal-ft {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
  background: color-mix(in oklch, var(--bg-2) 50%, var(--bg-elev));
}
.modal textarea.input {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  font-size: 13px;
}
/* Inputs dentro del modal: blanco puro y texto oscuro para máximo contraste */
.modal .input,
.modal input.input,
.modal select.input,
.modal textarea.input {
  background: oklch(1 0 0);
  color: oklch(0.18 0.01 260);
  border-color: oklch(0.85 0.006 265);
  font-weight: 500;
}
.modal .input::placeholder { color: oklch(0.55 0.01 265); font-weight: 400; }
.modal .form-row .lbl,
.modal .field > span:first-child {
  color: oklch(0.32 0.012 265);
}
.modal .form-row {
  display: flex; flex-direction: column; gap: 4px;
}
.modal .form-row .lbl {
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .04em;
}
.modal .form-row .lbl .sub {
  display: block;
  font-size: 10.5px; font-weight: 500;
  color: var(--ink-4);
  text-transform: none; letter-spacing: 0;
  margin-top: 2px;
}

/* ───── KPI tiles PRO (dashboard 2026-07) — tarjetas serias, sombra en capas, sin borde de color ───── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi-tile { position: relative; overflow: hidden; --kpi-c: var(--accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--kpi-c) 6%, transparent), transparent 58%), var(--bg-elev);
  border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 12px 28px -22px rgba(15,23,42,.25);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease; }
.kpi-tile::after { content: ""; position: absolute; left: 16px; bottom: 0; height: 3px; width: 34%;
  border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--kpi-c) 55%, transparent); }
.kpi-tile:hover { transform: translateY(-1px); border-color: var(--line-2);
  box-shadow: 0 2px 4px rgba(15,23,42,.06), 0 18px 38px -20px rgba(15,23,42,.30); }
.kpi-hd { display: flex; align-items: center; gap: 9px; min-height: 28px; }
.kpi-ico { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.kpi-lbl { font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: color-mix(in srgb, var(--kpi-c) 52%, var(--ink-3)); font-weight: 650; line-height: 1.35; }
.kpi-val { font-family: var(--font-display); font-size: 24px; font-weight: 650; color: var(--ink); letter-spacing: -0.02em; margin-top: 9px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.sec-hd { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.sec-hd h3 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.sec-hd .hint { color: var(--ink-3); font-size: 11.5px; margin-top: 1px; }
/* sombra en capas también para las tarjetas de métricas clásicas */
.metric { box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 12px 28px -22px rgba(15,23,42,.22); border-radius: 14px; }

.kpi-sub.pos { color: #059669; font-weight: 600; }
.kpi-sub.neg { color: #DC2626; font-weight: 600; }
.kpi-val.neg { color: #DC2626; }

/* ───── Sidebar plegable (2026-07-02) ───── */
.app.side-collapsed { grid-template-columns: 0 1fr; }
.app.side-collapsed .sidebar { width: 0; min-width: 0; padding: 0; overflow: hidden; border-right: none; }
.app .sidebar, .app { transition: grid-template-columns .22s ease; }
.side-toggle { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-3);
  cursor: pointer; margin-right: 10px; flex: none; transition: background .15s ease, color .15s ease; }
.side-toggle:hover { background: var(--bg-2); color: var(--ink); }

/* ═══════════════════════════════════════════════════════════════
   MÓVIL (≤860px) — SOLO afecta a pantallas pequeñas: el escritorio
   no cambia. Menú hamburguesa off-canvas, una columna, scroll
   vertical, tablas con scroll lateral y controles táctiles.
   ═══════════════════════════════════════════════════════════════ */
.m-overlay { display: none; }

@media (max-width: 860px) {
  /* ── layout: una columna; sidebar = cajón lateral ── */
  .app, [data-density="compact"] .app { grid-template-columns: 1fr !important; }
  .sidebar {
    position: fixed !important; top: 0; bottom: 0; left: 0; z-index: 120;
    width: 280px !important; min-width: 280px !important; max-width: 82vw;
    padding: 14px 12px !important; overflow-y: auto !important;
    transform: translateX(-105%); transition: transform .25s ease;
    border-right: 1px solid var(--line) !important;
  }
  .app:not(.side-collapsed) .sidebar { transform: translateX(0); box-shadow: 24px 0 70px -20px rgba(0,0,0,.4); }
  .app:not(.side-collapsed) .m-overlay { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 110; }

  /* ── topbar compacta ── */
  .search kbd { display: none; }
  .search { min-width: 0; }
  .topbar-actions .icon-btn:nth-child(1), .topbar-actions .icon-btn:nth-child(2) { display: none; } /* tema y automations fuera; campana y ayuda quedan */
  .page { padding: 14px 12px !important; gap: 16px !important; }
  .page-hd { flex-wrap: wrap; gap: 10px; }
  .page-hd h1 { font-size: 21px; }
  .ov-slot { width: 100%; margin-left: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ov-strip { flex-wrap: nowrap; justify-content: flex-start; }

  /* ── cualquier grid inline pasa a una columna (solo móvil) ── */
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* ── tablas: scroll horizontal en vez de aplastarse ── */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  table thead, table tbody, table tr { width: max-content; min-width: 100%; }

  /* ── kanban/pipeline: swipe horizontal con columnas anchas ── */
  .kanban { display: flex !important; overflow-x: auto; scroll-snap-type: x mandatory; }
  .kanban .col { min-width: 84vw; scroll-snap-align: start; }

  /* ── táctil: inputs sin zoom iOS y botones con dedo ── */
  input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 38px; }
  .icon-btn { width: 36px; height: 36px; }

  /* ── modales y fichas a pantalla completa ── */
  .card[style*="96vw"], .card[style*="94vw"] { width: 100vw !important; height: 100vh !important; max-height: 100vh !important; border-radius: 0 !important; }

  /* ── gráficos del dashboard sin desbordar ── */
  canvas { max-width: 100% !important; height: auto !important; }
}

/* ── barra inferior móvil (oculta en escritorio) ── */
.m-tabbar { display: none; }
@media (max-width: 860px) {
  .m-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    background: var(--bg-elev); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px -12px rgba(15,23,42,.18);
  }
  .m-tabbar button {
    flex: 1; border: 0; background: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10px; font-weight: 600; color: var(--ink-3); padding: 4px 0;
    border-radius: 10px;
  }
  .m-tabbar button .e { font-size: 19px; line-height: 1; }
  .m-tabbar button.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
  /* hueco para que la barra no tape el contenido ni el menú lateral */
  .page { padding-bottom: 86px !important; }
  .sidebar { padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important; }
  /* topbar pegada arriba al hacer scroll */
  .topbar { position: sticky; top: 0; z-index: 90; background: var(--bg); }
}

/* móvil: nada puede expandir el viewport horizontal (arregla la tabbar fija) */
@media (max-width: 860px) {
  html, body, #root { max-width: 100vw; overflow-x: clip; }
  .main, .page { max-width: 100vw; overflow-x: clip; }
  .topbar { flex-wrap: wrap; }
}

/* ── Pestañas de módulo en forma de recuadro ────────────────────────────
   Las pestañas eran texto suelto sobre una línea: hasta que no pulsabas una
   no cambiaba nada y parecían un PDF, no algo que se pueda clicar. Ahora van
   dentro de una barra de fondo y la activa se levanta como una ficha blanca.
   Funciona en claro y en oscuro porque todo sale de las variables del tema. */
.mod-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 5px; margin-bottom: 16px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
}
.mod-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: 8px;
  /* Mayúsculas con espaciado: en versalitas las letras se pegan y cuesta leer.
     El color sale de --ink (negro en claro, blanco en oscuro), no de --ink-3,
     para que la pestaña inactiva se lea con el mismo peso que la activa. */
  font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.035em;
  color: var(--ink); cursor: pointer;
  border: 1px solid transparent;
  transition: background .13s ease, color .13s ease, box-shadow .13s ease;
  white-space: nowrap; user-select: none;
}
.mod-tab:hover { background: color-mix(in oklch, var(--bg-elev) 60%, transparent); }
.mod-tab.on {
  background: var(--bg-elev);
  color: var(--accent);
  font-weight: 700;
  border-color: var(--line-2);
  box-shadow: 0 1px 2px rgba(0,0,0,.07), 0 1px 6px rgba(0,0,0,.04);
}
.mod-tab .badge {
  font-size: 11px; font-weight: 700; line-height: 1;
  min-width: 17px; text-align: center;
  padding: 3px 6px; border-radius: 20px;
  background: var(--tab-badge, #EF4444); color: #fff;
}
.mod-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Aviso de versión nueva (lo inyecta build.js en index.html, no un módulo).
   Abajo a la derecha para no tapar la barra de acciones de los módulos. */
#aviso-version {
  position: fixed; right: 18px; bottom: 18px; z-index: 9999;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--ink); color: #fff;
  font-size: 13px; box-shadow: 0 8px 28px rgba(0,0,0,.28);
}
#aviso-version button {
  border: 0; border-radius: 7px; padding: 6px 12px; cursor: pointer;
  background: #fff; color: var(--ink); font-weight: 600; font-size: 13px;
}

/* Controles compactos de las barras de filtros (2026-09-07) */
.input.sm { padding: 5px 9px; font-size: 12.5px; }
select.input { background: var(--bg-elev); color: inherit; }

/* ═══════════ Dashboard · widgets (rediseño 22-09-2026) ═══════════
   Antes eran ocho cajas iguales con marco: todas gritaban lo mismo y no se
   veía qué importaba. Ahora hay UNA cifra grande (la que el tenant marque
   como «hero») y el resto alrededor, sin bordes — se separan por sombra.
   Debajo, a media pantalla, el desglose; la otra mitad queda libre para los
   widgets que se vayan añadiendo. */
.wgrid { display: grid; grid-template-columns: 1.55fr 1fr 1fr 1fr; gap: 12px; align-items: stretch; }
@media (max-width: 1100px) { .wgrid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px)  { .wgrid { grid-template-columns: 1fr; } }

.w-tile { position: relative; overflow: hidden; --c: var(--accent);
  background: var(--bg-elev); border: 0; border-radius: 16px; padding: 15px 17px 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 18px 34px -28px rgba(15,23,42,.45);
  transition: transform .18s ease, box-shadow .18s ease; }
.w-tile:hover { transform: translateY(-2px);
  box-shadow: 0 2px 5px rgba(15,23,42,.07), 0 22px 42px -26px rgba(15,23,42,.5); }
.w-lbl { display: flex; align-items: center; gap: 8px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); line-height: 1.3; }
.w-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 16%, transparent); }
.w-val { font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -.03em;
  margin-top: 10px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.w-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.w-tile.aviso   { background: linear-gradient(160deg, color-mix(in srgb, var(--c) 10%, var(--bg-elev)), var(--bg-elev) 62%); }
.w-tile.aviso .w-val { color: var(--c); }

.w-hero { grid-row: span 2; display: flex; flex-direction: column; position: relative; overflow: hidden;
  background: linear-gradient(155deg, var(--bg-elev) 0%, color-mix(in srgb, var(--c) 6%, var(--bg-elev)) 55%,
              color-mix(in srgb, var(--c) 13%, var(--bg-elev)) 100%);
  border-radius: 18px; padding: 18px 20px 16px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 22px 40px -30px rgba(15,23,42,.5); }
.w-hero .w-val { font-size: clamp(34px, 3.4vw, 50px); margin-top: 12px; }
.w-hero .w-sub { font-size: 13px; }
.w-spark { position: absolute; left: 0; right: 0; bottom: 0; height: 58px; opacity: .55; pointer-events: none; }
.w-hero-pie { position: relative; margin-top: auto; padding-top: 14px; display: flex; gap: 22px; flex-wrap: wrap;
  border-top: 1px solid var(--line); }
.w-hero-pie div { font-size: 12px; color: var(--ink-3); }
.w-hero-pie b { display: block; font-family: var(--font-display); font-size: 17px; font-weight: 700;
  color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* fila de abajo: desglose a la izquierda, sitio libre a la derecha */
.w-abajo { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .w-abajo { grid-template-columns: 1fr; } }
.w-card { background: var(--bg-elev); border: 0; border-radius: 18px; padding: 17px 19px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 20px 38px -30px rgba(15,23,42,.45); }
.w-card-hd { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.w-card-hd h3 { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.w-card-hd .tot { font-family: var(--font-display); font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: #0F8B8D; letter-spacing: -.02em; }
.w-card-hd .sub { font-size: 12px; color: var(--ink-3); }
.w-fila { margin-top: 13px; }
.w-fila .l { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13.5px; }
.w-fila .l .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-fila .l em { font-style: normal; color: var(--ink-3); font-size: 11.5px; margin-left: 7px; }
.w-fila .l b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.w-barra { height: 7px; border-radius: 7px; background: var(--bg-2); overflow: hidden; margin-top: 6px; }
.w-barra i { display: block; height: 100%; border-radius: 7px; background: linear-gradient(90deg, #0F8B8D, #35BBA9); }

.w-mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .w-mini-grid { grid-template-columns: 1fr; } }
.w-mini { background: var(--bg-elev); border-radius: 14px; padding: 13px 15px;
  box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 16px 30px -28px rgba(15,23,42,.45); }
.w-mini .k { display: flex; align-items: center; gap: 7px; font-size: 10px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }
.w-mini .v { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin-top: 7px;
  letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.w-hueco { border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 16px 15px; text-align: center;
  color: var(--ink-3); font-size: 12.5px; line-height: 1.5; background: color-mix(in srgb, var(--bg-2) 55%, transparent); }
.w-hueco b { display: block; color: var(--ink-2); font-size: 13px; margin-bottom: 2px; }

/* ═══════════════════════════════════════════════════════════════════════
   PULIDO VISUAL · 24-09-2026
   Capa aditiva: no reescribe nada de arriba, solo afina. Todo sale de las
   variables del tema, así que vale para claro y oscuro y para todos los CRMs.
   Si algo no convence, basta con borrar este bloque.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(17,17,20,.04), 0 1px 1px rgba(17,17,20,.03);
  --shadow-2: 0 1px 2px rgba(17,17,20,.04), 0 10px 30px -12px rgba(17,17,20,.14);
  --ring: 0 0 0 3px color-mix(in oklch, var(--accent) 28%, transparent);
}
:root[data-theme="dark"] { --ring: 0 0 0 3px color-mix(in oklch, var(--accent) 45%, transparent); }
body { font-feature-settings: "cv11", "ss01", "ss03"; letter-spacing: -0.003em; }
.num, .metric .val, .w-val, .table td { font-variant-numeric: tabular-nums; }

/* DermoPM: fondo cálido de clínica (solo si no se ha elegido otro tono) */
:root[data-ws="dermo"][data-bg-tone="grey"]:not([data-theme="dark"]) {
  --bg: oklch(0.975 0.007 45);
  --bg-2: oklch(0.955 0.010 45);
  --line: oklch(0.925 0.008 45);
  --line-2: oklch(0.88 0.010 45);
}

/* Cabecera translúcida */
.topbar {
  background: color-mix(in oklch, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
}
.search { background: var(--bg-elev); transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: color-mix(in oklch, var(--accent) 55%, var(--line)); box-shadow: var(--ring); }

/* Menú lateral: la opción activa lleva una marca de color */
.nav-item { position: relative; transition: background .15s, color .15s; }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-group { letter-spacing: .1em; }

/* Títulos de página con más presencia */
.page-hd h1 { font-size: 28px; letter-spacing: -0.028em; }
.card-hd h3, .sec-hd h3 { letter-spacing: -0.015em; }

/* Tarjetas y KPIs: se levantan un poco al pasar el ratón */
.card { transition: box-shadow .2s ease, border-color .2s ease; }
.card:hover { box-shadow: var(--shadow-2); }
.metric { transition: box-shadow .2s ease, transform .2s ease; }
.metric:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.metric .val { font-size: 30px; letter-spacing: -0.03em; }

/* Botones: foco visible para teclado y botón de acento con relieve */
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .chip:focus-visible {
  outline: none; box-shadow: var(--ring);
}
.btn.accent {
  background: linear-gradient(180deg, color-mix(in oklch, var(--accent) 88%, white), var(--accent));
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 16px -8px color-mix(in oklch, var(--accent) 70%, transparent);
}
.btn.accent:hover { filter: brightness(1.04); }
.input:focus, input.input:focus, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: color-mix(in oklch, var(--accent) 55%, var(--line-2)); box-shadow: var(--ring);
}

/* Tablas más legibles */
.table thead th { font-size: 11px; letter-spacing: .06em; font-weight: 600; background: var(--bg-2); }
.table tbody td { padding: 13px 14px; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: color-mix(in oklch, var(--accent) 5%, var(--bg-elev)); }
.table tbody tr:last-child td { border-bottom: 0; }

/* Pastillas un pelín más redondas y legibles */
.pill { padding: 2px 9px; font-weight: 550; }

/* Barras de desplazamiento finas */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* Widgets del dashboard: más aire y número principal con más peso */
.w-tile, .w-mini, .w-card { transition: box-shadow .2s ease, transform .2s ease; }
.w-mini:hover, .w-card:hover { box-shadow: var(--shadow-2); }
.w-val { letter-spacing: -0.03em; }
.w-hueco { transition: border-color .15s, background .15s, color .15s; }
.w-hueco:hover { border-color: color-mix(in oklch, var(--accent) 50%, var(--line-2));
  background: color-mix(in oklch, var(--accent) 5%, transparent); }

/* Móvil: cabecera ordenada (botón · sección · iconos) y buscador a lo ancho debajo */
@media (max-width: 860px) {
  .topbar { padding: 10px 12px; gap: 8px; row-gap: 10px; }
  .crumbs { min-width: 0; flex: 1; overflow: hidden; }
  .crumbs > span:not(.cur):not(.sep), .crumbs > .sep { display: none; }
  .crumbs .cur { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
  .side-toggle { margin-right: 2px; }
  .topbar-actions { margin-left: auto; }
  .search { order: 3; flex: 1 1 100%; max-width: none; margin-left: 0; }
  .page-hd h1 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .metric, .w-tile, .w-mini, .w-card { transition: none; }
  .metric:hover { transform: none; }
}
/* fila de widgets secundarios sin tarjeta lateral: a todo el ancho (24-09-2026) */
.w-abajo.solo { grid-template-columns: 1fr; }
.w-abajo.solo .w-mini-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
