:root {
  --brand: #1f6fb2;
  --brand-dark: #16527f;
  --side-bg: #0f2233;
  --side-fg: #b8c7d6;
  --bg: #f3f5f8;
  --card: #ffffff;
  --line: #e3e8ee;
  --muted: #6b7a89;
  --orange: #e8710a;
  --bs-primary: var(--brand);
}
html, body { height: 100%; }
body { background: var(--bg); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: #1d2a36; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark); --bs-btn-active-bg: var(--brand-dark); }
a { color: var(--brand); }

/* ---- Layout ---- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: 0 0 236px; background: var(--side-bg); color: var(--side-fg); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 1040; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: #fff; text-decoration: none; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar .brand img { width: 34px; height: 34px; border-radius: 8px; background: #fff; }
.sidebar nav { padding: 12px 10px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 2px; color: var(--side-fg); text-decoration: none; border-radius: 8px; }
.sidebar nav a i { width: 18px; text-align: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-foot img { max-width: 120px; opacity: .6; filter: brightness(0) invert(1); }
.sidebar-backdrop { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; display: flex; align-items: center; gap: 10px; padding: 0 22px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020; }
.page-title { font-size: 18px; font-weight: 600; margin: 0; }
.content { padding: 22px; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: -250px; transition: left .2s; }
  body.sb-open .sidebar { left: 0; }
  body.sb-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1030; }
  .content { padding: 14px; }
  .topbar { padding: 0 12px; }
}

/* ---- Cards ---- */
.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; padding: 12px 16px; }
.kpi { padding: 16px; display: flex; flex-direction: row; gap: 14px; align-items: center; height: 100%; }
.kpi .ico { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: 0 0 44px; }
.kpi .val { font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .lbl { color: var(--muted); font-size: 12.5px; }
.kpi.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.kpi.clickable:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,24,40,.08); }
.ico-blue { background: #e6f0fa; color: var(--brand); }
.ico-green { background: #e5f6ec; color: #198754; }
.ico-yellow { background: #fff5d9; color: #b58100; }
.ico-orange { background: #fdeede; color: var(--orange); }
.ico-red { background: #fde7e9; color: #dc3545; }
.ico-gray { background: #eef1f4; color: #5c6b7a; }

/* ---- Badges de estado ---- */
.badge.bg-orange { background: var(--orange) !important; }
.badge.bg-warning { color: #3d2e00; }
.est { font-weight: 600; font-size: 11.5px; padding: 5px 8px; border-radius: 6px; }
.dias { font-variant-numeric: tabular-nums; font-weight: 600; }
.dias.neg { color: #dc3545; }

/* ---- Tablas ---- */
table.dataTable { font-size: 13.5px; }
table.dataTable thead th { font-weight: 600; color: #3b4a58; background: #f8fafc; }
.table > :not(caption) > * > * { padding: .55rem .6rem; }
.dataTables_wrapper .dataTables_filter input { border-radius: 8px; }
tr.clickable-row { cursor: pointer; }

/* Filtros tipo chip */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: #3b4a58; }
.chip .n { background: #eef1f4; border-radius: 999px; padding: 0 7px; margin-left: 4px; font-size: 12px; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.active .n { background: rgba(255,255,255,.25); }

/* ---- Detalle de cliente ---- */
.lic-hero { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; padding: 18px; }
.lic-dias { text-align: center; min-width: 120px; padding: 10px 16px; border-radius: 12px; }
.lic-dias .n { font-size: 38px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.lic-dias .t { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.lic-success { background: #e5f6ec; color: #146c43; }
.lic-warning { background: #fff5d9; color: #8a6300; }
.lic-danger  { background: #fde7e9; color: #b02a37; }
.lic-bar { height: 8px; background: #eef1f4; border-radius: 99px; overflow: hidden; }
.lic-bar > span { display: block; height: 100%; }
.plan-btn { min-width: 150px; text-align: left; }
.plan-btn small { display: block; opacity: .8; font-size: 11.5px; }

.nav-tabs .nav-link { color: #4a5968; }
.nav-tabs .nav-link.active { font-weight: 600; color: var(--brand); }

.mod-grupo { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.mod-grupo h6 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.mod-grupo .form-check { margin-bottom: 2px; }

.cred-box { background: #f8fafc; border: 1px dashed #c9d3dd; border-radius: 10px; padding: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre.code { background: #0f2233; color: #d6e2ee; border-radius: 10px; padding: 14px; font-size: 12.5px; max-height: 360px; overflow: auto; white-space: pre; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #0f2233 0%, #1f6fb2 100%); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card img { height: 40px; }

/* ---- Impresion (ficha de entrega) ---- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}

/* SweetAlert con el color del panel (los botones de peligro traen su color propio) */
body .swal2-popup .swal2-styled.swal2-confirm { background-color: var(--brand); }
body .swal2-popup .swal2-styled.swal2-confirm:focus { box-shadow: 0 0 0 3px rgba(31,111,178,.35); }
