/* Operations-wall layout: fills the viewport, scales with it, dark by design. */
:root {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #222220;
  --ink: #ffffff; --ink2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --base: #383835; --ring: rgba(255,255,255,0.10);
  --s1: #3987e5; --s2: #d95926;
  --good: #0ca30c; --warn: #fab219; --crit: #d03b3b; --goodtxt: #0ca30c;
  --land: #2f2f2c; --land-co: #1d4270;
  --tip-bg: #ffffff; --tip-ink: #0b0b0b;
  --gap: clamp(8px, 0.9vw, 22px);
  font-size: clamp(12px, 0.8vw, 30px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }

.flag { position: fixed; inset: 0 0 auto 0; height: 4px; display: flex; z-index: 5; }
.flag i { display: block; height: 100%; }
.flag i:nth-child(1) { flex: 2; background: #fcd116; }
.flag i:nth-child(2) { flex: 1; background: #003893; }
.flag i:nth-child(3) { flex: 1; background: #ce1126; }

.wall { height: 100vh; display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: var(--gap); padding: calc(var(--gap) + 4px) calc(var(--gap) * 1.3) var(--gap); }

/* ---- header -------------------------------------------------------------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
h1 { font-size: 1.75rem; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.sub { color: var(--ink2); font-size: 0.95rem; margin-top: 0.3rem; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.badge { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; color: var(--ink2); border: 1px solid var(--base); border-radius: 999px; padding: 0.15rem 0.6rem; }
.controls { display: flex; align-items: center; gap: 0.9rem; }
.seg { display: inline-flex; border: 1px solid var(--ring); border-radius: 0.55rem; overflow: hidden; background: var(--surface-1); }
.seg button { font: inherit; font-size: 0.95rem; background: none; border: 0; padding: 0.45rem 0.9rem; color: var(--ink2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--ring); }
.seg button.on { color: var(--ink); font-weight: 650; background: var(--surface-2); }
.seg button:hover:not(.on) { background: var(--surface-2); }
.select { font-size: 0.95rem; color: var(--ink2); display: inline-flex; align-items: center; gap: 0.5rem; }
.select select { font: inherit; color: var(--ink); background: var(--surface-1); border: 1px solid var(--ring); border-radius: 0.55rem; padding: 0.4rem 0.6rem; }
.clock { display: flex; align-items: baseline; gap: 0.55rem; padding-left: 0.9rem; border-left: 1px solid var(--base); }
.clock b { font-size: 1.55rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.clock small { color: var(--muted); font-size: 0.85rem; }
.live-pill { align-self: center; display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; color: var(--goodtxt); }
.pulse { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--good); display: inline-block; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---- cards --------------------------------------------------------------- */
.card { background: var(--surface-1); border: 1px solid var(--ring); border-radius: 0.9rem; padding: 1rem 1.15rem; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.card h2 { font-size: 1.05rem; margin: 0; font-weight: 650; }
.card .hint { font-size: 0.85rem; color: var(--muted); margin: 0.2rem 0 0.7rem; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.plot { flex: 1; min-height: 0; position: relative; }
.plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* ---- KPI row ------------------------------------------------------------- */
.kpirow { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 1.7fr); gap: var(--gap); }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--gap); }
.kpi { justify-content: space-between; }
.kpi .lbl { font-size: 0.9rem; color: var(--ink2); }
.kpi .val { font-size: 2.5rem; font-weight: 650; line-height: 1.1; margin: 0.35rem 0 0.25rem; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 0.82rem; color: var(--muted); }
.kpi .d b { color: var(--goodtxt); font-weight: 650; }
.cta { border-color: rgba(57,135,229,0.45); background: linear-gradient(135deg, rgba(57,135,229,0.16), rgba(57,135,229,0.04)) , var(--surface-1); justify-content: space-between; }
.cta-label { font-size: 0.9rem; color: var(--ink2); }
.cta-num { font-size: 2.3rem; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; line-height: 1.15; margin: 0.25rem 0; }
.cta-num:hover { text-decoration: underline; }
.cta-last { font-size: 0.85rem; color: var(--ink2); line-height: 1.4; }
.cta-last b { color: var(--ink); font-weight: 650; }

/* ---- main grid ----------------------------------------------------------- */
.main { display: grid; gap: var(--gap); min-height: 0;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1.05fr);
  grid-template-rows: minmax(0, 1.28fr) minmax(0, 1fr);
  grid-template-areas: "map map sedes" "trend motivos live"; }
.map-card { grid-area: map; padding-bottom: 0.4rem; }
.sedes-card { grid-area: sedes; }
.trend-card { grid-area: trend; }
.motivos-card { grid-area: motivos; }
.live { grid-area: live; }

/* map */
.map-wrap { flex: 1; min-height: 0; position: relative; }
.map-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-legend { display: flex; gap: 1rem; font-size: 0.82rem; color: var(--ink2); }
.map-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.m-land { fill: var(--land); }
.m-co { fill: var(--land-co); }
.m-border { fill: none; stroke: #45453f; stroke-width: 0.7; vector-effect: non-scaling-stroke; }
.m-arc { fill: none; stroke: var(--s1); stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: 0.55; }
.m-flow { fill: none; stroke: #9ec5f4; stroke-linecap: round; stroke-dasharray: 1.5 9; vector-effect: non-scaling-stroke; animation: flow 3.2s linear infinite; opacity: 0.9; }
@keyframes flow { to { stroke-dashoffset: -105; } }
.m-dot { stroke: var(--surface-1); stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: default; }
.m-dot.ok { fill: var(--good); } .m-dot.hi { fill: var(--warn); } .m-dot.cr { fill: var(--crit); }
.m-dim { opacity: 0.18; }
.m-label { fill: var(--ink2); paint-order: stroke; stroke: var(--surface-1); stroke-linejoin: round; }
.m-hub-label { fill: var(--ink); font-weight: 700; paint-order: stroke; stroke: var(--surface-1); stroke-linejoin: round; }
.m-hub-sub { fill: #9ec5f4; font-weight: 700; letter-spacing: 0.05em; paint-order: stroke; stroke: var(--surface-1); stroke-linejoin: round; }
.m-hub { fill: #ffffff; stroke: var(--s1); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.m-hub-ring { fill: none; stroke: var(--s1); stroke-width: 1.5; vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: center; animation: ring 2.4s ease-out infinite; }
.m-ping { fill: none; stroke: #ffffff; stroke-width: 1.5; vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: center; animation: ring 1.6s ease-out forwards; }
@keyframes ring { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(3.2); opacity: 0; } }
.map-stats { position: absolute; right: 0.4rem; bottom: 0.5rem; text-align: right; font-size: 0.9rem; color: var(--ink2); line-height: 1.5; pointer-events: none; }
.map-stats b { color: var(--ink); font-size: 1.15rem; font-weight: 700; }

/* table */
.table-wrap { flex: 1; min-height: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 0.82rem; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 0.5rem; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.n, th.n { text-align: right; }
tr:last-child td { border-bottom: none; }
td b { font-weight: 650; }
td.muted { color: var(--ink2); }
.st { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.ic { width: 1.1rem; height: 1.1rem; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 0.68rem; font-weight: 800; font-style: normal; }
.ic.ok { background: var(--good); } .ic.hi { background: var(--warn); color: #0b0b0b; } .ic.cr { background: var(--crit); }
.meter { display: inline-block; width: 4.2rem; height: 0.4rem; background: var(--grid); border-radius: 0.2rem; vertical-align: middle; margin-right: 0.5rem; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--s1); border-radius: 0.2rem; }

/* charts */
svg text { font-family: inherit; }
.t-ink { fill: var(--ink); } .t-ink2 { fill: var(--ink2); } .t-muted { fill: var(--muted); }
.g-grid { stroke: var(--grid); } .g-base { stroke: var(--base); }
.f-s1 { fill: var(--s1); } .f-s2 { fill: var(--s2); }
.l-s1 { stroke: var(--s1); } .l-s2 { stroke: var(--s2); }
.ring { stroke: var(--surface-1); }
.bar-row:hover .bar { opacity: .85; }
.hit { fill: transparent; }
.legend { display: flex; gap: 1rem; font-size: 0.85rem; color: var(--ink2); margin-bottom: 0.3rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.sw { width: 0.9rem; height: 3px; border-radius: 2px; display: inline-block; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); }

/* live */
.live ul { margin: 0; padding: 0; flex: 1; min-height: 0; overflow: hidden; }
.live li { list-style: none; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr) 3.2rem; gap: 0.6rem; font-size: 0.95rem; padding: 0.42rem 0; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; transition: background .8s; }
.live li > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live li.new { background: rgba(57,135,229,0.14); }
.live li:last-child { border-bottom: none; }
.live li .r { text-align: right; }
.muted { color: var(--ink2); }
.who { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--ink2); }
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; display: inline-block; flex: none; }
.dot.ia { background: var(--s1); } .dot.hu { background: var(--s2); } .dot.cola { background: var(--muted); }
.alert { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.9rem; padding: 0.55rem 0.7rem; border-radius: 0.55rem; background: var(--surface-2); margin-top: 0.5rem; line-height: 1.35; }
.alert small { color: var(--ink2); font-size: 0.82rem; }

/* toast for real bookings */
.toast { position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%); z-index: 20; background: #0f2a17; border: 1px solid var(--good); color: var(--ink); border-radius: 0.9rem; padding: 0.9rem 1.3rem; font-size: 1.05rem; box-shadow: 0 12px 40px rgba(0,0,0,.5); display: flex; gap: 0.8rem; align-items: center; max-width: 80vw; animation: toast-in .35s ease-out; }
.toast small { display: block; color: var(--ink2); font-size: 0.88rem; margin-top: 0.15rem; }
.toast .ic { width: 1.6rem; height: 1.6rem; font-size: 0.95rem; }
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

.tip { position: fixed; pointer-events: none; background: var(--tip-bg); color: var(--tip-ink); font-size: 0.85rem; line-height: 1.5; padding: 0.5rem 0.7rem; border-radius: 0.5rem; z-index: 30; font-variant-numeric: tabular-nums; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.tip b { font-weight: 650; }
.tip .row { display: flex; align-items: center; gap: 0.4rem; }

@media (prefers-reduced-motion: reduce) {
  .pulse, .m-flow, .m-hub-ring, .m-ping, .toast { animation: none; }
  .live li { transition: none; }
}

@media (max-width: 1600px) { .meter { display: none; } }

/* ---- small screens: stack and scroll ------------------------------------ */
@media (max-width: 1100px), (max-height: 640px) {
  :root { font-size: 13px; }
  body { overflow: auto; }
  .wall { height: auto; grid-template-rows: auto; }
  .top { flex-wrap: wrap; }
  .kpirow { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
  .main { grid-template-columns: 1fr; grid-template-rows: none;
    grid-template-areas: "map" "sedes" "trend" "motivos" "live"; }
  .map-card { height: 62vw; min-height: 260px; }
  .trend-card, .motivos-card { height: 320px; }
  .table-wrap { overflow-x: auto; }
}
@media (max-width: 640px) {
  .controls { flex-wrap: wrap; }
  .clock { border-left: 0; padding-left: 0; }
  .map-legend, .map-stats, .m-label { display: none; }
  table th:nth-child(3), table td:nth-child(3) { display: none; }
  .meter { display: none; }
}
