/* =========================================================
   Sistema de Eventuales – RD · Tema claro (único)
   ========================================================= */
:root, [data-bs-theme="light"] {
  color-scheme: light;
  --rd-primary: #1f3652;          /* azul marino (logo) */
  --rd-primary-600: #172a40;
  --rd-primary-050: #eaeff5;
  --rd-accent: #f8d427;           /* amarillo (logo) */
  --rd-accent-600: #c9a800;       /* amarillo oscuro para íconos sobre blanco */
  --rd-accent-050: #fef9e3;
  --rd-bg: #f5f7f9;
  --rd-surface: #ffffff;
  --rd-border: #e3e8ed;
  --rd-text: #1d2a33;
  --rd-muted: #66757f;
  --rd-success: #1f9d61;
  --rd-danger: #d1435b;
  --rd-warning: #c98a12;
  --rd-radius: 12px;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-bg: var(--rd-bg);
  --bs-body-color: var(--rd-text);
  --bs-primary: var(--rd-primary);
  --bs-primary-rgb: 31, 54, 82;
  --bs-link-color: var(--rd-primary);
  --bs-link-color-rgb: 31, 54, 82;
  --bs-link-hover-color: var(--rd-primary-600);
  --bs-border-color: var(--rd-border);
}
/* Nunca tema oscuro, aunque el SO esté en modo oscuro */
@media (prefers-color-scheme: dark) {
  html, body { background: var(--rd-bg) !important; color: var(--rd-text) !important; }
}

html, body { background: var(--rd-bg); color: var(--rd-text); font-size: 14px; }
body { -webkit-font-smoothing: antialiased; }

.btn-primary { --bs-btn-bg: var(--rd-primary); --bs-btn-border-color: var(--rd-primary); --bs-btn-hover-bg: var(--rd-primary-600); --bs-btn-hover-border-color: var(--rd-primary-600); --bs-btn-active-bg: var(--rd-primary-600); --bs-btn-disabled-bg: #8b9aac; --bs-btn-disabled-border-color: #8b9aac; }
.btn-outline-primary { --bs-btn-color: var(--rd-primary); --bs-btn-border-color: var(--rd-primary); --bs-btn-hover-bg: var(--rd-primary); --bs-btn-hover-border-color: var(--rd-primary); --bs-btn-active-bg: var(--rd-primary-600); }
.text-primary { color: var(--rd-primary) !important; }
.bg-primary-soft { background: var(--rd-primary-050) !important; }
.form-control:focus, .form-select:focus { border-color: #8b9aac; box-shadow: 0 0 0 .2rem rgba(248,212,39,.35); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--rd-surface); border-right: 1px solid var(--rd-border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 1040;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 18px 18px 14px; border-bottom: 1px solid var(--rd-border); }
.brand-title { font-weight: 700; color: var(--rd-primary); font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--rd-muted); letter-spacing: .04em; text-transform: uppercase; }
.sidebar .nav { padding: 12px 10px; gap: 2px; overflow-y: auto; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: 10px; color: #3c4a54; border-radius: 9px; padding: 9px 12px; font-weight: 500;
}
.sidebar .nav-link i { font-size: 16px; color: #7d8c96; }
.sidebar .nav-link:hover { background: #f1f5f7; color: var(--rd-text); }
.sidebar .nav-link.active { background: var(--rd-primary-050); color: var(--rd-primary); box-shadow: inset 3px 0 0 var(--rd-accent); }
.sidebar .nav-link.active i { color: var(--rd-primary); }
.sidebar .nav-link.disabled { color: #a8b3ba; cursor: default; }
.sidebar .nav-link.disabled i { color: #c3ccd2; }
.badge-fase { margin-left: auto; font-style: normal; font-size: 10px; background: #f1f4f6; color: #8a979f; padding: 2px 6px; border-radius: 6px; }
.sidebar-foot { margin-top: auto; padding: 12px 18px; font-size: 11px; color: #a0abb2; }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: rgba(255,255,255,.9);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--rd-border); position: sticky; top: 0; z-index: 1030;
}
.page-title { font-size: 18px; font-weight: 600; margin: 0; }
.btn-icon { border: 1px solid var(--rd-border); background: #fff; width: 38px; height: 38px; padding: 0; font-size: 20px; }
.btn-user { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--rd-border); border-radius: 30px; padding: 4px 12px 4px 4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--rd-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.content { padding: 24px 28px; flex: 1; }
.footer { padding: 12px 28px; font-size: 12px; color: var(--rd-muted); border-top: 1px solid var(--rd-border); background: #fff; }

/* ---------- Componentes ---------- */
.card { border: 1px solid var(--rd-border); border-radius: var(--rd-radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--rd-border); padding: 14px 18px; font-weight: 600; border-radius: var(--rd-radius) var(--rd-radius) 0 0 !important; }
.card-body { padding: 18px; }
.kpi { padding: 16px 18px; }
.kpi .kpi-label { font-size: 12px; color: var(--rd-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi .kpi-value { font-size: 24px; font-weight: 700; margin-top: 4px; color: var(--rd-text); }
.kpi .kpi-icon { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--rd-primary-050); color: var(--rd-primary); font-size: 19px; }
.kpi .kpi-sub { font-size: 12px; color: var(--rd-muted); }

.table { --bs-table-bg: #fff; margin-bottom: 0; }
.table > thead th { background: #f7f9fa; color: #4c5b65; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--rd-border); white-space: nowrap; }
.table td, .table th { vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f5f7fa; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td, .table tfoot th { background: #eef1f6; font-weight: 700; border-top: 2px solid var(--rd-accent); }
.badge-soft { background: var(--rd-primary-050); color: var(--rd-primary); font-weight: 600; }
.badge-warn { background: #fff4dc; color: #8a5d00; font-weight: 600; }
.badge-danger-soft { background: #fde8ec; color: #a32a40; font-weight: 600; }
.badge-ok { background: #e3f6ec; color: #13774a; font-weight: 600; }
.badge-muted { background: #eef1f3; color: #66757f; font-weight: 600; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: #f2f5f7; padding: 1px 6px; border-radius: 5px; }

/* Carga de archivo */
.dropzone {
  border: 2px dashed #c3ccd8; border-radius: 14px; background: #fcfdfe; padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all .15s ease;
}
.dropzone:hover, .dropzone.drag { background: var(--rd-accent-050); border-color: var(--rd-accent); }
.dropzone i { font-size: 42px; color: var(--rd-accent-600); }
.step { display: flex; align-items: center; gap: 8px; color: #9aa7af; font-weight: 500; }
.step .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #cfd8dd; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.step.on { color: var(--rd-primary); } .step.on .dot { border-color: var(--rd-primary); background: var(--rd-primary); color: #fff; }
.step.done { color: var(--rd-success); } .step.done .dot { border-color: var(--rd-success); background: var(--rd-success); color: #fff; }
.steps-line { flex: 1; height: 2px; background: #e3e8ed; min-width: 20px; }
tr.req-map > td { background: #fffaf0 !important; }


/* ---------- Reportes ---------- */
.rep-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.rep-main { min-width: 0; }
@media (min-width: 992px) { .rep-layout { grid-template-columns: 230px minmax(0, 1fr); } }
.table-rep > :not(caption) > * > * { padding: .5rem .55rem; }
.areas-list .list-group-item { border-color: var(--rd-border); padding: 9px 14px; font-size: 13.5px; }
.areas-list .list-group-item.active { background: var(--rd-primary); border-color: var(--rd-primary); }
.areas-list .list-group-item.active .text-muted { color: #d6dde6 !important; }
.areas-list .list-group-item.sin-datos { color: #a3afb6; }
.rep-titulo { padding: 18px 20px 12px; border-bottom: 1px solid var(--rd-border); }
.rep-titulo h2 { font-size: 17px; font-weight: 700; color: var(--rd-primary); margin: 0; letter-spacing: .02em; }
.rep-fecha { color: var(--rd-muted); font-size: 13px; margin-top: 2px; }
.table-rep td { font-size: 13px; }
.table-rep > thead th { white-space: normal; vertical-align: bottom; line-height: 1.2; }
.table-rep > tbody > tr:not(.fila-desglose) > td:nth-child(2) { min-width: 210px; }
.table-rep > tfoot td:nth-child(2) { white-space: nowrap; }
.table-rep > tbody > tr > td:first-child { white-space: nowrap; }
.text-cero { color: #c3ccd2; }
.fila-vacia td { color: #a3afb6; }
.fila-dif > td { background: #fffbef !important; }
.btn-desg { border: 0; background: transparent; padding: 0 4px 0 0; color: var(--rd-primary); line-height: 1; }
.btn-desg i { display: inline-block; transition: transform .15s; }
.btn-desg.abierto i { transform: rotate(90deg); }
.fila-desglose > td { background: #f8f9fb !important; padding-top: 0; }
.tabla-desglose { --bs-table-bg: transparent; font-size: 12px; }
.tabla-desglose th { font-size: 10.5px !important; background: transparent !important; }
.tabla-labores { font-size: 12.5px; }
.mini { border: 1px solid var(--rd-border); border-radius: 10px; padding: 10px 12px; background: #fbfcfd; height: 100%; }
.mini span { display: block; font-size: 11.5px; color: var(--rd-muted); }
.mini b { font-size: 18px; }
.print-head, .print-foot, .print-firmas { display: none; }

/* Dashboard */
.var { display: flex; justify-content: space-between; font-size: 11.5px; padding: 2px 0; border-top: 1px dashed #edf1f3; }
.var-lbl { color: var(--rd-muted); }
.var-val { font-weight: 600; white-space: nowrap; }
.var-buena .var-val { color: var(--rd-success); }
.var-mala .var-val { color: var(--rd-danger); }
.var-igual .var-val { color: var(--rd-muted); }
.var-na { color: #b4bec5; }
.chart-box { position: relative; height: 280px; }
.chart-box.chart-sm { height: 230px; }
.dn-barra { display: flex; height: 22px; border-radius: 6px; overflow: hidden; gap: 2px; background: #fff; }
.dn-d { background: var(--rd-accent); border-radius: 4px 0 0 4px; }
.dn-n { background: var(--rd-primary); border-radius: 0 4px 4px 0; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-d { background: var(--rd-accent); } .sw-n { background: var(--rd-primary); }
.tarifas-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 575.98px) { .tarifas-grid { grid-template-columns: 1fr; } }
.tarifa-mini { border: 1px solid var(--rd-border); border-radius: 10px; padding: 8px 10px 4px; }
.tm-head { display: flex; align-items: baseline; gap: 6px; font-size: 12px; }
.tm-nom { color: var(--rd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; font-size: 11px; }
.tm-val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tm-box { position: relative; height: 96px; }
.lab-checks { columns: 2; max-height: 220px; overflow: auto; }
@media (max-width: 575.98px) { .tarifas-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 575.98px) { .tarifas-grid { grid-template-columns: 1fr; } }
.tarifa-mini { border: 1px solid var(--rd-border); border-radius: 10px; padding: 8px 10px 4px; }
.tm-head { display: flex; align-items: baseline; gap: 6px; font-size: 12px; }
.tm-nom { color: var(--rd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; font-size: 11px; }
.tm-val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tm-box { position: relative; height: 96px; }
.lab-checks { columns: 1; } }
.filtros .form-select, .filtros .form-control { min-width: 140px; }

/* Calendario */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-h { font-size: 11px; font-weight: 600; color: var(--rd-muted); text-align: center; text-transform: uppercase; }
.cal-d { min-height: 64px; border: 1px solid var(--rd-border); border-radius: 9px; padding: 6px 8px; background: #fff; display: flex; flex-direction: column; color: #b4bec5; text-decoration: none; }
.cal-d.vacio { border: 0; background: transparent; }
.cal-d.hoy { border-color: #9fd0d3; }
.cal-d.con-datos { background: var(--rd-primary-050); border-color: #b9dcde; color: var(--rd-text); }
.cal-d.con-datos:hover { border-color: var(--rd-accent); }
.cal-d.sel { background: var(--rd-primary); color: #fff; border-color: var(--rd-primary); }
.cal-d.sel .cal-p { color: var(--rd-accent); }
.cal-n { font-weight: 600; font-size: 13px; }
.cal-v { font-size: 12px; font-weight: 600; margin-top: auto; }
.cal-p { font-size: 11px; color: var(--rd-muted); }
@media (max-width: 575.98px) { .cal-v, .cal-p { display: none; } .cal-d { min-height: 40px; } }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, #fdf6d3 0, transparent 45%), radial-gradient(circle at 90% 90%, #e6ecf4 0, transparent 40%), var(--rd-bg); }
.login-card { width: 100%; max-width: 410px; background: #fff; border: 1px solid var(--rd-border); border-radius: 18px; box-shadow: 0 12px 40px rgba(31,54,82,.10); padding: 34px; }

.list-group { --bs-list-group-active-bg: var(--rd-primary); --bs-list-group-active-border-color: var(--rd-primary); }
.nav-pills { --bs-nav-pills-link-active-bg: var(--rd-primary); --bs-nav-link-color: var(--rd-primary); --bs-nav-link-hover-color: var(--rd-primary-600); }

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.08); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(20,30,40,.25); z-index: 1035; }
  .content { padding: 16px; }
  .kpi .kpi-value { font-size: 19px; }
  .kpi .kpi-icon { width: 32px; height: 32px; font-size: 16px; }
  .topbar { padding: 10px 16px; }
  .footer { padding: 10px 16px; }
}

/* Impresión */
@media print {
  @page { size: A4 portrait; margin: 12mm 10mm; }
  .sidebar, .topbar, .footer, .no-print, .btn, .alert, .collapse { display: none !important; }
  .content { padding: 0; }
  body, html { background: #fff !important; font-size: 11px; }
  .card { border: none; box-shadow: none; }
  .rep-layout { display: block; }
  .row > [class*="col-xl-8"] { width: 100% !important; flex: 0 0 100%; max-width: 100%; }
  .table-rep > thead th { font-size: 9px !important; }
  .table-rep > tbody > tr > td:nth-child(2) { white-space: nowrap; min-width: 0 !important; }
  .table-responsive { overflow: visible !important; }
  .table-rep td, .table-rep th { padding: 3px 5px !important; font-size: 10.5px; }
  .table-rep thead th { background: #eaeff5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-rep tfoot td { background: #eaeff5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-head { display: flex; justify-content: space-between; font-size: 10px; border-bottom: 2px solid #1f3652; padding-bottom: 6px; margin-bottom: 4px; }
  .print-foot { display: block; font-size: 9px; color: #666; margin-top: 10px; }
  .print-firmas { display: flex !important; gap: 28px; margin-top: 56px; page-break-inside: avoid; font-size: 10px; text-align: center; }
  .print-firmas > div { flex: 1; }
  .print-firmas .linea { display: block; border-top: 1px solid #222; margin-bottom: 4px; }
  .table-rep thead { display: table-header-group; }
  .rep-titulo { padding: 6px 0; text-align: center; }
  .fila-desglose.d-none { display: none !important; }
  a { color: inherit !important; text-decoration: none !important; }
}
