/* ── Variables ─────────────────────────────────────── */
:root {
  --sidebar-w: 244px;
  --topbar-h: 56px;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;

  /* Paleta — monocromática (neutral / zinc) */
  --bg: #f7f7f8;
  --panel: #ffffff;
  --surface: #f4f4f5;
  --line: #e4e4e7;
  --muted: #71717a;
  --ink: #18181b;
  --ink-faint: #a1a1aa;

  --accent: #18181b;
  --accent-ink: #ffffff;
  --accent-dim: rgba(24, 24, 27, .06);
  --accent-hover: #000000;
  --teal: #18181b;
  --teal-dim: rgba(24, 24, 27, .06);
  --copper: #a9672a;
  --copper-dim: rgba(192, 111, 43, .12);
  --warning: #f59e0b;
  --warning-dim: #fff8e0;
  --danger: #dc2626;
  --danger-dim: #fee2e2;

  --success: #10b981;
  --shadow-xs: 0 1px 2px rgba(24, 24, 27, .04);
  --shadow: 0 4px 16px rgba(24, 24, 27, .06);
  --shadow-lg: 0 18px 48px rgba(24, 24, 27, .14);

  /* Sidebar — light mode: panel blanco, texto neutro */
  --sb-bg: #ffffff;
  --sb-text: #3f3f46;
  --sb-text-dim: #a1a1aa;
  --sb-active-bg: #f4f4f5;
  --sb-active-text: #18181b;
  --sb-hover: rgba(24, 24, 27, .04);
  --sb-line: #ececed;
  --sb-avatar-bg: #18181b;
  --sb-avatar-color: #ffffff;

  /* Superficies y texto secundarios (Studio, AI chat) */
  --surface2: #ececee;
  --text2: #71717a;
  --accent2: #3f3f46;
  --red: #ef4444;

  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

:root[data-theme="dark"] {
  --bg: #09090b;
  --panel: #18181b;
  --surface: #1f1f23;
  --line: #27272a;
  --muted: #a1a1aa;
  --ink: #fafafa;
  --ink-faint: #71717a;
  --accent: #fafafa;
  --accent-ink: #18181b;
  --accent-dim: rgba(250, 250, 250, .10);
  --accent-hover: #ffffff;
  --teal: #fafafa;
  --teal-dim: rgba(250, 250, 250, .10);
  --warning-dim: rgba(245, 158, 11, .15);
  --danger-dim: rgba(220, 38, 38, .16);
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, .28);
  --shadow: 0 8px 22px rgba(0, 0, 0, .32);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .48);
  /* Sidebar — dark mode */
  --sb-bg: #0c0c0e;
  --sb-text: rgba(255,255,255,.78);
  --sb-text-dim: rgba(255,255,255,.40);
  --sb-active-bg: rgba(255,255,255,.08);
  --sb-active-text: #ffffff;
  --sb-hover: rgba(255,255,255,.05);
  --sb-line: rgba(255,255,255,.08);
  --sb-avatar-bg: rgba(255,255,255,.14);
  --sb-avatar-color: #ffffff;

  /* Superficies y texto secundarios (Studio, AI chat) — dark mode */
  --surface2: #27272a;
  --text2: #a1a1aa;
  --accent2: #a1a1aa;
  --red: #ef4444;
}

body.auth-pending .sidebar,
body.auth-pending .sidebar-overlay,
body.auth-pending .topbar,
body.auth-pending .main-content,
body.auth-pending.client-page .client-session-actions,
body.auth-pending.client-page > main,
body.auth-gate .sidebar,
body.auth-gate .sidebar-overlay,
body.auth-gate .topbar,
body.auth-gate .main-content,
body.auth-gate.client-page .client-session-actions,
body.auth-gate.client-page > main {
  visibility: hidden;
}

body.tenant-blocked .sidebar,
body.tenant-blocked .sidebar-overlay,
body.tenant-blocked .topbar,
body.tenant-blocked .panel,
body.tenant-blocked .notif-drawer,
body.tenant-blocked .notif-overlay,
body.tenant-blocked .prog-overlay {
  display: none !important;
}
body.tenant-blocked {
  padding-left: 0;
}

body.tenant-blocked .main-content {
  max-width: 820px;
  margin: 0 auto;
  padding-top: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; }

h1, h2, h3, h4, p { margin: 0; }

body {
  background: var(--bg);
  padding-left: var(--sidebar-w);
  transition: padding-left .25s ease;
}

body.sidebar-collapsed {
  padding-left: 0;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 30;
  transform: translateX(0);
  transition: transform .25s cubic-bezier(.4,0,.2,1), background .25s ease;
  border-right: 1px solid var(--sb-line);
}

:root[data-theme="dark"] .sidebar {
  border-right: 1px solid var(--sb-line);
}

body.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--sb-line);
}

.brand-mark {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .04em;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-xs);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  color: var(--sb-text);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -.01em;
}

.brand-name strong {
  font-weight: 700;
}

.brand-tagline {
  color: var(--sb-text-dim);
  font-size: 11px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

/* Etiqueta de grupo (Status / Group en la referencia) */
.nav-group-label {
  padding: 10px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--sb-text-dim);
  text-transform: none;
  user-select: none;
}
.nav-group-label:first-child { padding-top: 2px; }

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sb-text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}

.nav-item [data-lucide] {
  width: 17px;
  height: 17px;
  stroke-width: 2;
  flex: 0 0 auto;
  opacity: .85;
  transition: opacity .15s;
}

.nav-item span:not(.nav-count) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sb-hover);
  color: var(--sb-active-text);
}

.nav-item:hover [data-lucide] { opacity: 1; }

.nav-item.active {
  background: var(--sb-active-bg);
  color: var(--sb-active-text);
  font-weight: 600;
}

.nav-item.active [data-lucide] { opacity: 1; }

/* Contador alineado a la derecha (estilo referencia) */
.nav-count {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--sb-text-dim);
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { color: var(--sb-active-text); }

.sidebar-footer {
  padding: 8px 8px;
  border-top: 1px solid var(--sb-line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.help-link {
  margin: 2px 10px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.help-link:hover { background: var(--sb-hover); color: var(--sb-active-text); }
.help-link [data-lucide] { width: 17px; height: 17px; opacity: .85; }

.user-chip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.user-avatar {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sb-avatar-bg);
  color: var(--sb-avatar-color);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.user-email {
  color: var(--sb-text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  color: var(--sb-text-dim);
  font-size: 11px;
  text-transform: capitalize;
}

.btn-sidebar-logout {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sb-text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
}

.btn-sidebar-logout:hover {
  background: rgba(220, 38, 38, .18);
  color: #ff6b6b;
}

.btn-sidebar-logout [data-lucide] { width: 15px; height: 15px; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.50);
  z-index: 29;
  opacity: 0;
  transition: opacity .25s;
}

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hamburger {
  display: inline-flex;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.hamburger:hover { background: var(--surface); color: var(--accent); }
.hamburger [data-lucide] { width: 20px; height: 20px; }

.breadcrumb {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .07s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(.98); }

.btn [data-lucide] { width: 15px; height: 15px; stroke-width: 2.2; flex: 0 0 auto; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(24,24,27,.18), 0 1px 0 rgba(255,255,255,.08) inset;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(24,24,27,.22);
}

.btn-secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: #f4f6f9; }
:root[data-theme="dark"] .btn-secondary:hover { background: #364052; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
:root[data-theme="dark"] .btn-ghost { color: #d4dbea; }
:root[data-theme="dark"] .btn-ghost:hover { background: #3a4558; color: #ffffff; }

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }

.btn-full { width: 100%; }

.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-google {
  background: var(--panel);
  color: var(--ink);
  border: 1.5px solid var(--line);
  gap: 10px;
  font-weight: 500;
}
.btn-google:hover { background: var(--surface); box-shadow: var(--shadow-xs); }

.btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface); color: var(--accent); }
.btn-icon [data-lucide] { width: 15px; height: 15px; }

/* ── Login ─────────────────────────────────────── */
/* ── Login: split layout ─────────────────────────── */
.login-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* Left — brand / visual side */
.login-left {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, #18181b 0%, #0c0c0e 60%, #000000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 56px;
}

.login-left::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.06) 1.5px, transparent 1.5px);
  background-size: 30px 30px;
}

.login-left-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}
.login-left-orb-1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(255,255,255,.10), transparent 70%);
  top: -120px; right: -100px;
  animation: orb-drift 12s ease-in-out infinite;
}
.login-left-orb-2 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(255,255,255,.06), transparent 70%);
  bottom: -80px; left: -60px;
  animation: orb-drift 16s ease-in-out infinite reverse;
}
.login-left-orb-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,.08), transparent 70%);
  top: 45%; left: 55%;
  animation: orb-drift 10s ease-in-out infinite 3s;
}
@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(16px, -22px) scale(1.06); }
}

/* ── Scan line animada ── */
.login-left::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.10) 50%, transparent 100%);
  z-index: 2;
  pointer-events: none;
  animation: scan-down 8s ease-in-out infinite;
}

@keyframes scan-down {
  0%, 100% { top: 0; opacity: 0; }
  6% { opacity: 1; }
  44% { opacity: 1; }
  50% { top: 100%; opacity: 0; }
}

/* ── Tagline con entrada sutil ── */
.login-left-tagline {
  animation: tagline-fade 1.2s cubic-bezier(.16,1,.3,1) both;
}
@keyframes tagline-fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-left-content {
  position: relative;
  z-index: 1;
  max-width: 380px;
}

.login-left-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.login-left-mark {
  width: 52px; height: 52px;
  background: #ffffff;
  color: #18181b;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.03em;
  flex-shrink: 0;
  box-shadow: 0 8px 22px rgba(0,0,0,.35);
}

.login-left-name {
  font-size: 26px;
  font-weight: 700;
  color: rgba(255,255,255,.92);
  letter-spacing: -.03em;
}
.login-left-name strong { color: #ffffff; }

.login-left-tagline {
  font-size: 17px;
  line-height: 1.55;
  color: rgba(255,255,255,.54);
  margin: 0 0 40px;
}

.login-left-features {
  position: relative;
  list-style: none;
  padding: 0;
  margin: 0;
  min-height: 210px;
}

.login-left-features li {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13.5px;
  color: rgba(255,255,255,.60);
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  filter: blur(4px);
  will-change: transform, opacity, filter;
  animation: feature-cycle 40s infinite;
}
.login-left-features li:nth-child(1) { animation-delay: 0s; }
.login-left-features li:nth-child(2) { animation-delay: 5s; }
.login-left-features li:nth-child(3) { animation-delay: 10s; }
.login-left-features li:nth-child(4) { animation-delay: 15s; }
.login-left-features li:nth-child(5) { animation-delay: 20s; }
.login-left-features li:nth-child(6) { animation-delay: 25s; }
.login-left-features li:nth-child(7) { animation-delay: 30s; }
.login-left-features li:nth-child(8) { animation-delay: 35s; }

@keyframes feature-cycle {
  0%   { opacity: 0; transform: translateY(24px) scale(0.96); filter: blur(4px); }
  3%   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
  11%  { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
  12.5% { opacity: 0; transform: translateY(-24px) scale(0.96); filter: blur(4px); }
  100% { opacity: 0; transform: translateY(-24px) scale(0.96); filter: blur(4px); }
}

.login-left-features li svg {
  flex-shrink: 0;
  color: rgba(255,255,255,.85);
  animation: icon-glow 40s infinite;
}
.login-left-features li:nth-child(1) svg { animation-delay: 0s; }
.login-left-features li:nth-child(2) svg { animation-delay: 5s; }
.login-left-features li:nth-child(3) svg { animation-delay: 10s; }
.login-left-features li:nth-child(4) svg { animation-delay: 15s; }
.login-left-features li:nth-child(5) svg { animation-delay: 20s; }
.login-left-features li:nth-child(6) svg { animation-delay: 25s; }
.login-left-features li:nth-child(7) svg { animation-delay: 30s; }
.login-left-features li:nth-child(8) svg { animation-delay: 35s; }

@keyframes icon-glow {
  0%, 2.5% { filter: drop-shadow(0 0 0px rgba(255,255,255,0)); opacity: 0.7; }
  3.5%, 10% { filter: drop-shadow(0 0 12px rgba(255,255,255,0.55)); opacity: 1; }
  11.5%, 100% { filter: drop-shadow(0 0 0px rgba(255,255,255,0)); opacity: 0.7; }
}

/* Right — form side */
.login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 40px 32px;
  overflow-y: auto;
}

.login-box {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: login-in .3s cubic-bezier(.16,1,.3,1) both;
}

/* Mobile: hide left panel, center form */
@media (max-width: 800px) {
  .login-panel { grid-template-columns: 1fr; }
  .login-left  { display: none; }
  .login-right { padding: 32px 20px; }
}

@keyframes login-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  margin-bottom: 16px;
}

.login-logo .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  font-size: 16px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-faint);
  font-size: 12px;
  margin: 14px 0;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.login-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}

/* ── Form elements ─────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 9px;
}

.field-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.req { color: var(--accent); }

.input-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink-faint);
  stroke-width: 2;
  pointer-events: none;
}

input, .select-input {
  height: 34px;
  padding: 0 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--panel);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  outline: none;
}

.input-wrap input {
  padding-left: 33px;
}

input:focus, .select-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder { color: var(--ink-faint); }

.select-input { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364707d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.select-inline {
  height: 32px;
  min-width: 210px;
  background-color: var(--surface);
}

.invalid-input { border-color: var(--danger) !important; background: #fff5f5; }

/* ── Main content ─────────────────────────────── */
.main-content {
  min-height: calc(100vh - var(--topbar-h));
  padding: 10px;
}

.org-strip {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-xs);
  max-width: min(44vw, 360px);
  white-space: nowrap;
  overflow: hidden;
}

.org-strip span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
}

.org-strip strong {
  color: var(--ink);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tenant-notice {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(192, 111, 43, .25);
  border-left: 4px solid var(--copper);
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--copper-dim), rgba(255,255,255,.84));
  color: #6b3b13;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-xs);
}

.tenant-notice div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tenant-notice strong {
  font-size: 14px;
}

.tenant-notice span {
  font-size: 13px;
  color: #7c4a1c;
}

.tenant-notice [data-lucide] {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

/* ── Panels ─────────────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; animation: panel-in .2s ease both; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.panel-title-group { display: flex; align-items: baseline; gap: 10px; }

.panel-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
}

.panel-meta {
  font-size: 12px;
  color: var(--muted);
}

/* ── Barra de filtros del dashboard ─────────────── */
.runs-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.runs-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.runs-filter-label svg { width: 14px; height: 14px; }

.filter-group { position: relative; }
.filter-group[hidden] { display: none; }

.filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.filter-trigger:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.filter-group.open .filter-trigger { border-color: var(--accent); }
.filter-trigger svg { width: 15px; height: 15px; }
.filter-caret { transition: transform .18s; opacity: .7; }
.filter-group.open .filter-caret { transform: rotate(180deg); }

.filter-badge {
  min-width: 18px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  color: var(--panel);
  background: var(--accent);
  border-radius: 999px;
}

.filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  width: 280px;
  max-width: calc(100vw - 40px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.filter-panel-head { padding: 8px; border-bottom: 1px solid var(--line); }
.filter-search { width: 100%; }

.filter-panel-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
.filter-link {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.filter-link:hover { text-decoration: underline; }

.filter-options { max-height: 260px; overflow-y: auto; padding: 4px; }

.filter-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  font-size: 13px;
  color: var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
}
.filter-option:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.filter-option input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }
.filter-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.filter-empty {
  padding: 14px 8px;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}

.filter-clear-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
.filter-clear-all:hover { color: var(--ink); }
.filter-clear-all svg { width: 14px; height: 14px; }

.run-card.filtered-out { display: none; }

/* ── Run form ─────────────────────────────────── */
.run-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.run-form input {
  width: 200px;
}

/* ── Runs grid ─────────────────────────────────── */
.runs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  width: 100%;
}

.run-card {
  position: relative;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: panel-in .22s ease both;
  transition: box-shadow .2s, border-color .2s;
}

.run-card:hover { box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

.run-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  background: linear-gradient(90deg, var(--surface), color-mix(in srgb, var(--surface) 85%, var(--accent-dim)));
  border-bottom: 1px solid var(--line);
}

.run-identity {
  min-width: 0;
  flex: 1;
}

.run-identity h2 {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-container {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

/* Metadata del flow vinculado a la instancia */
.run-flow-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.run-flow-meta.hidden { display: none; }

.flow-chip {
  display: inline-flex;
  align-items: center;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  cursor: default;
  user-select: text;
}
.flow-chip.muted {
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted);
  border-color: color-mix(in srgb, var(--muted) 25%, transparent);
}

.run-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--surface);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .25s ease, color .25s ease, box-shadow .25s ease;
}

/* Punto indicador a la izquierda del texto: hereda el color de fase */
.run-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ── Color del badge según la fase del run (#3) ─────────────────
   Las fases se derivan en JS (runStatePhase) y se exponen en data-phase,
   con colores semánticos que funcionan en claro y oscuro vía color-mix. */

/* Reservada / detectada / sin actividad → neutro tranquilo */
.run-status[data-phase="idle"] {
  background: var(--surface);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* Arranque / conexión del visor → azul informativo */
.run-status[data-phase="starting"] {
  background: color-mix(in srgb, #3b82f6 16%, var(--panel));
  color: color-mix(in srgb, #3b82f6 70%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #3b82f6 35%, transparent);
}

/* Login en progreso → ámbar (trabajo en curso) */
.run-status[data-phase="login"] {
  background: color-mix(in srgb, var(--warning) 18%, var(--panel));
  color: color-mix(in srgb, var(--warning) 60%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warning) 40%, transparent);
}

/* Esperando acción humana → contorno marcado de atención */
.run-status[data-phase="waiting"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

/* Login / flujo OK → verde éxito */
.run-status[data-phase="success"] {
  background: color-mix(in srgb, var(--success) 18%, var(--panel));
  color: color-mix(in srgb, var(--success) 55%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 40%, transparent);
}

/* Fallo / rechazo / timeout / cancelado → rojo peligro */
.run-status[data-phase="error"] {
  background: var(--danger);
  color: #fff;
  box-shadow: none;
}

/* El punto late mientras el run está trabajando (#6) */
.run-card[data-working="true"] .run-status::before {
  animation: status-dot-pulse 1.1s ease-in-out infinite;
}

@keyframes status-dot-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: .35; transform: scale(.7); }
}

/* Barra indeterminada bajo la cabecera: señal viva de que la app sigue
   trabajando aunque haya demoras entre pasos del login (#6). */
.run-header { position: relative; }
.run-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 40%;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--warning), transparent);
  opacity: 0;
  transform: translateX(-100%);
}
.run-card[data-working="true"] .run-header::after {
  opacity: 1;
  animation: header-progress 1.4s ease-in-out infinite;
}

@keyframes header-progress {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.run-body {
  display: grid;
  grid-template-columns: minmax(520px, 520px) minmax(0, 1fr);
  height: 304px;
}

/* ── Viewer ─────────────────────────────────────── */
.viewer {
  position: relative;
  background: #0c0c0e;
  overflow: hidden;
  min-width: 0;
}

.viewer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.viewer-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0,0,0,.55);
  color: rgba(255,255,255,.78);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid rgba(255,255,255,.16);
}

.empty-viewer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #3f5068;
}

.empty-viewer [data-lucide] { width: 36px; height: 36px; stroke-width: 1.2; opacity: .5; }
.empty-viewer span { font-size: 13px; opacity: .6; }

.control-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  transition: background .15s;
}
.control-btn:hover { background: #fff; }
.control-btn:disabled { opacity: .45; cursor: not-allowed; }
.control-btn [data-lucide] { width: 14px; height: 14px; }

/* ── Studio overlay (iframe full-screen) ─────────── */
.studio-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: studio-in .18s ease;
}
.studio-overlay.hidden { display: none; }
.studio-frame { flex: 1; width: 100%; border: none; display: block; }

@keyframes studio-in {
  from { opacity: 0; transform: scale(.98); }
  to   { opacity: 1; transform: scale(1); }
}

.studio-overlay-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 36px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--accent);
}

.studio-overlay-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent2);
}
.studio-overlay-title [data-lucide] { width: 14px; height: 14px; }

.studio-frame {
  flex: 1;
  width: 100%;
  border: none;
  display: block;
}

/* ── Suite Phos overlay (iframe centrado, Fase 37): deja ver el dashboard de
   fondo, a diferencia del Studio que es fullscreen ──────────────────────── */
.suite-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.suite-overlay.hidden { display: none; }
.suite-panel {
  width: min(1100px, 92vw);
  height: min(800px, 90vh);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.suite-frame { width: 100%; height: 100%; border: none; display: block; }

.studio-close-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: 5px;
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s;
}
.studio-close-btn:hover { background: var(--line); }
.studio-close-btn [data-lucide] { width: 13px; height: 13px; }

/* ── Run side panel ─────────────────────────────── */
.run-side {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  background: var(--surface);
  border-left: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
}

.run-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 7px 9px 7px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.run-side-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.run-side-header [data-lucide] { width: 13px; height: 13px; }

.run-side-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.log-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 27px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
}

.run-log-action {
  height: 27px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background .15s, border-color .15s, color .15s;
}
.run-log-action:hover {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}
.run-log-action-stop {
  color: #92400e;
  border-color: color-mix(in srgb, #f59e0b 34%, var(--line));
}
.run-log-action-stop:hover {
  background: color-mix(in srgb, #f59e0b 13%, var(--surface));
  border-color: color-mix(in srgb, #f59e0b 50%, var(--line));
}
.run-log-action-danger {
  color: #b91c1c;
  border-color: color-mix(in srgb, #ef4444 30%, var(--line));
}
.run-log-action-danger:hover {
  background: color-mix(in srgb, #ef4444 12%, var(--surface));
  border-color: color-mix(in srgb, #ef4444 45%, var(--line));
}
.run-log-action [data-lucide] { width: 13px; height: 13px; }
.run-log-separator {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 2px;
  flex: 0 0 auto;
}

.run-retry-panel {
  margin: 8px 10px 0;
  padding: 8px 10px;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  background: #fefce8;
}
.run-retry-panel .run-retry-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.run-retry-panel [data-lucide] { width: 13px; height: 13px; color: #b45309; flex-shrink: 0; }
.run-retry-panel span { font-size: 12px; color: #78350f; flex: 1; min-width: 0; }
.btn-cancel-retry {
  margin-left: auto;
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  background: #fff;
  color: #dc2626;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background .15s;
}
.btn-cancel-retry:hover { background: #fee2e2; }
.btn-cancel-retry:disabled { opacity: .5; cursor: default; }
.btn-cancel-retry [data-lucide] { width: 12px; height: 12px; color: #dc2626; }

.run-action-panel {
  margin: 8px 10px 0;
  padding: 9px 10px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.run-action-panel span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 5px;
}

.run-action-panel strong {
  display: block;
  font-size: 13px;
  color: var(--ink);
}

.run-action-panel p {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.logs {
  margin: 0;
  padding: 8px 10px;
  overflow: auto;
  height: 100%;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.45;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 92%, #0f172a), var(--surface)),
    var(--surface);
  color: var(--ink);
  border-top: 1px solid var(--line);
}

.log-line {
  position: relative;
  margin: 0 0 3px;
  padding: 4px 8px 4px 28px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
}

.log-line::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.log-info::before { background: #3b82f6; }
.log-warn {
  background: color-mix(in srgb, #f59e0b 11%, var(--panel));
  border-color: color-mix(in srgb, #f59e0b 25%, transparent);
}
.log-warn::before { background: #f59e0b; }
.log-error {
  background: color-mix(in srgb, #ef4444 12%, var(--panel));
  border-color: color-mix(in srgb, #ef4444 30%, transparent);
  color: color-mix(in srgb, #ef4444 55%, var(--ink));
}
.log-error::before { background: #ef4444; }
.log-state {
  font-weight: 700;
  border-color: color-mix(in srgb, var(--accent) 20%, transparent);
}
.log-flow {
  background: color-mix(in srgb, #10b981 8%, var(--panel));
}
.log-flow::before { background: #10b981; }
.log-variable {
  color: color-mix(in srgb, #2563eb 58%, var(--ink));
}
.log-var-change {
  font-size: 10px; opacity: .75; padding-left: 18px;
  color: color-mix(in srgb, #a78bfa 70%, var(--ink));
  border-color: transparent;
}
.log-var-change::before { background: #a78bfa; }
.log-operator {
  border-style: dashed;
}

/* ── Form cards (admin panels) ──────────────────── */
.form-card {
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--accent-dim);
  overflow: hidden;
  animation: form-slide-in .18s cubic-bezier(.16,1,.3,1) both;
}

@keyframes form-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.form-card-header h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  padding: 12px;
}

.field-group--wide {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

/* ── Data tables ────────────────────────────────── */
.data-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table thead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.data-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  color: var(--ink);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: color-mix(in srgb, var(--surface) 60%, var(--accent-dim)); }

.data-table tr[data-editing] td {
  background: var(--accent-dim) !important;
}
.data-table tr[data-editing] td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.data-table .badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}

/* Grilla de servidores Docker: evita desbordamiento horizontal del wrapper */
#tbl-docker-hosts { overflow: hidden; max-width: 100%; }

/* Resultado inline de "Probar conexión" — espacio reservado para evitar reflow */
.badge-result {
  display: inline-block;
  min-width: 120px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.82em;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: middle;
  background: transparent;
  color: var(--muted);
}
.badge-result--ok    { background: color-mix(in srgb, var(--color-success, #16a34a) 12%, transparent); color: var(--color-success, #16a34a); }
.badge-result--error { background: color-mix(in srgb, var(--color-danger, #dc2626) 12%, transparent);  color: var(--color-danger, #dc2626); }
.badge-result--warn  { background: color-mix(in srgb, #ca8a04 12%, transparent); color: #ca8a04; }

/* Escala tonal monocromática: mayor jerarquía = más oscuro */
.badge-role-admin   { background: #18181b; color: #ffffff; }
.badge-role-admin   { background: #3f3f46; color: #ffffff; }
.badge-role-miembro { background: #d4d4d8; color: #18181b; }
.badge-role-user    { background: #e4e4e7; color: #3f3f46; }
.badge-role-miembro  { background: #f4f4f5; color: var(--muted); }
.badge-plan-trial   { background: #f4f4f5; color: var(--muted); }
.badge-plan-idle    { background: #f4f4f5; color: var(--muted); }
.badge-plan-starter { background: #e4e4e7; color: #3f3f46; }
.badge-plan-pro     { background: #d4d4d8; color: #18181b; }
.badge-plan-enterprise { background: #18181b; color: #ffffff; }

.empty-state {
  padding: 34px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.surface-empty { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.loading-cell { padding: 20px; color: var(--muted); text-align: center; }
.muted-cell { color: var(--muted); }
.mono-code { font-family:'JetBrains Mono',monospace; font-size:12px; color: var(--ink); }
.mono-muted { font-family:'JetBrains Mono',monospace; font-size:11px; color: var(--muted); }
.sub-cell { display:block; margin-top:2px; color:var(--muted); font-size:11.5px; }

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg);
  display: grid;
  place-items: center;
}

.empty-icon [data-lucide] { width: 22px; height: 22px; stroke-width: 1.5; opacity: .6; }
.empty-state p { font-size: 14px; font-weight: 500; }

/* ── Interaction modal ──────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10,18,34,.55);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  width: min(490px, 100%);
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
  overflow: hidden;
}

.run-card-action-modal {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10,18,34,.34);
  backdrop-filter: blur(3px);
}

.run-card-action-modal .action-dialog {
  width: min(430px, calc(100% - 16px));
  max-height: calc(100% - 16px);
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0,0,0,.24);
}

.run-card-action-modal .dialog-title {
  font-size: 17px;
  margin-bottom: 6px;
}

.run-card-action-modal .dialog-message {
  font-size: 13px;
}

.run-card-action-modal .action-buttons .btn {
  height: 38px;
}

.action-dialog { padding: 28px; }

.dialog-header {
  margin-bottom: 10px;
}

.dialog-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.dialog-kicker [data-lucide] { width: 13px; height: 13px; }

.dialog-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  margin-bottom: 8px;
}

.dialog-message {
  font-size: 15px;
  color: #3f4c5a;
  line-height: 1.5;
  margin-bottom: 6px;
}

.dialog-countdown {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 16px;
}

.action-inputs { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }

.action-field { display: flex; flex-direction: column; gap: 5px; }
.action-field > span { font-size: 13px; font-weight: 600; color: var(--ink); }
.action-field input { width: 100%; }

.action-buttons { display: flex; gap: 8px; }
.action-buttons .btn { flex: 1; height: 44px; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

/* Authenticator number highlight */
.authenticator-number {
  display: inline-grid;
  place-items: center;
  min-width: 58px;
  min-height: 52px;
  margin: 0 4px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 30px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
  vertical-align: middle;
  box-shadow: var(--shadow);
}

/* ── Viewer start layer ──────────────────────────── */
.viewer-start-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: rgba(10,20,36,.40);
  backdrop-filter: blur(4px);
}

.viewer-start-button {
  height: 48px;
  padding: 0 24px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.30);
  transition: background .15s, border-color .15s;
}
.viewer-start-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.viewer-start-button [data-lucide] { width: 18px; height: 18px; }

/* ── Client page overrides ──────────────────────── */
.client-page .run-body {
  height: clamp(340px, 54vh, 460px);
}

.client-page .run-card {
  box-shadow: var(--shadow-lg);
}

.client-session-actions {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Utility ─────────────────────────────────────── */
.hidden { display: none !important; }

[data-lucide] {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
  flex: 0 0 auto;
}

/* ── Mobile breakpoints ─────────────────────────── */
@media (max-width: 1024px) {
  body { padding-left: 0; }

  .sidebar {
    transform: translateX(-100%);
  }

  .hamburger { display: flex; }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
  }

  .main-content { padding: 12px; }

  .runs-grid { grid-template-columns: 1fr; }

  .run-body { grid-template-columns: 1fr; height: auto; }
  .run-side { border-left: none; border-top: 1px solid #e8edf4; }

  .run-header { flex-wrap: wrap; gap: 8px; }

  .panel-header { flex-direction: column; align-items: flex-start; }

  .form-grid { grid-template-columns: 1fr; }
  .field-group--wide { grid-column: 1; }

  .run-form { flex-wrap: wrap; }
  .run-form input { width: 100%; flex: 1 1 140px; }
}

@media (max-width: 640px) {
  .login-box { padding: 28px 20px 22px; }

  .action-buttons { flex-direction: column; }

  .modal-overlay { align-items: flex-end; padding: 0; }

  .modal-dialog {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 90vh;
    overflow-y: auto;
  }

  .viewer, .viewer img { min-height: 240px; }
}

/* Final density and font normalization after utility CSS */
html body,
html body button,
html body input,
html body select,
html body textarea {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

html body input,
html body select,
html body .select-input {
  font-size: 12.5px;
  line-height: 1.2;
  padding: 0 12px;
}

html body .input-wrap input {
  padding-left: 34px;
  padding-right: 12px;
}

html body input[type="checkbox"],
html body input[type="radio"] {
  padding: 0;
  width: auto;
  height: auto;
}

html body .btn,
html body .nav-item,
html body .help-link {
  font-size: 13px;
}

html body .btn-sm {
  font-size: 12px;
}

html body .hamburger,
html body .theme-toggle {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

html body .hamburger:hover,
html body .theme-toggle:hover {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

:root[data-theme="dark"] body .hamburger,
:root[data-theme="dark"] body .theme-toggle {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

:root[data-theme="dark"] body .hamburger:hover,
:root[data-theme="dark"] body .theme-toggle:hover {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

/* Escala tonal monocromática en modo oscuro (mayor jerarquía = más claro) */
:root[data-theme="dark"] .badge-role-admin,
:root[data-theme="dark"] .badge-plan-enterprise { background: #fafafa; color: #18181b; }
:root[data-theme="dark"] .badge-role-admin       { background: #d4d4d8; color: #18181b; }
:root[data-theme="dark"] .badge-role-miembro,
:root[data-theme="dark"] .badge-plan-pro         { background: #52525b; color: #fafafa; }
:root[data-theme="dark"] .badge-role-user,
:root[data-theme="dark"] .badge-plan-starter     { background: #3f3f46; color: #e4e4e7; }
:root[data-theme="dark"] .badge-role-miembro,
:root[data-theme="dark"] .badge-plan-trial,
:root[data-theme="dark"] .badge-plan-idle        { background: #27272a; color: var(--muted); }

/* El badge de estado del run usa colores por fase con color-mix sobre las
   variables de tema, por lo que no necesita overrides dark dedicados. */

/* Tabulator row actions */
.tbl-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.tbl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}

.tbl-btn:hover { background: var(--surface); color: var(--ink); }
.tbl-btn.danger:hover { background: var(--danger-dim); color: var(--danger); border-color: #fecdd3; }
.tbl-btn.primary { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-dim); }
.tbl-btn.primary:hover { background: var(--accent); color: var(--accent-ink); }
.tbl-btn.success { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tbl-btn.success:hover { background: var(--accent-hover); }
.tbl-btn.warning { background: var(--surface); color: var(--ink); border-color: var(--ink); }
.tbl-btn.warning:hover { background: var(--accent-dim); }
.tbl-btn[disabled] { opacity: .4; pointer-events: none; }

.tbl-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }

/* Acciones agrupadas en encabezados de panel (visores: export + actualizar) */
.panel-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Encabezados ordenables de los visores */
th.visor-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.visor-sortable:hover { color: var(--accent); }
th.visor-sortable .visor-sort-arrow { font-size: 10px; margin-left: 3px; opacity: .8; }
.tbl-badge.ok { background: var(--accent-dim); color: var(--accent); }
.tbl-badge.danger { background: var(--danger-dim); color: var(--danger); }
.tbl-badge.neutral { background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

.scheduler-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.scheduler-cell .tbl-btn {
  height: 24px;
  padding-inline: 7px;
}

.org-procesos-table td {
  padding: 8px 0 !important;
  border: 0 !important;
  background: transparent !important;
}

.op-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 96%, var(--surface));
  box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

:root[data-theme="dark"] .op-card {
  background: color-mix(in srgb, var(--panel) 94%, var(--surface));
  box-shadow: none;
}

.op-card-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.op-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.op-card-title {
  min-width: 0;
  flex: 1;
}

.op-card-title strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pill de estado de la instancia (reemplaza el dot + texto del subtítulo anterior) */
.op-pill-instance {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}
.op-pill-instance.active   { background: var(--accent-dim); color: var(--accent); animation: pulse-dot 2s infinite; }
.op-pill-instance.detected { background: color-mix(in srgb, var(--success) 14%, var(--panel)); color: color-mix(in srgb, var(--success) 60%, var(--ink)); }
.op-pill-instance.danger   { background: var(--danger-dim); color: var(--danger); }
.op-pill-instance.idle     { background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

.op-card-meta {
  display: grid;
  gap: 8px;
}

.op-card-meta-primary {
  grid-template-columns: 1fr 1fr;
}

.op-card-meta-secondary {
  grid-template-columns: 1fr 1fr;
}
.op-card-meta-secondary > span {
  padding: 5px 8px;
}
.op-card-meta-secondary small { font-size: 9.5px; }
.op-card-meta-secondary code,
.op-card-meta-secondary b { font-size: 11px; }

.op-meta-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.op-meta-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.op-meta-row > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Automatización overlay (Nueva / Editar) ─── */
.org-proceso-modal { width: min(560px, 100%); }
.org-proceso-body {
  overflow-y: auto;
  flex: 1;
}

.op-card-meta > span {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 7px;
  background: var(--surface);
}

.op-card-meta small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1;
  text-transform: uppercase;
}

.op-card-meta code,
.op-card-meta b {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tercera fila en los chips del meta: nombre completo debajo del código */
.op-meta-sub {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  font-style: normal;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Área de indicadores de estado apilados verticalmente */
.op-card-status {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.op-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 20px;
}

.op-status-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.op-alert-text {
  color: var(--danger) !important;
}

.op-card-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.op-card-tags-secondary {
  padding-top: 6px;
  border-top: 1px dashed color-mix(in srgb, var(--line) 70%, transparent);
}

.op-card-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.op-card-actions .tbl-btn {
  height: 30px;
}

.op-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0;
}
.op-line { font-size: 12px; color: var(--ink); line-height: 1.4; }
.op-line.op-inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.op-muted { color: var(--muted); font-size: 12px; line-height: 1.4; }
.op-card-tag-line { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; line-height: 1.4; }
.op-detail { font-size: 11px; line-height: 1.4; }
.op-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink);
}
.op-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
}
.op-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.op-pill.on  { background: color-mix(in srgb, var(--success) 16%, var(--panel)); color: color-mix(in srgb, var(--success) 55%, var(--ink)); }
.op-pill.off { background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.tbl-badge.danger [data-lucide],
.tbl-badge.danger svg { width: 11px; height: 11px; }

.op-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.op-actions .tbl-btn { height: 26px; }

.visor-entity {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.visor-entity strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visor-entity code {
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Instance status indicator */
.instance-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted);
  flex-shrink: 0;
}
.instance-dot.running { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); animation: pulse-dot 2s infinite; }
.instance-dot.error { background: var(--danger); }
.instance-dot.waiting { background: var(--ink-faint); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}

@media (max-width: 1100px) {
  .op-card-meta-primary,
  .op-card-meta-secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .op-card-meta {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 400px) {
  .op-card-meta {
    grid-template-columns: 1fr;
  }
}

/* ════════════════════════════════════════════════════════════
   Fase 5 — Centro de notificaciones (drawer) y modal de
   programaciones. Estos estilos faltaban: el HTML/JS existía
   pero sin CSS el drawer y el modal se renderizaban rotos.
   ════════════════════════════════════════════════════════════ */

/* ── Campana + badge en la topbar ─────────────────── */
.notif-bell { position: relative; }
.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--panel);
}

/* ── Overlay y drawer ─────────────────────────────── */
.notif-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 9, 11, .42);
  backdrop-filter: blur(2px);
  animation: fade-in .15s ease both;
}

.notif-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 61;
  width: min(420px, 92vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: drawer-in .22s cubic-bezier(.22,.61,.36,1) both;
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.notif-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.notif-drawer-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.notif-drawer-header h3 [data-lucide] { width: 16px; height: 16px; }
.notif-drawer-actions { display: flex; align-items: center; gap: 6px; }

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notif-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.notif-item:hover { background: var(--surface); }
.notif-item.unread {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: var(--accent-dim);
}

.notif-item-icon {
  flex: none;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}
.notif-item-icon [data-lucide] { width: 15px; height: 15px; }
.notif-item.sev-error   .notif-item-icon { background: var(--danger-dim);  color: var(--danger); }
.notif-item.sev-warning .notif-item-icon { background: var(--warning-dim); color: var(--warning); }
.notif-item.sev-info    .notif-item-icon { background: var(--accent-dim);  color: var(--accent); }

.notif-item-body { min-width: 0; flex: 1; }
.notif-item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}
.notif-item-detail {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 4px;
  word-break: break-word;
}
.notif-item-meta {
  font-size: 10.5px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.notif-item.unread .notif-item-title::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}

/* ── Modal de programaciones ──────────────────────── */
.prog-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(9, 9, 11, .48);
  backdrop-filter: blur(2px);
  animation: fade-in .15s ease both;
}

.prog-modal {
  width: min(820px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: panel-in .2s ease both;
}

.prog-modal .form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  margin: 0;
}
.prog-modal .form-card-header h3 { font-size: 15px; font-weight: 700; color: var(--ink); }

.prog-aviso {
  margin: 0;
  padding: 10px 18px;
  background: var(--warning-dim);
  color: color-mix(in srgb, var(--warning) 75%, var(--ink));
  font-size: 12.5px;
  line-height: 1.45;
  border-bottom: 1px solid var(--line);
}
.prog-aviso.hidden { display: none; }

.prog-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  min-height: 0;
}

.prog-list {
  padding: 14px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prog-form {
  padding: 16px 18px;
  overflow-y: auto;
  margin: 0;
}
.prog-form .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.prog-form .field-checkbox label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}
.prog-form .field-checkbox input { width: auto; height: auto; }

.prog-preview {
  margin-top: 4px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
  line-height: 1.5;
}
.prog-preview:empty { display: none; }
.prog-err { color: var(--danger); font-weight: 600; }

/* ── Item de programación existente ───────────────── */
.prog-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.prog-item.paused { opacity: .62; }
.prog-item-main { min-width: 0; flex: 1; }
.prog-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 3px;
}
.prog-item-meta {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}
.prog-item-actions { flex: none; }

@media (max-width: 720px) {
  .prog-body { grid-template-columns: 1fr; }
  .prog-list { border-right: none; border-bottom: 1px solid var(--line); max-height: 30vh; }
}

/* ── Pantalla Archivos ──────────────────────────────── */
.archivos-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.archivos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.archivos-table th {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--surface);
}

.archivos-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  white-space: nowrap;
  vertical-align: middle;
}

.archivos-table tbody tr:last-child td { border-bottom: none; }
.archivos-table tbody tr:hover td { background: color-mix(in srgb, var(--surface) 60%, var(--accent-dim)); }

.archivos-table .col-check  { width: 36px; text-align: center; padding-right: 4px; }
.archivos-table .col-nombre { min-width: 180px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.archivos-table .col-instancia { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.archivos-table .col-tipo   { width: 100px; }
.archivos-table .col-tam    { width: 90px; }
.archivos-table .col-fecha  { width: 160px; }
.archivos-table .col-acciones { width: 72px; text-align: center; }

/* Nombre de archivo con icono alineado */
.archivo-nombre-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.archivo-nombre-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--surface);
}

.archivo-nombre-icon svg { width: 14px; height: 14px; }

.archivo-nombre-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--ink);
}

/* Celda instancia con texto más sutil */
.archivos-table .col-instancia {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--muted);
}

/* Celda tamaño */
.archivos-table .col-tam {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Celda fecha */
.archivos-table .col-fecha {
  font-size: 12px;
  color: var(--muted);
}

.archivo-tipo-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.archivo-tipo-badge svg { width: 13px; height: 13px; flex-shrink: 0; }

.archivo-tipo--pdf     { color: #e53e3e; }
.archivo-tipo--excel   { color: #38a169; }
.archivo-tipo--csv     { color: #319795; }
.archivo-tipo--word    { color: #3182ce; }
.archivo-tipo--txt     { color: var(--muted); }
.archivo-tipo--code    { color: #805ad5; }
.archivo-tipo--archive { color: #dd6b20; }
.archivo-tipo--image   { color: #d53f8c; }
.archivo-tipo--video   { color: #6b46c1; }
.archivo-tipo--audio   { color: #d69e2e; }
.archivo-tipo--other   { color: var(--muted); }

.btn-icon--sm {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}
.btn-icon--sm:hover { background: var(--accent-dim); color: var(--ink); }
.btn-delete-archivo:hover { color: var(--danger); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger:hover { filter: brightness(.9); }

.archivos-sort-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.archivos-sort-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 2px;
}

.archivos-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.archivos-sort-btn:hover,
.archivos-sort-btn.active {
  background: var(--accent-dim);
  color: var(--ink);
  border-color: transparent;
}
.archivos-sort-btn.active { font-weight: 600; }

.archivos-search-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--panel);
  margin-left: auto;
}

.archivos-search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--ink);
  width: 160px;
}

.archivos-date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px 4px;
}

.archivos-date-range {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 8px 8px;
  font-size: 12px;
  color: var(--muted);
}

.archivos-date-range label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.archivos-date-range input[type="date"] {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  background: var(--surface);
  color: var(--ink);
}

.archivos-confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.archivos-confirm-modal.hidden { display: none; }

.archivos-confirm-box {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.archivos-confirm-box h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 15px;
}

.archivos-confirm-box p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Confirm modal (reemplaza confirm() nativo) ────── */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  transition: opacity .2s ease;
}
.confirm-modal-overlay.visible { opacity: 1; }

.confirm-modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: scale(.94) translateY(8px);
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .2s ease;
  opacity: 0;
}
.confirm-modal-box.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.confirm-modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.confirm-modal-header [data-lucide],
.confirm-modal-header svg {
  width: 20px; height: 20px; flex: 0 0 20px;
  color: var(--accent2);
}
.confirm-modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.confirm-modal-box p {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 20px;
}

.confirm-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.confirm-modal-actions .btn {
  padding: 6px 18px;
  font-size: 13px;
  height: 36px;
}

/* ── Centro operativo ──────────────────────────────── */
.ops-header {
  align-items: center;
}

.ops-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ops-scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.ops-scope-badge svg {
  width: 13px;
  height: 13px;
}

/* ── KPI metrics ── */
.ops-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.ops-metric {
  position: relative;
  min-width: 0;
  padding: 10px 14px 9px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ops-metric--blue   { border-top-color: #3b82f6; }
.ops-metric--red    { border-top-color: #ef4444; }
.ops-metric--purple { border-top-color: #8b5cf6; }
.ops-metric--amber  { border-top-color: #f59e0b; }

.ops-metric-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.ops-metric-head svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.ops-metric--blue   .ops-metric-head svg { color: #3b82f6; }
.ops-metric--red    .ops-metric-head svg { color: #ef4444; }
.ops-metric--purple .ops-metric-head svg { color: #8b5cf6; }
.ops-metric--amber  .ops-metric-head svg { color: #f59e0b; }

.ops-metric-head span,
.ops-metric small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-metric-head span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.ops-metric strong {
  display: block;
  margin: 0 0 2px;
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.02em;
}

.ops-metric small {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Progress bar within metric card */
.ops-metric-prog {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.ops-metric-prog-fill {
  height: 100%;
  border-radius: inherit;
  transition: width .6s ease;
}

.ops-metric-prog--blue   { background: #3b82f6; }
.ops-metric-prog--red    { background: #ef4444; }
.ops-metric-prog--purple { background: #8b5cf6; }
.ops-metric-prog--amber  { background: #f59e0b; }

/* ── Charts row ── */
.ops-charts {
  display: grid;
  grid-template-columns: 240px 1fr 220px;
  gap: 8px;
  margin-bottom: 10px;
}

.ops-chart-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ops-chart-panel header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 76%, var(--panel));
}

.ops-chart-panel h3 {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 13px;
  font-weight: 750;
  color: var(--ink);
}

.ops-chart-panel h3 svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.ops-chart-body {
  padding: 14px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 170px;
}

.ops-chart-body--donut {
  gap: 24px;
}

.ops-chart-canvas-wrap {
  width: 148px;
  height: 148px;
  flex-shrink: 0;
}

.ops-chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Donut chart legend */
.ops-chart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.ops-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.ops-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.ops-legend-label {
  flex: 1;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-legend-val {
  font-weight: 700;
  color: var(--ink);
  min-width: 20px;
  text-align: right;
}

/* Bar chart canvas fills panel */
#ops-chart-runs {
  width: 100% !important;
  max-height: 188px;
}

/* ── Detail grid ── */
.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .85fr);
  gap: 8px;
  align-items: start;
}

.ops-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ops-panel--wide {
  grid-column: 1 / -1;
}

.ops-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 76%, var(--panel));
}

.ops-panel h3 {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  min-width: 0;
  font-size: 13px;
  font-weight: 750;
  color: var(--ink);
}

.ops-panel h3 svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.ops-panel header > span {
  min-width: 24px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.ops-list {
  display: flex;
  flex-direction: column;
  max-height: 420px;
  overflow: auto;
}

.ops-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
}

.ops-row:last-child {
  border-bottom: none;
}

.ops-row:hover {
  background: color-mix(in srgb, var(--surface) 52%, transparent);
}

.ops-row--alert {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--danger) 72%, var(--line));
}

.ops-row-main {
  min-width: 0;
}

.ops-row-main strong,
.ops-row-main span,
.ops-row-main p {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ops-row-main strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
  white-space: nowrap;
}

.ops-row-main span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.ops-row-main p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ops-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
}

.ops-row-side small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

/* ── Pills ── */
.ops-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 750;
  text-transform: uppercase;
}

.ops-pill--active {
  background: color-mix(in srgb, #10b981 14%, transparent);
  color: #047857;
}

:root[data-theme="dark"] .ops-pill--active {
  color: #34d399;
}

.ops-pill--warn {
  background: color-mix(in srgb, #d69e2e 18%, transparent);
  color: #9a5b00;
}

:root[data-theme="dark"] .ops-pill--warn {
  color: #fbbf24;
}

.ops-pill--danger {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
}

/* ── Empty state ── */
.ops-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 13px;
  color: var(--muted);
  font-size: 13px;
}

.ops-empty svg {
  width: 15px;
  height: 15px;
}

/* ── Toasts ────────────────────────────────────────── */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1100;
  display: flex;
  width: min(380px, calc(100vw - 32px));
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 28px;
  gap: 10px;
  align-items: start;
  min-height: 48px;
  padding: 12px 10px 12px 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 94%, white);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in .18s ease-out;
}

:root[data-theme="dark"] .toast-item {
  background: color-mix(in srgb, var(--panel) 92%, black);
}

.toast-item--closing {
  animation: toast-out .18s ease-in forwards;
}

.toast-item--success { border-left-color: var(--success); }
.toast-item--warning { border-left-color: #d69e2e; }
.toast-item--error { border-left-color: var(--danger); }

.toast-icon {
  width: 19px;
  height: 19px;
  margin-top: 1px;
  color: var(--accent);
}

.toast-item--success .toast-icon { color: var(--success); }
.toast-item--warning .toast-icon { color: #b7791f; }
.toast-item--error .toast-icon { color: var(--danger); }

.toast-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.toast-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toast-close:hover {
  background: var(--surface);
  color: var(--ink);
}

.toast-close svg {
  width: 16px;
  height: 16px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 640px) {
  .toast-container {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }
}

/* ── Responsive ── */
@media (max-width: 1380px) {
  .ops-charts { grid-template-columns: 200px 1fr 200px; }
}

@media (max-width: 1180px) {
  .ops-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ops-charts  { grid-template-columns: 1fr 1fr; }
  .ops-grid    { grid-template-columns: 1fr; }
  .ops-chart-body--donut { justify-content: flex-start; }
}

@media (max-width: 860px) {
  .ops-charts { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .ops-metrics { grid-template-columns: 1fr; }
  .ops-row { grid-template-columns: 1fr; }
  .ops-row-side { align-items: flex-start; flex-direction: row; justify-content: flex-start; }
}
.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.badge-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.readonly-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}

.readonly-pill.ok {
  color: var(--success, #059669);
  background: color-mix(in srgb, var(--success, #059669) 10%, transparent);
  border-color: color-mix(in srgb, var(--success, #059669) 24%, transparent);
}

.readonly-pill.warning {
  color: var(--warning, #b45309);
  background: color-mix(in srgb, var(--warning, #b45309) 10%, transparent);
  border-color: color-mix(in srgb, var(--warning, #b45309) 24%, transparent);
}

.readonly-pill.muted {
  color: var(--muted);
  background: var(--surface-muted, rgba(148, 163, 184, 0.12));
}

/* ── Visores de eventos / ejecuciones ── */
.visor-sev, .visor-estado {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
  background: var(--surface-2, #f4f4f5);
  color: var(--text-2, #52525b);
}
.visor-sev--error, .visor-estado--error, .visor-estado--error_login, .visor-estado--error_flujo {
  background: rgba(220, 38, 38, .12);
  color: #dc2626;
}
.visor-sev--warning, .visor-estado--sesion_expirada {
  background: rgba(217, 119, 6, .12);
  color: #d97706;
}
.visor-sev--info, .visor-estado--exitoso, .visor-estado--finished {
  background: rgba(22, 163, 74, .12);
  color: #16a34a;
}
.visor-estado--cancelado, .visor-estado--cancelled {
  background: rgba(113, 113, 122, .15);
  color: #71717a;
}
.visor-detalle, .visor-runid {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Formulario dinámico de flowImputs (AUTOMATIZACIONES) ─────────────────── */
.flow-inputs-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.flow-input-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(240px, 1.5fr) 150px;
  gap: 8px;
  align-items: center;
}
.flow-input-row .flow-input-label {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flow-input-row .flow-input-source {
  height: 30px;
  font-size: 12px;
}
.flow-inputs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.btn-xs {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}
.flow-functions-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, #eef2ff);
}
.flow-fn-token {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, #2563eb);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
  cursor: grab;
}
.flow-fn-token:hover {
  border-color: #2563eb;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .12);
}
.flow-fn-token span {
  font-size: 12px;
  font-weight: 700;
}
.flow-fn-token code {
  overflow: hidden;
  color: #047857;
  font-size: 11px;
  font-style: italic;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flow-expression-wrap {
  min-width: 0;
}
.flow-expression-editor {
  min-height: 32px;
  max-height: 92px;
  overflow: auto;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.flow-expression-editor:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.flow-expression-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}
.flow-expression-token {
  color: #047857;
  font-style: italic;
  font-weight: 700;
}
.flow-expression-wrap.disabled .flow-expression-editor {
  opacity: .65;
  background: color-mix(in srgb, var(--surface) 92%, var(--line));
  font-style: italic;
}
.tbl-badge.warn {
  background: rgba(217, 119, 6, .12);
  color: #d97706;
}

/* Toggle "Persistir" en la toolbar del Studio */
.studio-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: default;
  user-select: none;
}
.studio-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}
.studio-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.studio-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border, #4a5568);
  border-radius: 20px;
  transition: background 0.2s;
}
.studio-toggle-slider::before {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.studio-toggle input:checked + .studio-toggle-slider {
  background: var(--ink, #6366f1);
}
.studio-toggle input:checked + .studio-toggle-slider::before {
  transform: translateX(16px);
}
.studio-toggle input:disabled + .studio-toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}
.studio-toggle-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Webhooks overlay ──────────────────────────── */
.webhook-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(9, 9, 11, .48);
  backdrop-filter: blur(2px);
  animation: fade-in .15s ease both;
}
.webhook-overlay.hidden { display: none; }

.webhook-modal {
  width: min(860px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: panel-in .2s ease both;
}

.webhook-modal .form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  margin: 0;
  flex-shrink: 0;
}
.webhook-modal .form-card-header h3 { font-size: 15px; font-weight: 700; color: var(--ink); }

.webhook-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
}

.webhook-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 0;
  overflow: hidden;
  min-height: 0;
  flex: 1;
}

.webhook-list-col {
  padding: 14px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.webhook-form-col {
  padding: 16px 18px;
  overflow-y: auto;
}
.webhook-form-col .form-grid { margin: 0; }

/* ── Loading / Actualizar animations ─────────────────── */
@keyframes ui-spin {
  to { transform: rotate(360deg); }
}
.tbl-btn.is-loading svg,
.btn.is-loading svg {
  animation: ui-spin .65s linear infinite;
}
.spinner-xs {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ui-spin .65s linear infinite;
  vertical-align: middle;
}
.tbl-btn.is-loading,
.btn.is-loading {
  opacity: .6;
  pointer-events: none;
}

/* Indicador de carga flotante — posicionado sobre el panel sin desplazar contenido */
.panel-loading-bar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  pointer-events: none;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
}
.panel-loading-gear {
  font-size: 16px;
  display: inline-block;
  animation: gear-spin 1.4s linear infinite;
  line-height: 1;
}
@keyframes gear-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (max-width: 640px) {
  .webhook-body { grid-template-columns: 1fr; }
  .webhook-list-col { border-right: none; border-bottom: 1px solid var(--line); max-height: 180px; }
}
.windows-station-box { width: min(620px, 94vw); }
.windows-station-box p { margin: 0 0 18px; color: var(--text-muted, #71717a); line-height: 1.5; }
.windows-station-field { display: grid; gap: 8px; font-size: 12px; font-weight: 700; color: var(--text, #18181b); }
.windows-station-field select {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border, #e4e4e7);
  border-radius: 8px; background: var(--surface, #fff); color: var(--text, #18181b); font: inherit;
}
.windows-station-field option:disabled { color: #a1a1aa; }
.op-windows-station b { color: #2563eb; }

/* ── Desktop Clients ─────────────────────────────── */
.desktop-client-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.desktop-client-metric {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.desktop-client-metric svg { width: 18px; height: 18px; }
.desktop-client-metric span { color: var(--muted); font-size: 12px; font-weight: 650; }
.desktop-client-metric strong { color: var(--ink); font-size: 22px; }
.desktop-client-metric--online svg, .desktop-client-metric--available svg { color: #16a34a; }
.desktop-client-metric--running svg { color: #2563eb; }
.desktop-client-metric--offline svg { color: #71717a; }

.desktop-clients-layout {
  display: grid;
  grid-template-columns: minmax(340px, .9fr) minmax(460px, 1.35fr);
  gap: 14px;
  min-height: 570px;
}
.desktop-client-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow-y: auto;
}
.desktop-client-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.desktop-client-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-1px); }
.desktop-client-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent); }
.desktop-client-card-top { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.desktop-client-device-icon {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 9px; background: var(--surface); color: var(--muted);
}
.desktop-client-device-icon svg { width: 19px; }
.desktop-client-presence { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border: 2px solid var(--panel); border-radius: 50%; background: #a1a1aa; }
.desktop-client-presence.is-online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.12); }
.desktop-client-identity { min-width: 0; display: grid; gap: 2px; }
.desktop-client-identity strong { overflow: hidden; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.desktop-client-identity span { color: var(--muted); font-size: 11px; }
.desktop-client-state { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 750; letter-spacing: .02em; text-transform: uppercase; }
.desktop-client-state--available { color: #15803d; background: rgba(34,197,94,.12); }
.desktop-client-state--running { color: #1d4ed8; background: rgba(59,130,246,.13); }
.desktop-client-state--local { color: #a16207; background: rgba(234,179,8,.13); }
.desktop-client-state--offline, .desktop-client-state--unlinked { color: #71717a; background: rgba(113,113,122,.13); }
.desktop-client-card-info { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.desktop-client-card-info span { display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; color: var(--muted); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.desktop-client-card-info svg { width: 12px; height: 12px; flex: none; }
.desktop-client-run { display: grid; grid-template-columns: 15px auto minmax(0, 1fr); align-items: center; gap: 6px; margin-top: 10px; padding: 7px 9px; border-radius: 7px; background: rgba(37,99,235,.08); color: #2563eb; font-size: 10.5px; }
.desktop-client-run svg { width: 13px; }
.desktop-client-run code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.desktop-client-live { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.desktop-client-live-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.desktop-client-live-head h3 { margin: 3px 0 0; color: var(--ink); font-size: 17px; }
.desktop-client-eyebrow { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.desktop-client-eyebrow svg { width: 12px; height: 12px; color: #ef4444; animation: desktop-live-pulse 1.6s ease infinite; }
@keyframes desktop-live-pulse { 50% { opacity: .35; } }
.desktop-client-screen { position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid #27272a; border-radius: 9px; background: #09090b; }
.desktop-client-screen img { display: block; width: 100%; height: 100%; object-fit: contain; }
.desktop-client-screen-placeholder { display: grid; justify-items: center; gap: 8px; color: #a1a1aa; font-size: 11px; }
.desktop-client-screen-placeholder svg { width: 24px; height: 24px; }
.desktop-client-screen:not(.is-offline) .desktop-client-screen-placeholder svg[data-lucide="loader-circle"] { animation: ui-spin .8s linear infinite; }
.desktop-client-current { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; align-items: center; margin: 12px 0; padding: 11px 12px; border-left: 3px solid var(--accent); background: var(--surface); }
.desktop-client-current span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.desktop-client-current strong { grid-row: 2; color: var(--ink); font-size: 12px; }
.desktop-client-current code { grid-column: 2; grid-row: 1 / 3; max-width: 260px; overflow: hidden; color: var(--accent); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.desktop-client-details { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.desktop-client-details div { min-width: 0; padding: 9px 11px; border-bottom: 1px solid var(--line); }
.desktop-client-details div:nth-child(odd) { border-right: 1px solid var(--line); }
.desktop-client-details div:nth-last-child(-n+2) { border-bottom: 0; }
.desktop-client-details dt { color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; }
.desktop-client-details dd { margin: 3px 0 0; overflow: hidden; color: var(--ink); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.desktop-client-id { font-family: var(--font-mono, monospace); }
.desktop-client-error { display: flex; align-items: flex-start; gap: 7px; margin-top: 10px; padding: 9px 10px; border: 1px solid rgba(220,38,38,.2); border-radius: 7px; background: rgba(220,38,38,.07); color: var(--danger); font-size: 11px; }
.desktop-client-error svg { width: 14px; flex: none; }
.desktop-client-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.desktop-client-empty { display: grid; place-content: center; justify-items: center; gap: 7px; min-height: 100%; padding: 30px; color: var(--muted); text-align: center; }
.desktop-client-empty svg { width: 28px; height: 28px; opacity: .55; }
.desktop-client-empty strong { color: var(--ink); font-size: 13px; }
.desktop-client-empty span { max-width: 280px; font-size: 11px; line-height: 1.5; }
.desktop-client-empty--list { min-height: 260px; border: 1px dashed var(--line); border-radius: var(--radius); }

@media (max-width: 1100px) {
  .desktop-client-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desktop-clients-layout { grid-template-columns: 1fr; }
  .desktop-client-live { min-height: 520px; }
}
@media (max-width: 640px) {
  .desktop-client-metrics { grid-template-columns: 1fr 1fr; }
  .desktop-client-card-info, .desktop-client-details { grid-template-columns: 1fr; }
  .desktop-client-details div:nth-child(odd) { border-right: 0; }
  .desktop-client-details div:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
  .desktop-client-details div:last-child { border-bottom: 0; }
}
