/* Oprisia DB — tema oscuro con la paleta de marca (#070B24 · #FF5C5C · #3D7BFF · #4F5BD5) */
:root {
  --bg: #070B24;
  --bg-2: #0B1030;
  --surface: #0F1537;
  --surface-2: #151C45;
  --surface-3: #1C2455;
  --line: rgba(160, 175, 255, 0.10);
  --line-2: rgba(160, 175, 255, 0.18);
  --text: #EEF0FF;
  --text-2: #C4C9EA;
  --muted: #8E96C2;
  --red: #FF5C5C;
  --blue: #3D7BFF;
  --indigo: #4F5BD5;
  --violet: #A06CFF;
  --green: #2ECC8F;
  --amber: #FFB547;
  --pink: #E86BD8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: #9DB8FF; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; color: var(--text-2); }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.icon { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.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: 10px; }
.pad { padding: 14px 18px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- Botones e inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); border-color: rgba(160, 175, 255, .3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--blue), var(--indigo)); border-color: transparent; box-shadow: 0 6px 18px rgba(61, 123, 255, .3); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--red); border-color: transparent; color: #fff; }
.btn.danger.ghost { background: transparent; color: #FF8A8A; border-color: rgba(255, 92, 92, .35); }
.btn.danger.ghost:hover { background: rgba(255, 92, 92, .1); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; height: 42px; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.wa { background: rgba(46, 204, 143, .12); border-color: rgba(46, 204, 143, .35); color: #7FE8BF; }
.btn.wa:hover { background: rgba(46, 204, 143, .2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { font-size: 12.5px; font-weight: 600; }

.input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
  font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 90px; line-height: 1.5; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(61, 123, 255, .2); }
.input::placeholder { color: #5E6693; }
input[type="datetime-local"].input, input[type="date"].input, input[type="time"].input { color-scheme: dark; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 42px; }
.in-input { position: absolute; right: 3px; top: 2px; }
.input.code { height: 56px; text-align: center; font: 700 28px/1 var(--mono); letter-spacing: .45em; padding-left: .45em; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.req { color: var(--red); }
.form-error { background: rgba(255, 92, 92, .12); border: 1px solid rgba(255, 92, 92, .35); color: #FFB3B3; padding: 9px 12px; border-radius: 10px; font-size: 13px; }
.notice { background: rgba(61, 123, 255, .12); border: 1px solid rgba(61, 123, 255, .3); color: #BFD0FF; padding: 9px 12px; border-radius: 10px; font-size: 13px; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .icon { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search-wrap .input { padding-left: 34px; width: 260px; }

/* ---------- Pantallas de acceso ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; position: relative; overflow: hidden; }
.auth-glow { position: absolute; inset: -20%; background:
  radial-gradient(40% 35% at 20% 20%, rgba(79, 91, 213, .35), transparent 70%),
  radial-gradient(35% 30% at 85% 80%, rgba(255, 92, 92, .22), transparent 70%),
  radial-gradient(30% 30% at 70% 15%, rgba(61, 123, 255, .18), transparent 70%);
  filter: blur(10px); pointer-events: none; }
.auth-card {
  position: relative; width: 100%; max-width: 410px; padding: 32px 28px;
  background: rgba(15, 21, 55, .82); backdrop-filter: blur(18px);
  border: 1px solid var(--line-2); border-radius: 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  display: flex; flex-direction: column; gap: 12px;
}
.auth-card h1 { font-size: 22px; margin-top: 10px; }
.auth-card form { margin-top: 8px; }
.auth-foot { position: relative; margin-top: 18px; display: flex; align-items: center; gap: 4px; }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.qr { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 14px; width: max-content; margin: 4px auto; }
.qr img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.manual summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.secret { display: block; margin-top: 8px; font-size: 15px; letter-spacing: .08em; text-align: center; padding: 10px; user-select: all; word-break: break-all; }
.meter-wrap { display: flex; align-items: center; gap: 10px; }
.meter { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; width: 0; border-radius: 99px; transition: width .2s, background .2s; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.brand b { background: linear-gradient(90deg, #8FA3FF, var(--red)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, var(--indigo), var(--red)); box-shadow: 0 6px 16px rgba(255, 92, 92, .25); }
.brand.big { font-size: 22px; }
.brand.big .brand-mark { width: 42px; height: 42px; border-radius: 13px; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 18px 12px; background: linear-gradient(180deg, #0B1030, #080C28); border-right: 1px solid var(--line);
}
.sidebar > .brand { padding: 4px 10px 18px; }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #5E6693; padding: 16px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500; text-decoration: none !important; position: relative; }
.nav-item:hover { background: rgba(160, 175, 255, .07); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(61, 123, 255, .22), rgba(79, 91, 213, .08)); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--blue); }
.nav-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot-alert { flex: none !important; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(255, 92, 92, .2); }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--line); margin-top: 10px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me .small { display: flex; align-items: center; gap: 3px; color: var(--green); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: linear-gradient(135deg, var(--blue), var(--violet)); }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.main { flex: 1; padding: 28px 32px 60px; max-width: 1500px; width: 100%; outline: none; }
.scrim { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; }
.card-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: rgba(61, 123, 255, .14); color: #9DB8FF; flex: none; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.stack-cards { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.note { padding: 0 18px 14px; display: flex; align-items: center; gap: 4px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi { position: relative; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--k, var(--blue)); opacity: .10; filter: blur(4px); }
.kpi-blue { --k: var(--blue); } .kpi-violet { --k: var(--violet); } .kpi-green { --k: var(--green); } .kpi-red { --k: var(--red); } .kpi-amber { --k: var(--amber); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.kpi-top .icon { color: var(--k); }
.kpi-label { font-size: 12.5px; font-weight: 600; }
.kpi-value { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Embudo */
.funnel { padding: 4px 18px 16px; display: flex; flex-direction: column; gap: 4px; }
.funnel-row { display: grid; grid-template-columns: 190px 1fr 36px; align-items: center; gap: 12px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; color: var(--text); text-decoration: none !important; }
.funnel-row:hover { background: var(--surface-2); }
.funnel-row.zero { color: var(--muted); }
.funnel-label { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.funnel-track { height: 12px; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.funnel-fill { height: 100%; border-radius: 0 4px 4px 0; background: linear-gradient(90deg, #3D7BFF, #6E8DFF); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.funnel-fill.other { background: #5A628F; }
.funnel-n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Barras por día */
.bars-wrap { display: flex; gap: 8px; padding: 6px 18px 0; }
.bars-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); padding-bottom: 2px; text-align: right; min-width: 14px; }
.bars { position: relative; flex: 1; height: 120px; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line-2); }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bar-col:hover .bar { background: #8FB0FF; }
.bar { width: 100%; background: var(--blue); border-radius: 4px 4px 0 0; }
.bar.empty { background: var(--surface-3); border-radius: 0; }
.bars-foot { display: flex; justify-content: space-between; padding: 6px 18px 14px 40px; }
.chart-tip { position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); background: #fff; color: #0B1030; font-size: 12px; padding: 5px 9px; border-radius: 8px; white-space: nowrap; box-shadow: var(--shadow); pointer-events: none; z-index: 2; }

/* Canales */
.canal-list { padding: 0 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.canal-row { display: grid; grid-template-columns: 110px 1fr 30px 40px; align-items: center; gap: 10px; }
.canal-bar { height: 8px; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.canal-bar span { display: block; height: 100%; background: var(--green); border-radius: 0 4px 4px 0; }
.canal-row b { text-align: right; font-variant-numeric: tabular-nums; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0 8px 10px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; cursor: pointer; }
.list-item:hover { background: var(--surface-2); }
.list-item.static { cursor: default; }
.list-item.static:hover { background: transparent; }
.list-item .icon { color: var(--muted); }
.list-item .strong { display: flex; align-items: center; gap: 8px; }
.when { display: flex; flex-direction: column; min-width: 64px; }
.when b { font-size: 16px; font-variant-numeric: tabular-nums; }
.days-badge { font-size: 12px; font-weight: 700; color: #FF8A8A; background: rgba(255, 92, 92, .12); padding: 2px 8px; border-radius: 99px; }

/* Chips */
.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip-green { background: rgba(46, 204, 143, .14); color: #7FE8BF; }
.chip-red { background: rgba(255, 92, 92, .14); color: #FF9E9E; }
.chip-amber { background: rgba(255, 181, 71, .14); color: #FFCF85; }
.chip-blue { background: rgba(61, 123, 255, .16); color: #A9C2FF; }
.chip-violet { background: rgba(160, 108, 255, .16); color: #CDB0FF; }
.chip-pink { background: rgba(232, 107, 216, .15); color: #F5B0EC; }
.chip-stage { --c: #6B7394; background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 55%, white); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.canal { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.canal.wa { color: #7FE8BF; }
.canal.ig { color: #F5B0EC; }
.bool { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; }
.bool.yes { color: #7FE8BF; }
.bool.no { color: var(--muted); }
.bool.warn { color: #FFCF85; }

/* ---------- Kanban ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; min-height: 60vh; scroll-snap-type: x proximity; }
.kcol { --c: var(--blue); flex: 0 0 280px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 190px); scroll-snap-align: start; transition: border-color .15s, background .15s; }
.kcol.over { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, var(--bg-2)); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: relative; }
.kcol-head::before { content: ""; position: absolute; top: -1px; left: 14px; right: 14px; height: 2px; background: var(--c); border-radius: 0 0 2px 2px; }
.kcol-title { flex: 1; font-weight: 700; font-size: 13px; }
.kcol-count { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 99px; }
.kcol-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 80px; }
.kcol-empty { border: 1px dashed var(--line-2); border-radius: 10px; padding: 18px; text-align: center; color: #5E6693; font-size: 12px; }
.board.is-dragging .kcol-empty { border-color: var(--c); color: var(--text-2); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; cursor: grab; display: flex; flex-direction: column; gap: 6px; transition: transform .12s, border-color .12s, box-shadow .12s; }
.kcard:hover { border-color: var(--line-2); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0, 0, 0, .3); }
.kcard.dragging { opacity: .45; }
.kcard.stale { border-left: 3px solid var(--red); }
.kcard-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.kcard-top strong { font-size: 13.5px; line-height: 1.3; }
.kcard-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.kcard-meta span { font-size: 11px; color: var(--text-2); background: var(--surface-2); padding: 1px 7px; border-radius: 6px; }
.kcard-notes { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; }
.kcard-foot .small { display: inline-flex; align-items: center; gap: 3px; }
.stale-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; color: #FF9E9E; }

/* ---------- Reuniones ---------- */
.tabs { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); padding: 3px; border-radius: 11px; gap: 2px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 6px 13px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); }
.tabs.small .tab { padding: 4px 10px; font-size: 12px; }
.callout { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 11px; background: rgba(255, 181, 71, .08); border: 1px solid rgba(255, 181, 71, .25); color: #FFD9A0; font-size: 13px; margin-bottom: 18px; }
.agenda { display: flex; flex-direction: column; gap: 22px; }
.day { display: flex; flex-direction: column; gap: 8px; }
.day-head { font-size: 14px; padding-left: 2px; }
.day-head::first-letter { text-transform: uppercase; }
.day-head.today { color: #9DB8FF; }
.meeting { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 16px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .12s, background .12s; }
.meeting:hover { border-color: var(--line-2); background: var(--surface-2); }
.meeting.cancelled { opacity: .55; }
.meeting.cancelled .meeting-title strong { text-decoration: line-through; }
.meeting-time { display: flex; flex-direction: column; border-right: 1px solid var(--line); padding-right: 12px; }
.meeting-time b { font-size: 18px; font-variant-numeric: tabular-nums; }
.meeting-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meeting-meta { display: flex; align-items: center; gap: 12px; margin-top: 4px; flex-wrap: wrap; }
.rem { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; color: #5E6693; font-weight: 600; }
.rem.on { color: #7FE8BF; }
.wa-link { color: #7FE8BF; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg-btn:hover { color: var(--text); background: var(--surface-2); }
.seg-btn.on.green { background: rgba(46, 204, 143, .18); color: #7FE8BF; }
.seg-btn.on.red { background: rgba(255, 92, 92, .18); color: #FF9E9E; }
.seg-btn.on.amber { background: rgba(255, 181, 71, .18); color: #FFCF85; }

/* ---------- Tabla genérica ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 220px); transition: opacity .15s; }
.table-wrap.loading { opacity: .55; pointer-events: none; }
.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.grid th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 600; border-bottom: 1px solid var(--line-2); padding: 0; white-space: nowrap; }
.th-btn { all: unset; box-sizing: border-box; display: flex; gap: 6px; align-items: center; width: 100%; padding: 10px 14px; cursor: pointer; color: var(--text-2); font-size: 12.5px; }
.th-btn:hover { color: var(--text); }
.th-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.sorted .th-btn { color: #fff; }
.sort-ind { color: var(--blue); font-weight: 800; }
.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; max-width: 340px; }
.grid tbody tr { cursor: pointer; transition: background .1s; }
.grid tbody tr:hover { background: rgba(61, 123, 255, .07); }
.grid tbody tr:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.grid td.pk { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.num { font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }

/* ---------- Drawer / formulario ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(3, 5, 20, 0); transition: background .2s; }
.drawer-backdrop.open { background: rgba(3, 5, 20, .55); }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--bg-2); border-left: 1px solid var(--line-2); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1); box-shadow: -20px 0 60px rgba(0, 0, 0, .4); }
.drawer-backdrop.open .drawer { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.drawer-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drawer-head h2 { font-size: 19px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
.record { display: flex; flex-direction: column; gap: 18px; }
.summary { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.summary-item { display: flex; flex-direction: column; }
.summary .btn { margin-left: auto; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field-control { display: flex; gap: 8px; align-items: center; }
.hint { display: flex; gap: 5px; align-items: flex-start; font-size: 11.5px; color: #FFCF85; line-height: 1.4; }
.hint .icon { margin-top: 2px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; height: 38px; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 40px; height: 22px; background: var(--surface-3); border-radius: 99px; position: relative; transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch-input:checked + .switch-track { background: var(--green); }
.switch-input:checked + .switch-track::after { transform: translateX(18px); }
.switch-input:focus-visible + .switch-track { outline: 2px solid var(--blue); outline-offset: 2px; }
.toggle-group { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle { border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text-2); padding: 6px 12px; border-radius: 99px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.toggle.on { background: rgba(61, 123, 255, .2); border-color: var(--blue); color: #fff; }
.record-actions { position: sticky; bottom: -28px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 0 4px; margin-top: 18px; background: linear-gradient(180deg, transparent, var(--bg-2) 30%); }
.sys { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 16px; }
.sys summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sys-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 4px; font-size: 12.5px; }
.sys-list dt { color: var(--muted); }
.sys-list dd { margin: 0; word-break: break-all; }
.related { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.related-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.related-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.related-list li:hover { background: var(--surface-2); }

/* ---------- Modal ---------- */
.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(3, 5, 20, .65); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); animation: pop .18s cubic-bezier(.2, .8, .2, 1); max-height: calc(100vh - 32px); overflow: auto; }
.modal.wide { width: min(620px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; }
.modal-body { padding: 4px 18px 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }

/* ---------- Ajustes ---------- */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-card > :not(.card-head) { margin: 0 18px 18px; }
.settings-card .card-head { align-items: flex-start; }
.settings-card form .input { flex: 1; min-width: 200px; }
.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.audit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 900px; overflow-y: auto; }
.audit-item { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.audit-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; flex: none; background: var(--surface-2); color: var(--muted); }
.tone-green .audit-icon { background: rgba(46, 204, 143, .14); color: #7FE8BF; }
.tone-red .audit-icon { background: rgba(255, 92, 92, .14); color: #FF9E9E; }
.tone-amber .audit-icon { background: rgba(255, 181, 71, .14); color: #FFCF85; }
.tone-blue .audit-icon { background: rgba(61, 123, 255, .16); color: #A9C2FF; }
.changes { margin: 6px 0 0; padding: 8px 10px; list-style: none; background: var(--bg-2); border-radius: 8px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; word-break: break-word; }
.changes .old { color: #FF9E9E; text-decoration: line-through; }
.changes .new { color: #7FE8BF; }
.snapshot { margin-top: 6px; font-size: 12px; }
.snapshot summary { cursor: pointer; color: var(--muted); }
.snapshot pre { background: var(--bg-2); padding: 10px; border-radius: 8px; overflow: auto; max-height: 260px; font-size: 11.5px; }

/* ---------- Estados ---------- */
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--blue); animation: spin .7s linear infinite; margin: 30px auto; }
.spinner.page { margin: 20vh auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--text); }
.empty.error .icon { color: var(--red); }
.empty .btn { margin-top: 8px; }

/* Toasts */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 15px; border-radius: 12px; background: #F4F6FF; color: #0B1030; font-weight: 600; font-size: 13px; box-shadow: var(--shadow); animation: pop .2s; max-width: 380px; transition: opacity .4s, transform .4s; }
.toast-ok .icon { color: #16A36B; }
.toast-error { background: #FFE9E9; color: #7A1010; }
.toast-error .icon { color: #E03A3A; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- Responsive ---------- */
@media (max-width: 1250px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2, .settings-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 30; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(3, 5, 20, .6); }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; background: rgba(7, 11, 36, .92); backdrop-filter: blur(10px); }
  .main { padding: 18px 16px 50px; }
  h1 { font-size: 22px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 26px; }
  .search-wrap, .search-wrap .input { width: 100%; }
  .head-actions { width: 100%; }
  .fields { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 130px 1fr 28px; }
  .meeting { grid-template-columns: 60px 1fr; }
  .meeting .seg { grid-column: 1 / -1; justify-self: start; }
  .kcol { flex-basis: 84vw; }
  #toasts { left: 16px; right: 16px; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
