/* Central — design handoff "Panel de la central": crema background, white panels, 72 px noche sidebar,
   the map takes most of the screen. Unit states always with text: Libre #1F7A4D, En viaje noche, Fuera de servicio piedra, SOS #C8261E. */
html, body { overflow: hidden; }
.small { font-size: 13px; }
.login-foot { text-align: center; }
.grow { flex: 1; }

#app { height: 100%; display: grid; grid-template-columns: 72px 400px 1fr; grid-template-rows: 64px 1fr; }
#app.wide-mode { grid-template-columns: 72px 1fr 0; }
#app.wide-mode .map { visibility: hidden; }

/* Sidebar */
.side { grid-row: 1 / 3; background: var(--noche); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 4px; overflow-y: auto; }
.side-logo { width: 72px; display: grid; place-items: center; padding: 2px 0 10px; }
.side-logo .iso { width: 42px; height: 42px; --c: var(--amarillo); --a: var(--crema); color: var(--amarillo); }
.side button { position: relative; width: 60px; min-height: 56px; padding: 6px 2px; border: 0; border-radius: 12px; background: transparent; color: #AEB6C2;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; line-height: 1.1; text-align: center; }
.side button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side button:hover { background: #1B2A40; color: var(--crema); }
.side button[aria-selected="true"] { background: var(--superficie); color: var(--amarillo); }
.side button[aria-selected="true"]::before { content: ''; position: absolute; left: -6px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--amarillo); }
.nbadge { position: absolute; top: 2px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--amarillo); color: var(--noche);
  font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.nbadge:empty { display: none; }
.nbadge.red { background: #C8261E; color: #fff; }

/* Top bar */
.bar { grid-column: 2 / 4; background: #fff; border-bottom: 1px solid #E4DED2; display: flex; align-items: center; gap: 14px; padding: 0 20px; min-width: 0; }
/* Author credit, centred on the top bar (hidden when there is no room) */
.bar { position: relative; }
.credit { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 13px; font-weight: 600; color: var(--piedra); text-decoration: none; white-space: nowrap; }
.credit:hover { color: var(--noche); text-decoration: underline; }
@media (max-width: 1300px) { .credit { display: none; } }
.bar-title { font-family: var(--font-display); font-weight: 800; font-stretch: 110%; font-size: 21px; color: var(--noche); white-space: nowrap; }
.counts { display: flex; gap: 14px; align-items: center; font-size: 14px; color: var(--text-2); white-space: nowrap; }
.fleet-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; white-space: nowrap; margin-left: 6px; padding-left: 14px; border-left: 2px solid var(--amarillo, #F6B800); }
@media (max-width: 900px) { .fleet-name { display: none; } }
.counts b { font-family: var(--font-display); font-size: 17px; }
.counts .free b { color: #1F7A4D; }
.counts .busy b { color: var(--noche); }
.counts .pend b { color: #A34A06; }
.counts .sos-pill { display: flex; align-items: center; gap: 8px; background: #C8261E; color: #fff; font-weight: 700; padding: 7px 12px; border-radius: 8px; }
.conn { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.clock { font-family: var(--font-display); font-weight: 700; font-stretch: 80%; font-size: 18px; color: var(--noche); }
.me { color: var(--muted); font-size: 14px; white-space: nowrap; }

/* Left panel */
.side-panel { background: #fff; border-right: 1px solid #E4DED2; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel { overflow: auto; padding: 16px 18px 24px; flex: 1; min-height: 0; }
.ptitle { font-weight: 800; font-stretch: 110%; font-size: 22px; color: var(--noche); margin-bottom: 12px; }
.sub { font-family: var(--font-display); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--piedra); margin: 20px 0 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 > * { min-width: 0; }
.wide { width: 100%; margin-top: 10px; }
.big { min-height: 56px; font-size: 17px; }

.seg { display: flex; gap: 6px; }
.seg label { margin: 0; flex: 1; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px; border: 1.5px solid var(--input-line); border-radius: 10px; color: var(--text); font-weight: 700; cursor: pointer; }
.seg input:checked + span { background: var(--noche); border-color: var(--noche); color: var(--amarillo); }
.seg input:focus-visible + span { outline: 3px solid var(--amarillo); outline-offset: 1px; }

.geo-results button { display: block; width: 100%; text-align: left; font-weight: 400; margin-top: 4px; min-height: 0; padding: 8px 10px; }
.geo-results button.sel { border-color: var(--noche); background: #F1ECDF; }

/* Lists */
.item { border-top: 1px solid #EFE9DD; padding: 12px 4px; cursor: pointer; }
.item:first-child { border-top: 0; }
.item:hover { background: #FBF8F2; }
.item .title { font-weight: 700; color: var(--tinta); }
.item .meta { font-size: 13px; color: var(--piedra); }
.item .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.item.flagged { box-shadow: inset 4px 0 0 #C8261E; padding-left: 12px; }
.item.inactive { opacity: .55; }
.unit { font-family: var(--font-display); font-weight: 700; font-stretch: 80%; font-size: 18px; color: var(--noche); }
.st { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 6px; color: #fff; white-space: nowrap; }
.st.free { background: #1F7A4D; } .st.busy { background: var(--noche); } .st.off { background: var(--piedra); } .st.sos { background: #C8261E; }
.cands { margin-top: 8px; display: grid; gap: 4px; }
.cands .row { font-size: 13px; }
.id-photo { max-width: 100%; border-radius: 8px; margin-top: 8px; display: block; }
.countdown { font-variant-numeric: tabular-nums; }

.map { min-height: 0; background: #E9E1D2; }

/* SOS pinned on top of the panel */
.alerts:empty { display: none; }
.alerts { padding: 14px 14px 0; display: grid; gap: 10px; }
.alert { padding: 14px; border-radius: 12px; background: #FBE9E7; border: 2px solid #C8261E; display: flex; flex-direction: column; gap: 6px; }
.alert .big { font-family: var(--font-display); font-weight: 800; font-size: 13px; letter-spacing: .14em; color: #C8261E; }
.alert.open .big { animation: blink 1s steps(2, start) infinite; }
.alert .who { font-size: 17px; font-weight: 700; color: var(--tinta); }
.alert .where { font-size: 14px; color: var(--text-2); }
.alert .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.alert .acts > * { flex: 1; min-height: 44px; border-radius: 8px; font-size: 14px; }
.alert .acts .danger { background: #C8261E; color: #fff; border: 0; }
.alert .acts .outline { background: #fff; color: #C8261E; border: 1.5px solid #C8261E; }
.alert .safe { background: #1F7A4D; color: #fff; border-radius: 6px; padding: 3px 8px; font-weight: 700; font-size: 13px; width: max-content; }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .alert.open .big { animation: none; } }

/* Map markers */
.car { display: flex; align-items: center; gap: 4px; white-space: nowrap; transform: translate(-10px, -10px); }
.car i { width: 20px; height: 20px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .5); flex: none; }
.car b { font: 700 12px var(--font-display); font-stretch: 85%; background: #fff; color: var(--noche); padding: 2px 6px; border-radius: 6px; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
.car.available i { background: #1F7A4D; }
.car.busy i { background: var(--noche); border-color: var(--amarillo); }
.car.offline i, .car.stale i { background: var(--piedra); }
.car.stale b { opacity: .6; }
.car.panic i { background: #C8261E; animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(200 38 30 / .8); } 100% { box-shadow: 0 0 0 18px rgb(200 38 30 / 0); } }
.pin { font-size: 26px; line-height: 1; transform: translate(-13px, -26px); filter: drop-shadow(0 1px 2px rgb(0 0 0 / .5)); }

/* WhatsApp */
.wa-panel { display: flex; flex-direction: column; }
.wa-mode { margin: 0 0 10px; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.wa-mode.cloud { background: #E3F1EA; }
.wa-sim, .wa-bridge { margin-bottom: 12px; padding: 12px; }
.wa-sim summary { cursor: pointer; font-weight: 700; }
.wa-bridge { text-align: center; }
.wa-bridge img { width: 240px; max-width: 100%; background: #fff; padding: 8px; border-radius: 8px; margin: 8px auto; display: block; }
.wa-bridge ol { text-align: left; font-size: 13px; margin: 8px 0; padding-left: 20px; }
.wa-conv .title { display: flex; gap: 6px; align-items: center; }
.wa-conv .last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.wa-head { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.wa-note { margin-top: 8px; font-size: 12px; padding: 6px 10px; border-radius: 8px; background: #FBEFD9; }
.wa-msgs { flex: 1; min-height: 200px; overflow: auto; padding: 10px 2px; display: flex; flex-direction: column; gap: 6px; background: #F7F2E8; border-radius: 12px; margin-top: 8px; }
.bubble { max-width: 85%; padding: 8px 11px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; margin: 0 8px; }
.bubble.in { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: #D8EFE6; border-bottom-right-radius: 4px; }
.bubble.out.operator { background: #DDE6F5; }
.bubble .who { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bubble .when { display: block; font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.bubble .when .failed { color: #C8261E; font-weight: 700; }
.bubble .btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.bubble .btns button { min-height: 30px; font-size: 12px; padding: 2px 10px; }
.wa-tools { font-size: 13px; padding: 6px 0; }
.wa-as { margin: 0; display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.wa-as input { width: auto; min-height: 0; }
.wa-form { padding-top: 8px; }
.wa-picking #map { cursor: crosshair; }

/* Admin sections (wide) */
.panel.wide { padding: 24px 28px 40px; }
.adm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.adm-head .ptitle { margin: 0; margin-right: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
.tbl th { text-align: left; font-family: var(--font-display); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--piedra); padding: 10px; border-bottom: 2px solid var(--noche); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid #EFE9DD; vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #FBF8F2; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .due { color: #A34A06; font-weight: 700; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 20px; align-items: start; }
.box { background: #fff; border: 1px solid #E4DED2; border-radius: 16px; padding: 18px; }
.box h3 { font-weight: 800; font-stretch: 108%; font-size: 18px; margin-bottom: 8px; color: var(--noche); }
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--piedra); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.docs figure { margin: 0; }
.docs img { width: 100%; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid #E4DED2; cursor: zoom-in; background: #F1ECDF; }
.docs figcaption { font-size: 12px; color: var(--piedra); margin-top: 4px; }
.dgrp { margin: 14px 0 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--piedra); }
.dgrp:first-of-type { margin-top: 4px; }
.docs figure.gap .ph { height: 120px; border-radius: 10px; border: 1.5px dashed #C8261E; background: #FBE9E7; color: #C8261E; display: grid; place-items: center; font-weight: 800; }
.docs figure.gap figcaption { color: #C8261E; font-weight: 700; }
.flag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: #C8261E; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em; vertical-align: middle; }
.alertbox { margin-bottom: 14px; padding: 12px 16px; border-radius: 12px; border: 1.5px solid #C8261E; background: #FBE9E7; color: #7A130E; }
.alertbox p { margin: 4px 0 0; font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button[aria-pressed="true"] { background: var(--noche); color: var(--amarillo); border-color: var(--noche); }
.pinbox { background: var(--noche); color: var(--crema); border-radius: 14px; padding: 16px; margin-top: 12px; }
.pinbox b { font-family: var(--font-display); font-size: 32px; letter-spacing: .1em; color: var(--amarillo); }
.brief-q { padding: 10px 0; border-top: 1px solid #EFE9DD; }
.brief-q .q { font-weight: 600; color: var(--text-2); font-size: 14px; }
.brief-q .a { margin-top: 2px; white-space: pre-wrap; }
.brief-q .a.empty { color: #B8B0A0; font-style: italic; }
.sec-title { font-family: var(--font-display); font-weight: 800; font-size: 16px; margin: 18px 0 4px; color: var(--noche); }
.lightbox { position: fixed; inset: 0; z-index: 9000; background: rgb(0 0 0 / .85); display: grid; place-items: center; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

@media (max-width: 900px) {
  #app { grid-template-columns: 60px 1fr; grid-template-rows: 56px 45vh 1fr; }
  #app.wide-mode { grid-template-columns: 60px 1fr; grid-template-rows: 56px 1fr; }
  #app.wide-mode .map { display: none; }
  .side { grid-row: 1 / 4; }
  .side button { width: 52px; font-size: 9.5px; }
  .bar { grid-column: 2; padding: 0 10px; gap: 8px; }
  .bar-title, .clock, .me { display: none; }
  .map { grid-column: 2; grid-row: 2; }
  .side-panel { grid-column: 2; grid-row: 3; border-right: 0; }
  #app.wide-mode .side-panel { grid-row: 2; }
}
.docs figcaption small.okc { color: #1F7A4D; font-weight: 700; }
.docs figcaption small.warnc { color: #A34A06; font-weight: 700; }
