:root {
  --navy: #10182e;
  --navy-2: #1a2340;
  --gold: #c9920a;
  --ink: #1b2430;
  --muted: #667085;
  --line: #e6e8ee;
  --page: #f5f6f8;
  --card: #ffffff;
  --blue: #1d4ed8;
  --green: #0f7a4a;
  --cream: #fbf6e8;
  --cream-ink: #6d5420;
  --radius: 14px;
  --sans: "Roboto", system-ui, sans-serif;
  --content: min(1180px, calc(100% - 48px));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

button, select { font-family: inherit; }

[hidden] { display: none !important; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background: var(--navy);
}

.gate-card {
  width: min(640px, 100%);
  background: #fff;
  border-radius: 22px;
  padding: 36px 32px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.brand {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 500;
}

.brand-sub {
  margin: 4px 0 28px;
  color: var(--muted);
}

.gate-card h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
}

.gate-card > p { margin: 0 0 8px; color: var(--muted); }

.entity {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  text-align: left;
  background: transparent;
  border: none;
  border-top: 1px solid var(--line);
  padding: 16px 4px;
  cursor: pointer;
  color: var(--ink);
}

.entity strong { display: block; font-size: 1.02rem; font-weight: 500; }
.entity span { display: block; margin-top: 2px; color: var(--muted); font-size: 0.95rem; }
.entity em { font-style: normal; color: var(--blue); font-weight: 500; }
.entity:hover strong,
.entity:focus-visible strong { color: var(--blue); }
.entity:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.gate-foot {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.gate-foot a { color: var(--blue); }

.topbar {
  background: var(--navy);
  color: #fff;
}

.topbar-row,
.nav-row {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
}

.mark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark-icon {
  width: 32px;
  height: 32px;
  flex: none;
  display: block;
}

.mark-icon img {
  display: block;
  width: 32px;
  height: 32px;
}

.mark strong { display: block; font-size: 1.25rem; font-weight: 500; }
.mark span { display: block; color: rgba(255, 255, 255, 0.72); font-size: 0.92rem; }

.exit {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.exit:hover { border-color: var(--gold); }

.nav-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.nav-row button {
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.nav-row button[aria-current="page"] {
  background: var(--navy-2);
  border-color: var(--gold);
  color: #fff;
}

.shell { padding: 22px 0 48px; }

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.side {
  background: #0c0f24;
  color: #d6d9e6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid #23284a;
  color: #f3f0e8;
}

.login-card .brand { border: 0; padding: 0; margin-bottom: 24px; color: var(--ink); }

.brand b {
  display: block;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.brand span span {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  opacity: 0.75;
}

.login-card .brand span span { opacity: 1; color: #6b7187; }

.side nav { padding: 12px 10px; display: grid; gap: 2px; }

.side nav button {
  text-align: left;
  background: none;
  border: 0;
  color: #c3c7d9;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}

.side nav button:hover { background: #171c3a; color: #fff; }

.side nav button[aria-current="page"] {
  background: #1c2246;
  color: #fff;
  box-shadow: inset 3px 0 0 #e8b84b;
}

.who {
  margin-top: auto;
  padding: 16px 20px 20px;
  border-top: 1px solid #23284a;
  font-size: 14px;
}

.who b { color: #fff; display: block; }
.who p { color: #9ea3bd; font-size: 13px; margin: 6px 0 0; line-height: 1.45; }

.who button {
  margin-top: 12px;
  background: none;
  border: 1px solid #3a4068;
  color: #d6d9e6;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}

.who button:hover { border-color: #f3f0e8; }

.main { min-width: 0; display: flex; flex-direction: column; }

.bar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.bar .in {
  width: var(--content);
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  gap: 16px 24px;
  align-items: center;
  flex-wrap: wrap;
}

.bar h1 { font-size: 20px; margin-right: auto; font-family: var(--sans); font-weight: 700; }
.bar h1 small { display: block; font-size: 13px; font-weight: 400; color: #6b7187; margin-top: 2px; }

.ctl { color: var(--muted); font-size: 0.95rem; }

.env {
  font-size: 13px;
  font-weight: 500;
  color: #7a5b0c;
  background: #fff8e6;
  border: 1px solid #f0dfae;
  border-radius: 6px;
  padding: 3px 9px;
  white-space: nowrap;
}

.login-page {
  min-height: 100vh;
  background: #0c0f24;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  width: min(560px, 100%);
}

.login-card h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.login-card .field input,
.login-card .field select { min-height: 49px; }
.login-card .btn.full { min-height: 47px; }
.login-foot {
  display: flex;
  justify-content: center;
  margin: 4px 0 0;
  padding: 20px 0 0;
  border-top: 1px solid #e2e5ea;
}
.login-partners { display: block; width: min(100%, 420px); height: auto; }
.login-card .field input[readonly] { background: #fff; }

.field { display: grid; gap: 6px; margin-top: 16px; font-size: 14px; color: #444b63; font-weight: 500; }

.field input, .field select {
  width: 100%;
  border: 1px solid #cdd2da;
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
}

.field input:focus, .field select:focus { outline: 2px solid #2f6fd0; outline-offset: 1px; }
.field input[readonly] { background: #f7f8fa; color: var(--ink); cursor: default; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8b84b;
  color: #1c1500;
  border: 0;
  padding: 10px 16px;
  border-radius: 9px;
  font-weight: 500;
  cursor: pointer;
  font-size: 15px;
}

.btn.full { width: 100%; margin: 20px 0 16px; padding: 12px; }
.btn.line { background: #fff; color: var(--ink); border: 1px solid #cdd2da; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { display: flex; overflow-x: auto; }
  .side nav button { white-space: nowrap; }
  .who {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 0;
    padding: 10px 16px 14px;
  }
  .who p { display: none; }
  .who b { margin-right: auto; }
  .who button { margin-top: 0; }
}

.wrap { width: var(--content); margin: 0 auto; }

.page-head h1 { margin: 0; font-size: 1.7rem; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin: 18px 0;
}

.filters label { color: var(--muted); font-size: 0.95rem; }

select, .seg {
  border: 1px solid #d5d8e0;
  background: #fff;
  border-radius: 10px;
}

select { padding: 8px 12px; color: var(--ink); }

.seg { display: inline-flex; padding: 3px; background: #eceef3; border: none; }

.seg button {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  color: var(--ink);
}

.seg button[aria-pressed="true"] {
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 46, 0.12);
}

.banner {
  background: var(--cream);
  color: var(--cream-ink);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
  margin-bottom: 16px;
}

.kpi { padding: 18px 16px 16px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: none; }
.kpi strong { display: block; font-size: 1.8rem; font-weight: 700; letter-spacing: -0.03em; }
.kpi span { display: block; margin: 4px 0 10px; color: var(--muted); font-size: 0.92rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.78rem;
  border: 1px solid currentColor;
}

.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: currentColor;
}

.pill.is-camera { color: var(--green); }
.pill.is-model { color: var(--blue); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 8px;
  margin-bottom: 16px;
}

.card h2 { margin: 0 0 4px; font-size: 1.05rem; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: 0.92rem; }

.alert {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.alert p { margin: 4px 0 0; color: var(--muted); }
.alert button {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  font-weight: 500;
}

.split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; align-items: start; }

.bar-row, .funnel-row {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr 64px;
  gap: 10px;
  align-items: center;
  margin: 8px 0 12px;
  font-size: 0.92rem;
}

.funnel-row .bar-track { height: 18px; border-radius: 6px; }
.week-row .bar-track i { background: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chips span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.crop p { margin: 8px 0 0; color: var(--muted); font-size: 0.92rem; }
.call { font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem; }
.table-wrap { overflow-x: auto; }

.bar-track { height: 10px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: #2457d6; border-radius: inherit; }
.tip-row { cursor: default; }
.series { width: 100%; height: auto; display: block; }
.tt {
  position: fixed;
  z-index: 30;
  max-width: 260px;
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.45;
  pointer-events: none;
}
.api-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr); gap: 16px; align-items: start; }
.api-side { display: grid; gap: 16px; }
.api-note { margin-top: 12px; }
.api-export { display: flex; flex-wrap: wrap; gap: 10px; }
.card pre {
  margin: 0;
  background: #0c0f24;
  color: #e5e8f5;
  border-radius: 10px;
  padding: 16px;
  overflow: auto;
  font: 13.5px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  max-height: 420px;
  white-space: pre-wrap;
}
.endpoint {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: baseline;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  cursor: pointer;
}
.endpoint b { color: #2f6fd0; font-weight: 500; }
.endpoint span { color: var(--ink); word-break: break-all; }
.endpoint[aria-pressed="true"] span { font-weight: 500; }
.steps { margin: 12px 0 0; padding-left: 1.2rem; }
.steps li { margin: 8px 0; }
.steps b { font-weight: 500; }
#view-fuentes .card + .card { margin-top: 16px; }
#view-fuentes a { color: #2a5bb5; }
.origin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 1px 9px 1px 7px;
  border-radius: 6px;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.6;
  background: #fff;
}
.origin:before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  flex: none;
}
.origin.open { color: #00897b; border-color: #9ed3cd; }
#view-fuentes em { color: var(--muted); font-style: italic; }

.fauna-anim { --fa-surf: #fbfcfa; --fa-tx: #1a221d; --fa-mut: #5d6a61; --fa-bd: #d4d9d1; --fa-track: #dde3da; --fa-cam: #97a39b; --fa-green: #3f8a2a; --fa-okbg: #e4f1dd; --fa-oktx: #2c5f1c; --fa-amb: #9a5c08; --fa-ambbg: #f6e8cf; --fa-ac: #2f6a4a; color: var(--fa-tx); font: 15px/1.55 Roboto, system-ui, sans-serif; }
.fauna-anim svg { display: block; }
.fauna-anim .piece { background: var(--fa-surf); border: 1px solid var(--fa-bd); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.fauna-anim .hd { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 8px; }
.fauna-anim .hd span { font: 400 12px ui-monospace, Consolas, monospace; color: var(--fa-mut); }
.fauna-anim #fauna-scene { width: 100%; height: auto; border-radius: 6px; background: #2b302d; }
.fauna-anim .mv { transition: transform 1.8s cubic-bezier(.2, .7, .3, 1); }
.fauna-anim #fauna-mover-jag { transform: translateX(-420px); }
.fauna-anim #fauna-mover-gua { transform: translateX(260px); transition-duration: 2.2s; }
.fauna-anim .in #fauna-mover-jag, .fauna-anim .in #fauna-mover-gua { transform: none; }
.fauna-anim #fauna-rec { opacity: 0; transition: opacity .3s; }
.fauna-anim .rec #fauna-rec { opacity: 1; }
.fauna-anim .blink { animation: fauna-bl 1s steps(2, jump-none) infinite; }
@keyframes fauna-bl { 50% { opacity: .15; } }
.fauna-anim #fauna-flash { opacity: 0; pointer-events: none; }
.fauna-anim #fauna-flash.go { animation: fauna-fl .5s ease-out; }
@keyframes fauna-fl { 0% { opacity: .85; } 100% { opacity: 0; } }
.fauna-anim .bx { fill: none; stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .9s ease; }
.fauna-anim .det .bx { stroke-dashoffset: 0; }
.fauna-anim .b1 { stroke: #7cc53a; }
.fauna-anim .b2 { stroke: #e0912a; }
.fauna-anim .lb { font: 400 11px ui-monospace, Consolas, monospace; opacity: 0; transition: opacity .4s .7s; }
.fauna-anim .det .lb { opacity: 1; }
.fauna-anim .step-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 10px; }
.fauna-anim .pill { font: 500 12.5px Roboto, system-ui, sans-serif; border: 1px solid var(--fa-bd); background: transparent; color: var(--fa-mut); padding: 5px 11px; border-radius: 99px; cursor: pointer; }
.fauna-anim .pill[aria-current="step"] { background: var(--fa-tx); color: #eef0ec; border-color: var(--fa-tx); }
.fauna-anim .pill.past { color: var(--fa-tx); }
.fauna-anim .pill:focus-visible, .fauna-anim .act:focus-visible { outline: 2px solid var(--fa-ac); outline-offset: 2px; }
.fauna-anim .cap { min-height: 62px; }
.fauna-anim .cap b { display: block; font-weight: 600; font-size: 16px; }
.fauna-anim .cap p { margin: 2px 0 0; color: var(--fa-mut); font-size: 14px; }
.fauna-anim .ctl { display: flex; gap: 8px; margin-top: 6px; }
.fauna-anim .act { font: 500 13px Roboto, system-ui, sans-serif; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--fa-bd); background: transparent; color: var(--fa-tx); cursor: pointer; }
.fauna-anim .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fauna-anim .crop h3 { font: 600 14px Roboto, system-ui, sans-serif; margin: 0 0 8px; }
.fauna-anim .thumb { width: 100%; height: 120px; background: #2b302d; border-radius: 6px; }
.fauna-anim .f { opacity: 0; transform: translateY(8px); transition: opacity .5s, transform .5s; }
.fauna-anim .f.on { opacity: 1; transform: none; }
.fauna-anim .row { display: grid; grid-template-columns: 92px 1fr 38px; gap: 8px; align-items: center; font-size: 13px; margin: 7px 0; }
.fauna-anim .track { position: relative; height: 8px; background: var(--fa-track); border-radius: 4px; }
.fauna-anim .fill { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--fa-cam); transition: width 1s ease .15s; }
.fauna-anim .fill.ok { background: var(--fa-green); }
.fauna-anim .on .fill { width: calc(var(--v) * 100%); }
.fauna-anim .th { position: absolute; left: 90%; top: -4px; bottom: -4px; width: 1.5px; background: var(--fa-tx); }
.fauna-anim .row span:last-child { font: 500 12px ui-monospace, Consolas, monospace; text-align: right; }
.fauna-anim .note { font-size: 12px; color: var(--fa-mut); margin: 2px 0 0; }
.fauna-anim .verdict { padding: 9px 11px; border-radius: 8px; font-size: 13.5px; margin-top: 10px; }
.fauna-anim .v-ok { background: var(--fa-okbg); color: var(--fa-oktx); }
.fauna-anim .v-rev { background: var(--fa-ambbg); color: var(--fa-amb); }
.fauna-anim .verdict b { font-weight: 600; }
@media (max-width: 560px) { .fauna-anim .cols { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  .fauna-anim .mv, .fauna-anim .bx, .fauna-anim .lb, .fauna-anim .fill, .fauna-anim .f { transition-duration: .01s; transition-delay: 0s; }
  .fauna-anim .blink { animation: none; }
}

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 12px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }

.layout {
  display: grid;
  grid-template-columns: 1.45fr 0.8fr;
  gap: 16px;
}

#map-host {
  height: 520px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #e7eef2;
}

.map-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.map-legend i, .map-legend b {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.map-legend i { background: #d5d8de; }
.map-legend b { background: #c9920a; }
.map-legend .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px #cdd2da; }
.map-legend .dot.pending { background: #e0453a; }
.map-legend .dot.sent { background: #0f7a4a; }

.maplibregl-popup-content { font-family: var(--sans); font-size: 0.85rem; }

.dept-card, .tooltip { position: absolute; z-index: 2; }
.dept-card {
  left: 14px;
  bottom: 14px;
  width: min(300px, calc(100% - 28px));
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.dept-card .region { color: var(--muted); font-size: 0.8rem; }
.dept-card h2 { margin: 0; }
.dept-card .metric strong { font-size: 1.6rem; }
.dept-card .level { color: var(--green); font-weight: 500; }
.close-card, .text-btn {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  padding: 0;
}
.dept-head { display: flex; justify-content: space-between; gap: 8px; }

.tooltip {
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.82rem;
  pointer-events: none;
}
.tooltip span { display: block; color: rgba(255, 255, 255, 0.75); }

.rank button {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.rank button strong { display: block; }
.rank button span { color: var(--muted); font-size: 0.88rem; }
.rank button.is-on { border-color: var(--gold); }

.crops { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crop {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.crop b { display: block; margin-top: 8px; font-size: 1.4rem; font-weight: 500; }
.crop .tag { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }

.match { display: grid; grid-template-columns: 1fr 120px 36px; gap: 8px; align-items: center; margin: 6px 0; font-size: 0.9rem; }
.match-track { height: 8px; background: #eef0f4; border-radius: 999px; position: relative; }
.match-track i { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.match-track i.is-low { background: #c5cad3; }
.threshold { position: absolute; left: 90%; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.verdict { background: #eef8f2; color: var(--green); border-radius: 8px; padding: 8px 10px; }
.verdict.is-review { background: var(--cream); color: var(--cream-ink); }

.chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 210px);
  min-height: 520px;
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.chat .head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.chat h3 { margin: 0; font-size: 17px; line-height: 1.35; }
.chat .fine { margin: 4px 0 0; font-size: 13px; color: #6b7187; line-height: 1.5; }
.chat .body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f0f2f5;
}
.chat .sub { margin: 0; color: #444b63; }
.chat .msg { max-width: 78%; padding: 12px 14px; border-radius: 12px; font-size: 15px; line-height: 1.6; }
.chat .msg.u { align-self: flex-end; background: #0c0f24; color: #fff; border-bottom-right-radius: 4px; }
.chat .msg.a { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat .msg.muted { color: #6b7187; }
.chat .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chat .src {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 1px 9px 1px 7px;
  border-radius: 6px;
  border: 1px solid;
  line-height: 1.6;
  background: #fff;
}
.chat .src:before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; flex: none; }
.chat .src.model { color: #2f6fd0; border-color: #b7cff5; }
.chat .src.private { color: #a87a12; border-color: #e6d3a1; }
.chat .how { margin-top: 8px; font-size: 13px; color: #6b7187; }
.chat form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fff; }
.chat input { flex: 1; border: 1px solid #cdd2da; border-radius: 9px; padding: 10px 12px; font-size: 15px; min-width: 0; font-family: inherit; }
.chat .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.chat .sugg { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 16px 18px; background: #fff; }
.chat .sugg button {
  background: #fff;
  border: 1px solid #cdd2da;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  color: #444b63;
  cursor: pointer;
}
.chat .sugg button:hover { border-color: #6b7187; color: var(--ink); }
.chat .sugg button:disabled { opacity: 0.45; cursor: not-allowed; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.bell-wrap { position: relative; }
.bell {
  width: 40px;
  height: 40px;
  border: 1px solid #cdd2da;
  background: #fff;
  border-radius: 10px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.bell[aria-expanded="true"] { border-color: var(--ink); }
.bell-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #e0453a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.bell-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(380px, 78vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(16, 24, 46, 0.16);
  padding: 10px;
  z-index: 40;
}
.bell-title { margin: 2px 6px 8px; font-size: 13px; font-weight: 700; color: #444b63; }
.notice-list { display: grid; gap: 8px; }
.notice {
  width: 100%;
  display: grid;
  gap: 2px;
  text-align: left;
  background: #fff;
  border: 1px solid #e1e4ea;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--ink);
}
.notice:hover { border-color: #98a0b3; }
.notice .kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.notice .kicker.is-sight { color: #1d4ed8; }
.notice .kicker.is-area { color: #9a5c08; }
.notice .kicker.is-sent { color: var(--green); }
.notice strong { font-size: 14px; font-weight: 500; }
.notice span { color: var(--muted); font-size: 13px; }
.detail-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.shot { position: relative; margin: 0 0 8px; background: #141816; border-radius: 12px; overflow: hidden; }
.shot-frame { position: relative; }
.shot img { display: block; width: 100%; height: auto; }
.shot figcaption { margin: 0; padding: 8px 10px 10px; color: #d7ddd9; background: #1b1e1c; font-size: 13px; line-height: 1.45; }
.shot-box {
  position: absolute;
  border: 2px solid #7cc53a;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
}
.is-analyzed .shot-box { opacity: 1; }
.shot-box b {
  position: absolute;
  left: 0;
  top: 0;
  background: #7cc53a;
  color: #14210c;
  font: 700 12px/16px ui-monospace, Consolas, monospace;
  padding: 0 4px;
  white-space: nowrap;
}
.crop-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.crop-thumb { width: 220px; height: 140px; position: relative; overflow: hidden; border-radius: 10px; background: #141816; }
.crop-thumb img { position: absolute; max-width: none; }
.crop-thumb span { position: absolute; left: 8px; bottom: 8px; color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.detail-map { height: 340px; border-radius: 12px; overflow: hidden; background: #eef0f4; }
.detail-map + .notice-list { margin-top: 14px; }
.send-box { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--cream); }
.send-box p { margin: 0 0 10px; }
.send-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sent-flag { color: var(--green); font-weight: 700; }

.photo-open {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(12, 15, 36, 0.72);
  display: grid;
  place-items: center;
  padding: 24px;
}
.photo-open-card {
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 16px 16px 4px;
}
.photo-open h2 { margin: 8px 0 12px; font-size: 1.15rem; }
.photo-open .btn { float: right; }
.photo-open img { display: block; width: 100%; height: auto; border-radius: 8px; }
.photo-open figcaption { margin: 8px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.45; }

@media (min-width: 1500px) {
  :root { --content: min(1360px, calc(100% - 64px)); }
  .split, .layout, .api-grid { gap: 20px; }
  #map-host { height: 640px; }
  .detail-map { height: 460px; }
  .shot { max-width: 1040px; }
}

@media (min-width: 1800px) {
  :root { --content: min(1520px, calc(100% - 80px)); }
  .kpi { padding: 22px 22px 18px; }
  .kpi strong { font-size: 2.05rem; }
  #map-host { height: 700px; }
  #view-detalle .card:has(> .shot + .shot) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    align-items: start;
  }
  #view-detalle .card:has(> .shot) > h2 { grid-column: 1 / -1; }
  #view-detalle .card:has(> .shot + .shot) .shot { max-width: none; }
}

@media (max-width: 860px) {
  .kpis, .layout, .crops, .split, .bar-row, .funnel-row, .match, .api-grid { grid-template-columns: 1fr; }
  .kpi { border-right: none; border-bottom: 1px solid var(--line); }
  #map-host { height: 380px; }
  .chat .msg { max-width: 92%; }
  .chat { height: auto; min-height: 70vh; }
}
