/* ============================================================== *
 * styles.css — Tablero Departamentos Miami · estética Airbnb
 * Mobile-first. Tokens en design-tokens.css.
 * ============================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; overflow-x: hidden; }
body {
  background: var(--bg-soft); color: var(--hof);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1,h2,h3 { margin: 0; letter-spacing: -0.02em; }
.tnum { font-variant-numeric: tabular-nums; }
.usd { font-variant-numeric: tabular-nums; }
button { font-family: inherit; cursor: pointer; }
canvas { max-width: 100%; }

/* ---------------- Top bar ---------------- */
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: 12px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--rausch); color: #fff;
  display: grid; place-items: center; flex: 0 0 auto; }
.brand-mark svg { width: 18px; height: 18px; }
.brand > div { min-width: 0; }
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--foggy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-ctl { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.auto-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--foggy); cursor: pointer; }
.btn-refresh { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--rausch);
  color: var(--rausch); background: #fff; font-size: 14px; font-weight: 600; padding: 8px 16px; border-radius: var(--radius-pill);
  transition: background .15s, color .15s; min-height: 40px; }
.btn-refresh:hover { background: var(--rausch); color: #fff; }
.btn-refresh .ric { display: inline-flex; }
.btn-refresh .ric svg { width: 16px; height: 16px; }
.btn-refresh.loading .ric { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Layout ---------------- */
.page { max-width: 1200px; margin: 0 auto; padding: 18px 16px 60px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 28px 2px 12px; }
.section-title { font-size: 20px; font-weight: 700; }
.section-hint, .card-cap { font-size: 12.5px; color: var(--foggy); }
.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }

/* ---------------- Card genérica ---------------- */
.card { background: var(--bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; }
.chart-wrap { position: relative; width: 100%; }
.chart-wrap.h240 { height: 240px; }
.chart-wrap.h200 { height: 200px; }

/* ---------------- Banners ---------------- */
.banner { border-radius: var(--radius-med); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.banner.stale { background: var(--arches-soft); color: #9a4012; border-left: 3px solid var(--arches); }
.banner.note { background: #f3f2ee; color: var(--foggy); border-left: 3px solid var(--line); }
.banner.note summary { cursor: pointer; font-weight: 600; color: var(--hof); }
.banner.note table { margin-top: 8px; font-size: 12px; border-collapse: collapse; width: 100%; }
.banner.note th, .banner.note td { text-align: right; padding: 3px 10px 3px 0; }
.banner.note th:first-child, .banner.note td:first-child { text-align: left; }

/* ---------------- Hero KPIs ---------------- */
.hero-row { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: 6px; margin: 6px 0 2px; -webkit-overflow-scrolling: touch; }
.hero-row::-webkit-scrollbar { height: 0; }
.kpi { flex: 0 0 74%; scroll-snap-align: start; background: var(--bg); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 16px; min-height: 116px; display: flex; flex-direction: column; gap: 2px; }
.kpi .k-top { display: flex; align-items: center; gap: 7px; color: var(--foggy); font-size: 12.5px; font-weight: 500; }
.kpi .k-top svg { width: 15px; height: 15px; }
.kpi .k-val { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .k-sub { font-size: 12.5px; color: var(--foggy); }
.kpi .k-delta { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.k-delta.up { color: var(--ok); } .k-delta.down { color: var(--bad); } .k-delta.flat { color: var(--foggy); }
.k-delta svg { width: 13px; height: 13px; vertical-align: middle; }
.kpi.accent .k-val { color: var(--rausch); }
.kpi .k-bar { height: 6px; border-radius: 999px; background: var(--line); margin-top: 8px; overflow: hidden; }
.kpi .k-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--babu); }

/* ---------------- Listing cards (unidades) ---------------- */
.units-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.unit-card { background: var(--bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  overflow: hidden; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.unit-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.unit-photo { position: relative; height: 118px; width: 100%; background-size: cover; background-position: center;
  display: grid; place-items: center; }
.unit-photo .ph-initial { font-size: 24px; font-weight: 800; color: rgba(255,255,255,.95); letter-spacing: -0.02em;
  text-align: center; padding: 0 14px; line-height: 1.12; text-shadow: 0 1px 6px rgba(0,0,0,.12); }
.unit-photo .badge { position: absolute; top: 12px; left: 12px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 5px 10px;
  border-radius: var(--radius-pill); background: #fff; color: var(--hof); box-shadow: var(--shadow-rest); }
.badge svg { width: 13px; height: 13px; }
.badge.ok { color: #00736a; } .badge.ok .dotb { background: var(--babu); }
.badge.gray { color: var(--foggy); } .badge.gray .dotb { background: var(--foggy); }
.badge.warn { color: #9a4012; } .badge.warn .dotb { background: var(--arches); }
.dotb { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.unit-body { padding: 14px 16px 16px; }
.unit-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.unit-tenant { font-size: 13px; color: var(--foggy); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit-mini { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 14px; }
.unit-mini .m { }
.unit-mini .m-l { font-size: 11px; color: var(--foggy); text-transform: uppercase; letter-spacing: .3px; }
.unit-mini .m-v { font-size: 15px; font-weight: 700; margin-top: 2px; }
.unit-foot { display: flex; align-items: center; gap: 7px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--foggy); }
.unit-foot svg { width: 14px; height: 14px; flex: 0 0 auto; }
.unit-foot.red { color: var(--bad); } .unit-foot.warn { color: #9a4012; }

/* ---------------- Breakdown egresos ---------------- */
.breakdown { display: grid; grid-template-columns: 130px 1fr; gap: 16px; align-items: center; }
.breakdown-chart { position: relative; height: 130px; }
.breakdown-list { display: flex; flex-direction: column; gap: 7px; }
.bd-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bd-dot { width: 10px; height: 10px; border-radius: 3px; }
.bd-name { color: var(--hof); }
.bd-val { font-weight: 600; }
.bd-pct { color: var(--foggy); font-size: 12px; margin-left: 6px; }

/* ---------------- Liquidez ---------------- */
.liq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.liq-total { grid-column: 1 / -1; }
.liq-card { background: var(--bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 16px; }
.liq-card .l-name { font-size: 12.5px; color: var(--foggy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liq-card .l-val { font-size: 22px; font-weight: 700; margin-top: 4px; }
.liq-total .l-name { font-size: 13px; }
.liq-total .l-val { font-size: 30px; color: var(--babu); }

/* ---------------- Timeline ---------------- */
.tl { margin-top: 4px; }
.tl-row { display: grid; grid-template-columns: 118px 1fr; align-items: center; gap: 10px; padding: 5px 0; }
.tl-name { font-size: 13px; font-weight: 600; }
.tl-track { position: relative; height: 40px; background: var(--bg-soft); border-radius: 8px; }
.tl-today { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--rausch); }
.tl-today::after { content: "HOY"; position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 700; color: var(--rausch); }
.tl-marker { position: absolute; transform: translate(-50%,-50%); height: 15px; border-radius: var(--radius-pill);
  display: flex; align-items: center; padding: 0 7px; font-size: 10px; font-weight: 700; color: #fff; white-space: nowrap; z-index: 1; }
.tl-marker.red { background: var(--bad); } .tl-marker.warn { background: var(--arches); } .tl-marker.ok { background: var(--babu); }
.tl-marker.ins { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.28) 0 3px, transparent 3px 6px); }
.tl-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--foggy); margin-top: 12px; }
.tl-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: middle; }

/* ---------------- Alertas ---------------- */
.alerts { display: grid; grid-template-columns: 1fr; gap: 9px; }
.alert { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: var(--radius-med);
  background: var(--bg-soft); border-left: 3px solid var(--line); }
.alert.red { border-left-color: var(--bad); } .alert.warn { border-left-color: var(--arches); }
.alert .a-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto; background: #fff; }
.alert .a-ic svg { width: 17px; height: 17px; }
.alert.red .a-ic { color: var(--bad); } .alert.warn .a-ic { color: var(--arches); } .alert .a-ic { color: var(--foggy); }
.alert .a-txt { flex: 1; min-width: 0; font-size: 13.5px; }
.alert .a-who { font-weight: 700; }
.alert .a-when { font-size: 12.5px; font-weight: 600; white-space: nowrap; }

/* ---------------- Tabla unidades ---------------- */
.table-scroll { overflow-x: auto; }
.utable { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.utable thead th { position: sticky; top: 0; background: #fff; text-align: right; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .3px; color: var(--foggy); padding: 10px 12px; border-bottom: 1.5px solid var(--line); cursor: pointer; white-space: nowrap; user-select: none; }
.utable thead th:first-child { text-align: left; }
.utable thead th.sorted { color: var(--hof); }
.utable tbody td { text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.utable tbody td:first-child { text-align: left; font-weight: 600; }
.utable tbody tr { cursor: pointer; }
.utable tbody tr:hover { background: var(--bg-soft); }
.pos { color: var(--ok); } .neg { color: var(--bad); } .muted { color: var(--foggy); }

/* ---------------- Vista unidad ---------------- */
.btn-back { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff;
  border-radius: var(--radius-pill); padding: 8px 15px; font-size: 13.5px; font-weight: 600; color: var(--hof); margin-bottom: 16px; min-height: 40px; }
.btn-back:hover { background: var(--bg-soft); }
.btn-back svg { width: 16px; height: 16px; }
.unit-hero { display: grid; grid-template-columns: 1fr; gap: 16px; background: var(--bg); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); overflow: hidden; margin-bottom: 16px; }
.unit-hero .uh-photo { aspect-ratio: 16/9; background-size: cover; background-position: center; display: grid; place-items: center; }
.unit-hero .uh-photo .ph-initial { font-size: 34px; }
.unit-hero .uh-body { padding: 4px 20px 20px; }
.unit-hero .uh-name { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.unit-hero .uh-tenant { color: var(--foggy); font-size: 14px; margin-top: 2px; }
.unit-hero .uh-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-top: 16px; }
.uh-facts .f-l { font-size: 11px; color: var(--foggy); text-transform: uppercase; letter-spacing: .3px; }
.uh-facts .f-v { font-size: 15px; font-weight: 600; margin-top: 1px; }

/* ---------------- Ledger ---------------- */
.ledger { border-collapse: collapse; font-size: 12.5px; width: 100%; min-width: 560px; }
.ledger th, .ledger td { padding: 6px 9px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.ledger thead th { font-size: 11px; text-transform: uppercase; color: var(--foggy); }
.ledger th:first-child, .ledger td:first-child { text-align: left; position: sticky; left: 0; background: #fff; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.ledger td.z { color: #cfcec7; }
.ledger td.tot { font-weight: 700; border-left: 1px solid var(--line); }
.ledger tr.result td { font-weight: 700; border-top: 2px solid var(--line); background: var(--bg-soft); }

/* ---------------- Controles chicos ---------------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-input); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: #fff; color: var(--foggy); padding: 5px 10px; font-size: 12px; font-weight: 600; }
.seg button.active { background: var(--hof); color: #fff; }
.minisel { border: 1px solid var(--line); background: #fff; color: var(--hof); font-family: inherit; font-size: 12.5px;
  font-weight: 600; padding: 6px 9px; border-radius: var(--radius-input); cursor: pointer; }

/* ---------------- Skeleton ---------------- */
.sk { background: linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0%{background-position:100% 0} 100%{background-position:-100% 0} }

.foot { margin-top: 30px; text-align: center; color: var(--foggy); font-size: 12px; }

/* count-up no rompe layout */
.k-val[data-count] { min-height: 1em; }

/* ====================== Responsive ====================== */
@media (max-width: 480px) {
  body { overflow-x: hidden; }
  .topbar-in { padding: 10px 12px; gap: 8px; }
  .brand-sub { display: none; }                     /* secundario: se oculta en pantallas chicas */
  .auto-toggle span { display: none; }              /* solo el checkbox */
  .btn-refresh { padding: 8px 13px; }
  .page { padding: 14px 12px 48px; }
}
@media (min-width: 700px) {
  .units-grid { grid-template-columns: 1fr 1fr; }
  .liq-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  .hero-row { display: grid; grid-template-columns: repeat(3, 1fr); overflow: visible; }
  .kpi { flex: none; }
}
@media (min-width: 900px) {
  .two-col { grid-template-columns: 1fr 1fr; }
  .unit-hero { grid-template-columns: 1.1fr 1fr; }
  .unit-hero .uh-photo { aspect-ratio: auto; height: 100%; min-height: 240px; }
}
@media (min-width: 1100px) {
  .hero-row { grid-template-columns: repeat(6, 1fr); }
  .units-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi .k-val { font-size: 27px; }
}
