/* ============================================================
   TORNUS DESIGN SYSTEM — ESTILOS COMPARTIDOS
   Marca Tornus: Petróleo profundo (#00232c), Crema (#f7f2df),
   Amarillo solar (#fbfb75), Acento (#0b4a57) y Terracota (#b07a12).
   Tipografías: Archivo, Instrument Serif, IBM Plex Mono.
   ============================================================ */

:root {
  --bg: #f7f2df;
  --surface: #fffdf6;
  --ink: #00232c;
  --muted: #56686b;
  --line: #e3dbc2;
  --accent: #0b4a57;
  --accent-soft: #e7eee9;
  --sun: #b07a12;
  --band: #00232c;
  --band-ink: #f7f2df;
  --band-muted: #9db3b4;
  --band-accent: #fbfb75;
  --band-line: #15424d;
  --btn: #00232c;
  --btn-ink: #fbfb75;
  --crit: #a8321f;
  --crit-soft: #f6e0d8;
  --warn: #8a5f00;
  --warn-soft: #f5e9c4;
  --ok: #2c6b45;
  --ok-soft: #e0ecdf;
  --idle: #5f6668;
  --idle-soft: #ebe7d8;
  --c-prom: #0b4a57;
  --c-evt: #b07a12;
  --c-plan: #6b5a86;
  --c-infra: #5f7045;
  --c-serv: #94505c;
  --display: "Instrument Serif", "Times New Roman", Georgia, serif;
  --body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 4px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #00232c;
    --surface: #032d38;
    --ink: #f3efe0;
    --muted: #98adb0;
    --line: #12404b;
    --accent: #fbfb75;
    --accent-soft: #16404a;
    --sun: #e8b957;
    --band: #001b22;
    --band-ink: #f3efe0;
    --band-muted: #98adb0;
    --band-accent: #fbfb75;
    --band-line: #12404b;
    --btn: #fbfb75;
    --btn-ink: #00232c;
    --crit: #ff9b85;
    --crit-soft: #3d2320;
    --warn: #f0c860;
    --warn-soft: #3a3016;
    --ok: #8fd3a5;
    --ok-soft: #15372a;
    --idle: #a9b3b5;
    --idle-soft: #16363f;
    --c-prom: #fbfb75;
    --c-evt: #e8b957;
    --c-plan: #b8a7dc;
    --c-infra: #b3c58c;
    --c-serv: #e39aa7;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #00232c;
  --surface: #032d38;
  --ink: #f3efe0;
  --muted: #98adb0;
  --line: #12404b;
  --accent: #fbfb75;
  --accent-soft: #16404a;
  --sun: #e8b957;
  --band: #001b22;
  --band-ink: #f3efe0;
  --band-muted: #98adb0;
  --band-accent: #fbfb75;
  --band-line: #12404b;
  --btn: #fbfb75;
  --btn-ink: #00232c;
  --crit: #ff9b85;
  --crit-soft: #3d2320;
  --warn: #f0c860;
  --warn-soft: #3a3016;
  --ok: #8fd3a5;
  --ok-soft: #15372a;
  --idle: #a9b3b5;
  --idle-soft: #16363f;
  --c-prom: #fbfb75;
  --c-evt: #e8b957;
  --c-plan: #b8a7dc;
  --c-infra: #b3c58c;
  --c-serv: #e39aa7;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: .005em;
}

/* Iconografía Vectorial SVG */
.ico {
  display: inline-block;
  vertical-align: -2px;
  flex-shrink: 0;
  stroke-width: 2;
}
.ico-fill { fill: currentColor; }

/* Header de Marca Tornus */
.brand {
  background: var(--band);
  color: var(--band-ink);
  border-bottom: 1px solid var(--band-line);
}
.brand-in {
  max-width: 1220px;
  margin: 0 auto;
  padding-inline: 20px;
  padding-block: 16px 22px;
  display: grid;
  gap: 18px;
}
.brand-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--band-muted);
}
.brand-top .wm {
  font-stretch: 125%;
  font-weight: 700;
  letter-spacing: .32em;
  color: var(--band-ink);
  font-size: 13px;
  text-decoration: none;
}
.brand-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
}
.brand h1 {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  color: var(--band-accent);
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: .98;
  letter-spacing: .005em;
  margin: 0;
}
.brand .sub {
  color: var(--band-muted);
  margin: .5rem 0 0;
  max-width: 65ch;
  font-size: 14px;
  line-height: 1.4;
}
.brand .toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.brand .status {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--band-muted);
}
.brand .status.err { color: #ffb4a3; }

/* Navegación Principal Unificada */
.nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--band-line);
  padding-top: 14px;
  margin-top: 4px;
}
.nav-link {
  color: var(--band-muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  font-stretch: 112%;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: var(--r);
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover {
  color: var(--band-ink);
  background: rgba(255, 255, 255, .06);
}
.nav-link.active {
  color: var(--band-accent);
  background: rgba(251, 251, 117, .12);
  border: 1px solid rgba(251, 251, 117, .25);
}
.nav-badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--band-accent);
  color: #00232c;
  font-weight: 700;
}

/* Botones */
.btn {
  border-radius: var(--r);
  background: var(--btn);
  color: var(--btn-ink);
  border: 1px solid var(--btn);
  font-stretch: 112%;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all .15s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.brand .btn { background: var(--band-accent); color: #00232c; border-color: var(--band-accent); }
.brand .btn.ghost { background: rgba(255, 255, 255, .08); color: var(--band-ink); border-color: var(--band-line); }
.brand .btn.ghost:hover { background: rgba(255, 255, 255, .16); border-color: var(--band-muted); }
.btn.sm { font-size: 11px; padding: 4px 8px; }

/* Contenedor Principal */
.wrap {
  max-width: 1220px;
  margin: 0 auto;
  padding-inline: 20px;
  padding-block: 24px 60px;
  display: grid;
  gap: 20px;
}

/* KPIs y Métricas */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.kpi {
  background: transparent;
  padding: 16px 18px;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 3px;
}
.kpi:first-child { border-left: 0; }
.kpi .lab {
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
}
.kpi .val {
  font-family: var(--display);
  font-weight: 400;
  font-size: 2.3rem;
  line-height: 1;
  margin: 4px 0 2px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kpi .note { font-size: 12px; color: var(--muted); }
.kpi.hot .val { color: var(--crit); }
.kpi.star .val { color: var(--sun); }
.kpi.ok .val { color: var(--ok); }

/* Paneles */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 20px;
  min-width: 0;
}
.panel h2 {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .01em;
  margin: 0 0 12px;
}
.panel h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
}

/* Filtros y Controles */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.filters label {
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  display: grid;
  gap: 4px;
}
select, input[type=search], input[type=text], textarea {
  font: inherit;
  font-size: 13.5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}
input[type=search] { width: 230px; max-width: 100%; }
select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  align-self: center;
}

/* Píldoras de Estado y Categorías */
.pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 2px;
  letter-spacing: .02em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.p-cat { background: var(--bg); color: var(--ink); }
.p-tier { background: var(--band); color: var(--band-accent); }
.p-star { background: #fef9c3; color: #854d0e; border: 1px solid #ca8a04; }
.p-prep { background: #e0ecdf; color: #2c6b45; border: 1px solid #2c6b45; }
.p-mod { background: var(--accent-soft); color: var(--accent); }
.p-crit { background: var(--crit-soft); color: var(--crit); }
.p-warn { background: var(--warn-soft); color: var(--warn); }
.p-ok { background: var(--ok-soft); color: var(--ok); }
.p-idle { background: var(--idle-soft); color: var(--idle); }
.p-sig { background: var(--accent-soft); color: var(--accent); }

/* Tarjetas de Procesos */
.list { display: grid; gap: 10px; }
.row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--line));
  border-radius: var(--r);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 20px;
  transition: box-shadow .15s ease;
}
.row:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, .03); }
.row.is-star {
  border-left-color: var(--sun) !important;
  background: linear-gradient(90deg, rgba(176, 122, 18, .04) 0%, var(--surface) 20%);
}
.row.is-prep {
  border-left-color: #2c6b45 !important;
  background: linear-gradient(90deg, rgba(44, 107, 69, .04) 0%, var(--surface) 20%);
}
.row.dismissed { opacity: .5; background: var(--bg); }
.row .top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.obj {
  font-weight: 500;
  font-size: 15px;
  line-height: 1.4;
  margin: 8px 0 4px;
  text-wrap: pretty;
}
.meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.side {
  display: grid;
  gap: 6px;
  justify-items: end;
  align-content: start;
  text-align: right;
}
.money {
  font-family: var(--body);
  font-weight: 600;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.close { font-size: 12.5px; color: var(--muted); }
.id { font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* Acciones en la tarjeta */
.acts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2px;
}
.btn-act {
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .15s ease;
}
.btn-act:hover { background: var(--bg); border-color: var(--ink); }
.btn-act.active-star { background: #fef9c3; color: #854d0e; border-color: #ca8a04; }
.btn-act.active-prep { background: #e0ecdf; color: #2c6b45; border-color: #2c6b45; }
a.go {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--ink);
  padding: 5px 9px;
  border-radius: var(--r);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .15s ease;
}
a.go:hover, a.go:focus-visible { background: var(--band); color: var(--band-accent); }
.nolink { font-size: 11px; color: var(--muted); max-width: 18ch; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.loading { padding: 32px; text-align: center; color: var(--muted); font-family: var(--mono); }

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--band);
  color: var(--band-accent);
  border: 1px solid var(--band-line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  padding: 12px 18px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(20px);
  opacity: 0;
  transition: all .25s cubic-bezier(.16, 1, .3, 1);
  pointer-events: auto;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.err { color: #ff9b85; border-color: #a8321f; }

/* Footer */
footer.fin {
  max-width: 1220px;
  margin: 0 auto;
  padding-inline: 20px;
  padding-block: 0 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
footer.fin .wm {
  font-stretch: 125%;
  font-weight: 700;
  letter-spacing: .32em;
  color: var(--ink);
}

/* Responsividad */
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2n+1) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 680px) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .side { justify-items: start; text-align: left; }
  .acts { justify-content: flex-start; }
  .brand .toolbar { justify-content: flex-start; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi { border-left: 0; border-top: 1px solid var(--line); }
  .kpi:first-child { border-top: 0; }
}

/* ============================================================
   DRAWER / FICHA LATERAL DETALLADA 360°
   ============================================================ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 27, 34, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer.open {
  transform: translateX(0);
}
.drawer-head {
  padding: 20px 24px;
  background: var(--band);
  color: var(--band-ink);
  border-bottom: 1px solid var(--band-line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.drawer-head-info {
  display: grid;
  gap: 6px;
}
.drawer-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--band-line);
  color: var(--band-ink);
  border-radius: var(--r);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease;
}
.drawer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}
.drawer-body {
  padding: 24px;
  overflow-y: auto;
  display: grid;
  gap: 20px;
  flex: 1;
}
.drawer-foot {
  padding: 16px 24px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.drawer-sec-title {
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}
.drawer-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  background: var(--bg);
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
}
.drawer-detail-item {
  display: grid;
  gap: 3px;
}
.drawer-detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}
.drawer-detail-val {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

/* ============================================================
   COMMAND PALETTE (CMD + K / SPOTLIGHT)
   ============================================================ */
.cmd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 27, 34, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 10010;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.cmd-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.cmd-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: min(680px, 100%);
  max-height: 70vh;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-10px);
  transition: transform .18s ease;
}
.cmd-backdrop.open .cmd-box {
  transform: translateY(0);
}
.cmd-input-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.cmd-input {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}
.cmd-results {
  overflow-y: auto;
  padding: 8px;
  display: grid;
  gap: 4px;
}
.cmd-item {
  padding: 10px 14px;
  border-radius: var(--r);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background .12s ease;
}
.cmd-item:hover, .cmd-item.active {
  background: var(--bg);
}
.cmd-kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}
.cmd-foot {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
}

/* ============================================================
   CHECKLIST & CALIFICACIÓN COMERCIAL EN CARTERA
   ============================================================ */
.cartera-qualification {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 10px;
}
.qual-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.score-pills {
  display: inline-flex;
  gap: 4px;
}
.score-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  transition: all .15s ease;
}
.score-pill:hover { border-color: var(--ink); }
.score-pill.active-alta { background: #e0ecdf; color: #2c6b45; border-color: #2c6b45; }
.score-pill.active-media { background: #fef9c3; color: #854d0e; border-color: #ca8a04; }
.score-pill.active-baja { background: #f6e0d8; color: #a8321f; border-color: #a8321f; }

.checklist {
  display: grid;
  gap: 6px;
  font-size: 12px;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--muted);
}
.check-item input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}
.check-item.done {
  color: var(--ink);
  text-decoration: line-through;
  opacity: .75;
}

/* ============================================================
   ESTILOS DE LA PÁGINA DE ALERTAS
   ============================================================ */
.grid-2col {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr);
  gap: 20px;
}
@media (max-width: 860px) {
  .grid-2col { grid-template-columns: minmax(0, 1fr); }
}

.table-subscribers {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table-subscribers th {
  text-align: left;
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.table-subscribers td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table-subscribers tr:hover td {
  background: rgba(0, 35, 44, 0.02);
}
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-status.active {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-status.paused {
  background: var(--idle-soft);
  color: var(--idle);
}
