/* =====================================================================
   RASTRO · app.css
   Tokens neutros + cor da marca (--brand) injetada pelas configurações.
   Para rebrand: mude cor/logo em Configurações — não edite este arquivo.
   ===================================================================== */

:root {
  --brand: #2F6BFF; --brand-rgb: 47,107,255; --brand-ink: #fff;
  --brand-soft: rgba(var(--brand-rgb), .12);
  --brand-line: rgba(var(--brand-rgb), .35);

  --bg: #F3F4F6; --surface: #FFFFFF; --surface-2: #F7F8FA; --surface-3: #EEF0F3;
  --line: #E2E5EA; --line-2: #CDD2DA;
  --ink: #12151A; --ink-2: #48505C; --ink-3: #6B7380;

  --ok: #15803D;     --ok-soft: rgba(21,128,61,.11);
  --late: #C2410C;   --late-soft: rgba(194,65,12,.11);
  --warn: #A16207;   --warn-soft: rgba(161,98,7,.12);
  --off: #6B7280;    --off-soft: rgba(107,114,128,.13);
  --danger: #B91C1C; --danger-soft: rgba(185,28,28,.1);
  --info: #0369A1;   --info-soft: rgba(3,105,161,.1);

  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', monospace;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 18px 50px -12px rgba(16,24,40,.28);
  --side-w: 248px; --top-h: 58px;
}

[data-theme="dark"] {
  --bg: #0C0E11; --surface: #14171B; --surface-2: #191D22; --surface-3: #20252B;
  --line: #252A31; --line-2: #343A43;
  --ink: #ECEEF1; --ink-2: #A8B0BB; --ink-3: #7D8693;
  --ok: #34D17A;     --ok-soft: rgba(52,209,122,.13);
  --late: #FF8A4C;   --late-soft: rgba(255,138,76,.14);
  --warn: #F2C14E;   --warn-soft: rgba(242,193,78,.13);
  --off: #8C95A3;    --off-soft: rgba(140,149,163,.14);
  --danger: #F87171; --danger-soft: rgba(248,113,113,.13);
  --info: #5BC0EB;   --info-soft: rgba(91,192,235,.13);
  --brand-soft: rgba(var(--brand-rgb), .18);
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.65);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--ink-3); }
.ink2 { color: var(--ink-2); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.ico { width: 18px; height: 18px; flex-shrink: 0; }
.ico-sm { width: 15px; height: 15px; }

/* ---------- SHELL ---------- */
.shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 60; transition: transform .22s ease; }
.brand { display: flex; align-items: center; gap: 11px; padding: 16px 16px 14px; border-bottom: 1px solid var(--line); min-height: var(--top-h); }
.brand-logo { width: 36px; height: 36px; border-radius: 9px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; font-weight: 800; letter-spacing: -.2px; }
.brand-text small { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.nav-group { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--ink-3); padding: 16px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 600; font-size: 13.5px; margin-bottom: 1px; transition: background .12s, color .12s; }
.nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav-link.on { background: var(--brand-soft); color: var(--ink); }
.nav-link.on .ico { color: var(--brand); }
.nav-badge { margin-left: auto; background: var(--late); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; font-family: var(--mono); }
[data-theme="dark"] .nav-badge { color: #1a0d05; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 10px; }
.user-chip { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; text-align: left; }
.user-chip:hover { background: var(--surface-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-meta strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 11px; color: var(--ink-3); }

.topbar { position: fixed; top: 0; left: var(--side-w); right: 0; height: var(--top-h); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 20px; z-index: 50; }
.crumb { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.icon-btn .dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--late); border: 2px solid var(--surface); }
.live-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); }
.live-chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
.live-chip.off { background: var(--danger-soft); color: var(--danger); }
.live-chip.off i { animation: none; }
.clock { font-size: 12.5px; color: var(--ink-3); padding: 0 4px; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

.main { margin-left: var(--side-w); padding: calc(var(--top-h) + 22px) 24px 40px; min-height: 100vh; outline: none; }
.main.full { padding: var(--top-h) 0 0; }
.scrim { display: none; }
.only-mobile { display: none; }

/* ---------- POPOVERS ---------- */
.pop-wrap { position: relative; }
.popover { position: absolute; top: calc(100% + 8px); right: 0; width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden; }
.popover-head { padding: 12px 14px; font-weight: 700; font-size: 12.5px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.popover-foot { display: block; padding: 10px 14px; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--brand); border-top: 1px solid var(--line); }
.user-pop { position: fixed; top: auto; bottom: 70px; left: 12px; right: auto; width: 224px; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 14px; font-weight: 600; font-size: 13px; cursor: pointer; }
.menu-item:hover { background: var(--surface-3); }

/* ---------- PAGE HEADER ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.page-head p { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- BUTTONS ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { border-color: var(--line-2); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand); border-color: var(--brand); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; }
.btn-icon { width: 30px; padding: 0; }
.btn-block { width: 100%; height: 42px; }
.btn.on { background: var(--brand-soft); border-color: var(--brand-line); }

/* ---------- CARDS / GRID ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; }
.card-head h3 { font-size: 14px; font-weight: 800; }
.card-head small { color: var(--ink-3); font-size: 12px; font-weight: 500; }
.card-body { padding: 14px 18px 18px; }
.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.mb { margin-bottom: 14px; }

/* KPI */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi-label { font-size: 12px; font-weight: 700; color: var(--ink-3); display: flex; align-items: center; gap: 7px; }
.kpi-label i { width: 8px; height: 8px; border-radius: 2px; background: var(--k, var(--brand)); }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin-top: 6px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; font-weight: 600; color: var(--ink-3); letter-spacing: 0; margin-left: 3px; }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.kpi-sub b { color: var(--k, var(--ink)); font-weight: 700; }
.kpi .bar { height: 4px; background: var(--surface-3); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.kpi .bar span { display: block; height: 100%; background: var(--k, var(--brand)); border-radius: 4px; transition: width .8s ease; }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 210px; }

/* ---------- BADGES / STATUS ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.st-ATIVO { background: var(--ok-soft); color: var(--ok); }
.st-ATRASO { background: var(--late-soft); color: var(--late); }
.st-MANUTENCAO { background: var(--warn-soft); color: var(--warn); }
.st-ENCERRADO { background: var(--off-soft); color: var(--off); }
.st-PENDENTE { background: var(--info-soft); color: var(--info); }
.st-APROVADO { background: var(--ok-soft); color: var(--ok); }
.st-REPROVADO { background: var(--danger-soft); color: var(--danger); }
.chip-code { font-family: var(--mono); font-size: 12px; font-weight: 600; background: var(--surface-3); padding: 2px 7px; border-radius: 5px; }
.area-dot { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; }
.area-dot::before { content: ''; width: 9px; height: 9px; border-radius: 3px; background: var(--c, var(--off)); }

/* ---------- ALERTS / FEED ---------- */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert-row { display: flex; gap: 11px; align-items: flex-start; padding: 11px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.alert-row .ai { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.alert-row.critico .ai { background: var(--danger-soft); color: var(--danger); }
.alert-row.atencao .ai { background: var(--late-soft); color: var(--late); }
.alert-row.info .ai { background: var(--info-soft); color: var(--info); }
.alert-row strong { display: block; font-size: 13px; }
.alert-row span { font-size: 12px; color: var(--ink-3); }
.alert { padding: 10px 12px; border-radius: var(--r); font-size: 13px; margin: 10px 0; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }

.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-ic { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center; font-size: 11px; font-weight: 800; font-family: var(--mono); background: var(--surface-3); color: var(--ink-2); }
.feed-ic.CRIACAO { background: var(--ok-soft); color: var(--ok); }
.feed-ic.MOVIMENTACAO { background: var(--brand-soft); color: var(--brand); }
.feed-ic.STATUS { background: var(--warn-soft); color: var(--warn); }
.feed-ic.INSPECAO { background: var(--info-soft); color: var(--info); }
.feed-ic.EXCLUSAO { background: var(--danger-soft); color: var(--danger); }
.feed-body { flex: 1; min-width: 0; font-size: 12.5px; }
.feed-body strong { font-weight: 600; display: block; }
.feed-body small { color: var(--ink-3); }
.feed-item.fresh { animation: fresh 2.4s ease; }
@keyframes fresh { 0% { background: var(--brand-soft); } 100% { background: transparent; } }
.feed-compact { max-height: 360px; overflow-y: auto; padding: 0 14px; }

/* barras por área */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; gap: 8px; }
.bar-row-top b { font-family: var(--mono); font-size: 12px; }
.bar-track { height: 7px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--c, var(--brand)); transition: width .8s ease; }
.bar-fill.over { background: repeating-linear-gradient(45deg, var(--danger), var(--danger) 6px, color-mix(in srgb, var(--danger) 70%, transparent) 6px, color-mix(in srgb, var(--danger) 70%, transparent) 12px); }

/* ---------- FILTER BAR / FORMS ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 260px; min-width: 200px; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; }
.input, .select, .textarea, .field input, .field select, .field textarea {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); outline: none; font-size: 13.5px; transition: border-color .12s, box-shadow .12s;
}
.search .input { padding-left: 34px; }
.select { width: auto; min-width: 140px; padding-right: 28px; cursor: pointer; }
.textarea, .field textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.field input[type="color"] { padding: 3px; cursor: pointer; }
.field .hint { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.span-2 { grid-column: 1 / -1; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
fieldset { border: 0; margin-bottom: 18px; }
legend { font-weight: 800; font-size: 13px; margin-bottom: 10px; color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 0 12px; height: 34px; font-weight: 700; font-size: 12.5px; cursor: pointer; color: var(--ink-2); border-right: 1px solid var(--line); display: inline-flex; align-items: center; gap: 6px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand-soft); color: var(--ink); }
.seg button .n { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* ---------- TABLE ---------- */
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--ink-3); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.tbl th[data-sort] { cursor: pointer; user-select: none; }
.tbl th[data-sort]:hover { color: var(--ink); }
.tbl th .arrow { opacity: .8; margin-left: 3px; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.click { cursor: pointer; }
.tbl .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tbl .desc { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.tbl .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.tbl tr.flash td { animation: fresh 2.4s ease; }
.pager { display: flex; align-items: center; gap: 6px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .info { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* ---------- MODAL / DRAWER ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8,10,14,.55); backdrop-filter: blur(3px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s ease; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: rise .18s ease; }
.modal.wide { max-width: 900px; }
.modal.narrow { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; font-weight: 800; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .left { margin-right: auto; }
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(14px); opacity: 0 } }

.drawer { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); z-index: 500; display: flex; flex-direction: column; animation: slidein .2s ease; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0 } }
.drawer-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.drawer-head .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.drawer-head h3 { font-size: 18px; font-weight: 800; letter-spacing: -.3px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { font-weight: 600; word-break: break-word; }
.section-title { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-3); margin: 18px 0 8px; }

/* ---------- TOASTS ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--surface); padding: 11px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; box-shadow: var(--shadow-lg); max-width: 360px; animation: rise .18s ease; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok::before { content: '✓ '; color: var(--ok); }

/* ---------- MAP PAGE ---------- */
.map-page { position: relative; display: grid; grid-template-columns: 330px minmax(0, 1fr); height: calc(100vh - var(--top-h)); }
.map-side { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.map-side-head { padding: 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.map-side-head .search { flex: none; min-width: 0; }
.map-counts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.map-count { border: 1px solid var(--line); border-radius: 9px; padding: 7px 8px; cursor: pointer; background: var(--surface); text-align: left; }
.map-count.on { border-color: var(--brand-line); background: var(--brand-soft); }
.map-count.dim { opacity: .45; }
.map-count { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.map-count b { display: block; font-size: 16px; order: 2; font-weight: 800; font-variant-numeric: tabular-nums; }
.map-count span { font-size: 10.5px; font-weight: 700; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.map-count span::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.map-list { flex: 1; overflow-y: auto; }
.map-li { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.map-li:hover, .map-li.sel { background: var(--surface-2); }
.map-li .sdot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.map-li .t { flex: 1; min-width: 0; }
.map-li .t strong { font-size: 13px; display: block; }
.map-li .t small { font-size: 11.5px; color: var(--ink-3); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-li .nopos { font-size: 10.5px; color: var(--warn); font-weight: 700; }
.map-canvas { position: relative; min-height: 0; }
#leaflet { position: absolute; inset: 0; background: var(--surface-3); }
.map-tools { position: absolute; top: 12px; left: 12px; z-index: 450; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 420px); }
.map-tools .btn { box-shadow: var(--shadow); }
.map-banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 460; background: var(--ink); color: var(--surface); padding: 9px 14px; border-radius: 10px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; }
.map-banner .btn { height: 28px; }
.map-legend { position: absolute; left: 12px; bottom: 22px; z-index: 450; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; display: flex; gap: 12px; font-size: 11.5px; font-weight: 700; box-shadow: var(--shadow); flex-wrap: wrap; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend span::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

/* marcadores */
.mk { width: 22px; height: 22px; border-radius: 50%; background: var(--c); border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 900; font-family: var(--font); transition: transform .15s; }
.mk.late { animation: ring 1.8s infinite; }
.mk.flash { animation: flash 1.2s ease 2; }
.mk.sel { transform: scale(1.35); box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .45), 0 1px 4px rgba(0,0,0,.45); }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255,138,76,.65), 0 1px 4px rgba(0,0,0,.4); } 70% { box-shadow: 0 0 0 11px rgba(255,138,76,0), 0 1px 4px rgba(0,0,0,.4); } 100% { box-shadow: 0 0 0 0 rgba(255,138,76,0), 0 1px 4px rgba(0,0,0,.4); } }
@keyframes flash { 50% { transform: scale(1.7); } }
.area-label { background: none; border: 0; box-shadow: none; font-weight: 800; font-size: 11px; letter-spacing: .6px; color: var(--ink); text-shadow: 0 0 3px var(--surface), 0 0 3px var(--surface), 0 0 3px var(--surface); white-space: nowrap; }
.area-label::before { display: none; }
.leaflet-container { font-family: var(--font); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--surface-2); }
[data-theme="dark"] .geo-mode .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.82) contrast(.92) saturate(.55); }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(var(--brand-rgb), .25); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: var(--brand); color: var(--brand-ink); font-weight: 800; font-family: var(--font); }

/* ---------- QR / ETIQUETAS ---------- */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-box .qr { background: #fff; padding: 12px; border-radius: 10px; }

/* ---------- IMPORT ---------- */
.drop { display: block; border: 2px dashed var(--line-2); border-radius: var(--r-lg); padding: 36px 20px; text-align: center; cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.drop:hover, .drop.drag { border-color: var(--brand); background: var(--brand-soft); }
.drop .ico { width: 34px; height: 34px; color: var(--brand); margin: 0 auto 8px; }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); width: 0; transition: width .3s; }

/* ---------- AI ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - var(--top-h) - 170px); min-height: 420px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78%; padding: 11px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.loading { color: var(--ink-3); }
.chat-input { display: flex; gap: 8px; padding: 14px; border-top: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 14px; }

/* ---------- SETTINGS ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 14px; font-weight: 700; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.on { color: var(--ink); border-bottom-color: var(--brand); }
.brand-preview { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px dashed var(--line-2); border-radius: var(--r); }
.brand-preview img { width: 48px; height: 48px; object-fit: contain; border-radius: 10px; }
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; }

/* ---------- AUTH ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 10% -10%, rgba(var(--brand-rgb), .14), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow-lg); }
.auth-card.install { max-width: 640px; }
.auth-card h1 { font-size: 22px; font-weight: 800; margin: 14px 0 4px; letter-spacing: -.3px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.auth-card .field input { height: 42px; }
.auth-logo { width: 54px; height: 54px; border-radius: 13px; object-fit: contain; }
.auth-foot { text-align: center; font-size: 11px; color: var(--ink-3); margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12.5px; margin: 14px 0; }
.checks .ok { color: var(--ok); } .checks .fail { color: var(--danger); font-weight: 700; }
.steps { margin: 14px 0 18px 18px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- FIELD PAGE (QR) ---------- */
.field-page { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
.field-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.field-top img { width: 34px; height: 34px; border-radius: 8px; }
.field-hero { padding: 18px; }
.field-hero h1 { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin: 6px 0 2px; }
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.big-actions .btn { height: 48px; font-size: 14px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
  .topbar { left: 0; padding: 0 12px; }
  .main { margin-left: 0; padding: calc(var(--top-h) + 16px) 14px 32px; }
  .only-mobile { display: grid; }
  .hide-sm { display: none; }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .map-page { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 42vh; }
  .map-side { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .map-tools { max-width: calc(100% - 24px); }
  .drawer { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 72%; }
  .user-pop { left: 12px; }
}
@media (max-width: 560px) {
  .g-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 23px; }
  .form-grid, .grid-2 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 19px; }
  .live-chip span { display: none; }
  .popover { width: calc(100vw - 24px); right: -60px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

/* ---------- PRINT ---------- */
@media print {
  .sidebar, .topbar, .actions, .toolbar, .pager, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
