:root {
  --primary: #16A3A6;        /* teal (header / acentos) */
  --primary-dark: #128B8E;
  --secondary: #2E86C1;      /* azul (item activo / botones) */
  --secondary-dark: #2573a7;
  --bg: #EEF2F5;
  --card: #ffffff;
  --text: #34495e;
  --muted: #8a98a5;
  --border: #e6ebef;
  --green: #1ABC9C;
  --yellow: #F4D03F;
  --orange: #EB984E;
  --red: #EC5f6A;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--secondary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===================== LOGIN ===================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), #0c6f72);
}
.login-card {
  background: #fff;
  padding: 40px 34px;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  width: 360px;
  max-width: 92vw;
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .brand { font-size: 26px; font-weight: 800; color: var(--primary); letter-spacing: .5px; }
.login-logo .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ===================== LAYOUT ===================== */
.layout { display: flex; min-height: 100vh; }

/* Sidebar BLANCO estilo Listo */
.sidebar {
  width: var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 30;
  box-shadow: 2px 0 8px rgba(0,0,0,.03);
}
.sidebar .logo {
  padding: 18px 18px;
  font-size: 21px;
  font-weight: 800;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  letter-spacing: .3px;
}
.sidebar .user-box {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sidebar .user-box .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.sidebar .user-box .nm { font-weight: 700; color: var(--text); margin-top: 2px; }
.sidebar nav { padding: 8px 0; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  color: #5a6b7b;
  font-size: 14px;
  border-left: 3px solid transparent;
  font-weight: 600;
}
.sidebar nav a:hover { background: #f3f6f8; color: var(--text); }
.sidebar nav a.active {
  background: var(--secondary);
  color: #fff;
  border-left-color: var(--primary);
}
.sidebar nav a .ic { width: 22px; text-align: center; font-size: 16px; }
.sidebar nav a .chev { margin-left: auto; opacity: .5; font-size: 12px; }
.sidebar nav a.active .chev { opacity: .9; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

/* Topbar TEAL estilo Listo */
.topbar {
  min-height: 56px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar .page-title { font-size: 17px; font-weight: 700; color: #fff; }
.topbar .tb-right { display: flex; align-items: center; gap: 18px; }
.topbar .tb-link { color: rgba(255,255,255,.92); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.topbar .tb-link:hover { color: #fff; }
.topbar .user-info { text-align: right; font-size: 13px; line-height: 1.2; }
.topbar .user-info .name { font-weight: 700; color: #fff; }
.topbar .user-info .ruta { color: rgba(255,255,255,.8); font-size: 11px; }
.content { padding: 22px; }

/* ===================== KPI STRIP (estilo Listo) ===================== */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-chip {
  background: var(--card);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  display: flex;
  align-items: center;
  gap: 12px;
}
.kpi-chip .kpi-ic {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; flex-shrink: 0;
}
.kpi-chip .kpi-ic.teal { background: var(--primary); }
.kpi-chip .kpi-ic.blue { background: var(--secondary); }
.kpi-chip .kpi-ic.green { background: var(--green); }
.kpi-chip .kpi-ic.orange { background: var(--orange); }
.kpi-chip .kpi-ic.red { background: var(--red); }
.kpi-chip .kpi-tx .v { font-size: 19px; font-weight: 800; color: var(--text); line-height: 1.1; }
.kpi-chip .kpi-tx .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }

/* ===================== STAT CARDS (compat) ===================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--card); border-radius: 12px; padding: 18px 20px; box-shadow: 0 2px 8px rgba(0,0,0,.05); border-left: 4px solid var(--primary); }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 26px; font-weight: 800; color: var(--primary); margin-top: 6px; }
.stat-card.green { border-left-color: var(--green); }
.stat-card.yellow { border-left-color: var(--yellow); }
.stat-card.red { border-left-color: var(--red); }

.card { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.05); margin-bottom: 18px; }
.card h3 { font-size: 15px; margin-bottom: 14px; color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 980px){ .grid-2 { grid-template-columns: 1fr; } }

/* ===================== CHART CARD ===================== */
.chart-card { background: var(--card); border-radius: 12px; padding: 18px 20px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.chart-card .chart-title { text-align: center; font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.chart-card .chart-sub { text-align: center; font-size: 20px; font-weight: 800; color: var(--primary); margin-bottom: 14px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-bottom: 14px; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }
.chart-legend .lg .dot { width: 12px; height: 12px; border-radius: 50%; }
.donut-wrap { position: relative; max-width: 320px; margin: 0 auto; }

/* ===================== FORMS ===================== */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #34495e; }
label .req { color: var(--red); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,166,.12); }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; }
.form-section-title { font-size: 14px; font-weight: 700; color: var(--primary); margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.radio-group { display: flex; gap: 16px; align-items: center; }
.radio-group label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.radio-group input { width: auto; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 7px; }
.checkbox-inline input { width: auto; }

/* ===================== BUTTONS ===================== */
.btn { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 600; }
.btn:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-light { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-light:hover { background: #e2e8ec; }
.btn-danger { background: var(--red); }
.btn-success { background: var(--green); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===================== TABLES ===================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f4f7f9; color: #5d6d7e; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:hover { background: #f7fafb; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===================== BADGES ===================== */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-green, .badge-AL_DIA { background: #d3f5ec; color: #138a72; }
.badge-yellow, .badge-ATRASADO { background: #fcf4d2; color: #a98807; }
.badge-red, .badge-VENCIDO { background: #fbdcdf; color: #c0392b; }
.badge-gray, .badge-CANCELADO { background: #eaeef2; color: #5d6d7e; }
.badge-blue, .badge-ACTIVO { background: #d6eaf8; color: #21618c; }
.badge-codigo { background: var(--secondary); color: #fff; }

/* ===================== TABS ===================== */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 10px 18px; cursor: pointer; border: none; background: none; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===================== MODAL ===================== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 760px; max-width: 96vw; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { color: var(--primary); font-size: 17px; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--muted); line-height: 1; }
.modal-body { padding: 22px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===================== HELPERS ===================== */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-box { min-width: 240px; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.money { font-weight: 700; }
.mt { margin-top: 14px; }
.hidden { display: none !important; }
.error-msg { background: #fbdcdf; color: #c0392b; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.success-msg { background: #d3f5ec; color: #138a72; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.spinner { text-align: center; padding: 30px; color: var(--muted); }
.kpi-line { display: flex; gap: 22px; flex-wrap: wrap; margin: 10px 0; }
.kpi-line .kpi { font-size: 13px; }
.kpi-line .kpi b { display: block; font-size: 18px; color: var(--primary); }

/* ===================== FILTER BAR (dashboard) ===================== */
.filter-bar { background: var(--card); border-radius: 12px; padding: 14px 18px; box-shadow: 0 2px 8px rgba(0,0,0,.05); margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filter-bar .fb-item { display: flex; flex-direction: column; gap: 4px; }
.filter-bar .fb-item label { margin: 0; font-size: 12px; color: var(--muted); }
.filter-bar .fb-item select { min-width: 180px; }
.filter-bar .fb-spacer { flex: 1; }

/* ===================== COMPROBANTE / RECIBO ===================== */
.receipt-overlay {
  position: fixed; inset: 0; background: rgba(15,35,55,.55); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.receipt-img { width: 100%; max-width: 380px; max-height: 92vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.receipt-img canvas { width: 100%; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.45); display: block; }
.receipt-img .r-foot { display: flex; flex-direction: column; gap: 10px; }
.btn-wa {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: #25D366; color: #fff; font-size: 15px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-wa:hover { background: #1eb958; }

/* ===================== PRINT ===================== */
@media print {
  .sidebar, .topbar, .toolbar, .filter-bar, .btn, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card, .chart-card { box-shadow: none; border: 1px solid #ddd; }
  body { background: #fff; }
}
