:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #161a23;
  --muted: #667085;
  --border: #e4e7ec;
  --border-soft: #edeff3;
  --primary: #1f6b57;
  --primary-dark: #164f41;
  --primary-soft: #e1f2ec;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --warn: #b45309;
  --warn-soft: #fef6e7;
  --danger: #d92d20;
  --danger-soft: #fef2f1;
  --mention: #7c3aed;
  --mention-soft: #f4edff;
  --leafy-primary: #17293a;
  --leafy-accent: #2c9c82;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 2px 8px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 28px rgba(16, 24, 40, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}

a { color: var(--primary); }

/* --- Barra superior --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon { flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-family: "Baloo 2", "Inter", sans-serif;
  font-weight: 800;
  font-size: 25px;
  letter-spacing: -0.01em;
  color: var(--leafy-primary);
}
.brand-tagline {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--leafy-accent);
  margin-top: 3px;
}
.topbar nav { display: flex; align-items: center; gap: 20px; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease;
}
.topbar nav a:hover { color: var(--primary); }
.who { color: var(--muted); font-size: 13px; }
.container { max-width: 1140px; margin: 0 auto; padding: 28px 24px 60px; }

/* --- Tarjetas / cajas --- */
.card,
.login-box,
.saldo-inicial-box,
.import-batches-box {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.muted { color: var(--muted); font-size: 13.5px; line-height: 1.5; }

.login-box {
  max-width: 380px;
  margin: 90px auto;
  padding: 36px;
  box-shadow: var(--shadow-lg);
}
.login-box h1 { margin-top: 0; margin-bottom: 4px; }

/* --- Formularios --- */
form label { display: block; margin: 10px 0 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=file], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-top: 10px;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-sm);
}
button:hover { background: var(--primary-dark); }
button:active { transform: translateY(1px); }

.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline-form input { width: auto; }

/* --- Tablas --- */
table.simple, table.movements, table.import-batches {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
}
table.simple th, table.simple td,
table.movements th, table.movements td,
table.import-batches th, table.import-batches td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}
table.movements th, table.import-batches th {
  background: #f7f8fa;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.movements tbody tr:hover, table.import-batches tbody tr:hover { background: #fafbfd; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.cargo { color: var(--danger); font-weight: 500; }
td.abono { color: var(--ok); font-weight: 500; }

/* Que quepa la tabla de movimientos en pantallas angostas sin romper el layout,
   sin tocar el display de la tabla (para no pelear con los encabezados). */
.table-scroll { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.table-scroll table.movements, .table-scroll table.import-batches { box-shadow: none; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }

.toggle-btn { margin: 0; padding: 5px 12px; font-size: 12.5px; font-weight: 600; border-radius: 999px; box-shadow: none; white-space: nowrap; width: auto; }
.toggle-btn.off { background: #f2f4f7; color: var(--muted); border: 1px solid var(--border); }
.toggle-btn.on { background: var(--ok-soft); color: var(--ok); border: 1px solid #b7ecc9; }
.toggle-btn:hover { background: #e9ecf1; }
.toggle-btn.on:hover { background: #d9f7e3; }

.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; margin: 0; font-size: 13px; font-weight: 600; box-shadow: none; }
.link-btn:hover { text-decoration: underline; background: none; }
.link-btn.danger { color: var(--danger); }

.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { width: auto; }
.filter-bar button { margin: 0; }

tr.is-pending .desc { font-weight: 600; }
.comments-row td { background: #fafbfc; }

/* --- Cartolas importadas (acordeón) --- */
.import-batches-box summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 2px 0;
  list-style: none;
}
.import-batches-box summary::-webkit-details-marker { display: none; }
.import-batches-box summary::before { content: "▸ "; color: var(--muted); }
.import-batches-box details[open] summary::before { content: "▾ "; }
.import-batches-box table.import-batches { margin-top: 14px; box-shadow: none; border: 1px solid var(--border-soft); }

/* --- Comentarios --- */
.thread { padding: 10px 4px; }
.comment { margin-bottom: 10px; padding: 10px 12px; background: #fafbfc; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.comment-meta { font-size: 12px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.comment-body { font-size: 14px; line-height: 1.45; }
.mention { color: var(--mention); font-weight: 600; background: var(--mention-soft); padding: 0 4px; border-radius: 4px; }
.lock { opacity: 0.55; }

.comment-form { position: relative; margin-top: 10px; }
.comment-form textarea { min-height: 60px; resize: vertical; }
.mention-suggestions {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 160px;
  overflow-y: auto;
  z-index: 20;
  width: 240px;
}
.mention-suggestions div { padding: 7px 10px; cursor: pointer; font-size: 13px; }
.mention-suggestions div:hover, .mention-suggestions div.active { background: var(--mention-soft); }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #fbd5d2; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #fbe4b8; }

/* --- Login: panel partido con color de marca --- */
.auth-body { margin: 0; background: var(--card); }
.auth-split { display: flex; min-height: 100vh; }
.auth-panel {
  flex: 1 1 46%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--leafy-primary), var(--leafy-accent));
  padding: 44px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
}
.auth-blob { position: absolute; border-radius: 50%; opacity: 0.14; background: #fff; pointer-events: none; }
.auth-blob-1 { width: 440px; height: 440px; top: -140px; right: -160px; }
.auth-blob-2 { width: 320px; height: 320px; bottom: -120px; left: -90px; }
.auth-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; position: relative; z-index: 1; }
.auth-brand-text { display: flex; flex-direction: column; line-height: 1; }
.auth-brand-name { font-family: "Baloo 2", "Inter", sans-serif; font-weight: 800; font-size: 26px; color: #fff; }
.auth-brand-tag {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d7f3e8;
  margin-top: 3px;
}
.auth-copy { position: relative; z-index: 1; max-width: 380px; }
.auth-copy h2 { font-size: 26px; line-height: 1.3; margin: 0 0 12px; font-weight: 700; }
.auth-copy p { font-size: 14.5px; line-height: 1.6; color: #dcefe8; margin: 0; }
.auth-form-panel {
  flex: 1 1 54%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg);
}
.auth-form-box {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}
.auth-form-box h1 { margin: 0 0 4px; }
@media (max-width: 860px) {
  .auth-panel { display: none; }
}

/* Barra de acciones de la cuenta (cargar cartola, pendientes, enviar) */
.actions-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 20px; }
.actions-bar form { margin: 0; }
.btn, .btn-secondary-btn {
  display: inline-block; padding: 9px 16px; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-weight: 600; font-size: 14px;
  text-decoration: none; border: 1px solid var(--primary); cursor: pointer; margin: 0;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary, .btn-secondary-btn {
  background: #fff; color: var(--primary); border: 1px solid var(--primary);
}
.btn-secondary:hover, .btn-secondary-btn:hover { background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe5d2; }
a.badge { text-decoration: none; }

/* --- Paginación de movimientos --- */
.pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 18px; margin: 0 0 12px; font-size: 13.5px; color: var(--muted);
}
.table-scroll + .pager { margin: 12px 0 0; }
.pager-info strong { color: var(--text); }
.pager-size { display: flex; align-items: center; gap: 8px; margin: 0; }
.pager-size select { width: auto; padding: 6px 28px 6px 10px; }
.pager-size button { margin: 0; }
.pager-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pager-links a, .pager-links span {
  min-width: 34px; padding: 6px 10px; text-align: center; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--primary);
  text-decoration: none; font-weight: 600; font-size: 13px;
}
.pager-links a:hover { background: var(--primary-soft); }
.pager-links .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-links .disabled { color: var(--muted); background: #f7f8fa; font-weight: 500; }
.pager-links .gap { border-color: transparent; background: transparent; color: var(--muted); min-width: 0; padding: 6px 2px; }
@media (max-width: 640px) { .pager { flex-direction: column; align-items: flex-start; } }

/* --- Último comentario visible en la fila --- */
td.comments-cell { min-width: 150px; max-width: 260px; }
.comment-preview {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 4px; font-size: 12.5px; line-height: 1.35; color: var(--muted); cursor: pointer;
  overflow-wrap: anywhere;
}
.comment-preview strong { color: var(--text); font-weight: 600; }
.comment-preview:hover { color: var(--text); }

.edit-account-form { max-width: 520px; display: flex; flex-direction: column; gap: 6px; }
.edit-account-form label { font-weight: 600; margin-top: 8px; }
.edit-account-form input { width: 100%; }
.edit-link { font-size: 0.8rem; font-weight: 500; margin-left: 10px; }
.dup-detail { margin: -6px 0 16px; font-size: 13px; }
.mismatch-detail { background: var(--surface, #fff); border: 1px solid #e3e3e3; border-radius: 8px; padding: 4px 16px; margin-bottom: 16px; font-size: 14px; }
.mismatch-detail ul { margin: 4px 0 8px 18px; padding: 0; }
.mismatch-force { margin-top: 24px; }
.toast-msg { display: none; position: fixed; top: 84px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 50; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.cuadre-table td { padding: 8px 12px; border-top: 1px solid var(--border, #e5e7eb); }
.cuadre-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cuadre-total td { font-weight: 700; background: var(--ok-soft, #eefaf3); }
.cuadre-box summary .badge { margin-left: 10px; }
.cuadre-box .alert ul { margin: 6px 0 0 18px; padding: 0; }
.cuadre-h { margin: 18px 0 8px; font-size: 15px; }

.check-cell { width: 34px; text-align: center; }
.check-cell input { width: auto; margin: 0; cursor: pointer; }
.bulk-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #1f2937; color: #fff; padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.bulk-bar .btn { margin: 0; padding: 6px 14px; }
.bulk-bar .link-btn { color: #cbd5e1; }
tr.row-selected { outline: 2px solid var(--primary, #1f6f54); outline-offset: -2px; background: #f1f8f4; }
.bulk-filtered { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.bulk-filtered .btn { margin: 0; padding: 6px 14px; }
.badge-cur { background: #eef1f5; color: #445; margin-left: 6px; vertical-align: middle; }

/* Tabla de movimientos: página más ancha y descripción más ancha (menos alta) */
.container.wide { max-width: 1560px; }
table.movements td.fecha, table.movements td.num { white-space: nowrap; }
table.movements td .toggle-btn { display: inline-block; white-space: nowrap !important; width: auto; min-width: 0; }
table.movements td.desc { min-width: 380px; width: 40%; line-height: 1.35; }
table.movements td.comments-cell { min-width: 230px; max-width: 360px; }
.comment-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.comment-line .link-btn { white-space: nowrap; flex: 0 0 auto; }
table.movements .comment-line .comment-preview { display: block; flex: 1 1 auto; min-width: 0; margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: unset; }

/* Empresas desplegables en el inicio */
.company-card { padding: 0; }
.company-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; cursor: pointer; list-style: none; }
.company-summary::-webkit-details-marker { display: none; }
.company-summary::before { content: "▸"; color: var(--muted); margin-right: 10px; font-size: 15px; transition: transform 0.15s ease; }
.company-card[open] > .company-summary::before { transform: rotate(90deg); }
.company-title { flex: 1; font-size: 19px; font-weight: 700; }
.company-title .muted { font-size: 13px; font-weight: 600; }
.company-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.company-summary:hover { background: #f7f9fb; border-radius: var(--radius); }
.company-body { padding: 0 22px 18px; border-top: 1px solid var(--border-soft); }

/* Filtro de estado dentro de la columna */
.estado-th { white-space: nowrap; }
.estado-filter { display: block; margin-top: 4px; padding: 3px 6px; font-size: 12px; font-weight: 600; border-radius: 6px; width: auto; max-width: 130px; }

/* Usuarios */
.user-actions { white-space: nowrap; }
.user-actions .btn { margin: 0 6px 0 0; padding: 6px 12px; }
.user-actions .btn-small { margin: 0; padding: 6px 12px; font-size: 13px; background: #f2f4f7; color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.user-actions .btn-small:hover { background: #e9ecf1; }

/* Selección de empresas con casillas */
.company-checks { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; background: #fff; }
.company-checks .check-row { display: flex; align-items: center; gap: 8px; margin: 0; padding: 6px 2px; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); cursor: pointer; }
.company-checks .check-row input { width: auto; margin: 0; }

/* Zona de peligro: eliminar cuenta */
.danger-zone { margin-top: 28px; max-width: 520px; border-color: #f3c9c5; }
.danger-zone h2 { color: var(--danger); margin-top: 0; font-size: 18px; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a3271d; }

a.link-danger { color: var(--danger); }

/* ===== Inicio rediseñado (v25) ===== */
[hidden] { display: none !important; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.dash-head h1 { margin: 0; }
.dash-new { position: relative; }
.dash-new > summary { list-style: none; cursor: pointer; display: inline-block; }
.dash-new > summary::-webkit-details-marker { display: none; }
.dash-new-form { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; display: flex; gap: 8px; flex-wrap: wrap; width: 440px; max-width: 90vw; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.dash-new-form input { flex: 1 1 180px; margin: 0; }
.dash-new-form button { margin: 0; }

.dash-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 16px 0 18px; }
.tile { background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; }
.tile-num { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; color: var(--text); }
.tile-num small { font-size: 15px; font-weight: 600; color: var(--muted); }
.tile-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.tile-warn { border-left: 4px solid var(--warn); }
.tile-warn .tile-num { color: var(--warn); }
.tile-ok { border-left: 4px solid var(--ok); }
.tile-ok .tile-num { color: var(--ok); }

.dash-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-search { flex: 1 1 280px; max-width: 420px; margin: 0; padding: 10px 14px; border-radius: 999px; }
.dash-chips { display: flex; gap: 6px; }
.chip { margin: 0; padding: 7px 14px; font-size: 13px; font-weight: 600; border-radius: 999px; background: var(--card); color: var(--muted); border: 1px solid var(--border); box-shadow: none; cursor: pointer; }
.chip:hover { background: #eef1f5; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.dash-count { font-size: 13px; margin-left: auto; }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); gap: 18px; align-items: start; }
.dash-card { padding: 0; margin: 0; }
.dash-card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.dash-card-title { flex: 1; min-width: 0; }
.dash-card-title h2 { margin: 0; font-size: 17px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-card-title .muted { font-size: 12.5px; }
.dash-card-side { display: flex; align-items: center; gap: 10px; flex: none; }

.acct-list { list-style: none; margin: 0; padding: 0; }
.acct-row { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--border-soft); }
.acct-row:hover { background: #f8fafb; }
.acct-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acct-name { font-weight: 600; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-name:hover { color: var(--primary); }
.acct-sub { font-size: 12px; }
.acct-status { flex: none; }
.acct-actions { flex: none; display: flex; align-items: center; gap: 12px; font-size: 13px; white-space: nowrap; }
.acct-more > summary { padding: 9px 18px; border-top: 1px solid var(--border-soft); font-size: 13px; font-weight: 600; color: var(--primary); cursor: pointer; }
.dash-empty-acc { padding: 4px 18px 12px; margin: 0; }
.dash-addacc { border-top: 1px solid var(--border-soft); padding: 10px 18px; }
.dash-addacc > summary { font-size: 13px; font-weight: 600; color: var(--primary); cursor: pointer; }
.dash-none { text-align: center; padding: 30px 0; }

.more-menu { position: relative; }
.more-menu > summary { list-style: none; cursor: pointer; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--muted); font-size: 18px; line-height: 1; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu > summary:hover, .more-menu[open] > summary { background: #eef1f5; color: var(--text); }
.more-pop { position: absolute; right: 0; top: 32px; z-index: 15; min-width: 150px; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 4px; }
.more-pop a { padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.more-pop a:hover { background: #f2f4f7; text-decoration: none; }

@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .dash-tiles { grid-template-columns: repeat(2, 1fr); }
  .acct-row { flex-wrap: wrap; }
  .acct-actions { width: 100%; justify-content: flex-end; }
  .dash-card-side .edit-link { display: none; }
}
.dash-card a, .dash-card .acct-more > summary { text-decoration: none; }
.acct-actions a:hover, .dash-card-side .edit-link:hover { text-decoration: underline; }
.acct-name:hover { text-decoration: none; }
.acct-actions { gap: 14px; }

/* Conciliados por mes (v27): 12 meses del año */
.dash-grid.single { grid-template-columns: 1fr; }
.dash-card { container-type: inline-size; }
.months { padding: 0 18px 14px; }
.months-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.months-detail { margin: 0; font-size: 13.5px; color: var(--muted); }
.months-detail strong { color: var(--ok); }
.months-detail .md-label { font-weight: 700; color: var(--text); }
.year-nav { display: flex; align-items: center; gap: 6px; }
.year-label { font-size: 13px; font-weight: 700; color: var(--text); min-width: 38px; text-align: center; }
.year-btn { margin: 0; width: 26px; height: 26px; padding: 0; border-radius: 50%; background: var(--card); color: var(--text); border: 1px solid var(--border); box-shadow: none; font-size: 16px; line-height: 1; cursor: pointer; }
.year-btn:hover { background: #eef1f5; }
.months-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.month { margin: 0; padding: 8px 6px 7px; display: flex; flex-direction: column; gap: 5px; align-items: stretch; text-align: center; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: none; cursor: pointer; font-weight: 500; min-width: 0; }
.month:hover:not(:disabled) { background: #f5f7fa; }
.month.sel { border: 2px solid var(--text); padding: 7px 5px 6px; }
.month.empty { background: #f7f8fa; border-style: dashed; cursor: default; opacity: .65; }
.month-label { font-size: 12.5px; white-space: nowrap; }
.month.sel .month-label { font-weight: 700; }
.month-bar { display: block; height: 6px; border-radius: 99px; background: #e5e8ee; overflow: hidden; }
.month-bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.month-num { font-size: 11px; color: var(--muted); }
@container (min-width: 760px) { .months-row { grid-template-columns: repeat(12, 1fr); } }
.container:has(.dash-grid) { max-width: 1360px; }

/* Filtros de movimientos (v28) */
.filter-bar { flex-wrap: wrap; align-items: center; }
.filter-bar .f-desc { flex: 1 1 220px; min-width: 180px; }
.filter-bar .f-monto { width: 130px; flex: none; }
.filter-clear { font-size: 13px; font-weight: 600; white-space: nowrap; }
.filter-bar .excel-btn { margin: 0; white-space: nowrap; }

/* Montos alineados a la derecha (encabezado y valores) (v30) */
table.simple td.num, table.movements td.num, table.import-batches td.num,
table.simple th.num, table.movements th.num, table.import-batches th.num { text-align: right; }
table.movements td.num, table.simple td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Fila contabilizada con color suave (v31) */
table.movements tbody tr.is-done > td { background: #eef8f1; }
table.movements tbody tr.is-done:hover > td { background: #e3f3ea; }
table.movements tbody tr.is-done > td:first-child { box-shadow: inset 3px 0 0 var(--ok); }

/* --- Filtros fijos al hacer scroll en la lista de movimientos --- */
.filter-bar.sticky-filters {
  position: sticky;
  top: var(--topbar-h, 70px);
  z-index: 25;
  background: var(--bg);
  padding: 10px 0;
  margin: 0 0 10px;
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 8px 8px -8px rgba(15, 23, 42, .18);
  gap: 8px;
}
.filter-bar.sticky-filters .f-monto { width: 112px; }
.filter-bar.sticky-filters input[type="date"] { width: 138px; padding-left: 8px; padding-right: 8px; }
/* La barra de "seleccionados" queda justo debajo de los filtros */
.bulk-bar { top: calc(var(--topbar-h, 70px) + var(--filters-h, 0px)); }
/* En pantallas bajitas o angostas no conviene que ocupen espacio fijo */
@media (max-height: 560px), (max-width: 700px) {
  .filter-bar.sticky-filters { position: static; box-shadow: none; border-bottom: 0; }
  .bulk-bar { top: var(--topbar-h, 70px); }
}

/* --- Pantalla de error amigable --- */
.error-page { max-width: 560px; margin: 60px auto; text-align: center; background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px; padding: 40px 32px; box-shadow: var(--shadow); }
.error-icon { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.error-page h1 { margin: 0 0 10px; font-size: 24px; }
.error-detail { font-size: 16px; line-height: 1.5; margin: 0 0 8px; }
.error-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.error-actions .btn { margin: 0; }

/* --- Ventana emergente de error --- */
.modal-backdrop { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; padding: 20px; animation: modal-fade .15s ease-out; }
.modal-box { background: #fff; border-radius: 16px; max-width: 480px; width: 100%; padding: 30px 28px 24px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); border-top: 5px solid var(--danger, #c0392b); animation: modal-pop .18s ease-out; }
.modal-icon { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.modal-box h2 { margin: 0 0 10px; font-size: 20px; color: var(--text); }
.modal-box p { margin: 0 0 20px; font-size: 15px; line-height: 1.55; color: #3b4858; }
.modal-box .btn { margin: 0; min-width: 130px; }
@keyframes modal-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes modal-pop { from { transform: translateY(8px) scale(.97); opacity: 0 } to { transform: none; opacity: 1 } }

/* Ventana "Enviar pendientes al cliente" */
.modal-backdrop[hidden] { display: none; }
.modal-box.modal-form { text-align: left; border-top-color: var(--leafy-accent, #2c9c82); max-height: 92vh; overflow-y: auto; }
.modal-box.modal-form h2 { text-align: left; }
.modal-box.modal-form label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; color: var(--text); }
.modal-box.modal-form input[type=text], .modal-box.modal-form textarea { width: 100%; box-sizing: border-box; }
.modal-box.modal-form textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.modal-box.modal-form .modal-hint { margin: 8px 0 0; font-size: 12.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-actions .btn { margin: 0; min-width: 110px; }
.field-error { margin-top: 6px; font-size: 13px; color: var(--danger, #d92d20); background: var(--danger-soft, #fef2f1); border: 1px solid #f5c2bd; border-radius: 8px; padding: 8px 10px; }
.field-error[hidden] { display: none; }
input.input-error { border-color: var(--danger, #d92d20) !important; }

/* Búsqueda en vivo: la tabla se atenúa un instante mientras se actualiza */
#movements-area { transition: opacity .15s; }
#movements-area.loading { opacity: .55; pointer-events: none; }

.comment-delete-form { margin-left: auto; }
.comment-delete { background: none; border: 0; padding: 0 2px; color: #b42318; font-size: 12px; cursor: pointer; text-decoration: underline; width: auto; }
.comment-delete:hover { color: #7a1a12; }

.cv-bar { display: flex; gap: 12px; align-items: end; margin: 12px 0; }
.cv-tabs { display: flex; gap: 8px; margin: 8px 0; }
.cv-table tfoot th { border-top: 2px solid var(--border-soft); }

.mov-docs { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.doc-chip { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; background: #eef6ff; border: 1px solid #cfe2fa; color: #1d4f91; border-radius: 999px; padding: 1px 8px; }
.doc-chip-auto { background: #effaf2; border-color: #cdebd6; color: #1f6b3a; }
.doc-unlink { background: none; border: 0; padding: 0 2px; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; width: auto; }
.doc-open { background: none; border: 0; padding: 0; font-size: 12px; color: var(--muted); cursor: pointer; text-decoration: underline; width: auto; }
.doc-open:hover { color: var(--text); }
.docs-panel { flex-basis: 100%; }
.docs-panel[hidden] { display: none; }
.docs-panel-inner { border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: #fafbfc; padding: 8px 10px; margin-top: 4px; }
.docs-panel-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.docs-panel-head .docs-q { flex: 1; min-width: 160px; }
.docs-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.docs-list li { display: flex; gap: 8px; align-items: center; padding: 4px 0; border-top: 1px solid var(--border-soft); font-size: 13px; }
.docs-list .doc-main { flex: 1; }
.docs-list .doc-total { font-variant-numeric: tabular-nums; }
button.doc-open, button.doc-open:hover, button.doc-open:focus, button.doc-unlink, button.doc-unlink:hover { background: transparent; box-shadow: none; border: 0; }
button.doc-open { color: var(--muted); padding: 0; font-weight: 400; }
button.doc-open:hover { color: var(--text); }
button.doc-unlink { color: inherit; }
.docs-panel-inner { min-width: 440px; }
.docs-panel-head strong { white-space: nowrap; }
.docs-list li { flex-wrap: wrap; }

/* Factura sugerida del SII bajo un movimiento del banco */
.doc-sug { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; background: #f1f8f4; border: 1px solid #cfe6d8; color: #1f6b4f; border-radius: 999px; padding: 2px 10px; }
.doc-sug-txt { font-weight: 500; }
.doc-sug-ok { color: var(--muted); font-size: 12px; }
button.doc-link, button.doc-comment { font-size: 12px; padding: 1px 8px; width: auto; border-radius: 999px; cursor: pointer; }
button.doc-comment { background: transparent; color: var(--muted); border: 1px solid var(--border-soft); box-shadow: none; font-weight: 400; }
button.doc-comment:hover { color: var(--text); }
button.doc-comment-del { color: #b42318; border-color: #f1c0bb; }
button.doc-comment-del:hover { color: #7a1710; background: #fdf1f0; }
