@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --navy: #1a303d;
  --navy-deep: #12242e;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-text: #5c717c;
  --sidebar-active: #1a303d;
  --sidebar-hover: #eef7fa;
  --sidebar-accent: #00a3c4;
  --topbar-bg: #ffffff;
  --border: #d7e0e6;
  --border-strong: #b7c4cc;
  --text: #1a303d;
  --muted: #5e717c;
  --silver: #a6a9aa;
  --accent: #00a3c4;
  --accent-hover: #0089a6;
  --accent-soft: #e6f7fb;
  --danger: #c0392b;
  --danger-soft: #fef3f2;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --escritura: #b42318;
  --escritura-bg: #fef3f2;
  --lectura: #166534;
  --lectura-bg: #f0fdf4;
  --console: #0f1720;
  --font: "Outfit", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --radius: 12px;
  --shadow: 0 10px 28px rgba(26, 48, 61, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  min-height: 100vh;
  background: var(--bg);
  display: flex;
}

a { color: var(--accent); text-decoration: none; font-weight: 500; }
a:hover { color: var(--accent-hover); }

/* ═══════════════════════ SIDEBAR ═══════════════════════ */

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(26, 48, 61, 0.04);
}

.sidebar-brand {
  padding: 1.15rem 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand a {
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
}
.sidebar-brand a:hover { color: var(--accent); }
.sidebar-brand .brand-logo-wrap {
  background: transparent;
  border-radius: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  box-shadow: none;
}
.sidebar-brand .brand-logo {
  display: block;
  height: 36px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}
.sidebar-brand .brand-sub {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.sidebar-user {
  padding: 1rem 1.3rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--sidebar-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
}
.sidebar-user .user-info {
  display: flex;
  flex-direction: column;
}
.sidebar-user .user-name {
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
}
.sidebar-user .user-role {
  color: var(--sidebar-text);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}
.sidebar-nav .nav-section {
  padding: 0.6rem 1.3rem 0.3rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--silver);
  font-weight: 600;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.9rem;
  margin: 0 0.55rem 0.15rem;
  color: var(--sidebar-text);
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s;
  min-width: 0;
}
.sidebar-nav a .nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}
.sidebar-nav a.active {
  color: var(--sidebar-active);
  background: var(--accent-soft);
  border-left: none;
  box-shadow: inset 3px 0 0 var(--sidebar-accent);
}
.sidebar-nav a .icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
}
.sidebar-nav .badge {
  margin-left: auto;
  background: var(--sidebar-accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 1rem 1.3rem;
  border-top: 1px solid var(--border);
}
.sidebar-footer a {
  color: var(--sidebar-text);
  font-size: 0.82rem;
  display: block;
  padding: 0.35rem 0;
}
.sidebar-footer a:hover { color: var(--text); }
.sidebar-footer form { display: inline; }
.sidebar-footer .linkish {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0;
  display: block;
  width: 100%;
  text-align: left;
}
.sidebar-footer .linkish:hover { color: var(--text); }

/* ═══════════════════════ TOPBAR ═══════════════════════ */

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem 0 1.5rem;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(26, 48, 61, 0.04);
  gap: 0.75rem;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}
.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle:hover { background: var(--accent-soft); border-color: #cdeef5; }
.topbar-greeting {
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar-right .user-pill {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--accent-soft);
  padding: 0.35rem 0.85rem 0.35rem 0.55rem;
  border-radius: 20px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid #cdeef5;
}
.topbar-right .user-pill .dot {
  width: 8px;
  height: 8px;
  background: var(--sidebar-accent);
  border-radius: 50%;
}

/* ═══════════════════════ MAIN LAYOUT ═══════════════════════ */

.layout-main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
}

.page-head {
  margin-bottom: 1.5rem;
}
.page-head h1 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 0.3rem;
}
.page-head .lede {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}

/* ═══════════ STATS ROW ═══════════ */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: var(--shadow);
}
.stat-card .stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.stat-card .stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.stat-card .stat-value small {
  font-size: 0.55em;
  font-weight: 500;
  color: var(--muted);
}
.stat-card .stat-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
.stat-card.accent { border-left: 3px solid var(--sidebar-accent); }
.stat-card.warn { border-left: 3px solid var(--warn); }
.stat-card.ok { border-left: 3px solid var(--ok); }

/* ═══════════ GRID / CARDS ═══════════ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.15rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card.narrow {
  max-width: 420px;
  margin: 2.5rem auto;
  border-top: 3px solid var(--accent);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.agent-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.agent-list-head,
.agent-row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) 148px 128px 92px 52px;
  gap: 0.85rem;
  align-items: center;
  padding: 0.95rem 1.35rem;
}
.agent-list-head {
  background: #f7fafb;
  border-bottom: 1px solid var(--border);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.agent-row {
  position: relative;
  color: inherit;
  font-weight: 400;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.agent-row:last-child { border-bottom: none; }
.agent-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--accent);
  transition: width 0.12s;
}
.agent-row:hover {
  background: var(--accent-soft);
  color: inherit;
}
.agent-row:hover::before { width: 3px; }
.agent-row-main {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
}
.agent-row-main .status-dot { margin-top: 0.38rem; }
.agent-row-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
.agent-row-copy strong {
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.agent-row-resumen {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-row .pill { justify-self: start; }
.agent-row .status-badge { margin-left: 0; justify-self: start; }
.agent-row-procs {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.agent-row-go {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.82rem;
  text-align: right;
}
.agent-row:hover .agent-row-go { color: var(--accent-hover); }
.info-card h3, .identity-card h3, .card h3 { margin-top: 0; }
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.5rem;
  margin: 0.35rem 0 0;
}
.info-grid dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.info-grid dd { margin: 0; font-size: 0.92rem; }
.info-grid .info-span { grid-column: 1 / -1; }
.info-grid.compact { margin-top: 0.75rem; }
.tech-details {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.tech-details summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
}
.tech-details summary::-webkit-details-marker { display: none; }
.tech-details summary::after { content: " +"; color: var(--accent); }
.tech-details[open] summary::after { content: " −"; }
.tech-details .logbox { margin-top: 0.75rem; }

/* ═══════════ SHARED COMPONENTS ═══════════ */

h2 { font-size: 1.08rem; font-weight: 650; letter-spacing: -0.015em; }
h2 a { color: var(--text); font-weight: 650; }
h2 a:hover { color: var(--accent); }
h3 {
  margin: 1.1rem 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted { color: var(--muted); }
.path { font-size: 0.82rem; color: var(--muted); margin: 0.3rem 0 0.65rem; }
.path code, code {
  font-family: var(--mono);
  font-size: 0.8em;
  background: #f4f7f8;
  color: var(--text);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
  word-break: break-all;
}

.pill {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.pill.escritura {
  color: var(--escritura);
  border-color: #fdba74;
  background: var(--escritura-bg);
}
.pill.lectura {
  color: var(--lectura);
  border-color: #86efac;
  background: var(--lectura-bg);
}

.jobs {
  list-style: none;
  margin: 0.75rem 0 1rem;
  border-top: 1px solid var(--border);
}
.jobs li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.jobs li:last-child { border-bottom: none; }
.jobs .muted { font-family: var(--mono); font-size: 0.76rem; }

.job-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.job-row strong { min-width: 0; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.running {
  background: var(--ok);
  box-shadow: 0 0 6px rgba(6, 118, 71, 0.45);
  animation: pulse-green 2s infinite;
}
.status-dot.scheduled {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(0, 163, 196, 0.45);
}
.status-badge.scheduled {
  background: var(--accent-soft);
  color: #007a94;
  border: 1px solid #b8e6f0;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-badge {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.status-badge.running {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid #abefc6;
}
.status-badge.stopped {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover {
  background: #edf1f5;
  border-color: var(--muted);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn.danger {
  background: var(--danger-soft);
  border-color: #fecdca;
  color: var(--danger);
}
.btn.danger:hover { filter: brightness(0.97); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: flex-end;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}
.confirm {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-weight: 500;
}
.confirm input {
  width: 4rem;
  padding: 0.38rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 5px;
  font-family: var(--mono);
  font-weight: 600;
}

label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--text);
}
input[type=text], input[type=password] {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.75rem;
  background: #fafbfc;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 7px;
  font: inherit;
}
input[type=text]:focus, input[type=password]:focus, .confirm input:focus {
  outline: 2px solid rgba(0, 163, 196, 0.28);
  border-color: var(--accent);
  background: #fff;
}

.logbox {
  background: var(--console);
  color: #d7e0ea;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  overflow: auto;
  max-height: 260px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.logbox.large { max-height: 65vh; }

/* ═══════════ DETALLE / CONSOLA TÉCNICA ═══════════ */

.agent-hero {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
  box-shadow: var(--shadow);
}
.agent-hero.compact { margin-bottom: 1rem; }
.agent-hero .back-link { margin: 0 0 0.55rem; }
.agent-hero .back-link a { color: var(--accent); font-weight: 600; }
.agent-hero .back-link a:hover { color: var(--accent-hover); }
.agent-hero h1 {
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.3rem;
}
.agent-hero .lede {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
  max-width: 40rem;
}
.agent-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
  padding-top: 1.4rem;
}
.agent-hero .status-badge { margin-left: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(240px, 0.85fr);
  gap: 1.15rem;
  margin-bottom: 1.25rem;
}
.detail-grid .card { margin-bottom: 0; }
.info-prose {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0.15rem 0 0;
}
.run-warn {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid #fedf89;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
}

.tech-meta {
  display: grid;
  gap: 0.85rem;
  margin: 0.35rem 0 0;
}
.tech-meta.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem 1.25rem;
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  background: #f4f7f8;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.tech-meta dt {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.tech-meta dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text);
  word-break: break-all;
  line-height: 1.4;
}

.process-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow);
}
.process-head {
  background: #f7fafb;
  color: var(--text);
  padding: 1.05rem 1.35rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}
.process-head .kicker {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.process-head h2 {
  color: var(--text);
  margin: 0.2rem 0 0.25rem;
  font-size: 1.08rem;
}
.process-hint {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.process-head .status-badge { margin-left: 0; flex-shrink: 0; }
.process-body { padding: 1.15rem 1.35rem 1.25rem; }
.process-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.process-toolbar .inline-form { margin: 0; }

.console-block { margin-top: 0.15rem; }
.console-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.console-head a { font-size: 0.78rem; letter-spacing: 0; text-transform: none; }

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.log-toolbar a {
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
}
.log-toolbar a.active,
.log-toolbar a:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.table-wrap { overflow-x: auto; margin-top: 0.35rem; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 0.45rem 0.6rem 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.55rem 0.6rem 0.55rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.result-ok { color: var(--ok); font-weight: 600; }
.result-error { color: var(--danger); font-weight: 600; }
.result-denegado { color: var(--warn); font-weight: 600; }

.messages { list-style: none; margin: 0 0 1rem; }
.msg {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 0.4rem;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 500;
}
.msg.success, .msg.ok { border-color: #abefc6; background: var(--ok-soft); color: var(--ok); }
.msg.error { border-color: #fecdca; background: var(--danger-soft); color: var(--danger); }
.msg.warning { border-color: #fedf89; background: var(--warn-soft); color: var(--warn); }

form p { margin-bottom: 0.75rem; }
form ul.errorlist { color: var(--danger); font-size: 0.85rem; padding-left: 1.1rem; }

.back-link { display: inline-block; margin-bottom: 0.75rem; font-size: 0.88rem; }

.footer {
  margin-top: auto;
  padding: 1rem 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

/* ═══════════ LOGIN corporativo ═══════════ */

body.login-page {
  display: block;
  background: var(--bg);
  min-height: 100vh;
}
body.login-page ::spelling-error,
body.login-page ::grammar-error {
  text-decoration: none !important;
  background: transparent !important;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
  min-height: 100vh;
}

.login-hero {
  background-color: #1a303d;
  background-image:
    linear-gradient(165deg, rgba(19, 37, 47, 0.72) 0%, rgba(26, 48, 61, 0.55) 45%, rgba(18, 48, 58, 0.78) 100%),
    url("/static/img/login-hero-bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #e8eef1;
  padding: 3.25rem 3rem 2.5rem;
  display: flex;
  flex-direction: column;
}

.login-hero-logo {
  background: #fff;
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  align-self: flex-start;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  margin-bottom: 2.25rem;
}
.login-hero-logo img {
  display: block;
  height: 42px;
  width: auto;
}

.login-kicker {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7dd3e8;
  margin: 0 0 0.55rem;
  text-decoration: none;
}

.login-hero h1 {
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: #fff;
  margin: 0 0 0.85rem;
  line-height: 1.15;
  text-decoration: none;
}

.login-lead {
  color: rgba(232, 238, 241, 0.78);
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 28rem;
  margin: 0 0 1.5rem;
}

.login-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.login-points li {
  font-size: 0.9rem;
  color: rgba(232, 238, 241, 0.9);
  padding-left: 1.15rem;
  position: relative;
}
.login-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.login-hero-foot {
  margin-top: auto;
  padding-top: 2.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(232, 238, 241, 0.45);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: #fff;
}

.login-panel-inner {
  width: 100%;
  max-width: 400px;
}

.login-panel-head {
  margin-bottom: 1.6rem;
}
.login-panel-head h2 {
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 0.35rem;
  text-transform: none;
}
.login-panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-form label {
  margin-bottom: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}
.login-form input[type=text] {
  margin-top: 0.25rem;
  margin-bottom: 0.85rem;
  padding: 0.72rem 0.85rem;
  border-radius: 8px;
  background: #f7fafb;
}
.login-form .password-wrap {
  margin-top: 0.25rem;
  margin-bottom: 0.85rem;
}
.login-form .password-wrap input {
  margin: 0;
  padding: 0.72rem 2.75rem 0.72rem 0.85rem;
  border-radius: 8px;
  background: #f7fafb;
}
.password-wrap {
  position: relative;
}
.password-wrap input {
  width: 100%;
  padding-right: 2.75rem;
  box-sizing: border-box;
}
.password-toggle {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.password-toggle:hover { color: var(--text); }
.login-submit {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
}
.login-hint {
  margin-top: 1.35rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}
.login-credit {
  margin-top: 1.1rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--silver);
}

/* ═══════════ RESPONSIVE — plantilla de sistema ═══════════ */

.sidebar-overlay {
  display: none;
}

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr; }
  .agent-list-head,
  .agent-row {
    grid-template-columns: minmax(0, 1.4fr) 130px 118px 80px 44px;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
  }
}

@media (max-width: 991px) {
  .nav-toggle { display: inline-flex; }
  .topbar { left: 0; }
  .layout-main { margin-left: 0; padding: 1.25rem; }

  .sidebar {
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 32px rgba(26, 48, 61, 0.18);
    z-index: 40;
  }
  body.nav-open .sidebar { transform: translateX(0); }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(26, 48, 61, 0.4);
    z-index: 35;
  }
  .sidebar-overlay[hidden] { display: none; }

  .stats-row { grid-template-columns: 1fr; }
  .card-head { flex-direction: column; }
  .actions { flex-direction: column; align-items: stretch; }
  .inline-form { width: 100%; }
  .btn, .actions .btn { width: 100%; text-align: center; }
  .user-pill { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .agent-list-head { display: none; }
  .agent-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem 0.75rem;
    padding: 1rem 1.1rem;
  }
  .agent-row-main { grid-column: 1; }
  .agent-row .pill { grid-column: 1; }
  .agent-row .status-badge { grid-column: 1; }
  .agent-row-procs { grid-column: 1; }
  .agent-row-go { grid-column: 2; grid-row: 1; align-self: start; }
  .agent-row-resumen { white-space: normal; }

  .detail-grid { grid-template-columns: 1fr; }
  .agent-hero, .process-head { flex-direction: column; }
  .agent-hero-meta { justify-content: flex-start; padding-top: 0; }
  .process-toolbar { flex-direction: column; align-items: stretch; }
  .process-toolbar .btn, .process-toolbar .inline-form { width: 100%; }
}

@media (max-width: 560px) {
  .page-head h1 { font-size: 1.25rem; }
  .layout-main { padding: 1rem; }
  .topbar { padding: 0 0.85rem; }
  .status-badge { margin-left: 0; }
}

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero {
    padding: 1.75rem 1.5rem 1.5rem;
    min-height: auto;
  }
  .login-hero h1 { font-size: 1.45rem; }
  .login-points { display: none; }
  .login-hero-foot { display: none; }
  .login-lead { margin-bottom: 0; }
}
