/* ===== Lechería Admin — Kondoo-style design system ===== */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  --bg: #070b18; --bg-elev: #0c1426; --surface: #101a31; --surface-2: #162340; --surface-3: #1d2c4d;
  --ink: #eef2fb; --ink-soft: #c2cce0; --ink-muted: #8593b0; --ink-faint: #5a6788;
  --line: #1d2742; --line-strong: #28365a;
  --blue: #2E6BF5; --blue-2: #1247C8; --gold: #2E9DCD; --gold-2: #5BC4E8;
  --teal: #0ABFAB; --coral: #FF5757; --amber: #F5A623; --green: #2BD46F;
  --r: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: 'JetBrains Mono', monospace; }
.display { font-family: 'Manrope', sans-serif; font-weight: 800; }
h1,h2,h3 { font-family: 'Manrope', sans-serif; font-weight: 800; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Login ===== */
#login {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #0e1c3a 0%, var(--bg) 60%);
}
.login-card {
  width: 380px; max-width: 92vw; background: var(--surface);
  border: 1px solid var(--line); border-radius: 22px; padding: 30px;
}
.login-card img { width: 76px; height: 76px; border-radius: 18px; display: block; margin: 0 auto 14px; }
.login-card h1 { font-size: 21px; text-align: center; }
.login-card p { text-align: center; color: var(--ink-muted); font-size: 13px; margin-top: 4px; margin-bottom: 22px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-muted); margin: 0 0 6px 3px; font-family: 'JetBrains Mono', monospace; }
.field input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; color: var(--ink); font-size: 15px; outline: none;
}
.field input:focus { border-color: var(--blue); }
.btn {
  width: 100%; background: var(--blue); color: #fff; border: none; border-radius: 12px;
  padding: 14px; font-weight: 700; font-family: 'Manrope'; font-size: 15px; transition: opacity .15s;
}
.btn:hover { opacity: .9; } .btn:active { opacity: .8; }
.btn[disabled] { opacity: .5; }
.login-err { color: var(--coral); font-size: 13px; text-align: center; margin-top: 10px; min-height: 18px; }
.login-demo { display: flex; gap: 8px; margin-top: 16px; }
.login-demo button { flex: 1; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft); border-radius: 10px; padding: 9px; font-size: 12px; font-weight: 600; }

/* ===== Shell ===== */
#app { display: none; height: 100vh; grid-template-columns: 244px 1fr; }
#app.on { display: grid; }
.sidebar { background: var(--bg-elev); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.brand b { font-family: 'Manrope'; font-weight: 800; font-size: 16px; }
.brand span { display: block; font-size: 10px; color: var(--ink-muted); font-family: 'JetBrains Mono'; text-transform: uppercase; letter-spacing: .1em; }
.nav-group { font-size: 9.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-faint); font-family: 'JetBrains Mono'; margin: 14px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px;
  color: var(--ink-muted); font-size: 14px; font-weight: 500; border: none; background: none; width: 100%; text-align: left; position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface); color: var(--ink-soft); }
.nav-item.active { background: var(--surface-2); color: var(--ink); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--gold-2); }
.nav-badge { margin-left: auto; background: var(--coral); color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-family: 'Manrope'; font-size: 13px; }
.user-row b { font-size: 13px; display: block; } .user-row span { font-size: 11px; color: var(--ink-muted); }
.logout { background: none; border: none; color: var(--ink-muted); padding: 6px; border-radius: 8px; }
.logout:hover { color: var(--coral); }

.main { overflow-y: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 28px 8px; position: sticky; top: 0; background: linear-gradient(var(--bg) 70%, transparent); z-index: 5; }
.topbar h2 { font-size: 23px; }
.topbar .sub { color: var(--ink-muted); font-size: 13px; margin-top: 2px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--green); font-family: 'JetBrains Mono'; text-transform: uppercase; letter-spacing: .1em; }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(43,212,111,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(43,212,111,.5)} 70%{box-shadow:0 0 0 7px rgba(43,212,111,0)} 100%{box-shadow:0 0 0 0 rgba(43,212,111,0)} }
.content { padding: 8px 28px 40px; }

/* ===== Cards / grid ===== */
.grid { display: grid; gap: 14px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px){ .cols-4{grid-template-columns:repeat(2,1fr)} .cols-3{grid-template-columns:repeat(2,1fr)} }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.kpi .ic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.kpi .ic svg { width: 20px; height: 20px; }
.kpi .val { font-family: 'Manrope'; font-weight: 800; font-size: 30px; line-height: 1; }
.kpi .lbl { color: var(--ink-muted); font-size: 12.5px; margin-top: 6px; }
.kpi .delta { font-size: 11px; margin-top: 8px; font-family: 'JetBrains Mono'; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-muted); font-family: 'JetBrains Mono'; margin: 26px 2px 12px; }

/* ===== Table / list ===== */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-top: 1px solid var(--line); }
.row:first-child { border-top: none; }
.row:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { font-size: 14px; font-weight: 600; }
.row .grow small { display: block; color: var(--ink-muted); font-size: 12px; margin-top: 2px; }
.thumb { width: 40px; height: 40px; border-radius: 11px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex: none; }
.thumb svg { width: 19px; height: 19px; color: var(--gold-2); }
.pill { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.pill.green { background: rgba(43,212,111,.14); color: #5be89a; }
.pill.amber { background: rgba(245,166,35,.15); color: #ffce5b; }
.pill.coral { background: rgba(255,87,87,.15); color: #ff8f8f; }
.pill.blue { background: rgba(46,107,245,.16); color: #88acff; }
.pill.grey { background: var(--surface-3); color: var(--ink-muted); }
.mini-btn { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); border-radius: 9px; padding: 8px 13px; font-size: 12.5px; font-weight: 600; }
.mini-btn:hover { border-color: var(--blue); }
.mini-btn.ok { background: var(--green); color: #06210f; border-color: transparent; }
.mini-btn.danger { color: #ff8f8f; }
.mini-btn.ghost { background: transparent; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; color: var(--ink); font-size: 14px; outline: none; }
.search:focus { border-color: var(--blue); }
.empty { text-align: center; color: var(--ink-muted); font-size: 13px; padding: 40px; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 84px; align-items: center; gap: 12px; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-val { text-align: right; font-family: 'Manrope'; font-weight: 700; font-size: 13px; }

/* ===== Modal ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(3,6,15,.7); backdrop-filter: blur(4px); z-index: 40; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-bg.on { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 20px; padding: 24px; width: 460px; max-width: 94vw; max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 19px; margin-bottom: 4px; }
.modal .msub { color: var(--ink-muted); font-size: 13px; margin-bottom: 18px; }
.modal .field input, .modal .field select, .modal .field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 12px; color: var(--ink); font-size: 14px; outline: none; font-family: inherit;
}
.modal .field select { appearance: none; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 13px; cursor: pointer; }
.perm.on { border-color: var(--blue); background: rgba(46,107,245,.12); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }
.modal-actions .btn.sec { background: var(--surface-2); color: var(--ink); }
.detail-row { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.detail-row span { color: var(--ink-muted); } .detail-row b { font-weight: 600; }
.proof-img { width: 100%; border-radius: 12px; margin-top: 10px; border: 1px solid var(--line); }

/* ===== maps & charts ===== */
.map { height: 460px; border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; }
.map-sm { height: 300px; }
.leaflet-container { background: #0a1120; font-family: 'Inter', sans-serif; }
/* dark-mode the OSM tiles */
.leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.8); }
.leaflet-control-attribution { background: rgba(12,20,38,.7) !important; color: var(--ink-faint) !important; }
.leaflet-control-attribution a { color: var(--ink-muted) !important; }
.leaflet-popup-content-wrapper { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 12px; }
.leaflet-popup-tip { background: var(--surface-2); }
.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content b { font-family: 'Manrope'; }
.leaflet-bar a { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.map-legend { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-muted); }
.map-legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.chart-card h4 { font-family: 'Manrope'; font-size: 14px; margin-bottom: 2px; }
.chart-card .csub { color: var(--ink-muted); font-size: 12px; margin-bottom: 14px; }
.chart-wrap { position: relative; height: 200px; }

/* print / PDF one-pager */
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .live, #modal-bg, #toast, .mini-btn, .nav-badge { display: none !important; }
  #app { display: block !important; }
  .main { overflow: visible; }
  .topbar { position: static; }
  .topbar h2, .topbar .sub, .section-title, .kpi .lbl, .kpi .val, .card, .row, .bar-row { color: #000 !important; }
  .card, .list, .chart-card { border-color: #ccc !important; background: #fff !important; box-shadow: none !important; break-inside: avoid; }
  .content { padding: 0; }
}

/* toast */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--ink); padding: 13px 20px; border-radius: 12px; font-size: 14px; font-weight: 600; opacity: 0; transition: all .25s; z-index: 60; pointer-events: none; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%{background: rgba(46,107,245,.22)} 100%{background: transparent} }
