/* ============================================================================
 * METRICORE · Sistema visual Alpha 0.1
 * Identidad: negro + oro + plata (logo METRICORE) · navy técnico del Excel.
 * ========================================================================== */
:root {
  color-scheme: light;
  --page: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef1f5;
  --ink: #0b0f14;
  --ink-2: #4a5361;
  --muted: #7a8494;
  --border: #e3e6eb;
  --border-strong: #cfd5dd;
  --grid: #eceef2;

  --brand-black: #0b0d10;
  --brand-gold: #c9a24a;
  --brand-gold-ink: #8a6a1f;      /* oro legible sobre fondo claro */
  --brand-gold-soft: #f6efdd;
  --brand-silver: #c8ccd2;
  --brand-navy: #0f2a3d;

  --series-1: #2a78d6;  /* azul */
  --series-2: #eb6834;  /* naranja */
  --series-3: #1baf7a;  /* aqua */
  --series-4: #eda100;  /* amarillo */
  --series-1-soft: #cde2fb;

  --good: #0ca30c;      /* semáforo verde */
  --warning: #fab219;   /* semáforo amarillo */
  --critical: #d03b3b;  /* semáforo rojo */
  --good-ink: #0a6e0a;
  --warning-ink: #8a5a00;
  --critical-ink: #b02a2a;
  --good-soft: #e3f4e3;
  --warning-soft: #fdf1d6;
  --critical-soft: #fbe3e1;

  --ai: #6d4fd8;
  --ai-soft: #efeafd;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --sidebar-w: 248px;
  --ai-w: 400px;
  --topbar-h: 64px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b0e12; --surface: #141920; --surface-2: #181e26; --surface-3: #1f2630;
    --ink: #f2f4f7; --ink-2: #b9c0cb; --muted: #8a93a1; --border: #252d38; --border-strong: #333d4a; --grid: #222a34;
    --brand-gold-ink: #d9b866; --brand-gold-soft: #2a2416;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-1-soft: #17304f;
    --good-ink: #4fd04f; --warning-ink: #fbc54d; --critical-ink: #f07a7a;
    --good-soft: #10291a; --warning-soft: #2e2510; --critical-soft: #331616;
    --ai: #a08cf5; --ai-soft: #221d3a;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0e12; --surface: #141920; --surface-2: #181e26; --surface-3: #1f2630;
  --ink: #f2f4f7; --ink-2: #b9c0cb; --muted: #8a93a1; --border: #252d38; --border-strong: #333d4a; --grid: #222a34;
  --brand-gold-ink: #d9b866; --brand-gold-soft: #2a2416;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-1-soft: #17304f;
  --good-ink: #4fd04f; --warning-ink: #fbc54d; --critical-ink: #f07a7a;
  --good-soft: #10291a; --warning-soft: #2e2510; --critical-soft: #331616;
  --ai: #a08cf5; --ai-soft: #221d3a;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.tnum { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
body.no-scroll { overflow: hidden; }
section { scroll-margin-top: calc(var(--head-h, 112px) + 12px); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.app.ai-docked { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--ai-w); }

/* Sidebar · tres zonas: logo (fijo) · navegación (scroll propio) · pie (fijo).
   Solo .nav desplaza; overscroll-behavior evita que el scroll pase al contenido principal. */
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  background: var(--brand-black); color: #d7dbe1;
  display: flex; flex-direction: column; padding: 18px 14px 14px;
  border-right: 1px solid #1b1f26; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; flex: none; border-bottom: 1px solid #1b1f26; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-name { font-weight: 800; letter-spacing: .06em; font-size: 17px; color: #e9ecef; line-height: 1; }
.brand-name b { color: var(--brand-gold); font-weight: 800; }
.brand-sub { font-size: 9.5px; letter-spacing: .16em; color: var(--brand-gold); margin-top: 5px; text-transform: uppercase; }
.nav {
  display: flex; flex-direction: column; gap: 2px; padding: 6px 4px 12px 0; margin-right: -8px; padding-right: 8px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #2b323c transparent;
}
.nav:focus { outline: none; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: #2b323c; border-radius: 8px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: #6b7480; padding: 14px 10px 6px; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
  color: #c3c8cf; text-decoration: none; background: none; border: 0; width: 100%; text-align: left;
}
.nav a:hover, .nav button:hover { background: #161a20; color: #fff; }
.nav a.active { background: #1a1f27; color: #fff; box-shadow: inset 3px 0 0 var(--brand-gold); }
.nav .ai-link { color: #cbbcff; }
.nav .soon { margin-left: auto; font-size: 10px; color: #6b7480; border: 1px solid #2a3039; border-radius: 99px; padding: 1px 7px; }
.sidebar-foot { flex: none; padding: 12px 10px 0; border-top: 1px solid #1b1f26; font-size: 11.5px; color: #7d8590; }
.sidebar-foot strong { color: #c3c8cf; font-weight: 600; }
.version-pill { display: inline-block; margin-top: 6px; font-size: 10.5px; padding: 2px 8px; border-radius: 99px; background: #1a1f27; color: var(--brand-gold); letter-spacing: .04em; }

/* Main */
.main { min-width: 0; display: flex; flex-direction: column; }
/* Barras fijas: superior (estado · fechas · usuario) + contexto (empresa · Proyecto / Obra) */
.sticky-head { position: sticky; top: 0; z-index: 30; box-shadow: 0 1px 0 var(--border), 0 4px 14px rgba(16, 24, 40, .05); }
.topbar {
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 8px 24px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.icon-btn.menu-btn, .icon-btn.nav-close, .nav-scrim { display: none; }
.projectbar {
  display: flex; align-items: center; gap: 10px 18px; padding: 8px 24px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--surface-2) 94%, transparent); backdrop-filter: blur(8px);
}
.project-ctx { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; font-size: 12.5px; color: var(--ink-2); }
.pb-emp { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.pb-emp b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-emp .ic { width: 15px; height: 15px; color: var(--brand-gold-ink); }
/* Estado del sistema y fechas (conceptos separados) */
.topstatus { display: flex; align-items: stretch; gap: 0; min-width: 0; }
.ts-item { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 0 14px; min-width: 0; font-size: 12.5px; line-height: 1.25; }
.ts-item:first-child { padding-left: 0; }
.ts-item + .ts-item { border-left: 1px solid var(--border); }
.ts-item b { color: var(--ink); font-weight: 600; white-space: nowrap; }
.ts-item .sem { align-self: flex-start; padding-top: 1px; padding-bottom: 1px; }
.ts-l { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.ts-l .short { display: none; }
.topbar .mobile-brand { display: none; }
.project-select { display: flex; align-items: center; gap: 10px; min-width: 0; }
.project-select label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); white-space: nowrap; }
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 8px 34px 8px 12px; min-width: 220px; font-weight: 600; max-width: 100%;
}
.select-wrap::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select-wrap select:focus-visible, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.topbar-spacer { flex: 1; }
.sys-status { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; min-width: 0; overflow: hidden; }
.sys-status .sep { width: 1px; height: 22px; background: var(--border); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 9px; padding: 8px 14px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
a.btn, a.badge { text-decoration: none; color: inherit; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-ai { background: var(--ai); border-color: var(--ai); color: #fff; }
.btn-ai:hover { background: color-mix(in srgb, var(--ai) 88%, #000); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.content { padding: 22px 24px 64px; display: flex; flex-direction: column; gap: 22px; max-width: 1480px; width: 100%; margin: 0 auto; }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; border-radius: 99px; padding: 3px 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); white-space: nowrap; }
.badge-demo { background: var(--warning-soft); color: var(--warning-ink); border-color: transparent; letter-spacing: .04em; }
.badge-ai { background: var(--ai-soft); color: var(--ai); border-color: transparent; }
.badge-gold { background: var(--brand-gold-soft); color: var(--brand-gold-ink); border-color: transparent; }

/* Filters */
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.filters-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.filters-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.filters-head .count { color: var(--muted); font-size: 12.5px; }
.filters-head .grow { flex: 1; }
.filters-toggle { display: none; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 14px 16px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.field .select-wrap select { min-width: 0; width: 100%; font-weight: 500; padding: 7px 30px 7px 10px; background: var(--surface); }
.field.is-active .select-wrap select { border-color: var(--brand-gold); background: var(--brand-gold-soft); font-weight: 600; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 99px; background: var(--brand-gold-soft); color: var(--brand-gold-ink); border: 0; font-size: 12px; font-weight: 600; }
.chip span.x { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; }
.chip:hover span.x { background: color-mix(in srgb, var(--brand-gold) 25%, transparent); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Section */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.section-head h2 .ic { color: var(--brand-gold-ink); }
.section-head .meta { color: var(--muted); font-size: 12.5px; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; grid-auto-flow: row dense; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 14px 13px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative;
}
.kpi-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; min-height: 30px; }
.kpi-top .ic { width: 16px; height: 16px; color: var(--ink-2); }
.kpi-top .lbl { flex: 1; min-width: 0; line-height: 1.25; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; white-space: nowrap; }
.kpi-value.money { font-size: 22px; }
.kpi-sub { color: var(--muted); font-size: 12px; min-height: 17px; }
.kpi.hero { grid-column: span 2; }
.kpi.hero .kpi-value { font-size: 32px; }
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--series-1); border-radius: 99px; }

/* Semáforo pill: color + ícono + texto */
.sem { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 2px 8px 2px 6px; border-radius: 99px; white-space: nowrap; text-transform: none; letter-spacing: 0; }
.sem i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sem-1 { background: var(--good-soft); color: var(--good-ink); } .sem-1 i { background: var(--good); }
.sem-2 { background: var(--warning-soft); color: var(--warning-ink); } .sem-2 i { background: var(--warning); }
.sem-3 { background: var(--critical-soft); color: var(--critical-ink); } .sem-3 i { background: var(--critical); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot-1, .dot-Verde { background: var(--good); } .dot-2, .dot-Amarillo { background: var(--warning); } .dot-3, .dot-Rojo { background: var(--critical); }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 16px 4px; }
.card-head h3 { margin: 0; font-size: 13.5px; }
.card-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-body { padding: 10px 16px 16px; }
.grid-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.grid-2-wide { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 12px; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); }
.ax { fill: var(--muted); font-size: 11px; }
.ax-ink { fill: var(--ink-2); font-size: 12px; }
.val { fill: var(--ink); font-size: 12px; font-weight: 600; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--border-strong); stroke-width: 1; }
.mark { transition: opacity .12s; }
.chart:hover .mark { opacity: .55; }
.chart .mark:hover, .chart .mark.hl { opacity: 1; }
.hit { fill: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--brand-black); color: #f2f4f7;
  font-size: 12px; padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 260px;
  opacity: 0; transform: translateY(4px); transition: opacity .1s, transform .1s;
}
.tooltip.show { opacity: 1; transform: none; }
.tooltip b { display: block; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; color: #c3c8cf; }
.tooltip .tt-row span:last-child { color: #fff; font-variant-numeric: tabular-nums; }
.stack-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface); }
.stack-bar > div { height: 100%; min-width: 4px; }
.stack-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin-top: 14px; }
.stack-legend .row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.stack-legend .row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 13px; padding: 18px 0; text-align: center; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .nowrap { white-space: nowrap; }
.tbl .muted { color: var(--muted); }
.tbl tr.clickable { cursor: pointer; }
.tbl .strong { font-weight: 600; }
.mini-progress { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.mini-progress .progress { flex: 1; }
.mini-progress span { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink-2); width: 40px; text-align: right; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.st-Completado i { background: var(--series-1); }
.st-En-proceso i { background: var(--series-2); }
.st-En-revisión i { background: var(--series-3); }
.st-Pendiente i { background: var(--series-4); }
.scroll-y { max-height: 460px; overflow: auto; }

/* Alert list */
.alert-list { display: flex; flex-direction: column; }
.alert-item { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.alert-item:last-child { border-bottom: 0; }
.alert-item .bar { align-self: stretch; border-radius: 4px; }
.alert-item .t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.alert-item .m { color: var(--muted); font-size: 12px; margin-top: 2px; }
.alert-item .r { text-align: right; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.action-tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); }

/* Estimaciones */
.est-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.est-card { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.est-card:hover { border-color: var(--border-strong); }
.est-card.on { border-color: var(--brand-gold); box-shadow: 0 0 0 1px var(--brand-gold); }
.est-card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.est-card .id { font-weight: 700; font-size: 13px; }
.est-card .obra { color: var(--muted); font-size: 12px; }
.est-card .amt { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.est-card .flags { display: flex; gap: 6px; flex-wrap: wrap; }
.flag { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 7px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.flag-volumen { background: color-mix(in srgb, var(--series-2) 16%, transparent); color: var(--ink); }
.flag-precio { background: color-mix(in srgb, var(--series-1) 16%, transparent); color: var(--ink); }
.flag-avance { background: color-mix(in srgb, var(--series-3) 18%, transparent); color: var(--ink); }
.est-detail { margin-top: 14px; }
.est-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; }
.est-summary > div { padding: 10px 12px; border-right: 1px solid var(--border); }
.est-summary > div:last-child { border-right: 0; }
.est-summary .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.est-summary .v { font-size: 16px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
tr.flagged td { background: color-mix(in srgb, var(--warning) 7%, transparent); }

/* Diagnóstico */
.diag { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--ink-2); padding: 12px 16px; }
.diag b { color: var(--ink); }

/* -------------------------------------------------------- METRICORE AI */
.ai-panel {
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; min-width: 0;
}
.ai-head { padding: 16px 18px 14px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--ai-soft), transparent); }
.ai-title { display: flex; align-items: center; gap: 10px; }
.ai-logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-black); display: grid; place-items: center; flex: none; }
.ai-logo svg { width: 20px; height: 20px; }
.ai-title h2 { margin: 0; font-size: 15px; letter-spacing: .04em; }
.ai-title h2 b { color: var(--brand-gold-ink); }
.ai-title p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.ai-title .icon-btn { margin-left: auto; }
.ai-mode { margin-top: 12px; display: block; font-size: 11.5px; color: var(--warning-ink); background: var(--warning-soft); border-radius: 8px; padding: 8px 10px; line-height: 1.4; }
.ai-mode.live { color: var(--ai); background: var(--ai-soft); }
.ai-scope { margin-top: 10px; font-size: 12px; color: var(--ink-2); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ai-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.ai-suggest { display: flex; flex-direction: column; gap: 6px; }
.ai-suggest .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.ai-suggest button { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 9px; padding: 8px 11px; font-size: 13px; color: var(--ink); }
.ai-suggest button:hover { border-color: var(--ai); background: var(--ai-soft); }
.msg-user { align-self: flex-end; max-width: 88%; background: var(--brand-black); color: #f2f4f7; padding: 9px 13px; border-radius: 14px 14px 4px 14px; font-size: 13.5px; }
:root[data-theme="dark"] .msg-user { background: #2a313c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg-user { background: #2a313c; } }
.msg-ai { border: 1px solid var(--border); border-radius: 4px 14px 14px 14px; padding: 12px 14px; font-size: 13.5px; background: var(--surface); }
.msg-ai .mh { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.msg-ai .mh strong { font-size: 13px; }
.msg-ai p { margin: 0 0 8px; }
.msg-ai ul { margin: 0 0 8px; padding-left: 18px; }
.msg-ai li { margin: 3px 0; }
.msg-ai .note { font-size: 12px; color: var(--muted); border-left: 2px solid var(--border-strong); padding-left: 9px; margin: 6px 0 8px; }
.msg-ai details { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; font-size: 12px; }
.msg-ai summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
.facts { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin-top: 8px; }
.facts span:nth-child(odd) { color: var(--muted); }
.facts span:nth-child(even) { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.ctx-json { max-height: 220px; overflow: auto; background: var(--surface-3); border-radius: 6px; padding: 8px; font: 11px/1.4 ui-monospace, Consolas, monospace; white-space: pre; margin-top: 6px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ai); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.ai-input { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; gap: 8px; align-items: flex-end; background: var(--surface); }
.ai-input textarea { flex: 1; resize: none; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 11px; background: var(--surface-2); min-height: 40px; max-height: 120px; }
.ai-input textarea:focus { outline: 2px solid var(--ai); outline-offset: 0; border-color: transparent; }
.ai-input .btn-ai { height: 40px; }
.ai-foot { font-size: 10.5px; color: var(--muted); padding: 0 14px 10px; background: var(--surface); }

.ai-fab { display: none; }
.scrim { display: none; }

/* AI insight card (inline en dashboard) */
.ai-strip { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: linear-gradient(90deg, var(--ai-soft), var(--surface) 70%); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); flex-wrap: wrap; }
.ai-strip .txt { flex: 1; min-width: 220px; font-size: 13.5px; }
.ai-strip .txt b { color: var(--ink); }

/* Mobile nav */
.bottom-nav { display: none; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 10, 14, .55); z-index: 200; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-bg.show { display: flex; }
.modal { background: var(--surface); border-radius: 14px; max-width: 760px; width: 100%; max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 20px 20px; }
.modal-body h4 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.modal-body h4:first-child { margin-top: 0; }

/* ------------------------------------------------- Alpha 0.2: panel IA */
.ai-ctrls { margin-left: auto; display: flex; gap: 6px; }
.ai-title .ai-ctrls .icon-btn { margin-left: 0; width: 32px; height: 32px; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; background: var(--muted); display: inline-block; flex: none; }
.nav-dot.real { background: var(--good); }
.nav-dot.pend { background: var(--warning); }
.ai-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 130; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px 10px 13px; border-radius: 99px; border: 0; background: var(--ai); color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: var(--shadow-lg);
}
.ai-launcher:hover { background: color-mix(in srgb, var(--ai) 88%, #000); }
.ai-launcher .nav-dot { margin-left: 2px; box-shadow: 0 0 0 2px var(--ai); }
.ai-status { margin-top: 10px; display: flex; align-items: flex-start; gap: 8px; font-size: 11.5px; line-height: 1.4; border-radius: 8px; padding: 8px 10px; }
.ai-status.real { background: var(--good-soft); color: var(--good-ink); }
.ai-status.pend { background: var(--warning-soft); color: var(--warning-ink); }
.ai-status.checking { background: var(--surface-3); color: var(--ink-2); }
.ai-status a { color: inherit; font-weight: 700; }
.ai-sec { margin: 8px 0 10px; }
.ai-sec h5 { margin: 0 0 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.ai-sec h5 i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ai-sec.calc h5 i { background: var(--series-1); }
.ai-sec.interp h5 i { background: var(--ai); }
.ai-sec.demo h5 i { background: var(--warning); }
.ai-sec.warn h5 i { background: var(--critical); }
.ai-sec.calc { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.ai-sec .facts { margin-top: 0; }
.origin { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); margin-left: 6px; white-space: nowrap; }
.origin.DEMO { background: var(--warning-soft); color: var(--warning-ink); }
.verif { font-size: 11.5px; margin-top: 8px; }
.verif.ok { color: var(--good-ink); } .verif.bad { color: var(--critical-ink); }

/* ------------------------------------------------- Alpha 0.2: carga de datos */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 28px 16px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand-gold); background: var(--brand-gold-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .ic { width: 28px; height: 28px; color: var(--brand-gold-ink); }
.ds-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; flex-wrap: wrap; }
.ds-row .grow { flex: 1; min-width: 200px; }
.ds-row h3 { margin: 0; font-size: 14px; }
.ds-row .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; }
.check-list li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.check-list .ok { color: var(--good-ink); font-weight: 700; } .check-list .no { color: var(--critical-ink); font-weight: 700; }
.msg-box { border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin: 10px 0; }
.msg-box.err { background: var(--critical-soft); color: var(--critical-ink); }
.msg-box.warn { background: var(--warning-soft); color: var(--warning-ink); }
.msg-box.ok { background: var(--good-soft); color: var(--good-ink); }
.msg-box ul { margin: 6px 0 0; padding-left: 18px; }
.import-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-top: 1px solid var(--border); }
.radio { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
tr.row-err td { background: var(--critical-soft); }
tr.row-warn td { background: color-mix(in srgb, var(--warning) 8%, transparent); }
.stat-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; background: var(--brand-black); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: calc(100vw - 32px); }

/* ------------------------------------------------- Alpha 0.3: plataforma */
.sem-0 { background: var(--surface-3); color: var(--ink-2); } .sem-0 i { background: var(--muted); }
.no-ai [data-action="open-ai"], .no-ai [data-ask], .no-ai .ai-panel, .no-ai .ai-launcher { display: none !important; }
.nav a span, .nav button span:not(.nav-dot):not(.soon) { flex: 1; min-width: 0; }
.btn-block { width: 100%; justify-content: center; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand-black); color: var(--brand-gold); font-weight: 800; font-size: 12px; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 42px; height: 42px; font-size: 14px; } .avatar.xl { width: 64px; height: 64px; font-size: 22px; }

/* Login: fotografía de construcción (local, ver assets/img/CREDITOS.md) con overlay oscuro para contraste */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    linear-gradient(115deg, rgba(8, 10, 14, .90) 0%, rgba(8, 10, 14, .74) 45%, rgba(8, 10, 14, .82) 100%),
    url("../img/login-construccion.jpg") center / cover no-repeat,
    radial-gradient(1200px 600px at 20% 0%, #1a1f27, var(--brand-black));
  background-color: var(--brand-black);
}
.login-card { border-top: 3px solid var(--brand-gold); }
.login-demo { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.login-demo summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.login-demo[open] summary { margin-bottom: 8px; }
.login-note .ic { width: 14px; height: 14px; vertical-align: -2px; }
.login-card { width: 100%; max-width: 460px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px 24px 18px; }
.login-brand { display: flex; justify-content: center; margin: -6px 0 6px; }
.login-brand img { width: 150px; height: 150px; object-fit: cover; border-radius: 14px; }
.login-card h1 { font-size: 20px; margin: 4px 0 2px; text-align: center; }
.login-card > p { text-align: center; margin: 0 0 16px; font-size: 13px; }
.login-card .field { margin-bottom: 10px; }
.login-card input[type=email], .login-card input[type=password] { width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface-2); }
.login-note { font-size: 11.5px; margin: 10px 0 0; }
.login-sep { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-tenant { margin-top: 10px; }
.lt-name { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.login-user { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 6px; }
.login-user:hover { border-color: var(--brand-gold); background: var(--brand-gold-soft); }
.login-user small { display: block; color: var(--muted); font-size: 11.5px; }
.login-foot { text-align: center; font-size: 11.5px; margin: 14px 0 0; }

/* Menú de usuario */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 3px 12px 3px 3px; max-width: 280px; }
.user-btn:hover { background: var(--surface-3); }
.user-txt { display: flex; flex-direction: column; text-align: left; min-width: 0; line-height: 1.2; }
.user-txt b { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-txt small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 290px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; z-index: 90; }
.up-head { display: flex; gap: 10px; align-items: center; padding: 8px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.up-head small { display: block; color: var(--muted); font-size: 11.5px; }
.up-local { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--warning-ink); background: var(--warning-soft); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; }
.up-local .ic { width: 14px; height: 14px; }
.user-pop a, .user-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none; text-decoration: none; color: var(--ink); font-size: 13px; text-align: left; }
.user-pop a:hover, .user-pop button:hover { background: var(--surface-3); }

/* Alpha 0.4 · barra de contexto: empresa · origen de datos · proyecto | estado · hoy · actualización · último registro */
.ctxbar { display: flex; justify-content: space-between; align-items: center; gap: 8px 18px; flex-wrap: wrap; padding: 7px 24px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--ink-2); }
.ctx-left, .ctx-right { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; min-width: 0; }
.ctx-right { margin-left: auto; }
.ctx-right .ctx-item { flex-direction: column; align-items: flex-start; gap: 1px; font-size: 12px; line-height: 1.25; }
.ctx-right .ctx-l { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.ctx-right .sem { padding-top: 1px; padding-bottom: 1px; }
.ctx-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-width: 0; }
.ctx-item .ic { width: 14px; height: 14px; color: var(--brand-gold-ink); }
.ctx-item b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ctx-l { color: var(--muted); }
.ctx-right .ctx-item + .ctx-item { padding-left: 12px; border-left: 1px solid var(--border); }
.badge-real { background: var(--good-soft); color: var(--good-ink); border-color: transparent; }
.badge-err { background: var(--critical-soft); color: var(--critical-ink); border-color: transparent; }
.up-real { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--good-ink); background: var(--good-soft); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; }
.up-real .ic { width: 14px; height: 14px; }

/* Alpha 0.4 · menú lateral: sección Administración diferenciada (grafito + acento dorado) */
.nav-admin { margin-top: 14px; padding: 4px 6px 8px; border-radius: 12px; background: #151a21; border: 1px solid #222934; box-shadow: inset 0 1px 0 rgba(201, 162, 74, .25); }
.nav-admin .nav-label { color: var(--brand-gold); padding-top: 10px; display: flex; align-items: center; gap: 8px; }
.nav-admin .nav-label::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(201, 162, 74, .45), transparent); }
.nav-admin a, .nav-admin button { color: #d4d8de; }
.nav-admin a:hover, .nav-admin button:hover { background: #1d232c; }
.nav-admin a.active { background: #232a34; }

/* Formularios en línea (usuarios, empresa, configuración) */
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { min-width: 180px; flex: 1; }
.inline-form input, .inline-form select, .mini-select { padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); }
.mini-select { padding: 4px 8px; font-size: 12.5px; }
.crumb-muted { color: var(--muted) !important; font-weight: 400 !important; }
.import-done { border-left: 3px solid var(--good); }
.import-done h3 { display: flex; align-items: center; gap: 8px; }
.import-done h3 .ic { color: var(--good-ink); }

/* Migas de pan */
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 24px 0; font-size: 12.5px; color: var(--muted); max-width: 1480px; width: 100%; margin: 0 auto; }
.crumbs a { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs a .ic { width: 14px; height: 14px; }
.crumbs span { color: var(--ink); font-weight: 600; }
.crumbs .sep { font-style: normal; color: var(--border-strong); }
.crumbs .crumb-ctx { margin-left: auto; font-weight: 400; color: var(--muted); }
.ph-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Proyectos, módulos, tarjetas */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 12px; }
.proj-card .pc-row { flex-wrap: wrap; }
.proj-card .pc-row .mini-kpi { min-width: 92px; }
.proj-card { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.proj-card:hover { border-color: var(--brand-gold); }
.pc-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.pc-sub { font-size: 12px; min-height: 16px; }
.pc-row { display: flex; gap: 10px; }
.pc-row.wrap { flex-wrap: wrap; }
.pc-row .mini-kpi { flex: 1; min-width: 120px; }
.pc-foot { font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 8px; }
.mini-kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.mini-kpi span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mini-kpi b { font-size: 15px; }
.section > .pc-row, .content > .pc-row { margin: 0; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tile { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand-gold); }
.tile .ic { color: var(--brand-gold-ink); margin-top: 2px; }
.tile b { display: block; font-size: 13.5px; }
.tile span { display: block; font-size: 16px; font-weight: 700; margin-top: 2px; }
.tile small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 26px 16px; color: var(--ink-2); }
.empty-state .ic { width: 28px; height: 28px; color: var(--muted); }
.empty-state span { color: var(--muted); font-size: 13px; max-width: 560px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; }
.profile { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.profile h2 { margin: 0; }
.profile p { margin: 2px 0; }
.hist { display: flex; flex-direction: column; gap: 10px; }
.hist-item { padding: 0; }
.hist-item > div, .hist-item summary { padding: 12px 16px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; cursor: pointer; }
.hist-item .muted { font-size: 12px; }

/* Curva S */
.cs-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 8px; padding: 14px 16px 6px; }
.cs-side { display: flex; flex-direction: column; gap: 8px; }
.cs-kpi { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding: 6px 0; font-size: 12.5px; }
.cs-kpi span { color: var(--muted); }
.cs-kpi b { font-size: 15px; font-variant-numeric: tabular-nums; }
.cs-notes { font-size: 12px; color: var(--muted); padding: 10px 16px 14px; border-top: 1px solid var(--border); line-height: 1.5; }

/* Importación */
.map-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 13px; }
.map-box summary { cursor: pointer; }
.map-box ul { margin: 8px 0 0; }
.mode-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.mode { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; position: relative; }
.mode input { position: absolute; opacity: 0; }
.mode b { font-size: 13.5px; }
.mode span { font-size: 12px; color: var(--muted); }
.mode.on { border-color: var(--brand-gold); background: var(--brand-gold-soft); box-shadow: 0 0 0 1px var(--brand-gold); }
.mode.off { opacity: .45; cursor: not-allowed; }
.mode:focus-within { outline: 2px solid var(--series-1); outline-offset: 2px; }
.summary-box { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
.tbl td.pos { color: var(--good-ink); font-weight: 700; }
.tbl td.upd { color: var(--series-1); font-weight: 700; }
.tbl td.neg { color: var(--critical-ink); font-weight: 700; }
.tag-new { font-size: 11px; font-weight: 700; color: var(--good-ink); background: var(--good-soft); border-radius: 6px; padding: 1px 6px; }
.tag-upd { font-size: 11px; font-weight: 700; color: var(--series-1); background: var(--series-1-soft); border-radius: 6px; padding: 1px 6px; }
.no { color: var(--critical-ink); font-weight: 700; }

/* ------------------------------------------------- Alpha 0.5 · workspace */
/* INTELIGENCIA arriba de CONTROL: acento púrpura de METRICORE AI, solo en este bloque */
.nav-intel { margin: 2px 0 8px; padding: 2px 6px 8px; border-radius: 12px; background: linear-gradient(180deg, rgba(160, 140, 245, .14), rgba(160, 140, 245, .04)); border: 1px solid rgba(160, 140, 245, .28); }
.nav-intel .nav-label { color: #b9a9ff; padding-top: 10px; }
.nav .nav-intel .ai-link { color: #fff; font-weight: 700; background: rgba(160, 140, 245, .16); box-shadow: inset 3px 0 0 #a08cf5; }
.nav .nav-intel .ai-link:hover { background: rgba(160, 140, 245, .26); }
.nav-intel .ai-link .ic { color: #c9bcff; }
.nav-intel-note { font-size: 10.5px; color: #8f86b8; padding: 6px 10px 0; letter-spacing: .02em; }
.nav-admin { flex: none; }

/* Menú de usuario: Bienvenido, nombre · rol · empresa */
.user-btn { max-width: 300px; padding-right: 10px; }
.user-txt small + small { color: var(--ink-2); }
.user-btn .chev { width: 14px; height: 14px; color: var(--muted); }

/* Ventana de diálogo */
#dlg .modal { max-width: 720px; }
#dlg h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 10px; }
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px 10px; margin: 0; min-width: 0; }
.perm-group legend { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 4px; font-weight: 700; }
.perm { display: flex; align-items: center; gap: 8px; padding: 4px 2px; font-size: 13px; cursor: pointer; }
.perm input { flex: none; width: 16px; height: 16px; accent-color: var(--brand-gold-ink); }
.perm span:not(.ptag) { flex: 1; min-width: 0; }
.ptag { display: inline-block; font-size: 10.5px; font-weight: 700; border-radius: 6px; padding: 1px 6px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.ptag.add { background: var(--good-soft); color: var(--good-ink); }
.ptag.rev { background: var(--critical-soft); color: var(--critical-ink); }
.perm-read { margin-bottom: 10px; }
.perm-read .check-list { margin: 4px 0 0; }
.temp-pass { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px dashed var(--border-strong); border-radius: 10px; padding: 12px; }
.temp-pass code { font: 700 18px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .06em; color: var(--ink); background: var(--surface-3); border-radius: 8px; padding: 6px 10px; user-select: all; }
.tbl.matrix th.c, .tbl.matrix td.c, .tbl td.c, .tbl th.c { text-align: center; }
.tbl.matrix tr.grp td { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.users-tbl td { vertical-align: middle; }
.modes-doc { margin: 0; padding-left: 18px; font-size: 13px; }
.modes-doc li { margin: 4px 0; }
.cfg-tabs { align-self: flex-start; max-width: 100%; overflow-x: auto; }
.cfg-tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* METRICORE AI: estado combinado DATOS × IA y respuesta estructurada */
.ai-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; border-radius: 99px; padding: 3px 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); margin-bottom: 6px; white-space: nowrap; }
.ai-pill i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--muted); }
.ai-pill .plus { color: var(--muted); font-weight: 600; }
.ai-pill[data-datos="real"] i.d { background: var(--good); } .ai-pill[data-datos="demo"] i.d { background: var(--warning); }
.ai-pill[data-ia="real"] i.a { background: var(--ai); } .ai-pill[data-ia="demo"] i.a, .ai-pill[data-ia="sin"] i.a { background: var(--warning); }
.ai-status { flex-direction: column; }
.ai-hello { font-size: 13px; color: var(--ink-2); background: var(--ai-soft); border-radius: 10px; padding: 10px 12px; }
.ai-suggest.compact button { padding: 6px 10px; font-size: 12.5px; }
.ai-sec.concl p { font-size: 13.5px; margin: 0; }
.ai-sec.concl h5 i { background: var(--ink); }
.ai-sec.risk h5 i { background: var(--critical); }
.ai-sec.prio h5 i { background: var(--warning); }
.ai-sec ol { margin: 0 0 4px; padding-left: 20px; }

/* Regreso al sitio corporativo METRILINKS (pie del menú lateral, menú de usuario, login) */
.metrilinks-back { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: #8fc4ff; text-decoration: none; border: 1px solid #23324a; border-radius: 99px; padding: 3px 10px 3px 6px; }
.metrilinks-back:hover { color: #fff; border-color: #3a7bd5; background: #101a2a; }
.metrilinks-back .ic { width: 14px; height: 14px; }
.metrilinks-back.on-light { color: var(--series-1); border-color: var(--border); }
.metrilinks-back.on-light:hover { color: var(--ink); background: var(--surface-3); }
.sidebar-foot .metrilinks-back { margin-right: 6px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) { .cs-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .user-txt { display: none; } .user-btn { padding: 3px; } }
@media (max-width: 440px) { .topbar .mobile-brand .brand-name { display: none; } .topbar { gap: 8px; } }
@media (max-width: 720px) {
  .ctxbar { padding: 8px 16px; gap: 6px; }
  .ctxbar .hide-sm { display: none; }
  .ctx-right { gap: 4px 12px; }
  .ctx-right .ctx-item + .ctx-item { border-left: 0; padding-left: 0; }
  .inline-form .field { min-width: 100%; }
}
@media (max-width: 720px) { .mode-picker { grid-template-columns: minmax(0, 1fr); } .crumbs { padding: 10px 16px 0; } .crumbs .crumb-ctx { margin-left: 0; width: 100%; } .login-brand img { width: 110px; height: 110px; } }
@media (min-width: 1440px) {
  .app:not(.ai-docked) .ai-panel { display: none; }
}
@media (max-width: 1600px) {
  .sys-status .hide-md { display: none; }
}
@media (max-width: 1200px) { .sys-status .hide-md { display: none; } }
@media (max-width: 1439px) {
  .app.ai-docked { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .ai-panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(var(--ai-w), 100vw); z-index: 150; transform: translateX(100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .ai-panel.open { transform: none; }
  .ai-panel:not(.open) { visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(8, 10, 14, .45); z-index: 140; }
  .grid-2-wide { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1023px) {
  .app, .app.ai-docked { grid-template-columns: minmax(0, 1fr); }
  /* Menú lateral como cajón: mismas tres zonas, la navegación conserva su scroll propio */
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); height: auto; z-index: 175; transform: translateX(-102%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  .nav-scrim { display: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(8, 10, 14, .5); z-index: 170; }
  body.nav-open { overflow: hidden; }
  .icon-btn.menu-btn { display: inline-grid; flex: none; }
  .icon-btn.nav-close { display: inline-grid; margin-left: auto; background: transparent; border-color: #2a3039; color: #c3c8cf; }
  .nav-close:hover { background: #161a20; color: #fff; }
  .topbar .mobile-brand { display: flex; align-items: center; gap: 8px; }
  .topbar .mobile-brand .brand-name { color: var(--ink); font-size: 15px; }
  .topbar .mobile-brand .brand-name b { color: var(--brand-gold-ink); }
  .sys-status .hide-md { display: none; }
  .grid-charts, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi.hero { grid-column: span 1; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 120;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); text-decoration: none; border: 0; background: none; padding: 4px 0; }
  .bottom-nav .active { color: var(--brand-gold-ink); }
  .bottom-nav .ai { color: var(--ai); }
  .content { padding-bottom: 96px; }
  .ai-launcher { bottom: calc(76px + env(safe-area-inset-bottom)); right: 14px; }
  .ai-panel { z-index: 160; }
}
@media (max-width: 720px) {
  :root { --topbar-h: auto; }
  .topbar { flex-wrap: wrap; padding: 8px 16px; gap: 6px 8px; }
  .topstatus { order: 5; width: 100%; display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: 0; padding-top: 6px; border-top: 1px solid var(--border); }
  .ts-item { padding: 0 8px; font-size: 11.5px; }
  .ts-item b { white-space: normal; }
  .ts-l .full { display: none; } .ts-l .short { display: inline; }
  .ts-item .sem { font-size: 11px; padding: 1px 7px; }
  .projectbar { padding: 6px 16px; gap: 8px; flex-wrap: nowrap; }
  .project-select { flex: 1; min-width: 0; }
  .project-select label { display: none; }
  .project-select .select-wrap { flex: 1; min-width: 0; }
  .project-select select { width: 100%; min-width: 0; }
  .project-ctx { margin-left: 0; max-width: 46%; }
  .project-ctx .badge { display: none; }
  .sys-status .sep, .sys-status .hide-sm { display: none; }
  .content { padding: 16px 16px 96px; gap: 18px; }
  .page-head h1 { font-size: 19px; }
  .filters-toggle { display: inline-flex; }
  .filters:not(.open) .filters-grid { display: none; }
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi.hero { grid-column: span 2; }
  .kpi-value { font-size: 22px; }
  .kpi-value.money { font-size: 18px; }
  .kpi.hero .kpi-value { font-size: 28px; }
  .stack-legend { grid-template-columns: minmax(0, 1fr); }
  .est-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .est-summary > div { border-bottom: 1px solid var(--border); }
  .ai-panel { width: 100vw; }
  .ai-launcher { padding: 12px; }
  .ai-launcher span { display: none; }
  .hide-mobile { display: none; }
}
/* Alpha 0.5 · ajustes por ancho de la barra superior */
@media (max-width: 1280px) {
  .ts-item { padding: 0 10px; }
  .user-btn { max-width: 270px; }
}
@media (max-width: 1180px) and (min-width: 721px) {
  .ts-l .full { display: none; } .ts-l .short { display: inline; }
  .user-txt small { display: none; }
}
@media (max-width: 900px) and (min-width: 721px) {
  .topbar .mobile-brand .brand-name { display: none; }
  .user-txt { display: none; } .user-btn { padding: 3px; } .user-btn .chev { display: none; }
}
@media (max-width: 720px) {
  .user-btn .chev { display: none; }
  .hide-sm { display: none; }
  .users-tbl th:nth-child(2), .users-tbl td:nth-child(2), .users-tbl th:nth-child(5), .users-tbl td:nth-child(5) { display: none; }
  #dlg .modal { max-height: 92vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (forced-colors: active) { .sem i, .dot { forced-color-adjust: none; } }

/* ============================================================================
 * Alpha 0.6 · EXPEDIENTE Y VISOR DE ESTIMACIONES (prefijo xp- para no mezclar con la sección del dashboard)
 * ========================================================================== */
.card[id^="xp-"] .card-head h3 { display: flex; align-items: center; gap: 8px; }
.card[id^="xp-"] .card-head h3 .ic { width: 17px; height: 17px; color: var(--brand-gold-ink); flex: none; }
.xp-concepto { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.xp-concepto > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.xp-concepto b { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.xp-concepto b .ic { width: 16px; height: 16px; color: var(--brand-gold-ink); }
.xp-concepto p { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-2); }
.xp-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.xp-sum > div { padding: 10px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.xp-sum span, .xp-grid span, .xp-money span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.xp-sum b { font-size: 15px; overflow-wrap: anywhere; }
.xp-verif { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
.xp-verif-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.xp-verif-head .ic { width: 16px; height: 16px; color: var(--brand-gold-ink); }
.xp-verif-head .muted { font-size: 12px; flex: 1; }
.xp-verif dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 0; }
.xp-verif dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.xp-verif dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.xp-ok { color: var(--good-ink); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.xp-ok .ic { width: 14px; height: 14px; }
.xp-bad { color: var(--critical-ink); font-weight: 700; }
.xp-warn-t { color: var(--warning-ink); font-weight: 600; }
.xp-badge-err { background: var(--critical-soft); color: var(--critical-ink); }
.xp-estado.xp-cargada { background: var(--series-1-soft); color: var(--series-1); }
.xp-warn summary { cursor: pointer; font-size: 12.5px; color: var(--warning-ink); font-weight: 600; margin: 10px 0 6px; }
.xp-issues td:last-child { min-width: 260px; }
.xp-modos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.xp-modo { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.xp-modo:has(input:checked) { border-color: var(--brand-gold); box-shadow: 0 0 0 1px var(--brand-gold); background: var(--brand-gold-soft); }
.xp-modo span { display: flex; flex-direction: column; gap: 2px; }
.xp-modo small { color: var(--ink-2); font-size: 12px; }
.xp-filters { flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.xp-filters .field { margin: 0; min-width: 200px; }
.xp-filters .meta { margin-left: auto; }
.xp-id { font-variant-numeric: tabular-nums; letter-spacing: .01em; white-space: nowrap; }
.xp-note { font-size: 12px; }
.xp-hero { padding: 18px 20px 0; }
.xp-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.xp-hero h2 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.01em; }
.xp-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--brand-gold-ink); font-weight: 700; }
.xp-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.xp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 18px; margin: 16px 0 14px; }
.xp-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.xp-grid b { font-size: 14px; overflow-wrap: anywhere; }
.xp-tabs { display: flex; gap: 4px; overflow-x: auto; border-top: 1px solid var(--border); margin: 0 -20px; padding: 6px 14px; scrollbar-width: thin; }
.xp-tabs button { border: 0; background: none; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.xp-tabs button:hover { background: var(--surface-2); color: var(--ink); }
.xp-money { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.xp-money > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.xp-money b { font-size: 16px; overflow-wrap: anywhere; }
.xp-money .xp-total { border-color: var(--brand-gold); background: var(--brand-gold-soft); }
.xp-dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 18px; margin: 0; }
.xp-dl > div { border-bottom: 1px solid var(--border); padding-bottom: 8px; min-width: 0; }
.xp-dl dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.xp-dl dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.xp-inline { margin: 0; display: flex; align-items: center; gap: 8px; }
.xp-inline label { margin: 0; }
.xp-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 14px 16px 16px; }
.xp-photo { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); display: flex; flex-direction: column; }
.xp-photo button { border: 0; padding: 0; background: var(--surface-3); cursor: zoom-in; display: block; aspect-ratio: 4 / 3; }
.xp-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.xp-ph { aspect-ratio: 4 / 3; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 12px; gap: 4px; padding: 10px; }
.xp-ph .ic { width: 22px; height: 22px; }
.xp-photo figcaption { padding: 8px 10px 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; }
.xp-photo figcaption .muted { font-size: 11.5px; }
.xp-up { border-top: 1px solid var(--border); padding: 12px 16px 16px; flex-wrap: wrap; }
.xp-up .msg-box { flex-basis: 100%; }
.xp-timeline { list-style: none; margin: 14px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.xp-timeline li { position: relative; display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.xp-timeline li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-gold); }
.xp-timeline time { font-size: 11.5px; color: var(--muted); }
.xp-ai-note { display: flex; gap: 8px; align-items: flex-start; background: var(--ai-soft); color: var(--ink-2); margin-top: 14px; }
.xp-ai-note .ic { width: 16px; height: 16px; color: var(--ai); flex: none; margin-top: 2px; }
.xp-ver { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.modal:has(.doc-viewer) { max-width: min(1100px, 96vw); }
.doc-viewer { background: var(--surface-3); border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.doc-viewer img { max-width: 100%; max-height: 70vh; display: block; }
.doc-viewer iframe, .doc-viewer object { width: 100%; height: 70vh; border: 0; background: #fff; display: block; }
.doc-fallback { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 40px 20px; color: var(--ink-2); font-size: 13px; }
.doc-fallback .ic { width: 30px; height: 30px; color: var(--brand-gold-ink); }
.doc-viewer object .doc-fallback { background: var(--surface-3); height: 100%; justify-content: center; }
.doc-meta { font-size: 12px; margin: 10px 0; }
.tbl.xp-resp tfoot td { font-weight: 700; border-top: 1px solid var(--border-strong); }
@media (max-width: 1100px) {
  .xp-money { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .xp-grid, .xp-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .xp-dl, .xp-verif dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .xp-concepto, .xp-modos { grid-template-columns: minmax(0, 1fr); }
  .xp-money { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .xp-dl, .xp-verif dl { grid-template-columns: minmax(0, 1fr); }
  .xp-hero { padding: 14px 14px 0; }
  .xp-hero h2 { font-size: 20px; }
  .xp-tabs { margin: 0 -14px; padding: 6px 8px; }
  .xp-filters .field { min-width: 0; flex: 1 1 140px; }
  .xp-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px; gap: 8px; }
  /* Tablas → tarjetas en móvil (mismo contenido, sin desplazamiento horizontal) */
  .tbl.xp-resp thead { display: none; }
  .tbl.xp-resp, .tbl.xp-resp tbody, .tbl.xp-resp tfoot, .tbl.xp-resp tr, .tbl.xp-resp td { display: block; width: 100%; }
  .tbl.xp-resp tr { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 10px; padding: 6px 12px; background: var(--surface); }
  .tbl.xp-resp tbody tr:hover td { background: none; }
  .tbl.xp-resp td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: right; white-space: normal; overflow-wrap: anywhere; }
  .tbl.xp-resp td::before { content: attr(data-label); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; flex: none; max-width: 42%; }
  .tbl.xp-resp td[data-label=""]::before { display: none; }
  .tbl.xp-resp td > div { text-align: right; }
  .table-wrap:has(> .tbl.xp-resp) { padding: 10px; overflow: visible; }
  .xp-issues td:last-child { min-width: 0; }
  .doc-viewer iframe { height: 60vh; }
}
