/* ==========================================================================
   YCOS - Panel de administración
   Paleta de la marca (azul marino + azul YCOS). Sencillo a propósito: una barra lateral oscura, contenido claro,
   tarjetas blancas y un solo color de acento.
   ========================================================================== */
:root {
  --navy: #070d1f;
  --navy-2: #0d1630;
  --accent: #3b6bff;
  --accent-dark: #2a55e0;
  --accent-soft: #e9efff;
  --bg: #f4f6fb;
  --card: #fff;
  --ink: #0d1630;
  --muted: #5d6a8a;
  --line: #e3e8f3;
  --ok: #0f7d57;
  --ok-soft: #e1f6ee;
  --warn: #8a5a00;
  --warn-soft: #fff3cd;
  --danger: #c0264a;
  --danger-soft: #fdecef;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(13 22 48 / 0.05), 0 8px 24px rgb(13 22 48 / 0.06);
  --sidebar-w: 248px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body.admin-body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 0.9rem; cursor: pointer; line-height: 1.2;
  transition: background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-outline { background: #fff; border-color: var(--line); }
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.btn-danger { background: #fff; border-color: #f2c4cf; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-dark); font-weight: 700; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Estructura ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.admin-main { flex: 1; min-width: 0; }
.admin-content { padding: 28px; max-width: 1180px; }

.admin-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 20px 14px; background: var(--navy); color: #fff;
}
.admin-brand { padding: 4px 10px 22px; }
.admin-brand img { display: block; width: 104px; height: auto; }
.admin-brand small { display: block; margin-top: 6px; color: #9aa6c5; font-size: 0.78rem; font-weight: 600; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.admin-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #c9d2ea; font-weight: 600; font-size: 0.92rem;
}
.admin-nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.admin-nav a:hover { background: rgb(255 255 255 / 0.07); color: #fff; }
.admin-nav a.active { background: var(--accent); color: #fff; }
.admin-nav .nav-sep { height: 1px; margin: 10px 8px; background: rgb(255 255 255 / 0.1); }
.admin-logout-btn {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left;
  background: none; border: 1px solid rgb(255 255 255 / 0.18); color: #fff; font-weight: 600; font-size: 0.9rem;
}
.admin-logout-btn:hover { background: rgb(255 255 255 / 0.07); }

.admin-topbar {
  height: 62px; padding: 0 28px; position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.admin-user { display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; font-weight: 700; font-size: 0.9rem; }
.admin-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--navy); color: #fff; font-size: 0.8rem; font-weight: 800;
}
.admin-user .who { min-width: 0; line-height: 1.2; }
.admin-user .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-user .who span { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.mobile-sidebar-toggle { display: none; background: none; border: 0; padding: 10px; margin-left: -10px; border-radius: 10px; cursor: pointer; }
.mobile-sidebar-toggle svg { width: 24px; height: 24px; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 55; background: rgb(7 13 31 / 0.55); }
body.sidebar-open { overflow: hidden; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.01em; }
.page-subtitle { margin-top: 2px; color: var(--muted); font-size: 0.93rem; }
.back-link { display: inline-block; margin-bottom: 10px; color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.back-link:hover { color: var(--accent-dark); }

@media (max-width: 900px) {
  .admin-sidebar { position: fixed; z-index: 60; left: 0; transform: translateX(-100%); transition: transform 0.25s ease; width: min(var(--sidebar-w), 86vw); }
  .admin-sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .admin-nav a { padding: 13px 12px; }
  .mobile-sidebar-toggle { display: block; }
  .admin-topbar { padding: 0 16px; }
  .admin-content { padding: 20px 16px 40px; }
}
@media (prefers-reduced-motion: reduce) { .admin-sidebar { transition: none; } }

/* ---------- Tarjetas, métricas ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 18px; }
.card h2 { font-size: 1.05rem; font-weight: 800; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; border-top: 3px solid var(--accent); }
.stat--warn { border-top-color: #e0a100; }
.stat--danger { border-top-color: var(--danger); }
.stat--ok { border-top-color: var(--ok); }
.stat__label { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.stat__value { margin-top: 4px; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat__note { margin-top: 4px; color: var(--muted); font-size: 0.8rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } .grid-2 > .card + .card { margin-top: 0; } }

/* ---------- Barra de herramientas y tablas ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar input, .toolbar select {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; min-width: 0;
}
.toolbar input[type="search"] { flex: 1 1 240px; max-width: 360px; }
.table-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover td { background: #f8faff; }
.table .cell-main { font-weight: 700; }
.table .cell-sub { color: var(--muted); font-size: 0.8rem; }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table-empty { text-align: center; color: var(--muted); padding: 34px 16px !important; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
.pager div { display: flex; gap: 8px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; background: #eef1f8; color: var(--muted); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- Formularios ---------- */
.form-group { margin-bottom: 14px; }
.form-group label, .form-label { display: block; margin-bottom: 5px; font-weight: 700; font-size: 0.85rem; }
.form-group input:not([type="checkbox"]), .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #cfd7e8; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.form-group input:disabled, .form-group select:disabled, .form-group textarea:disabled { background: #f4f6fb; color: var(--muted); }
.form-group textarea { min-height: 84px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }
.form-hint { margin-top: 4px; font-size: 0.78rem; color: var(--muted); }
.checkbox-label { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 0.9rem; }
.checkbox-label input { width: 18px; height: 18px; accent-color: var(--accent); }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 0.88rem; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f6c4cf; }
.alert-info { background: var(--accent-soft); color: #1d3f9e; border: 1px solid #cdd9ff; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0dc8a; }

/* ---------- Modal y avisos ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgb(7 13 31 / 0.55); }
.modal-box { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 20px 60px rgb(7 13 31 / 0.35); }
.modal-box.modal-wide { max-width: 680px; }
.modal-box h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.toast-stack { position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast-alert {
  max-width: 100%; opacity: 0; transform: translateY(12px);
  padding: 12px 18px; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast-alert.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); }
@media (prefers-reduced-motion: reduce) { .toast-alert { transition: none; } }

.secret-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--navy); color: #fff; }
.secret-box code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.05rem; letter-spacing: 0.04em; word-break: break-all; }

/* ---------- Detalle de sitio ---------- */
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 0.92rem; }
.detail-list dt { color: var(--muted); font-weight: 700; }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.module-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.module-row:last-child { border-bottom: 0; }
.module-row small { display: block; color: var(--muted); font-size: 0.78rem; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-slider { position: absolute; inset: 0; border-radius: 999px; background: #c3cbe0; transition: background 0.2s ease; }
.switch-slider::before { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.2s ease; }
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }
.switch input:focus-visible + .switch-slider { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .switch-slider { opacity: 0.5; }
@media (prefers-reduced-motion: reduce) { .switch-slider, .switch-slider::before { transition: none; } }

.role-card { padding: 12px 0; border-bottom: 1px solid var(--line); }
.role-card:last-child { border-bottom: 0; }
.role-card strong { display: block; }
.role-card ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.84rem; }

.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.activity-item:last-child { border-bottom: 0; }
.activity-item time { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }

/* ---------- Ingreso ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--navy); }
.login-card { width: 100%; max-width: 400px; padding: 34px; border-radius: 18px; background: #fff; box-shadow: 0 20px 60px rgb(0 0 0 / 0.35); }
.login-brand { background: var(--navy); border-radius: 12px; padding: 16px 20px; margin-bottom: 22px; }
.login-brand img { display: block; height: 40px; width: auto; }
.login-card h1 { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.login-lead { margin-bottom: 22px; color: var(--muted); font-size: 0.9rem; }
.pw-field { position: relative; }
.pw-field input { padding-right: 76px !important; }
.pw-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--accent-dark); font-weight: 700; font-size: 0.8rem; cursor: pointer; }
.pw-toggle:hover { background: var(--accent-soft); }
@media (max-width: 480px) { .login-wrap { align-items: flex-start; padding: 14px; } .login-card { margin-top: 5vh; padding: 24px 20px; } }

/* ---- Utilidades de las páginas (sin estilos en línea, para poder usar una CSP estricta) ---- */
.modal-intro { margin-bottom: 14px; }
.mt-12 { margin-top: 12px; }
.sub-title { font-size: 0.95rem; margin: 6px 0 8px; }
.sub-title--spaced { margin: 14px 0 4px; }
.card--spaced { margin-top: 18px; }
.table-card--flat { box-shadow: none; }
.table-card--tight { margin-top: 6px; }
.table--compact { min-width: 0; }
.form-hint--tight { margin: -8px 0 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row--spaced { margin: 14px 0; }
.roles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.role-item ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.84rem; }
.role-item li { margin-bottom: 2px; }
.account-grid { max-width: 560px; }

.page-title:focus { outline: none; } /* el título recibe el foco solo para anunciar el cambio de sección */
