:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #14532d;
  --accent2: #166534;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header { background: var(--accent); color: #fff; padding: 18px 24px; }
header h1 { margin: 0; font-size: 22px; }
header .sub { margin: 4px 0 0; color: #cbd5c0; font-size: 13px; }
main { padding: 20px; max-width: 1150px; margin: 0 auto; }

.filtro {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 18px;
}
.filtro label { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.filtro input[type=date] { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.filtro > button, .dropbtn {
  background: var(--accent2); color: #fff; border: 0; padding: 8px 18px;
  border-radius: 6px; font-size: 14px; cursor: pointer;
}
.dropbtn { padding: 8px 12px; }
.filtro > button:hover, .dropbtn:hover { background: var(--accent); }
.estado { font-size: 13px; color: var(--muted); }
.estado.error { color: #b91c1c; }

/* Dropdown multiseleccion de paises */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: 110%; left: 0; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  padding: 8px; min-width: 220px; max-height: 320px; overflow: auto;
}
.drop-actions { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.drop-actions a { color: var(--accent2); text-decoration: none; }
.chk { display: block; font-size: 14px; padding: 4px 6px; border-radius: 4px; cursor: pointer; color: var(--ink); }
.chk:hover { background: #f0f7f2; }
.chk input { margin-right: 6px; }

.hidden { display: none !important; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.card .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card .v { font-size: 22px; font-weight: 700; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 10px; font-size: 15px; color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.small { font-size: 12px; color: var(--muted); }
.nota { margin: 8px 0 0; line-height: 1.45; }

.hdr { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.hdr-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
#btn-logout { background: #0f3d24; color: #fff; border: 1px solid #cbd5c0; padding: 6px 12px; border-radius: 6px; cursor: pointer; }

.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0;
  background: linear-gradient(135deg, #14532d 0%, #166534 55%, #0f3d24 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 32px 34px;
  width: 340px; max-width: 92vw;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
  display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 2px; background: #14532d; color: #fff;
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; letter-spacing: .5px;
}
.login-card h1 { margin: 0; font-size: 20px; color: var(--ink); }
.login-sub { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
#login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 16px; color: var(--ink); background: #fbfcfc; transition: border-color .15s, box-shadow .15s;
}
#login-codigo { text-transform: uppercase; letter-spacing: 2px; }
.field input:focus { outline: none; border-color: #166534; box-shadow: 0 0 0 3px rgba(22,101,52,.15); background: #fff; }
#login-btn {
  margin-top: 4px; background: #166534; color: #fff; border: 0; padding: 12px;
  border-radius: 9px; font-size: 16px; font-weight: 600; cursor: pointer; transition: background .15s;
}
#login-btn:hover { background: #14532d; }
#login-btn:disabled { opacity: .6; cursor: default; }
.login-error { color: #b91c1c; font-size: 13px; min-height: 18px; margin: 0; text-align: center; }

/* Loader a pantalla completa */
.loader {
  position: fixed; inset: 0; z-index: 100; background: #f4f6f8;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.spinner {
  width: 52px; height: 52px; border-radius: 50%;
  border: 5px solid #cbd5c0; border-top-color: #166534;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-msg { color: #14532d; font-size: 15px; font-weight: 600; }

/* Graficos (Chart.js) */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.chart-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.chart-box h3 { margin: 0 0 8px; font-size: 13px; color: var(--accent); }
.chart-wrap { position: relative; height: 260px; }
