/* ============================================================
   AdminHost — estilos del panel (v1)
   Se carga encima de Bootstrap 5.3. Cambiando las variables de :root
   se cambia el aspecto de todo el sistema.
   ============================================================ */
:root {
  --ah-primary: #16425b;
  --ah-primary-700: #0f3043;
  --ah-primary-50: #eaf1f5;
  --ah-accent: #1f8a8a;
  --ah-accent-50: #e6f4f3;
  --ah-warm: #f4a53a;
  --ah-bg: #f4f6fa;
  --ah-surface: #ffffff;
  --ah-border: #e5e9f0;
  --ah-text: #15222d;
  --ah-muted: #6a7a8c;
  --ah-radius: 14px;
  --ah-radius-sm: 10px;
  --ah-shadow: 0 1px 2px rgba(16, 32, 48, .04), 0 4px 16px rgba(16, 32, 48, .05);
  --ah-shadow-lg: 0 12px 40px rgba(16, 32, 48, .14);
  --ah-sb-w: 264px;
  --ah-top-h: 64px;
  --ah-bottom-h: 66px;

  --bs-primary: #16425b;
  --bs-primary-rgb: 22, 66, 91;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-color: var(--ah-text);
  --bs-body-bg: var(--ah-bg);
  --bs-secondary-color: var(--ah-muted);
  --bs-border-color: var(--ah-border);
  --bs-border-radius: var(--ah-radius-sm);
  --bs-border-radius-lg: var(--ah-radius);
  --bs-link-color: #1a6d8f;
  --bs-link-color-rgb: 26, 109, 143;
  --bs-link-hover-color: var(--ah-primary);
}

body { font-family: var(--bs-body-font-family); color: var(--ah-text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, .fw-bold { letter-spacing: -.01em; }
.text-muted { color: var(--ah-muted) !important; }
a { text-decoration: none; }

/* ---------- Botones ---------- */
.btn { border-radius: var(--ah-radius-sm); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { border-radius: 8px; }
.btn-primary {
  --bs-btn-bg: var(--ah-primary); --bs-btn-border-color: var(--ah-primary);
  --bs-btn-hover-bg: var(--ah-primary-700); --bs-btn-hover-border-color: var(--ah-primary-700);
  --bs-btn-active-bg: var(--ah-primary-700); --bs-btn-active-border-color: var(--ah-primary-700);
  --bs-btn-disabled-bg: var(--ah-primary); --bs-btn-disabled-border-color: var(--ah-primary);
  box-shadow: 0 2px 6px rgba(22, 66, 91, .25);
}
.btn-outline-primary {
  --bs-btn-color: var(--ah-primary); --bs-btn-border-color: #b9cad6;
  --bs-btn-hover-bg: var(--ah-primary); --bs-btn-hover-border-color: var(--ah-primary);
  --bs-btn-active-bg: var(--ah-primary-700);
}
.btn-outline-secondary { --bs-btn-color: #44566a; --bs-btn-border-color: var(--ah-border); --bs-btn-hover-bg: #eef1f6; --bs-btn-hover-color: var(--ah-text); --bs-btn-hover-border-color: #d5dbe4; background: #fff; }
.btn-success { --bs-btn-bg: #1f8a5b; --bs-btn-border-color: #1f8a5b; --bs-btn-hover-bg: #187049; --bs-btn-hover-border-color: #187049; }
.btn-ah, .btn-accent { background: var(--ah-accent); border-color: var(--ah-accent); color: #fff; }
.btn-ah:hover, .btn-accent:hover { background: #176f6f; border-color: #176f6f; color: #fff; }

/* ---------- Tarjetas ---------- */
.card { border: 1px solid var(--ah-border); border-radius: var(--ah-radius); box-shadow: var(--ah-shadow); background: var(--ah-surface); }
.card.shadow-sm, .card.shadow { box-shadow: var(--ah-shadow) !important; }
.card-header { background: #fff; border-bottom: 1px solid var(--ah-border); padding: .9rem 1.1rem; font-weight: 600; }
.card-header:first-child { border-radius: var(--ah-radius) var(--ah-radius) 0 0; }
.card-body { padding: 1.1rem; }
.card-footer { background: #fafbfd; border-top: 1px solid var(--ah-border); }

/* ---------- Formularios ---------- */
.form-control, .form-select { border-color: #d8dee7; border-radius: var(--ah-radius-sm); padding: .55rem .8rem; }
.form-control-sm, .form-select-sm { border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: var(--ah-accent); box-shadow: 0 0 0 .2rem rgba(31, 138, 138, .15); }
.form-label { font-weight: 600; font-size: .85rem; color: #33475b; margin-bottom: .35rem; }
.form-check-input:checked { background-color: var(--ah-accent); border-color: var(--ah-accent); }
.input-group-text { background: #f6f8fb; border-color: #d8dee7; }

/* ---------- Tablas ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ah-muted); font-weight: 600; background: #f8fafc; border-bottom: 1px solid var(--ah-border); white-space: nowrap; padding: .7rem .75rem; }
.table > tbody td { padding: .75rem; border-color: #eef1f5; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f6f9fb; }

/* ---------- Varios ---------- */
.badge { font-weight: 600; border-radius: 999px; padding: .38em .7em; }
.list-group-item { border-color: #eef1f5; padding: .8rem 1.1rem; }
.list-group-item-action:hover { background: #f6f9fb; }
.alert { border-radius: var(--ah-radius-sm); border: none; }
.dropdown-menu { border: 1px solid var(--ah-border); border-radius: 12px; box-shadow: var(--ah-shadow-lg); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; }
.modal-content { border: none; border-radius: 18px; box-shadow: var(--ah-shadow-lg); }
.nav-tabs .nav-link, .nav-pills .nav-link { font-weight: 600; }
.nav-pills .nav-link.active { background: var(--ah-primary); }
.pagination .page-link { border-radius: 8px !important; margin: 0 2px; }

/* ============================================================
   Estructura del panel: barra lateral + barra superior + barra inferior (móvil)
   ============================================================ */
body:has(.ah-sidebar) { padding-left: var(--ah-sb-w); background: var(--ah-bg); }

.ah-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--ah-sb-w); z-index: 1045;
  background: linear-gradient(180deg, #123a51 0%, #0e2f42 100%); color: #cfe0ea;
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.ah-sb-head { height: var(--ah-top-h); display: flex; align-items: center; justify-content: space-between; padding: 0 1.1rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.ah-brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.ah-brand img.ah-logo { height: 46px; width: 46px; background: #fff; border-radius: 50%; padding: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.3); object-fit: contain; }
.ah-brand span { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; }
.ah-sb-close { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; line-height: 1; }

.ah-sb-negocio { display: flex; align-items: center; gap: .7rem; margin: 1rem .9rem .4rem; padding: .7rem; border-radius: 12px; background: rgba(255,255,255,.06); }
.ah-avatar { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--ah-accent); color: #fff; flex-shrink: 0; }
.ah-sb-negocio .nom { color: #fff; font-weight: 600; font-size: .9rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.ah-sb-negocio a { color: #8fd3cf; font-size: .78rem; }

.ah-sb-nav { flex: 1; overflow-y: auto; padding: .4rem .7rem 1rem; }
.ah-sb-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #7f9db0; padding: 1rem .7rem .4rem; font-weight: 600; }
.ah-sb-link { display: flex; align-items: center; gap: .75rem; padding: .58rem .75rem; border-radius: 10px; color: #cfe0ea; font-weight: 500; font-size: .92rem; margin-bottom: 2px; }
.ah-sb-link i { font-size: 1.1rem; width: 1.2rem; text-align: center; opacity: .85; }
.ah-sb-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.ah-sb-link.active { background: #fff; color: var(--ah-primary); font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.ah-sb-link.active i { color: var(--ah-accent); opacity: 1; }
.ah-sb-link .ah-pill { margin-left: auto; background: var(--ah-warm); color: #3b2500; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: .1rem .5rem; }

.ah-sb-foot { padding: .8rem .9rem 1rem; border-top: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.ah-lang { display: inline-flex; background: rgba(255,255,255,.08); border-radius: 8px; padding: 2px; }
.ah-lang a { color: #a9c3d2; font-size: .75rem; font-weight: 700; padding: .25rem .55rem; border-radius: 6px; }
.ah-lang a.on { background: #fff; color: var(--ah-primary); }
.ah-sb-salir { color: #cfe0ea; font-size: .85rem; font-weight: 500; }
.ah-sb-salir:hover { color: #fff; }

.ah-overlay { display: none; }

.ah-topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--ah-top-h);
  display: flex; align-items: center; gap: .8rem; padding: 0 1.5rem; margin-bottom: 1.5rem;
  background: rgba(255,255,255,.88); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--ah-border);
}
.ah-burger { display: none; border: 0; background: #f1f4f8; width: 40px; height: 40px; border-radius: 10px; font-size: 1.35rem; color: var(--ah-primary); }
.ah-top-title { font-weight: 700; font-size: 1.08rem; color: var(--ah-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ah-top-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.ah-icon-btn { width: 40px; height: 40px; border-radius: 10px; align-items: center; justify-content: center; color: #44566a; background: transparent; border: 1px solid var(--ah-border); font-size: 1.1rem; }
.ah-icon-btn:hover { background: #f1f4f8; color: var(--ah-primary); }

.ah-user { position: relative; }
.ah-user summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; padding: .25rem .4rem .25rem .25rem; border-radius: 12px; border: 1px solid var(--ah-border); background: #fff; }
.ah-user summary::-webkit-details-marker { display: none; }
.ah-user summary .ah-avatar { width: 32px; height: 32px; border-radius: 9px; font-size: .85rem; background: var(--ah-primary); }
.ah-user summary .u { font-size: .85rem; font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ah-user-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: #fff; border: 1px solid var(--ah-border); border-radius: 14px; box-shadow: var(--ah-shadow-lg); padding: .4rem; z-index: 1050; }
.ah-user-menu a { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 9px; color: var(--ah-text); font-size: .9rem; }
.ah-user-menu a:hover { background: #f3f6f9; }
.ah-user-menu hr { margin: .35rem 0; border-color: var(--ah-border); opacity: 1; }
.ah-user-menu .ah-lang { background: #f1f4f8; margin: .3rem .7rem; }
.ah-user-menu .ah-lang a { color: #55687b; padding: .25rem .7rem; }
.ah-user-menu .ah-lang a.on { background: var(--ah-primary); color: #fff; }

.ah-strip { text-align: center; font-size: .82rem; font-weight: 600; padding: .45rem 1rem; }
.ah-strip .btn { padding: .1rem .6rem; font-size: .78rem; margin-left: .5rem; }
.ah-strip-sa { background: #1d2833; color: #fff; }
.ah-strip-partner { background: #5a3e8f; color: #fff; }
.ah-strip-demo { background: #ffe9a8; color: #5a4500; }

.ah-bottomnav { display: none; }

/* ---------- Encabezado de página y KPIs (reutilizables) ---------- */
.ah-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.ah-page-head h1 { font-size: 1.55rem; font-weight: 800; margin: 0; }
.ah-page-head p { margin: .2rem 0 0; color: var(--ah-muted); }
.ah-kpi { padding: 1.1rem 1.15rem; height: 100%; display: flex; flex-direction: column; gap: .35rem; }
.ah-kpi-top { display: flex; align-items: center; justify-content: space-between; }
.ah-kpi-label { font-size: .8rem; color: var(--ah-muted); font-weight: 600; }
.ah-kpi-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 1.1rem; }
.ah-kpi-val { font-size: 1.55rem; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.ah-kpi-val small { font-size: .95rem; font-weight: 700; color: #44566a; display: block; }
.ah-kpi-sub { font-size: .78rem; color: var(--ah-muted); }
.ah-ico-blue { background: #e8f1f7; color: #1a6d8f; }
.ah-ico-green { background: #e5f5ec; color: #1f8a5b; }
.ah-ico-amber { background: #fff3df; color: #c47a0a; }
.ah-ico-red { background: #fdeceb; color: #c8433a; }
.ah-ico-teal { background: var(--ah-accent-50); color: var(--ah-accent); }
.ah-empty { text-align: center; padding: 1.6rem 1rem; color: var(--ah-muted); font-size: .9rem; }
.ah-empty i { font-size: 1.8rem; display: block; margin-bottom: .35rem; color: #b7c3cf; }

/* ---------- Tablas como tarjetas en el celular ---------- */
@media (max-width: 767.98px) {
  .table-mobile-cards thead, .table-stack thead { display: none; }
  .table-mobile-cards, .table-mobile-cards tbody, .table-mobile-cards tr, .table-mobile-cards td,
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-mobile-cards tr, .table-stack tr { background: #fff; border: 1px solid var(--ah-border); border-radius: 12px; margin: 0 0 .7rem; padding: .35rem .2rem; box-shadow: var(--ah-shadow); }
  .table-mobile-cards td, .table-stack td { border: 0 !important; padding: .35rem .8rem !important; display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: right; }
  .table-mobile-cards td::before, .table-stack td::before { content: attr(data-label); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ah-muted); text-align: left; flex-shrink: 0; }
  .table-mobile-cards td[data-label=""]::before, .table-stack td[data-label=""]::before { content: none; }
  .table-mobile-cards td[data-label=""], .table-stack td[data-label=""] { justify-content: flex-end; }
  .card:has(> .table-responsive > .table-mobile-cards), .card:has(> .table-mobile-cards) { background: transparent; border: 0; box-shadow: none; }
}

/* ---------- Responsive de la estructura ---------- */
@media (max-width: 991.98px) {
  body:has(.ah-sidebar) { padding-left: 0; padding-bottom: calc(var(--ah-bottom-h) + env(safe-area-inset-bottom)); }
  .ah-sidebar { transform: translateX(-102%); box-shadow: var(--ah-shadow-lg); width: min(84vw, 300px); }
  body.ah-sb-open .ah-sidebar { transform: none; }
  body.ah-sb-open { overflow: hidden; }
  .ah-sb-close { display: block; }
  .ah-overlay { position: fixed; inset: 0; background: rgba(10, 25, 35, .45); z-index: 1040; }
  body.ah-sb-open .ah-overlay { display: block; }
  .ah-burger { display: inline-grid; place-items: center; }
  .ah-topbar { padding: 0 .9rem; margin-bottom: 1rem; }
  .ah-user summary .u { display: none; }

  .ah-bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
    background: #fff; border-top: 1px solid var(--ah-border); box-shadow: 0 -4px 18px rgba(16, 32, 48, .06);
    padding-bottom: env(safe-area-inset-bottom); height: calc(var(--ah-bottom-h) + env(safe-area-inset-bottom));
  }
  .ah-bottomnav a, .ah-bottomnav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .68rem; font-weight: 600; color: #7a8a9b; background: none; border: 0; position: relative; }
  .ah-bottomnav i { font-size: 1.3rem; }
  .ah-bottomnav .active { color: var(--ah-primary); }
  .ah-bottomnav .active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--ah-accent); }
  .ah-bottomnav .ah-dot { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 16px; height: 16px; border-radius: 999px; background: var(--ah-warm); color: #3b2500; font-size: .62rem; display: grid; place-items: center; padding: 0 4px; }
  .ah-page-head h1 { font-size: 1.3rem; }
}
@media (max-width: 575.98px) {
  .container { padding-left: .9rem; padding-right: .9rem; }
  .ah-kpi-val { font-size: 1.3rem; }
  .card-body { padding: .95rem; }
}

@media print {
  body:has(.ah-sidebar) { padding: 0 !important; background: #fff; }
  .ah-sidebar, .ah-topbar, .ah-bottomnav, .ah-overlay, .ah-strip { display: none !important; }
  .card { box-shadow: none; }
}

/* ---------- Páginas heredadas (encabezados) ---------- */
.page-header-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--ah-accent-50); color: var(--ah-accent); font-size: 1.3rem; flex-shrink: 0; }
.container > .d-flex h4.fw-bold, .container > div > h4.fw-bold { font-weight: 800; font-size: 1.4rem; }
.table-responsive { border-radius: var(--ah-radius); }
.btn-group .btn { box-shadow: none; }
