/* CL Agency Manager — identidad visual de clearlanguageagency.com */
:root {
  --navy: #1b2a5e;
  --navy-2: #24367a;
  --ink: #1a2060;
  --blue: #2563eb;
  --blue-2: #3b82f6;
  --blue-soft: #93c5fd;
  --logo-dark: #3d4ba0;
  --logo-light: #7b92e8;
  --tint: #eef3fe;
  --line: #e3e8f2;
  --bg: #f6f8fc;
  --text: #1f2937;
  --muted: #6b7280;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "DM Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; color: var(--ink); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- Marca ---------- */
.brand-mark { position: relative; display: inline-block; width: 38px; height: 38px; flex: none; }
.brand-mark .sq { position: absolute; width: 26px; height: 26px; border-radius: 6px; color: #fff; font: 700 14px/26px Georgia, serif; text-align: center; }
.brand-mark .sq-c { left: 0; top: 0; background: var(--logo-dark); }
.brand-mark .sq-l { right: 0; bottom: 0; background: var(--logo-light); }
.brand-mark.lg { width: 58px; height: 58px; }
.brand-mark.lg .sq { width: 40px; height: 40px; border-radius: 9px; font-size: 20px; line-height: 40px; }

/* ---------- Estructura ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; background: var(--navy); color: #c0cce8; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; color: #fff; text-decoration: none !important; }
.brand-text strong { display: block; font-family: var(--serif); font-size: 22px; line-height: 1; font-weight: 700; letter-spacing: .2px; }
.brand-text small { font-size: 10.5px; letter-spacing: 3px; text-transform: uppercase; color: var(--blue-soft); }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.nav-section { margin: 18px 10px 6px; font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase; color: #8899bb; }
.nav a, .nav-soon { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #d6def3; font-weight: 500; text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(59, 130, 246, .18); color: #fff; box-shadow: inset 3px 0 0 var(--blue-2); }
.nav-soon { color: #6f7fa8; cursor: default; }
.sidebar-foot { padding: 14px 20px 18px; font-family: var(--serif); font-style: italic; font-size: 15px; color: #8899bb; border-top: 1px solid rgba(255, 255, 255, .06); }

.main { margin-left: 250px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 28px; background: rgba(246, 248, 252, .85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--tint); }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 999px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--tint); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.user-menu-panel { position: absolute; right: 0; top: 46px; min-width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(16, 24, 40, .12); padding: 6px; }
.user-menu-panel a, .user-menu-panel button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--tint); text-decoration: none; }
.content { padding: 28px; max-width: 1280px; }
.nav-toggle, .nav-backdrop { display: none; }

/* ---------- Encabezado de página ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-header h1 { font-family: var(--serif); font-size: 36px; font-weight: 700; line-height: 1.1; }
.lead { margin: 6px 0 0; color: var(--muted); font-size: 15.5px; max-width: 720px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.help-box { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--blue-2); border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; }
.help-box summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; }
.help-box summary::-webkit-details-marker { display: none; }
.help-box summary svg { color: var(--blue); }
.help-box p { margin: 8px 0 2px; color: #374151; }

/* ---------- Tarjetas ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { font-size: 17px; font-weight: 700; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2-wide { grid-template-columns: 2fr 1fr; }
.grid-2 > .card { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; gap: 4px; margin: 0; text-decoration: none !important; transition: border-color .15s, transform .15s; }
.stat:hover { border-color: var(--blue-soft); transform: translateY(-1px); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-variant-numeric: lining-nums tabular-nums; font-family: var(--serif); font-size: 38px; font-weight: 700; color: var(--ink); line-height: 1; }
.empty { text-align: center; padding: 48px 20px; }
.empty p { color: var(--muted); max-width: 480px; margin: 8px auto 18px; }
.empty-inline { padding: 14px 0; color: var(--muted); }

/* ---------- Botones y etiquetas ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 9px; border: 1px solid #d0d5dd; background: #fff; color: var(--text); font: 600 14px var(--sans); cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.badge { background: var(--tint); color: var(--navy); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f2f4f7; color: #475467; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-blue { background: var(--tint); color: var(--blue); }
.pill-navy { background: var(--navy); color: #fff; }
.level-global { background: #f2f4f7; color: #344054; }
.level-company { background: #f4f3ff; color: #5925dc; }
.level-account { background: var(--tint); color: var(--blue); }
.level-interpreter { background: var(--ok-bg); color: var(--ok); }
.code { display: inline-block; font: 700 12.5px var(--sans); letter-spacing: 1px; color: var(--navy); background: var(--tint); border-radius: 6px; padding: 2px 8px; }
.tag { display: inline-block; margin: 1px 4px 1px 0; padding: 2px 8px; border-radius: 6px; background: #f2f4f7; font-size: 12.5px; }

/* ---------- Alertas ---------- */
.messages { margin-bottom: 16px; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 8px; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #abefc6; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fecdca; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #fedf89; }
.alert-info { background: var(--tint); color: var(--navy); }

/* ---------- Tablas ---------- */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); background: #fafbfd; padding: 11px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbff; }
.table .num { text-align: right; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 4px; }
.row-muted td { opacity: .55; }
.table-compact td, .table-compact th { padding: 8px 10px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1; min-width: 220px; }

/* ---------- Formularios ---------- */
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d0d5dd; border-radius: 9px; font: 14.5px var(--sans); color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.toolbar select { width: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-2); box-shadow: 0 0 0 4px rgba(59, 130, 246, .15); }
.form-card { max-width: 900px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 22px; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.field { margin-bottom: 14px; }
.field:has(textarea), .field:has(ul), .field:has(div[id^="id_"] input[type=checkbox]), .field-check { grid-column: 1 / -1; }
.label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; color: #344054; }
.req { color: var(--danger); }
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.error { margin: 6px 0 0; font-size: 12.5px; color: var(--danger); font-weight: 500; }
.has-error input, .has-error select { border-color: #fda29b; }
.more { margin-top: 4px; font-size: 12.5px; }
.more summary { cursor: pointer; color: var(--blue); width: max-content; }
.more p { margin: 6px 0 0; padding: 8px 10px; background: var(--tint); border-radius: 8px; color: #344054; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }
.check .label { margin: 0; }
/* Listas de casillas (Django 5 las dibuja con <div id="id_x"><div><label><input> texto</label></div>…) */
.field > div[id^="id_"]:has(input[type=checkbox]), .field ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.field > div[id^="id_"]:has(input[type=checkbox]) label, .field ul li label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px; }
.field > div[id^="id_"]:has(input[type=checkbox]) label:has(input:checked), .field ul li label:has(input:checked) { border-color: var(--blue-2); background: var(--tint); }
.field > div[id^="id_"] input[type=checkbox], .field ul input { accent-color: var(--navy); width: 16px; height: 16px; flex: none; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.subform { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 6px 0 12px; }
.subform legend { font-weight: 700; color: var(--ink); padding: 0 6px; }
.suffix-input { display: inline-flex; align-items: center; gap: 6px; }
.suffix-input input { width: 110px; text-align: right; }
.danger-card { border-color: #fecdca; }
.danger-card h2 { color: var(--danger); margin-bottom: 8px; }

/* ---------- Panel ---------- */
.steps { list-style: none; padding: 0; margin: 14px 0 0; }
.steps li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.steps a { font-weight: 600; }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--tint); color: var(--navy); font-weight: 700; flex: none; }
.steps li.done .step-dot { background: var(--ok); color: #fff; }
.steps li.done a { color: var(--muted); }
.notices { list-style: none; padding: 0; margin: 8px 0 0; }
.notices li { padding: 10px 12px; border-radius: 9px; margin-bottom: 8px; }
.notices li p { margin: 2px 0 0; font-size: 13px; color: #475467; }
.notices .warn { background: var(--warn-bg); }
.notices .warn a { color: var(--warn); font-weight: 600; }
.notices .ok { background: var(--ok-bg); color: var(--ok); }
.split-bars { list-style: none; padding: 0; margin: 10px 0; }
.split-bars li { display: grid; grid-template-columns: 140px 1fr 70px; align-items: center; gap: 12px; padding: 6px 0; }
.split-bars strong { text-align: right; color: var(--ink); }
.bar { height: 10px; border-radius: 999px; background: var(--tint); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--navy), var(--blue-2)); }
.split { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.split-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.list { list-style: none; padding: 0; margin: 8px 0 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

/* ---------- Reglas ---------- */
.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.param { display: flex; flex-direction: column; gap: 8px; margin: 0; color: inherit; text-decoration: none !important; transition: border-color .15s, transform .15s; }
.param:hover { border-color: var(--blue-soft); transform: translateY(-1px); }
.param-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.param h2 { font-size: 16px; }
.param p { margin: 0; color: #475467; font-size: 13.5px; flex: 1; }
.param-value { font-variant-numeric: lining-nums; font-family: var(--serif); font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1; white-space: nowrap; }
.param-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.summary-row { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.big-value { font-variant-numeric: lining-nums; font-family: var(--serif); font-size: 40px; font-weight: 700; color: var(--navy); line-height: 1.1; }

/* ---------- Login ---------- */
.login-page { background: radial-gradient(1200px 600px at 10% -10%, #dbe6ff 0%, transparent 60%), linear-gradient(160deg, #f6f8fc 0%, #e8eefc 100%); }
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 410px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 50px rgba(27, 42, 94, .12); padding: 34px 32px 26px; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-title { margin: 0; font: 700 26px/1 Arial, sans-serif; color: var(--ink); }
.login-sub { margin: 6px 0 0; font-size: 11px; letter-spacing: 4px; color: var(--logo-light); }
.login-card h1 { font-family: var(--serif); font-size: 30px; }
.login-card .muted { margin: 4px 0 20px; }
.login-foot { font-size: 12px; color: var(--muted); text-align: center; margin: 16px 0 0; }
.login-tagline { margin-top: 22px; font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--navy); }

/* ---------- Celular y tablet ---------- */
@media (max-width: 1024px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2-wide { grid-template-columns: 1fr; }
  .form-grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 20; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 0 14px; }
  .content { padding: 18px 16px; }
  .page-header h1 { font-size: 30px; }
  .form-grid, .form-grid-4 { grid-template-columns: 1fr; }
  .user-name { display: none; }
  /* Tablas como tarjetas */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  /* Cada fila es una tarjeta compacta: la primera celda es el título; los datos van en dos columnas;
     las celdas sin etiqueta (avisos, detalles) y los botones ocupan todo el ancho. */
  .table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px;
              padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table tr[hidden] { display: none; }
  .table td { border: 0; padding: 0; text-align: left !important; min-width: 0; overflow-wrap: anywhere; }
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: 10.5px; text-transform: uppercase;
                                   letter-spacing: .5px; color: var(--muted); line-height: 1.5; }
  .table td:first-child, .table td:not([data-label]), .table td.td-wide { grid-column: 1 / -1; }
  .table td[data-label]:first-child { font-size: 15.5px; padding-bottom: 2px; }
  .table td[data-label]:first-child::before { display: none; }
  .table td.strong { color: var(--navy); font-size: 16px; }
  .row-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px !important; }
  /* Un solo botón: va en la columna libre, a la derecha (junto al total); con varios, ocupan una línea entera */
  .table td.row-actions:not(:has(> :nth-child(2))) { grid-column: auto / span 1; justify-content: flex-end; align-self: end; }
  .table td.row-actions:not(:has(> :nth-child(2))):nth-child(even) { grid-column: 2; }
  .row-actions:empty { display: none; }
  .split-bars li { grid-template-columns: 100px 1fr 60px; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 30px; }
}

/* ---------- Extracción ---------- */
.company-picks { display: grid; gap: 10px; margin-top: 12px; }
.pick { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; flex-wrap: wrap; }
.checks { list-style: none; padding: 0; margin: 4px 0 0; }
.checks li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks p { margin: 2px 0 0; font-size: 13px; color: #475467; }
.check-icon { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; font-size: 13px; }
.check-ok .check-icon { background: var(--ok-bg); color: var(--ok); }
.check-warning .check-icon { background: var(--warn-bg); color: var(--warn); }
.check-error .check-icon { background: var(--danger-bg); color: var(--danger); }
.run-queued, .res-pending { background: #f2f4f7; color: #475467; }
.run-running, .res-running { background: var(--tint); color: var(--blue); }
.run-ok, .res-ok { background: var(--ok-bg); color: var(--ok); }
.run-partial, .res-skipped { background: var(--warn-bg); color: var(--warn); }
.run-error, .res-error { background: var(--danger-bg); color: var(--danger); }
.run-cancelled { background: #f2f4f7; color: #667085; text-decoration: line-through; text-decoration-color: #98a2b3; }
.pill-lg { font-size: 14px; padding: 4px 12px; margin-top: 2px; }
.live { margin: 12px 0 0; color: var(--blue); }
.log summary { cursor: pointer; }
.log-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.log pre { margin: 12px 0 0; padding: 12px; background: #0f172a; color: #e2e8f0; border-radius: 8px; font-size: 12.5px; overflow-x: auto; white-space: pre-wrap; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stat-small { font-size: 22px; padding-top: 8px; }
.coverage { display: inline-block; width: 90px; height: 8px; border-radius: 999px; background: var(--tint); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.coverage span { display: block; height: 100%; background: var(--blue-2); }
@media (max-width: 820px) { .stats-3 { grid-template-columns: 1fr; } }

/* ---------- Vinculación ---------- */
.grid-link { grid-template-columns: 1fr 1.3fr; align-items: start; }
.link-queued, .link-running, .link-submitting { background: var(--tint); color: var(--blue); }
.link-waiting_code { background: var(--warn-bg); color: var(--warn); }
.link-linked { background: var(--ok-bg); color: var(--ok); }
.link-failed { background: var(--danger-bg); color: var(--danger); }
.link-message { font-size: 15px; margin: 10px 0 14px; }
.code-form { background: var(--warn-bg); border: 1px solid #fedf89; border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.code-row { display: flex; gap: 8px; margin-top: 10px; }
.code-row input { font-size: 20px; letter-spacing: 4px; text-align: center; max-width: 220px; }
.browser-shot { width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; }
@media (max-width: 1024px) { .grid-link { grid-template-columns: 1fr; } }

/* ---------- Cálculo ---------- */
.stat-mid { font-size: 28px; }
.warn-card { border-color: #fedf89; background: var(--warn-bg); }
.warn-card h2 { color: var(--warn); }
.warn-list { margin: 6px 0 0; padding-left: 20px; color: #7a2e0e; }
.warn-list li { margin: 4px 0; }
.inline-actions { margin-top: 12px; }
.rate-form { margin-top: 10px; max-width: 420px; }
.table-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 16px 6px; }
.steps-row td { background: #fafbff; }
.steps-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.steps-table td { padding: 6px 8px; border-bottom: 1px dashed var(--line); }
.steps-table .num { text-align: right; white-space: nowrap; font-weight: 600; }
.steps-total td { border-bottom: 0; font-weight: 700; color: var(--ink); }
.row-warn td { background: var(--warn-bg); }
.alloc-total { font-size: 15px; }
.adj-business_expense, .adj-interpreter_penalty { background: var(--danger-bg); color: var(--danger); }
.adj-interpreter_bonus, .adj-extra_income { background: var(--ok-bg); color: var(--ok); }

/* ---------- Facturas ---------- */
.inv-issued { background: var(--tint); color: var(--blue); }
.inv-paid { background: var(--ok-bg); color: var(--ok); }
.inv-void { background: var(--danger-bg); color: var(--danger); }
.pdf-frame { width: 100%; height: 820px; border: 1px solid var(--line); border-radius: 8px; background: #f3f4f6; }

/* ---------- Cierre y alertas ---------- */
.closed-card { border-color: #abefc6; background: var(--ok-bg); }
.closed-card h2 { color: var(--ok); }
.notices .info { background: var(--tint); }
.notices .info a { color: var(--navy); font-weight: 600; }
.report-filters { max-width: none; }

/* ---------- Seguimiento ---------- */
.chart-box { position: relative; height: 290px; }
.grid-charts { margin-bottom: 20px; }
.delta { display: inline-block; white-space: nowrap; font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.delta.up { background: var(--ok-bg); color: var(--ok); }
.delta.down { background: var(--danger-bg); color: var(--danger); }
.stat .delta, .stat .pill { width: max-content; margin-top: 4px; }

/* Login: los campos son <label class="field"> (en línea por defecto) → bloque para respetar los márgenes */
.login-card .field { display: block; margin-bottom: 16px; }
.login-card .btn-block { margin-top: 8px; }

/* ---------- Panel ---------- */
.grid-2, .grid-3 { margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-3 > .card { margin-bottom: 0; }
.card-head a.small { font-weight: 600; }
.chart-sm { height: 210px; }
.compact-list li { padding: 8px 0; gap: 10px; }
a.stat { color: inherit; }
@media (max-width: 1024px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Entrada mensual ---------- */
.monthly-form .suffix-input input { width: 120px; }
.monthly-foot { padding: 0 16px 16px; }


/* Clientes directos */
.q-draft { background: #f2f4f7; color: var(--muted); }
.q-sent { background: var(--tint); color: var(--blue); }
.q-accepted { background: var(--ok-bg); color: var(--ok); }
.q-rejected, .q-cancelled { background: var(--danger-bg); color: var(--danger); }
.q-expired { background: var(--warn-bg); color: var(--warn); }
.svc-scheduled { background: var(--tint); color: var(--blue); }
.svc-done { background: var(--ok-bg); color: var(--ok); }
.svc-cancelled { background: var(--danger-bg); color: var(--danger); }
.quote-lines input, .quote-lines select { width: 100%; }
.quote-lines td:first-child { min-width: 260px; }
.duplicate-form { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.doc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.doc-row strong:last-child { margin-left: auto; }

/* Documentación */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.doc-card { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.doc-main { display: flex; gap: 12px; align-items: flex-start; color: inherit; text-decoration: none !important; }
.doc-main strong { display: block; color: var(--ink); }
.doc-main .small { display: block; margin-top: 2px; }
.doc-ext { flex: none; width: 46px; height: 54px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--tint); color: var(--blue); }
.ext-pdf { background: var(--danger-bg); color: var(--danger); }
.ext-doc, .ext-docx, .ext-odt { background: #e8efff; color: #1d4ed8; }
.ext-xls, .ext-xlsx, .ext-csv, .ext-ods { background: var(--ok-bg); color: var(--ok); }
.ext-ppt, .ext-pptx { background: var(--warn-bg); color: var(--warn); }
.doc-desc { margin: 0; }
.doc-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-image { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }

/* Selector Dinero / Horas (Seguimiento) */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: #fff; gap: 2px; }
.segmented a { padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none !important; }
.segmented a:hover { color: var(--ink); background: #f2f4f7; }
.segmented a.active { background: var(--blue); color: #fff; }
.week-values { display: inline-flex; gap: 10px; align-items: baseline; }

/* Entrada mensual: monto y horas por campaña */
.monthly-table thead .group-head th { border-bottom: 0; padding-bottom: 2px; }
.monthly-table .campaign-head { text-align: center; color: var(--ink); font-weight: 700; border-left: 1px solid var(--line); }
.monthly-table .sub-head th { font-size: 12px; padding-top: 4px; }
.monthly-table .sub-head th:nth-child(odd) { border-left: 1px solid var(--line); }
.monthly-table td.hours-cell + td, .monthly-table td.not-worked { border-left: 1px solid var(--line); }
.monthly-table td.not-worked { text-align: center; font-size: 13px; }
.monthly-table td { vertical-align: top; }
.unit-input { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.unit-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--tint); }
.unit-input input { border: 0 !important; box-shadow: none !important; width: 104px; text-align: right; padding: 7px 8px; background: transparent; }
.unit-input .unit { padding: 0 10px; color: var(--muted); font-size: 13px; background: #f8f9fb; align-self: stretch; display: grid; place-items: center; }
.unit-input input.is-adjusted { color: #b54708; font-weight: 600; }
.hours-state { margin-top: 5px; font-size: 12px; color: var(--muted); min-height: 18px; }
.hours-state .state-adjusted { display: none; }
.hours-state.is-adjusted .state-calc { display: none; }
.hours-state.is-adjusted .state-adjusted { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.link-btn { border: 0; background: none; padding: 0; color: var(--blue); font-size: 12px; cursor: pointer; text-decoration: underline; }

/* Cálculo por fechas */
.period-form .form-grid { align-items: end; }
.period-submit { display: flex; align-items: flex-end; }
.preset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.preset-row > .muted { min-width: 170px; }
.chip { display: inline-block; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink); text-decoration: none !important; background: #fff; }
.chip:hover { border-color: var(--blue-soft); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.note-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 14px; color: var(--ink); }
.note-list li.warn { color: #b54708; }


/* ---------- Reparto entre socios con desglose por cuenta ---------- */
.partner-split { margin: 10px 0; }
.partner-row { border-radius: 10px; transition: background .2s; }
.partner-row[open] { background: #f8f9fc; }
.partner-row summary { display: grid; grid-template-columns: 140px 1fr 90px 18px; align-items: center; gap: 12px;
  padding: 8px 6px; cursor: pointer; list-style: none; border-radius: 10px; }
.partner-row summary::-webkit-details-marker { display: none; }
.partner-row summary:hover { background: #f4f6fb; }
.partner-row summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.partner-row summary strong { text-align: right; color: var(--ink); }
.partner-row .bar span { max-width: 100%; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.chev { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; transition: transform .2s; }
.partner-row[open] .chev { transform: rotate(180deg); }
.partner-detail { list-style: none; margin: 0; padding: 2px 10px 10px 18px; border-left: 2px solid var(--tint);
  margin-left: 12px; animation: fx-reveal .22s ease-out; }
.partner-detail li { display: grid; grid-template-columns: 1fr 70px 90px; gap: 10px; align-items: center; padding: 6px 0;
  border-bottom: 1px dashed var(--line); font-size: 14px; }
.partner-detail li:last-child { border-bottom: 0; }
.partner-detail .num { text-align: right; font-variant-numeric: tabular-nums; }
.partner-detail .neg { color: var(--danger); }
@media (max-width: 600px) {
  .partner-row summary { grid-template-columns: 1fr 90px 18px; }
  .partner-row summary .bar { display: none; }
  .partner-detail li { grid-template-columns: 1fr 50px 80px; }
}

/* ---------- Menú lateral: sin barra de desplazamiento visible ---------- */
.nav { scrollbar-width: none; -ms-overflow-style: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 18px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 18px), transparent 100%); }
.nav::-webkit-scrollbar { display: none; width: 0; height: 0; }
@media (max-height: 700px) {
  .sidebar-foot { display: none; }
  .brand { padding: 16px 20px 12px; }
  .nav-section { margin: 12px 10px 4px; }
  .nav a { padding: 7px 10px; }
}

/* ---------- Microinteracciones y efectos (se apagan con .fx-off / reducir movimiento) ---------- */
@keyframes fx-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes fx-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fx-particles { position: fixed; inset: 0 0 0 250px; width: calc(100% - 250px); height: 100%; pointer-events: none;
  z-index: 0; }
.fx-on .main { position: relative; z-index: 1; }
.fx-on .content > * { animation: fx-rise .35s ease-out both; }
.fx-on .content > *:nth-child(2) { animation-delay: .04s; }
.fx-on .content > *:nth-child(3) { animation-delay: .08s; }
.fx-on .content > *:nth-child(4) { animation-delay: .12s; }
.fx-on .content > *:nth-child(n+5) { animation-delay: .16s; }
.fx-on .card { transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease; }
.fx-on .card:hover { box-shadow: 0 6px 18px rgba(16, 24, 40, .07), 0 2px 6px rgba(16, 24, 40, .05); }
.fx-on .stat { transition: transform .15s ease-out, box-shadow .2s ease, border-color .2s ease; will-change: transform; }
.fx-on .btn { transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease; }
.fx-on .btn:active { transform: scale(.97); }
.fx-on .btn-primary:hover { box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.fx-on .nav a { transition: background .15s ease, color .15s ease, padding-left .15s ease; }
.fx-on .nav a:hover { padding-left: 13px; }
.fx-on .pill, .fx-on .chip { transition: transform .12s ease; }
.fx-on .chip:hover { transform: translateY(-1px); }
.user-menu-panel button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 12px;
  font: inherit; color: inherit; cursor: pointer; border-radius: 6px; }
.user-menu-panel button:hover { background: #f2f4f7; }
@media (max-width: 900px) { .fx-particles { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* ---------- Facturas: confirmar horas por WhatsApp ---------- */
.wa-card > summary { list-style: none; cursor: pointer; }
.wa-card > summary::-webkit-details-marker { display: none; }
.wa-card > summary h2::before { content: "▸"; display: inline-block; margin-right: 8px; color: var(--muted); transition: transform .2s; }
.wa-card[open] > summary h2::before { transform: rotate(90deg); }
.wa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-top: 12px; }
.wa-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fcfdff; display: grid; gap: 8px; }
.wa-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.wa-item textarea { width: 100%; resize: vertical; font: 14px/1.45 var(--sans); padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; }
.wa-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-wa { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn-wa:hover { background: #178a49; }
.btn.is-done { border-color: var(--ok); color: var(--ok); }


/* Botón «Por cuenta» del reparto entre socios: píldora discreta, a juego con los encabezados de tarjeta */
.toggle-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 11px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--muted); font: 600 12.5px var(--sans); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s; }
.toggle-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toggle-btn .toggle-chev { width: 13px; height: 13px; transition: transform .2s; }
.toggle-btn:hover { color: var(--ink); border-color: var(--blue-soft); }
.toggle-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.toggle-btn[aria-expanded="true"] { background: var(--tint); color: var(--blue); border-color: transparent; }
.toggle-btn[aria-expanded="true"] .toggle-chev { transform: rotate(180deg); }

/* Cálculo por fechas: navegación por ciclo de pago */
.period-bar { padding: 14px 18px; }
.cycle-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cycle-label { display: flex; flex-direction: column; align-items: center; min-width: 230px; text-align: center; }
.cycle-label strong { font-family: var(--serif); font-size: 22px; color: var(--ink); line-height: 1.2; }
.nav-arrow { border: 1px solid var(--line); background: #fff; }
.nav-arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.nav-arrow.is-disabled { opacity: .35; cursor: default; }
.nav-arrow.is-disabled:hover { background: #fff; }
.cycle-nav .btn { margin-left: auto; }
.custom-range { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.custom-range > summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; list-style: none; }
.custom-range > summary::-webkit-details-marker { display: none; }
.custom-range > summary::before { content: "▸"; display: inline-block; margin-right: 6px; transition: transform .2s; }
.custom-range[open] > summary::before { transform: rotate(90deg); }
.custom-range .period-form { margin-top: 10px; }
@media (max-width: 600px) { .cycle-label { min-width: 0; flex: 1; } .cycle-nav .btn { margin-left: 0; } }
.wa-card > summary { flex-wrap: wrap; row-gap: 2px; }
.wa-card > summary > .muted { flex-basis: 100%; }

/* Comprobantes de pago (IDs largos de transferencias) */
.ref-line { margin-top: 4px; font-size: 13px; }
.ref-code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; background: rgba(6, 118, 71, .08);
  padding: 1px 6px; border-radius: 5px; word-break: break-all; }

/* Seguridad: QR, códigos de recuperación, campo de código */
.qr-box { display: grid; place-items: center; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  margin: 12px 0; }
.qr-box svg { width: 220px; height: 220px; }
.recovery-grid { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px; }
.recovery-grid li { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 15px; text-align: center; padding: 10px;
  border: 1px dashed var(--line); border-radius: 8px; background: #fbfcfe; letter-spacing: .5px; }
.code-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 20px !important; letter-spacing: 4px; text-align: center; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }


/* ---------- Historial de cambios ---------- */
.last-change { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
.last-change svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; flex: none; }
.last-change strong { color: var(--ink); }
.last-change a { margin-left: 2px; }
td .last-change { margin-top: 4px; font-size: 12px; }
.audit-table td { vertical-align: top; }
.change-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13.5px; }
.change-list .before { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.audit-0 { background: var(--ok-bg); color: var(--ok); }
.audit-1 { background: var(--tint); color: var(--blue); }
.audit-2 { background: var(--danger-bg); color: var(--danger); }
.nowrap { white-space: nowrap; }

/* Cuentas cerradas o inactivas: sección aparte, debajo de las activas */
.closed-accounts { margin-top: 28px; }
.closed-accounts .section-title { font-size: 16px; margin: 0 0 4px; }
.closed-accounts > p { margin: 0 0 12px; }
.row-closed td { color: var(--muted, #667085); }

/* Notificaciones e instalar app */
.push-card h2, .push-help h2 { font-size: 16px; margin: 0 0 8px; }
.push-state { margin: 0 0 12px; }
.push-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.push-help ol, .push-help ul { margin: 8px 0; padding-left: 20px; line-height: 1.7; }
.table-card-title { font-size: 16px; margin: 0; padding: 16px 16px 8px; }

/* Recordar este dispositivo */
.check-row { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; font-size: 14px; cursor: pointer; }
.check-row input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.subhead { font-size: 14px; margin: 18px 0 4px; }

/* Aviso de instalación en iPhone */
.ios-install { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 80;
  max-width: 440px; margin: 0 auto; background: #fff; color: var(--text); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; box-shadow: 0 12px 40px rgba(27, 42, 94, .22); }
.ios-install[hidden] { display: none; }
.ios-install-head { display: flex; gap: 12px; align-items: center; padding-right: 28px; }
.ios-install-head img { border-radius: 10px; border: 1px solid var(--line); flex: none; }
.ios-install-sub { color: var(--muted); font-size: 13px; }
.ios-install-steps { margin: 12px 0 8px; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.ios-install-steps li { margin-bottom: 4px; }
.ios-install-steps li[hidden] { display: none; }
.ios-ico { width: 18px; height: 18px; vertical-align: -3px; fill: none; stroke: var(--blue); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.ios-ico circle { fill: var(--blue); stroke: none; }
.ios-install-note { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.ios-install-close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 24px;
  line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }

/* Avisos: descartar o recordar después */
.notices li { position: relative; padding-right: 36px; }
.notice-menu { position: absolute; top: 6px; right: 6px; }
.notice-menu summary { list-style: none; cursor: pointer; width: 28px; height: 28px; border-radius: 8px; display: grid;
  place-items: center; color: var(--muted); font-weight: 700; }
.notice-menu summary::-webkit-details-marker { display: none; }
.notice-menu summary:hover, .notice-menu[open] summary { background: var(--tint); color: var(--ink); }
.notice-menu form { position: absolute; right: 0; top: 32px; z-index: 20; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(27, 42, 94, .16); padding: 6px; display: flex; flex-direction: column;
  min-width: 190px; }
.notice-menu form button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px;
  font: inherit; font-size: 14px; color: var(--text); cursor: pointer; }
.notice-menu form button:hover { background: var(--tint); }
.notice-menu form button.danger { color: var(--danger); border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; }
.notice-menu-title { font-size: 12px; color: var(--muted); padding: 4px 10px; }
.notice-menu-date { display: flex; gap: 4px; padding: 4px 6px; align-items: center; }
.notice-menu-date input { flex: 1; min-width: 0; font-size: 13px; padding: 4px 6px; }
.notice-menu-date button { padding: 6px 10px !important; background: var(--tint) !important; }
.hidden-notices { margin-top: 10px; font-size: 13px; }
.hidden-notices summary { cursor: pointer; color: var(--muted); }
.hidden-notices ul { list-style: none; margin: 8px 0 0; padding: 0; }
.hidden-notices li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0;
  border-top: 1px solid var(--line); }

.wa-test { display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.btn-wa-business { background: #0b6e4f; border-color: #0b6e4f; color: #fff; }
.btn-wa-business:hover { background: #095c42; }
.btn-wa-business[hidden] { display: none; }

/* ---------- Celular: que nada se salga del ancho ---------- */
@media (max-width: 820px) {
  .grid-2 > *, .grid-3 > *, .stats > * { min-width: 0; }
  .mono { overflow-wrap: anywhere; }
  .card { padding: 16px; margin-bottom: 14px; }
  .card.table-card { padding: 0; }
  .card-head { flex-wrap: wrap; gap: 6px 10px; }
}
@media (max-width: 820px) { .table td.td-empty { display: none; } }
@media (max-width: 820px) {
  .table td.td-when div { display: inline; margin-left: 6px; }
  .table .change-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; font-size: 12.5px; }
  .table .change-list li { break-inside: avoid; }
}
@media (max-width: 820px) {
  .table-title { flex-wrap: wrap; gap: 2px 12px; }
  .table-title h2 { flex: 1 0 100%; }
}

/* ---------- Intérpretes: cuentas con entrada y salida ---------- */
.stint-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.stint-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; font-size: 13.5px; }
.stint-dates { color: #475467; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stint-ended { color: var(--muted); }
.stint-ended .stint-account { text-decoration: line-through; text-decoration-color: rgba(0,0,0,.2); }
.stint-list li.stint-heading { display: block; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stint-list li.stint-heading:first-child, .row-closed .stint-heading { display: none; }
.stint-summary { margin: 0 0 4px; font-size: 14.5px; }
.stint-howto { margin: 8px 0 12px; font-size: 13.5px; }
.stint-howto summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.stint-howto ul { margin: 8px 0; padding-left: 18px; display: grid; gap: 4px; }
.stint-table select, .stint-table input { width: 100%; min-width: 0; }
.stint-table td { vertical-align: top; }
.stints [data-formset-add] { margin-top: 10px; }

/* ---------- Cuadre entre socios ---------- */
.settle-transfer { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 10px; display: grid; gap: 8px; }
.settle-transfer.is-done { background: var(--ok-bg); border-color: transparent; }
.settle-who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 16px; }
.settle-arrow { color: var(--blue); font-size: 20px; font-weight: 700; }
.settle-amount { font-family: var(--serif); font-size: 30px; color: var(--navy); line-height: 1.1; }
.settle-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.settle-form label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.settle-form input { min-width: 0; }
.settle-form .settle-note { flex: 1 1 180px; }
.settle-done { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 0; }
.btn-link { background: none; border: 0; color: var(--blue); padding: 0 4px; text-decoration: underline; cursor: pointer; }
.settle-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.settle-tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: #475467; font-weight: 600; text-decoration: none; }
.settle-tabs a.active { color: var(--navy); border-bottom-color: var(--blue); }
.settle-month { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }

/* Cuadre: desglose de cada cuenta como recibo */
.settle-account { border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; }
.settle-account > summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; align-items: center;
  padding: 12px 14px; cursor: pointer; list-style: none; }
.settle-account > summary::-webkit-details-marker { display: none; }
.settle-account > summary::before { content: "▸"; color: var(--blue); margin-right: 4px; }
.settle-account[open] > summary::before { content: "▾"; }
.settle-acc-name { flex: 1 1 auto; }
.receipt { width: 100%; border-collapse: collapse; font-size: 14px; }
.receipt td { padding: 7px 14px; border-top: 1px dashed var(--line); vertical-align: top; }
.receipt td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.receipt tr.minus td.num { color: #b42318; }
.receipt tr.subtotal td { font-weight: 600; background: #f8fafc; }
.receipt tr.total td { font-weight: 700; color: var(--navy); border-top: 2px solid var(--line); background: var(--tint); }
.receipt tr.split-row td { font-size: 13px; color: #475467; }

/* ---------- Comunicados para aceptar (§14e) ---------- */
.agreement-text { font-size: 15px; line-height: 1.6; color: var(--text, #1f2937); }
.agreement-text h3 { font-size: 16px; font-weight: 700; color: var(--navy); margin: 18px 0 6px; }
.agreement-text h3:first-child { margin-top: 4px; }
.agreement-text p { margin: 0 0 10px; }
.agreement-text ul { margin: 0 0 12px; padding-left: 20px; }
.agreement-text li { margin: 4px 0; }
.agreement-text mark.todo { background: var(--warn-bg); color: var(--warn); padding: 0 4px; border-radius: 4px; font-weight: 700; }
textarea.mono-text { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13.5px; line-height: 1.5; }
.accept-list li { gap: 12px; align-items: flex-start; }
.accept-list .pill { margin-left: 4px; }
.inline-form { display: inline; }
.sign-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 22px 16px 32px; }
.sign-brand { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 640px; margin-bottom: 16px; }
.sign-brand .login-title { font-size: 21px; }
.sign-card { width: 100%; max-width: 640px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 40px rgba(27, 42, 94, .10); padding: 24px 22px; margin-bottom: 16px; }
.sign-card h1 { font-family: var(--serif); font-size: 28px; line-height: 1.15; margin: 4px 0 2px; }
.sign-card h2 { font-size: 18px; margin: 0 0 12px; }
.sign-card .agreement-text { margin-top: 16px; }
.sign-form input[type=text] { font-size: 16px; }   /* 16px: el iPhone no hace zoom al escribir */
.sign-check { align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0 4px; }
.sign-check input { margin-top: 2px; flex: none; }
.sign-legal { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; line-height: 1.45; }
.sign-ok { text-align: center; }
.sign-ok-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-bg); display: grid; place-items: center; margin: 4px auto 10px; }
.sign-ok-icon svg { width: 30px; height: 30px; fill: none; stroke: var(--ok); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.sign-ok p { margin: 10px 0 18px; }
@media (max-width: 480px) {
  .sign-card { padding: 20px 16px; border-radius: 14px; }
  .sign-card h1 { font-size: 25px; }
  .accept-list li { flex-direction: column; }
  .accept-list .row-actions { text-align: left; }
}

/* Calculadora del cuadre */
.calc { display: grid; gap: 10px; }
.calc-input { font-size: 18px; padding: 10px 12px; width: 100%; font-variant-numeric: tabular-nums; }
.calc-result { font-size: 15px; }
.calc-result strong { font-family: var(--serif); font-size: 28px; color: var(--navy); }
.calc-result [data-calc-error] { color: #b42318; margin-left: 8px; }
.calc-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; max-width: 360px; }
.calc-keys .btn { justify-content: center; font-size: 16px; min-height: 40px; }
.calc-convert { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.calc-convert label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.calc-convert select, .calc-convert input { min-width: 0; max-width: 100%; }
.calc-save { display: flex; flex-wrap: wrap; gap: 8px; }
.calc-save input[name=note] { flex: 1 1 220px; min-width: 0; }
.calc-history { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.calc-history-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.calc-history-head h3 { font-size: 15px; margin: 0; }
.calc-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.calc-item-main { grid-column: 1 / -1; text-align: left; background: none; border: 0; padding: 0; cursor: pointer;
  font-size: 14px; color: inherit; overflow-wrap: anywhere; }
.calc-item-main:hover .mono { text-decoration: underline; }
.calc-item-note { display: block; color: #475467; font-size: 13px; }
.calc-item-del { margin: 0; justify-self: end; }
.calc-pickable { cursor: copy; }
.calc-pickable:hover { text-decoration: underline dotted; }

/* ---------- Burbuja de herramientas (calculadora) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tools-fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--navy); color: #fff; box-shadow: 0 8px 24px rgba(16, 24, 40, .25); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: transform .15s; }
.tools-fab:hover { transform: scale(1.05); }
.tools-fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tools.is-open .tools-fab { background: var(--blue); }
.tools-panel { position: fixed; right: 20px; bottom: 88px; z-index: 60; width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 120px); overflow: auto; background: #fff; border: 2px solid var(--blue); border-radius: 16px;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12), 0 16px 48px rgba(16, 24, 40, .22); }
.tools-panel[hidden] { display: none; }
.tools-head { position: sticky; top: 0; background: #fff; display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px 0 14px; border-bottom: 1px solid var(--line); z-index: 1; }
.tools-tabs { display: flex; gap: 4px; }
.tools-tabs button { background: none; border: 0; padding: 8px 4px; font-weight: 700; color: var(--navy);
  border-bottom: 2px solid var(--blue); cursor: default; }
.tools-body { padding: 12px 14px 14px; }
.tools-body .calc-history h3 { font-size: 14px; margin: 0 0 2px; }
.calc-error { color: #b42318; font-size: 12px; margin-left: 6px; }
.calc-tip { margin: 0; }
@media (max-width: 600px) {
  .tools-fab { right: 14px; bottom: 14px; width: 52px; height: 52px; }
  .tools-panel { right: 8px; left: 8px; width: auto; bottom: 76px; max-height: calc(100vh - 100px); }
}
@media print { .tools { display: none; } }

/* ---------- Montos que se voltean US$ ↔ RD$ ---------- */
.flip { display: inline-grid; perspective: 600px; cursor: pointer; vertical-align: baseline; border-radius: 4px; }
.flip:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.flip-inner { display: grid; transition: transform .45s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; }
.flip-face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; justify-self: end; }
.flip-back { transform: rotateX(180deg); color: #0b6e4f; }
.flip.is-flipped .flip-inner { transform: rotateX(180deg); }
.flip:hover .flip-face { text-decoration: underline dotted; text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }
.flip-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin: 0 0 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 14px; font-weight: 600; cursor: pointer; color: #475467; }
.seg button.active { background: var(--navy); color: #fff; }
.stat-value .flip-face { justify-self: start; }
@media (max-width: 600px) {
  .tools-panel { top: auto; max-height: 62vh; }   /* deja ver la página arriba para tocar montos */
  .tools-body .calc-keys { gap: 4px; }
  .tools-body .calc-keys .btn { min-height: 34px; }
}

/* ---------- Descarga en iPhone: aviso «Guardar / compartir» ---------- */
.dl-toast { position: fixed; left: 12px; right: 12px; bottom: 80px; z-index: 70; display: flex; align-items: center; gap: 10px;
  background: #fff; border: 2px solid var(--blue); border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .22); }
.dl-toast span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.dl-x { border: 0; background: none; font-size: 22px; line-height: 1; color: #667085; cursor: pointer; }
