/* ============================================================
   idSwift Stats — brand styling (forest/mint/cream, Ubuntu).
   Same visual system as the deck slides: forest marks with
   visible labels, recessive grid, dark tooltips, paper canvas.
   ============================================================ */

@font-face {
  font-family: 'Croogla 4F';
  src: url('/assets/fonts/Croogla-4F-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --forest: #27524e;
  --forest-deep: #1d3f3c;
  --mint: #91cca9;
  --mint-soft: #d6ecdf;
  --cream: #f5f1e8;
  --paper: #faf7f0;
  --ink: #1a2e2a;
  --muted: #607471;
  --line: #e4dfd3;
  --card: #ffffff;
  --bad: #b3563e;
  --bad-soft: #f3ddd5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: 'Ubuntu', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- wordmark (Croogla, ring dot) ---- */
.wm {
  font-family: 'Croogla 4F', 'Ubuntu', sans-serif;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
}
.wm .s-cap { font-size: 1.135em; letter-spacing: -.02em; margin: 0 -.015em; display: inline-block; }
.wm .ring {
  display: inline-block; width: .17em; height: .17em; border-radius: 50%;
  border: .05em solid currentColor; margin-left: .06em;
  transform: translateY(.03em); box-sizing: border-box;
}

/* ---- shell ---- */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 36px) 64px; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 18px 0 14px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .brand { font-size: 24px; color: var(--forest); display: flex; align-items: baseline; gap: 10px; }
.topbar .brand .app-tag {
  font-family: 'Ubuntu', sans-serif; font-weight: 500; font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: var(--muted); }
.topbar .env-pill {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  padding: 4px 10px; border-radius: 999px;
  background: var(--mint-soft); color: var(--forest);
}
.topbar .env-select {
  font-size: 12.5px; font-weight: 600; color: var(--forest);
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--mint-soft); background: #fff; cursor: pointer;
}
.topbar button.linklike {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 12.5px; text-decoration: underline;
}
.topbar button.linklike:hover { color: var(--forest); }

/* ---- filtro global por hotel (fase 3B) ---- */
.topbar .f-hotel { display: inline-flex; align-items: center; gap: 8px; }
.topbar .f-hotel label {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: var(--muted);
}
.topbar .f-hotel select {
  font-family: inherit; font-size: 12.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 5px 9px; min-width: 110px; cursor: pointer;
}

/* Chip «global»: el dato no tiene dimensión hotel y se muestra el total
   de la flota aunque haya un hotel seleccionado (tooltip en title). */
.gchip {
  display: inline-block; vertical-align: middle; margin-left: 8px;
  font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  padding: 2px 8px 1px; border-radius: 999px;
  background: #efe8d5; color: #8a7d5e; border: 1px solid #e0d6bc;
  cursor: help; user-select: none;
}
.projbanner .gchip { background: rgba(245, 241, 232, .16); color: var(--mint); border-color: transparent; }

.demo-banner {
  position: fixed; bottom: 14px; right: 14px; z-index: 50;
  background: var(--forest-deep); color: var(--mint);
  font-size: 11px; font-weight: 700; letter-spacing: .22em;
  padding: 5px 14px 5px 16px; border-radius: 999px;
  box-shadow: 0 8px 20px -8px rgba(29, 63, 60, .5);
  user-select: none; pointer-events: none;
}

/* ---- tabs ---- */
.tabs {
  display: flex; gap: 4px; margin: 16px 0 22px;
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
}
.tabs button {
  border: 0; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--muted); padding: 10px 16px 12px; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs button:hover { color: var(--forest); }
.tabs button.on {
  color: var(--forest); font-weight: 700;
  border-bottom-color: var(--forest);
}

.view { display: none; }
.view.on { display: block; }

/* ---- section headers ---- */
.vhead { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.vhead h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.vhead .sub { font-size: 12.5px; color: var(--muted); }
.vhead .spacer { flex: 1; }
.live-dot {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
}
.hoy-updated { font-size: 12px; color: var(--muted); margin-right: 10px; }
.refresh-btn {
  font-size: 12.5px; font-weight: 600; color: var(--forest);
  padding: 5px 12px; border-radius: 8px;
  border: 1px solid var(--mint-soft); background: #fff; cursor: pointer;
}
.refresh-btn:hover { background: var(--mint-soft); }
.refresh-btn:disabled { opacity: .5; cursor: default; }
.live-dot i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--mint);
  box-shadow: 0 0 0 0 rgba(145, 204, 169, .7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(145, 204, 169, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(145, 204, 169, 0); }
  100% { box-shadow: 0 0 0 0 rgba(145, 204, 169, 0); }
}

/* ---- filters ---- */
.filters {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  background: var(--cream); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 18px;
}
.filters .f { display: flex; flex-direction: column; gap: 4px; }
.filters label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.filters select, .filters input[type="date"] {
  font-family: inherit; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 7px 10px; min-width: 130px;
}
button.apply {
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  background: var(--forest); color: var(--cream); border: 0;
  border-radius: 8px; padding: 8px 18px;
}
button.apply:hover { background: var(--forest-deep); }

/* ---- KPI tiles ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px 14px; position: relative; overflow: hidden;
}
.kpi .k-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.kpi .k-value {
  font-size: clamp(26px, 3vw, 34px); font-weight: 700; letter-spacing: -.03em;
  color: var(--forest); margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.05;
}
.kpi .k-value .unit { font-size: .55em; color: var(--mint); font-weight: 700; }
.kpi .k-sub { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.kpi.bad .k-value { color: var(--bad); }
.kpi.bad .k-value .unit { color: var(--bad); opacity: .55; }
.kpi.good .k-value { color: var(--forest); }

/* ---- cards / chart panels ---- */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 16px; min-width: 0;
}
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.card .sub { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }
.card .note { font-size: 10.5px; color: #a49a86; margin-top: 10px; line-height: 1.5; }

/* ⓘ de ayuda junto al título */
.help {
  display: inline-block; margin-left: 6px; cursor: help;
  font-size: 12px; font-weight: 400; color: var(--mint); vertical-align: 1px;
}
.help:hover, .help:focus { color: var(--forest); outline: none; }
.help-pop {
  position: absolute; z-index: 120; display: none;
  background: var(--forest-deep); color: var(--cream);
  font-size: 12.5px; line-height: 1.55; font-weight: 400;
  padding: 10px 13px; border-radius: 10px;
  box-shadow: 0 10px 30px -8px rgba(20, 40, 38, .5);
  pointer-events: none; text-transform: none; letter-spacing: 0;
}
.help-pop.on { display: block; }
.csv-btn {
  margin-left: 10px; font-size: 10.5px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 2px 8px; cursor: pointer; vertical-align: 1px;
}
.csv-btn:hover { color: var(--forest); border-color: var(--mint); }

/* card ampliable: cursor + pista ⤢ en la esquina */
.card.zoomable { position: relative; cursor: pointer; }
.card.zoomable::after {
  content: '⤢'; position: absolute; top: 14px; right: 16px;
  font-size: 14px; color: var(--muted); opacity: 0; transition: opacity .12s;
  pointer-events: none;
}
.card.zoomable:hover::after { opacity: .6; }

/* ---- chart containers ---- */
.chartbox { position: relative; width: 100%; }
.chartbox svg { display: block; width: 100%; height: auto; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--forest-deep); color: var(--cream);
  border-radius: 9px; padding: 7px 11px; font-size: 12px; line-height: 1.45;
  opacity: 0; transition: opacity .15s;
  transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap;
  box-shadow: 0 10px 24px -8px rgba(29, 63, 60, .5);
}
.chart-tip b { color: var(--mint); }
.chart-tip.on { opacity: 1; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink); margin-bottom: 8px; }
.legend .li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 8px 10px;
  border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.data td { padding: 8px 10px; border-bottom: 1px solid #efeadd; font-variant-numeric: tabular-nums; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr:hover td { background: var(--cream); }
table.data .pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; background: var(--mint-soft); color: var(--forest);
}
table.data .pill.bad { background: var(--bad-soft); color: var(--bad); }
table.data .pill.warn { background: #f3ecd0; color: #8a6d1a; }

/* ---- OHIP ---- */
.warnbox {
  background: #f6efd6; border: 1px solid #e3d6a8; color: #8a6d1a;
  border-radius: 12px; padding: 10px 16px; font-size: 12.5px;
  line-height: 1.55; margin-bottom: 16px;
}

/* ---- OHIP · banner de proyección mensual (fase 3) ---- */
.projbanner {
  background: var(--forest-deep); color: var(--cream);
  border-radius: 14px; padding: 16px 20px 14px; margin-bottom: 18px;
  box-shadow: 0 12px 28px -14px rgba(29, 63, 60, .55);
}
.projbanner .pb-head {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 700; color: var(--mint); margin-bottom: 12px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.projbanner .pb-tag {
  font-size: 10px; letter-spacing: .06em; text-transform: none;
  font-weight: 500; color: rgba(245, 241, 232, .55);
}
.projbanner .pb-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.projbanner .pb-s b {
  display: block; font-size: clamp(22px, 2.6vw, 30px); font-weight: 700;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.projbanner .pb-s span { font-size: 11px; color: rgba(245, 241, 232, .7); }
.projbanner .pb-eta {
  margin-top: 12px; padding-top: 10px; font-size: 12.5px; line-height: 1.5;
  border-top: 1px solid rgba(245, 241, 232, .16); color: rgba(245, 241, 232, .85);
}
.projbanner .pb-eta.warn { color: #f0d789; font-weight: 500; }

/* ---- Recomendaciones ---- */
.reco-status {
  min-height: 22px; font-size: 13px; color: var(--muted);
  display: flex; align-items: center; gap: 9px; margin-bottom: 8px;
}
.reco-status .err { color: var(--bad); }
.spin-inline {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 3px solid var(--mint-soft); border-top-color: var(--forest);
  animation: spin .8s linear infinite; display: inline-block;
}
button.apply:disabled { opacity: .55; cursor: default; }
.reco-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.reco-summary {
  background: var(--cream); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; line-height: 1.55; margin-bottom: 14px;
}
.reco-card {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px 10px; margin-bottom: 12px; background: #fff;
}
.reco-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; }
.reco-area {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: var(--muted);
}
.reco-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; line-height: 1.35; }
.reco-field { font-size: 12.5px; line-height: 1.5; margin-bottom: 8px; }
.reco-field b {
  display: block; font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1px;
}
/* pills genéricos (los de tabla siguen scoped a table.data) */
.pill {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
  background: var(--mint-soft); color: var(--forest);
}
.pill.sev-alta { background: var(--bad-soft); color: var(--bad); }
.pill.sev-media { background: #f3ecd0; color: #8a6d1a; }
.pill.sev-baja { background: #edeade; color: var(--muted); }
.pill.consensus { background: var(--forest); color: var(--cream); }

/* ---- Recomendaciones · consulta ad-hoc (fase 3B) ---- */
button.btn-sec {
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  background: transparent; color: var(--forest);
  border: 1.5px solid var(--forest); border-radius: 8px; padding: 7px 16px;
}
button.btn-sec:hover { background: var(--mint-soft); }
button.btn-sec:disabled { opacity: .55; cursor: default; }
button.textbtn {
  border: 0; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 12.5px; font-weight: 700; color: var(--forest); text-decoration: underline;
  padding: 2px 4px;
}
button.textbtn:hover { color: var(--forest-deep); }

.adhoc-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--cream); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
.adhoc-head .q { font-weight: 500; line-height: 1.45; }
.adhoc-head .spacer { flex: 1; }
.pill.adhoc { background: #e6def1; color: #5a4a8a; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(29, 63, 60, .58);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
/* display:flex ganaría al atributo hidden del UA stylesheet */
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--paper); border-radius: 16px; padding: 22px 24px 20px;
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px -18px rgba(20, 40, 38, .55);
}
.modal-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.modal-card .modal-sub { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 14px; }
.modal-label {
  display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: var(--muted); margin-bottom: 5px;
}
.modal-label.inline { display: inline; margin: 0; }
.modal-card textarea {
  width: 100%; font-family: inherit; font-size: 13.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 10px 12px; resize: vertical; min-height: 84px; line-height: 1.5;
}
.modal-card textarea:focus { outline: 2px solid var(--mint); outline-offset: 1px; }
.modal-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.modal-row .spacer { flex: 1; }
.modal-row .counter { font-size: 11.5px; color: #a49a86; font-variant-numeric: tabular-nums; }
.modal-row select {
  font-family: inherit; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 6px 9px; cursor: pointer;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---- modal de zoom (ampliar card) ---- */
.zoom-overlay {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(29, 63, 60, .58);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.zoom-overlay[hidden] { display: none; }
.zoom-card {
  position: relative;
  background: var(--paper); border-radius: 16px; padding: 26px 30px;
  width: min(1100px, 96vw); max-height: 92vh; overflow: auto;
  box-shadow: 0 24px 60px -18px rgba(20, 40, 38, .55);
}
.zoom-card .card {
  border: 0; padding: 0; margin: 0; background: transparent; cursor: default;
}
.zoom-card .card h3 { font-size: 18px; }
.zoom-card .card .sub { font-size: 13px; margin-bottom: 18px; }
.zoom-close {
  position: absolute; top: 14px; right: 16px; z-index: 2;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  width: 30px; height: 30px; cursor: pointer; color: var(--muted);
  font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.zoom-close:hover { color: var(--forest); border-color: var(--mint); }

/* ---- states ---- */
.state { padding: 34px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.state .spin {
  width: 26px; height: 26px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--mint-soft); border-top-color: var(--forest);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.state.error { color: var(--bad); }
.state .hint { font-size: 11.5px; color: #a49a86; margin-top: 6px; }

/* ---- footer ---- */
.foot { margin-top: 30px; font-size: 11px; color: #a49a86; display: flex; gap: 12px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
