/* Cobros · Tesorería — colores del "Panel de Tesorería v3"; tipografía, botones,
   formas y ritmo tomados del sistema de ClickUp: títulos pesados y apretados
   (Plus Jakarta Sans), texto en Inter, rótulos en mono, todo lo que se toca en
   píldora, tarjetas planas con filete y un solo borde cónico animado por pantalla. */
@property --giro { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
:root {
  --bg: #F7F8F6;
  --card: #FFFFFF;
  --ink: #111A14;
  --ink-2: #3D4B43;
  --muted: #5C6A61;
  --line: #E8EBE7;
  --line-soft: #F1F4F1;
  --line-strong: #CBD4CD;
  --head: #FBFCFB;
  --hover: #FCFDFC;
  --chip: #F2F4F1;
  --brand: #17754A;
  --brand-dark: #0F5334;
  --brand-soft: #E7F4EC;
  --accent: #3CD07A;
  --warn: #C8922C;
  --danger: #C0392B;
  --side: #0D1F16;
  --side-hover: #16301F;
  --side-active: #1C3728;
  --side-ink: #B7CDBF;
  --side-muted: #7FA891;
  --side-label: #5E8571;
  --side-line: #23402F;
  --surface: var(--card);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --mono: 'Sometype Mono', 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --r-pill: 9999px;
  --r-input: 9px;
  --r-card: 12px;
  --r-card-lg: 20px;
  --ease: cubic-bezier(0.33, 1, 0.68, 1);
  /* Degradado cónico de la marca, con nuestros verdes. */
  --conic: conic-gradient(from var(--giro), var(--brand-dark) 0%, var(--brand) 20%, var(--accent) 40%, #B9F2CF 55%,
    var(--accent) 70%, var(--brand) 85%, var(--brand-dark) 100%);
  --grad-text: linear-gradient(83deg, var(--accent) -5%, var(--brand) 60%, var(--brand-dark) 125%);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); }
body { font-family: var(--font); font-feature-settings: "calt" 0, "liga" 0; color: var(--ink); font-size: 14px; line-height: 1.5;
  letter-spacing: -0.006em; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; text-wrap: pretty; }
a { color: var(--brand); text-decoration: none; cursor: pointer; transition: color .15s; }
a:hover { color: var(--brand-dark); text-decoration: underline; text-underline-offset: 3px; }
::selection { background: #CDEBD9; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; margin: 0; }
/* En montos el espaciado no se cierra: los separadores de miles tienen que verse. */
.num { font-family: var(--display); font-weight: 700; letter-spacing: 0; word-spacing: .08em; }
.muted { color: var(--muted); }
.ok { color: var(--brand); }
.warn { color: var(--warn); }
.error { color: var(--danger); }
.small { font-size: 12px; }
.right { text-align: right; justify-content: flex-end; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- botones */
/* Todo botón es píldora. El principal va relleno oscuro; los demás, con filete. */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; cursor: pointer;
  border-radius: var(--r-pill); padding: 0 20px; min-height: 40px; border: 1px solid var(--line-strong); background: #fff;
  color: var(--ink); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
button:hover { background: var(--chip); border-color: var(--ink-2); }
button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { background: #fff; border-color: var(--line-strong); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); padding: 0 24px; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-primary:disabled:hover { background: var(--ink); border-color: var(--ink); }
.btn-ghost { background: transparent; }
/* Variante con filete de color: acción secundaria que sí debe notarse. */
.btn-soft { color: var(--brand); border-color: var(--brand); background: #fff; font-size: 13px; min-height: 30px; padding: 0 14px; }
.btn-soft:hover { background: var(--brand-soft); border-color: var(--brand); }
.btn-danger { color: var(--danger); border-color: #EBC2BC; }
.btn-danger:hover { background: #FBEBE8; border-color: var(--danger); }
.btn-danger.btn-primary, .btn-primary.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { font-size: 13px; min-height: 30px; padding: 0 14px; }
.linkish { background: none; border: 0; padding: 0; min-height: 0; color: var(--brand); font-weight: 600; border-radius: 0; }
.linkish:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- campos */
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong);
  border-radius: var(--r-input); padding: 8px 12px; width: 100%; min-height: 40px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
select { appearance: none; padding-right: 36px; background-repeat: no-repeat; background-position: right 12px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235C6A61' stroke-width='1.5'/%3E%3C/svg%3E"); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px #CDEBD9; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--brand); }
label.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.field > input, label.field > select, label.field > textarea { font-weight: 400; color: var(--ink); font-size: 14px; }
label.field .small { font-weight: 400; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.check { width: 18px; height: 18px; min-height: 0; border-radius: 5px; flex: none; border: 1.5px solid var(--line-strong);
  background: #fff; cursor: pointer; display: inline-grid; place-items: center; color: #fff; font-size: 11px; padding: 0; }
.check.on { background: var(--brand); border-color: var(--brand); }
.check.on::after { content: "✓"; }

/* ---------------------------------------------------------------- rótulos mono */
.micro, table.t th, .fact-label, .section-label, .nav-label, .modal-kicker, .project-label, .brand-sub, .crumb, .kpi-title, .nav-soon {
  font-family: var(--mono); font-size: 10px; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; }

/* ---------------------------------------------------------------- píldoras */
.pill { font-size: 12px; font-weight: 600; letter-spacing: 0; padding: 3px 10px; border-radius: var(--r-pill); width: fit-content;
  white-space: nowrap; display: inline-block; background: var(--chip); color: #4A574E; line-height: 1.4; }
.pill-ok { background: var(--brand-soft); color: var(--brand-dark); }
.pill-warn { background: #FDF3E3; color: #8A5B07; }
.pill-danger { background: #FBEBE8; color: #94281B; }
.pill-info { background: #EEF1FA; color: #39479B; }
.pill-purple { background: #EEE9FA; color: #4A2E86; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Etiquetas de filtro: la activa va en el color de marca, como la etiqueta resaltada. */
.chip { font-size: 13px; font-weight: 700; background: #fff; padding: 0 16px; min-height: 34px; border-radius: var(--r-pill); cursor: pointer;
  border: 1px solid var(--line); color: var(--ink); }
.chip:hover { background: var(--head); border-color: var(--line-strong); }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.chip.danger { color: #94281B; }
.chip.danger.on { background: #FBEBE8; border-color: var(--danger); color: #94281B; }
.seg { display: flex; gap: 4px; background: var(--chip); border-radius: var(--r-pill); padding: 4px; width: fit-content; flex-wrap: wrap; }
.seg button { font-size: 13px; min-height: 30px; padding: 0 14px; border: 0; background: none; color: var(--muted); }
.seg button:hover { color: var(--ink); background: rgba(17,26,20,.04); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(17,26,20,.1), 0 1px 2px -1px rgba(17,26,20,.1); }

/* ---------------------------------------------------------------- estructura */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; background: var(--bg); }
.sidebar { background: var(--side); display: flex; flex-direction: column; gap: 2px; padding: 20px 12px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 14px 24px; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 17px; line-height: 1; color: var(--side); }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: .04em; line-height: 1; color: #fff; }
.brand-sub { color: var(--side-muted); line-height: 2; }
.project-box { position: relative; margin-bottom: 20px; }
.project-btn { width: 100%; border: 1px solid var(--side-line); border-radius: var(--r-card); padding: 8px 12px 8px 8px; min-height: 0;
  display: flex; align-items: center; gap: 8px; background: none; color: inherit; text-align: left; font-weight: 400; }
.project-btn:hover { background: var(--side-hover); border-color: var(--side-line); }
.project-count { width: 26px; height: 26px; border-radius: var(--r-pill); background: var(--side-active); display: grid;
  place-items: center; font-size: 11px; font-weight: 700; color: var(--accent); flex: none; }
.project-label { color: var(--side-muted); }
.project-name { font-size: 13px; font-weight: 600; color: #EAF3ED; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border-radius: var(--r-card);
  border: 1px solid var(--line); box-shadow: 0 1px 1px -.5px rgba(13,31,22,.06), 0 6px 6px -3px rgba(13,31,22,.06), 0 12px 12px -6px rgba(13,31,22,.06);
  padding: 4px; z-index: 30; max-height: 320px; overflow-y: auto; }
.project-menu button { width: 100%; border: 0; justify-content: space-between; min-height: 34px; font-weight: 500; border-radius: 8px; padding: 0 12px; }
.project-menu button.on { color: var(--brand); font-weight: 700; }
.nav-label { color: var(--side-label); padding: 0 12px 8px; }
.nav-label.gap { padding-top: 24px; }
/* Ítems de menú en píldora; el activo, píldora clara sobre el panel oscuro. */
.nav-item { display: flex; align-items: center; gap: 8px; padding: 0 14px; min-height: 36px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 500; cursor: pointer; color: var(--side-ink); border: 0; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.on { background: #fff; color: var(--side); font-weight: 700; }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--side-muted); }
.nav-item.on .nav-count { color: var(--muted); }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--accent); color: var(--side);
  border-radius: var(--r-pill); padding: 0 8px; line-height: 20px; }
.nav-badge.danger { background: #E0574A; color: #fff; }
.nav-soon { margin-left: auto; font-size: 9px; color: var(--side-label); border: 1px solid var(--side-line);
  border-radius: var(--r-pill); padding: 0 8px; line-height: 18px; }
.side-user { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--side-line); display: flex; align-items: center;
  gap: 8px; position: relative; }
.avatar { width: 32px; height: 32px; border-radius: var(--r-pill); background: var(--side-active); color: var(--accent);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; box-shadow: 0 0 0 2px var(--side); }
.side-user-name { font-size: 13px; font-weight: 600; color: #EAF3ED; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-role { font-size: 12px; color: var(--side-muted); }
.side-user-more { margin-left: auto; color: var(--side-muted); background: none; border: 0; padding: 0 10px; min-height: 28px; font-size: 14px; }
.side-user-more:hover { background: rgba(255,255,255,.06); color: #fff; }
.user-menu { position: absolute; bottom: calc(100% + 8px); right: 0; background: #fff; border-radius: var(--r-card);
  border: 1px solid var(--line); box-shadow: 0 6px 6px -3px rgba(13,31,22,.06), 0 12px 12px -6px rgba(13,31,22,.06);
  padding: 4px; min-width: 200px; z-index: 30; }
.user-menu button { width: 100%; border: 0; min-height: 34px; font-weight: 500; border-radius: 8px; padding: 0 12px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 28px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.crumb { color: var(--muted); line-height: 2; }
.page-title { font-family: var(--display); font-size: 26px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.1; }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: relative; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 0 8px 0 16px; min-width: 280px; background: var(--head); transition: border-color .15s, box-shadow .15s; }
.search:hover { border-color: var(--line-strong); }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px #CDEBD9; background: #fff; }
.search input { border: 0; padding: 8px 0; min-height: 38px; outline: none; font-size: 14px; border-radius: 0; background: transparent; }
.search input:focus { box-shadow: none; }
.search .kbd { font-family: var(--mono); font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; background: #fff; }
.icon-btn { position: relative; width: 40px; height: 40px; min-height: 0; padding: 0; justify-content: center; border-radius: var(--r-pill);
  border-color: var(--line); }
.icon-btn .alert-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
  box-shadow: 0 0 0 2px #fff; }
.me { width: 40px; height: 40px; border-radius: var(--r-pill); background: var(--brand-soft); color: var(--brand); display: grid;
  place-items: center; font-size: 12px; font-weight: 700; }
.menu-toggle { display: none; }
.popover { position: absolute; top: calc(100% + 8px); right: 0; width: min(380px, 90vw); background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: 0 6px 6px -3px rgba(13,31,22,.06), 0 12px 12px -6px rgba(13,31,22,.06); padding: 4px; z-index: 40; }
.popover .item { display: flex; gap: 12px; padding: 12px; border-radius: 8px; cursor: pointer; align-items: flex-start; }
.popover .item:hover { background: var(--chip); }
.content { padding: 28px 28px 64px; display: flex; flex-direction: column; gap: 24px; }
.back { font-size: 14px; font-weight: 600; color: var(--brand); cursor: pointer; width: fit-content; background: none; border: 0; padding: 0; min-height: 0; border-radius: 0; }
.back:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
.flash { background: var(--brand-soft); color: var(--brand-dark); border-radius: var(--r-card); padding: 12px 16px; font-weight: 600; }
.flash.error { background: #FBEBE8; color: #94281B; }

/* ---------------------------------------------------------------- tarjetas */
/* Planas: filete de 1 px, sin sombra. */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); }
.card-pad { padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 24px 28px 16px; flex-wrap: wrap; }
.card-title { font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.3; }
.card-sub { font-size: 13px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* Cifras grandes tipo "stat callout": pesadas y con el espaciado muy cerrado. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-card-lg); overflow: hidden; }
.kpi { background: #fff; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.kpi-title { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi-value { font-family: var(--display); font-size: 38px; font-weight: 800; letter-spacing: -0.02em; word-spacing: .1em; line-height: 1.05; }
.kpi-value.sm { font-size: 30px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: minmax(340px, 1.7fr) minmax(280px, 1fr); gap: 24px; align-items: stretch; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 24px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(265px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-card-lg); overflow: hidden; }
.tile { background: #fff; padding: 28px; display: flex; flex-direction: column; gap: 8px; min-height: 136px; }
.tile-title { font-family: var(--display); font-size: 18px; font-weight: 700; letter-spacing: -0.025em; }

/* ---------------------------------------------------------------- tablas */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { color: var(--muted); text-align: left; padding: 10px 16px; background: var(--head); border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.t th:first-child, table.t td:first-child { padding-left: 28px; }
table.t th:last-child, table.t td:last-child { padding-right: 28px; }
table.t tr.click { cursor: pointer; }
table.t tbody tr:hover td { background: var(--head); }
table.t th.r, table.t td.r { text-align: right; }
.cell-main { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; display: block; }
.cell-sub { font-size: 12px; color: var(--muted); }
.lv-mark { width: 3px; height: 30px; border-radius: 3px; display: inline-block; flex: none; }
.pager { display: flex; align-items: center; gap: 12px; padding: 16px 28px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager .pages { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.pager button { font-size: 13px; min-height: 32px; min-width: 32px; padding: 0 10px; justify-content: center; border-color: var(--line); }
.pager button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.empty { padding: 28px; color: var(--muted); }

/* ---------------------------------------------------------------- gráficos */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 200px; overflow: visible; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.legend { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--muted); }
.legend .ln { width: 16px; height: 2px; border-radius: 2px; display: inline-block; margin-right: 8px; vertical-align: middle; }
.stackbar { display: flex; height: 8px; border-radius: var(--r-pill); overflow: hidden; gap: 2px; }
.bar-track { flex: 1; height: 6px; border-radius: var(--r-pill); background: var(--line-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-pill); }
.tip { position: fixed; pointer-events: none; z-index: 60; background: var(--side); color: #fff; font-size: 12px;
  padding: 8px 12px; border-radius: 10px; line-height: 1.5; box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1); }
.tip b { font-weight: 700; }

/* ---------------------------------------------------------------- ficha */
.big-avatar { width: 48px; height: 48px; border-radius: var(--r-pill); background: var(--brand-soft); color: var(--brand); display: grid;
  place-items: center; font-family: var(--display); font-weight: 800; font-size: 16px; flex: none; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 16px; padding-top: 16px;
  border-top: 1px solid var(--line-soft); }
.fact-label { color: var(--muted); }
.fact-value { font-size: 15px; font-weight: 700; letter-spacing: -0.015em; }
.timeline-item { display: flex; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.timeline-item .dot { width: 8px; height: 8px; margin-top: 6px; }
.note-box { font-size: 13px; color: var(--muted); background: var(--head); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 16px; }
.policy { background: #FFFBEB; border-color: #F3E3B5; }
.policy ul { margin: 8px 0 0; padding-left: 16px; font-size: 13px; color: var(--ink-2); }
.policy li { margin: 4px 0; }
.inline-edit { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-edit input { width: 11rem; padding: 4px 10px; min-height: 32px; }
.tpl-text { white-space: pre-wrap; font-size: 12px; color: var(--muted); max-width: 420px; }
.preview { white-space: pre-wrap; background: #E7FBE6; border: 1px solid #CDECCB; border-radius: var(--r-card); padding: 12px 16px; }
.preview mark { background: #FFF3B0; border-radius: 3px; padding: 0 2px; }

/* ---------------------------------------------------------------- ventanas */
dialog.modal { border: 1px solid var(--line); border-radius: var(--r-card-lg); padding: 28px; width: min(560px, 96vw); max-height: 92vh;
  box-shadow: 0 1px 1px -.5px rgba(13,31,22,.06), 0 6px 6px -3px rgba(13,31,22,.06), 0 12px 12px -6px rgba(13,31,22,.06), 0 24px 48px -12px rgba(13,31,22,.12);
  color: var(--ink); }
dialog.modal.wide { width: min(760px, 96vw); }
dialog.modal::backdrop { background: rgba(13,31,22,.42); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.modal-kicker { color: var(--brand); }
.modal-title { font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.15; }
.modal-x { margin-left: auto; border: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 0;
  width: 34px; height: 34px; min-height: 0; justify-content: center; }
.modal-body { display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
.section-label { color: var(--muted); }
.opt-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 16px;
  min-height: 0; font-size: 14px; font-weight: 400; cursor: pointer; background: #fff; width: 100%; text-align: left; white-space: normal; }
.opt-row:hover { background: var(--head); border-color: var(--line-strong); }
.opt-row.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.money-input { font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: 0; border-color: var(--brand); }
fieldset.group { border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px 20px 20px; margin: 0; display: flex;
  flex-direction: column; gap: 16px; }
fieldset.group legend { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: -0.02em; padding: 0 8px; }
details.group { border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px 20px; }

/* ---------------------------------------------------------------- ingreso */
/* Dos columnas: titular enorme con lista de beneficios a la izquierda; la tarjeta
   de ingreso a la derecha con el único borde cónico animado del sistema. */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center;
  gap: 64px; padding: 48px max(24px, 7vw); background: #fff; }
.login-hero { display: flex; flex-direction: column; gap: 24px; max-width: 640px; }
.login-hero .brand { padding: 0 0 8px; }
.login-hero .brand-name { color: var(--ink); }
.login-hero .brand-sub { color: var(--muted); }
.login-title { font-family: var(--display); font-weight: 800; font-size: clamp(40px, 5.2vw, 72px); line-height: 1.05;
  letter-spacing: -0.045em; margin: 0; color: var(--ink); font-feature-settings: normal; }
/* La coma y el punto de Plus Jakarta traen mucho aire a la izquierda a este tamaño. */
.login-title .pt { margin-left: -.14em; }
.login-title em { font-style: normal; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-lead { font-size: 18px; line-height: 1.5; color: var(--muted); margin: 0; max-width: 500px; letter-spacing: -0.014em; }
.login-lead b { color: var(--ink); font-weight: 600; }
.login-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: var(--muted); }
.login-checks li { display: flex; gap: 8px; align-items: baseline; }
.login-checks li::before { content: "✓"; color: var(--brand); font-weight: 800; }
.login-checks b { color: var(--ink); font-weight: 700; }
.login-card { width: min(400px, 100%); justify-self: center; background: #fff; border-radius: var(--r-card-lg);
  padding: 28px; display: flex; flex-direction: column; gap: 16px; position: relative; isolation: isolate; }
.login-card::before { content: ""; position: absolute; inset: -2px; border-radius: calc(var(--r-card-lg) + 2px); background: var(--conic);
  z-index: -1; animation: girar 4s linear infinite; }
.login-card::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-card-lg); background: #fff; z-index: -1; }
@keyframes girar { to { --giro: 360deg; } }
@media (prefers-reduced-motion: reduce) { .login-card::before { animation: none; } }
.login-card .btn-primary { min-height: 44px; justify-content: center; }

/* ---------------------------------------------------------------- celular */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 50; transform: translateX(-100%);
    transition: transform .45s var(--ease); }
  .layout.menu-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(13,31,22,.42); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; gap: 8px; }
  .page-title { font-size: 22px; }
  .content { padding: 20px 16px 48px; }
  .search { min-width: 0; flex: 1; }
  .top-tools { width: 100%; }
  .two-col { grid-template-columns: 1fr; }
  .card-head, .card-pad { padding-left: 16px; padding-right: 16px; }
  table.t th:first-child, table.t td:first-child { padding-left: 16px; }
  .kpi-value { font-size: 34px; }
  .login { grid-template-columns: 1fr; padding: 32px 16px; gap: 32px; align-content: center; }
  .login-lead { font-size: 16px; }
  dialog.modal { padding: 24px 16px; }
  .modal-title { font-size: 24px; }
}

/* Historial de cobranza: barras por día/semana/mes/año con la línea del promedio. */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bars-plot { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 24px; }
.bar-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center;
  cursor: default; outline: 0; }
.bar-fill { position: relative; width: 100%; max-width: 48px; min-height: 2px; background: var(--brand);
  border-radius: 6px 6px 0 0; transition: filter .15s; }
.bar-col:hover .bar-fill, .bar-col:focus-visible .bar-fill { filter: brightness(1.25); }
/* El periodo en curso va rayado: todavía no termina, no se compara de igual a igual. */
.bar-fill.open { background: repeating-linear-gradient(135deg, var(--brand) 0 5px, var(--brand-dark) 5px 10px); opacity: .6; }
.bar-val { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px;
  font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.bar-avg { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line-strong); pointer-events: none; }
.bars-axis { display: flex; gap: 6px; }
/* Las etiquetas se rotulan salteadas: la que va, se deja desbordar sobre los
   huecos vacíos de al lado en vez de recortarse a una letra. */
.bars-axis span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: visible; }
@media (max-width: 720px) { .bars-plot { gap: 3px; height: 170px; } .bars-axis { gap: 3px; }
  .bars-axis span, .bar-val { font-size: 9.5px; } }

/* Tarjetas para elegir etapa: son botones, así que hay que quitarles el aspecto
   de botón del navegador y darles la reacción al pasar el ratón. */
.stage-card { border: 1px solid var(--line); background: var(--surface); font: inherit; border-radius: var(--r-card-lg);
  color: inherit; white-space: normal; min-height: 0; transition: border-color .15s, transform .45s var(--ease); }
.stage-card:hover { border-color: var(--brand); background: var(--surface); transform: translateY(-2px); }
.stage-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.stage-card .facts { border-top: 1px solid var(--line); }

/* Lotes del cliente: una pestaña por lote y el detalle del elegido debajo. */
.lote-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.lote-tab { display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  min-width: 200px; min-height: 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--surface); font: inherit; color: inherit; cursor: pointer; text-align: left; white-space: normal;
  transition: border-color .15s; }
.lote-tab:hover { border-color: var(--line-strong); background: var(--surface); }
.lote-tab.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--surface); }
.lote-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.lote-tab-name { font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: -0.02em; }
.lote-tab-meta { display: flex; gap: 8px; align-items: center; }

/* Barra de avance de pago del lote. */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; margin-bottom: 4px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); }

/* Cuota vencida y sin pagar, para que salte a la vista en el cronograma. */
.row-overdue td { background: color-mix(in srgb, var(--danger) 7%, transparent); }

@media (max-width: 640px) { .lote-tab { min-width: 0; flex: 1 1 100%; } }

/* Dónde está el lote (proyecto · etapa), bajo su título en la ficha. */
.lote-ubic { font-size: 13px; color: var(--muted); }

/* Columna del lote en las tablas: ancho propio para que no se estire ni parta el
   "Mz A Lt 1" en dos líneas, y el proyecto · etapa debajo sin romper la fila. */
.col-lote { white-space: nowrap; }
.col-lote .cell-main { max-width: 160px; }
.col-lote .cell-sub { display: block; overflow: hidden; text-overflow: ellipsis;
  max-width: 190px; white-space: nowrap; }

/* ================================================================ orden y jerarquía */
/* Franja de aviso: una línea con el estado; el detalle se despliega si hace falta. */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-radius: var(--r-card);
  border: 1px solid var(--line); background: #fff; font-size: 14px; }
.banner-icon { width: 24px; height: 24px; border-radius: var(--r-pill); display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 800; }
.banner-ok .banner-icon { background: var(--brand-soft); color: var(--brand); }
.banner-danger { border-color: #EBC2BC; background: #FFFBFA; }
.banner-danger .banner-icon { background: var(--danger); color: #fff; }
.banner-danger b { color: #94281B; }
.banner-sub { color: var(--muted); }
.banner-more { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--brand); white-space: nowrap; }
details.banner { display: block; padding: 0; }
details.banner > summary { display: flex; align-items: center; gap: 12px; padding: 12px 20px; cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.banner > summary .banner-more::after, .card-fold > summary .banner-more::after { content: " ↓"; }
details[open].banner > summary .banner-more::after, .card-fold[open] > summary .banner-more::after { content: " ↑"; }
details[open].banner > summary { border-bottom: 1px solid #F3DCD8; margin-bottom: 12px; }
details.banner .table-wrap { max-height: 420px; overflow-y: auto; border-top: 1px solid var(--line-soft); }
.card-fold > summary { cursor: pointer; list-style: none; }
.card-fold:not([open]) > summary { padding-bottom: 24px; }

/* Ficha: cabecera de perfil a lo ancho (quién es, cuánto debe, qué hacer). */
.profile { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px 32px; padding: 24px 28px; align-items: center; }
.profile-id { display: flex; gap: 16px; align-items: center; min-width: 0; }
.profile-id .big-avatar { width: 56px; height: 56px; font-size: 18px; }
.profile-name { font-family: var(--display); font-size: 24px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
.profile-money { display: flex; gap: 32px; align-items: flex-start; padding-left: 32px; border-left: 1px solid var(--line); }
.profile-money .kpi-value.sm { font-size: 28px; }
.profile-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; padding-top: 20px; border-top: 1px solid var(--line-soft); }

/* Dos columnas: el lote (lo que se consulta) y, al costado, lo que se gestiona del cliente. */
.ficha-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.ficha-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ficha-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ficha-side .card-pad { padding: 20px 24px; }
.ficha-main .section-title .card-title { font-size: 16px; }
.grid-side { grid-template-columns: 1fr; gap: 12px; }

/* Datos del lote: primero lo que importa hoy, en grande; lo contable, debajo y en pequeño. */
.facts-key { grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); gap: 16px 24px; border-top: 0; padding-top: 8px; }
.facts-key .kpi-value.sm { font-size: 26px; white-space: nowrap; }
.facts-sec { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin-top: 16px; }
.facts-sec .fact-value { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.crono-toggle { display: flex; align-items: center; gap: 12px; padding: 12px 28px 20px; }

/* Documentos en la columna: lista compacta, un archivo por fila. */
.doc-list { width: 100%; border-collapse: collapse; }
.doc-list td { padding: 12px 0; border-top: 1px solid var(--line-soft); }
.doc-list .cell-main { max-width: 100%; }
.doc-upload { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.doc-upload input[type=file] { grid-column: 1 / -1; font-size: 13px; padding: 8px; }
.doc-upload #doc-up { grid-column: 1 / -1; justify-content: center; }

@media (max-width: 1180px) {
  .ficha-grid { grid-template-columns: 1fr; }
  .ficha-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
}
@media (max-width: 900px) {
  .profile { grid-template-columns: 1fr; padding: 20px 16px; }
  .profile-money { padding-left: 0; border-left: 0; }
  .facts-key { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 16px; gap: 8px; }
  .kpi .kpi-value { font-size: 24px; }
  .kpi-foot .pill { white-space: normal; border-radius: 12px; }
  .banner-sub { display: none; }
  .crono-toggle { padding: 12px 16px 16px; }
}

/* Contenido de cada pestaña: tarjetas separadas, nunca pegadas. */
#gest, #pay-section, #rep { display: flex; flex-direction: column; gap: 16px; }
#gest > .kpis, #pay-section > .kpis { margin: 0; }

/* Estado vacío: ícono, qué pasa y qué hacer. */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 40px 24px 44px; }
.empty-state b { font-family: var(--display); font-size: 16px; letter-spacing: -0.02em; }
.empty-icon { width: 40px; height: 40px; border-radius: var(--r-pill); display: grid; place-items: center; margin-bottom: 6px;
  background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 16px; }

/* Barra de filtros dentro de la cabecera de una tarjeta. */
.filter-bar { margin-left: auto; gap: 8px; }
.filter-bar input, .filter-bar select { width: auto; }

/* Cierre de caja. */
.week-nav { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.week-nav .icon-btn { width: 36px; height: 36px; }
.cc-action { padding-top: 16px; border-top: 1px solid var(--line-soft); }

/* Motor de cobranza: los pasos en orden, de izquierda a derecha. */
.rule-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; padding: 0 28px 20px; }
.rule-step { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--head); position: relative; }
.rule-step.on { background: #fff; border-color: var(--line-strong); }
.rule-step:not(.on) { opacity: .7; }
.rule-step .pill { margin-top: auto; }
.rule-n { width: 24px; height: 24px; border-radius: var(--r-pill); display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: var(--chip); color: var(--muted); }
.rule-step.on .rule-n { background: var(--ink); color: #fff; }
.rule-when { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: -0.02em; line-height: 1.25; }

/* Redactar + vista previa: el formulario a la izquierda y cómo le llega, a la derecha. */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.wa-phone { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 96px; }
.wa-screen { background: #E9EFE9; border-radius: var(--r-card-lg); padding: 20px 16px; min-height: 220px;
  background-image: radial-gradient(rgba(17,26,20,.05) 1px, transparent 1px); background-size: 14px 14px; }
.wa-bubble { background: #D9FDD3; border-radius: 12px 12px 12px 4px; padding: 10px 12px 12px; font-size: 14px; line-height: 1.45;
  white-space: pre-wrap; color: var(--ink); max-width: 100%; box-shadow: 0 1px 1px rgba(17,26,20,.08); }
.wa-bubble mark { background: #FFF3B0; border-radius: 3px; padding: 0 2px; }
.wa-inline { font-size: 13px; }
.compose > .policy { align-self: stretch; }

@media (max-width: 1100px) { .compose { grid-template-columns: 1fr; } .wa-phone { position: static; } }
@media (max-width: 900px) {
  .rule-steps { padding: 0 16px 16px; }
  .filter-bar { margin-left: 0; width: 100%; }
  .week-nav { margin-left: 0; }
}
.empty-icon.danger { background: #FBEBE8; color: var(--danger); }
@media (max-width: 900px) {
  /* Pestañas en una sola fila deslizable, no partidas en dos líneas. */
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: none; }
}

/* ------------------------------------------------------------- comercial */
.com-avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; border-radius: 50%;
  background: var(--brand) center / cover no-repeat; color: #fff; font-weight: 700; font-size: 13px; }
.com-big { font-family: var(--display); font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.com-anulada td { color: var(--muted); }
.com-anulada td b { text-decoration: line-through; }
.com-file { display: inline-flex; align-items: center; cursor: pointer; border-radius: var(--r-pill); border: 1px solid var(--brand); }
.com-link { width: 100%; font-family: var(--mono); font-size: 12.5px; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--r-input); background: var(--head); color: var(--ink-2); }
.com-pasos { margin: 0; padding-left: 1.2rem; font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }
.com-dir { font-family: var(--mono); font-size: 13px; background: var(--chip); padding: 1px 8px; border-radius: 6px; }
.com-code { width: 170px; font-family: var(--mono); font-size: 24px; letter-spacing: .12em; text-align: center; padding: 6px 10px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-input); }
.com-code:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.com-qr { width: 132px; height: 132px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; flex: 0 0 auto; }
.crop-area { position: relative; width: min(420px, 100%); aspect-ratio: 1; margin: 0 auto; border-radius: 14px; overflow: hidden;
  cursor: grab; touch-action: none; background: #16301F; }
.crop-area:active { cursor: grabbing; }
.crop-area canvas { width: 100%; height: 100%; display: block; }
/* Fuera del círculo, oscurecido: es lo que la TV no muestra. */
.crop-mask { position: absolute; inset: 0; pointer-events: none; border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(13, 31, 22, .6); outline: 3px solid var(--accent); outline-offset: -3px; }
.com-lado { display: flex; gap: 16px; align-items: stretch; flex-wrap: wrap; }
.com-app { width: 280px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.com-app .com-qr { width: 180px; height: 180px; align-self: center; }
@media (max-width: 900px) { .com-app { width: 100%; } }
