/* TSG · Teseo Sistema de Gestión — paleta y tipografía de Teseo Consulting (igual que TRB y TTS). */
:root {
  --navy: #001f49;
  --navy-deep: #00122b;
  --night: #050a1f;
  --purple: #5e17eb;
  --purple-2: #8b5cf6;
  --purple-soft: #efe7fd;
  --teal: #00b6a6;
  --teal-dark: #00897d;
  --teal-soft: #dcf6f3;
  --bg: #f6f5f9;
  --surface: #ffffff;
  --ink: #16182b;
  --muted: #6b6f80;
  --line: #e3e2ea;
  --danger: #d13b3b;
  --danger-soft: #fde8e8;
  --warn: #e08a00;
  --warn-soft: #fff3dc;
  --ok: #1f9d55;
  --ok-soft: #e1f5e9;
  --info: #2a6de1;
  --info-soft: #e5eefc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 31, 73, .06), 0 4px 16px rgba(0, 31, 73, .06);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); display: flex; flex-direction: column; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--purple); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------- Login ---------- */
.login-screen { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: radial-gradient(ellipse at 30% 40%, #1a0b5c 0%, var(--night) 55%), var(--night); }
.login-net { position: absolute; inset: 0; background: url(red-teseo.svg) center/cover no-repeat; opacity: .7; animation: drift 40s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1) translateX(-1%); } to { transform: scale(1.06) translateX(1%); } }
@media (prefers-reduced-motion: reduce) { .login-net { animation: none; } }
.login-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; max-width: 380px; }
.login-logo { width: 132px; height: 132px; border-radius: 50%; box-shadow: 0 0 60px rgba(94, 23, 235, .45); }
.login-card { width: 100%; background: rgba(255, 255, 255, .97); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login-card h1 { font-size: 28px; color: var(--navy); }
.login-card h1::after { content: ''; display: block; width: 44px; height: 4px; border-radius: 2px; margin-top: 6px; background: linear-gradient(90deg, var(--purple), var(--teal)); }
.login-sub { margin: -4px 0 6px; color: var(--muted); letter-spacing: .02em; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 14px; border: 1px solid #c9ccd6; border-radius: 10px;
  background: #fff; color: #1f1f1f; font-weight: 600; font-size: 15px; text-decoration: none; transition: box-shadow .15s, background .15s; }
.btn-google:hover { background: #f7f8fa; box-shadow: 0 2px 8px rgba(0, 18, 43, .15); }
.btn-google:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.login-alt { border-top: 1px solid #e3e5ec; padding-top: 10px; }
.login-alt summary { cursor: pointer; font-size: 13px; color: var(--muted); text-align: center; list-style: none; }
.login-alt summary::-webkit-details-marker { display: none; }
.login-alt summary:hover { color: var(--navy); }
.login-alt form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.login-error { color: var(--danger); min-height: 1em; margin: 0; font-size: 13px; }
.login-hint, .login-version { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.login-env { margin: 0; text-align: center; font-weight: 700; color: var(--warn); font-size: 12px; }
body.logged-out > :not(.login-screen):not(dialog):not(.toast) { display: none !important; }
body:not(.logged-out) .login-screen { display: none; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; padding: 8px 20px; color: #fff;
  background: linear-gradient(100deg, var(--navy) 0%, var(--navy) 55%, #1b0c63 100%); box-shadow: 0 2px 10px rgba(0, 18, 43, .25); }
.topbar::before { content: ''; position: absolute; inset: 0; background: url(red-teseo.svg) right center/60% auto no-repeat; opacity: .35; pointer-events: none; }
.topbar > * { position: relative; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex-shrink: 0; }
.brand-mark { width: 42px; height: 42px; border-radius: 50%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 18px; }
.brand-sub { font-size: 10px; letter-spacing: .28em; text-transform: uppercase; color: var(--teal); }
.main-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.main-nav a { color: #cfd6ea; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; white-space: nowrap; position: relative; }
.main-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.main-nav a.active { color: #fff; background: rgba(139, 92, 246, .28); }
.main-nav a.active::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--teal); }
.nav-badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--teal); color: var(--navy-deep); font-size: 11px; font-weight: 800; text-align: center; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-badge { font-size: 12px; color: #dfe4f2; text-align: right; line-height: 1.2; }
.user-badge b { display: block; color: #fff; font-size: 13px; }
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border-radius: 10px; box-shadow: var(--shadow), 0 10px 30px rgba(0, 0, 0, .15); min-width: 230px; max-width: calc(100vw - 16px); padding: 6px; display: flex; flex-direction: column; z-index: 30; }
.menu-panel button { text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.menu-panel button:hover { background: var(--purple-soft); }
.env-banner { background: var(--warn); color: #fff; text-align: center; font-weight: 700; font-size: 12px; padding: 4px; letter-spacing: .04em; }
.app-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 14px; }
.app-footer a { color: var(--muted); }

/* ---------- Botones y campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 9px; padding: 8px 14px; font-weight: 600; cursor: pointer; background: #fff; border-color: var(--line); color: var(--ink); text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: #c9c6d6; background: #fbfaff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--purple), #7a3cf0); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(94, 23, 235, .25); }
.btn-primary:hover { background: linear-gradient(135deg, #5310d6, var(--purple)); }
.btn-teal { background: var(--teal); color: #fff; border-color: transparent; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-danger { color: var(--danger); border-color: #f1c4c4; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn-ok:hover { background: #18834a; }
.btn-link { background: none; border: 0; color: var(--purple); padding: 4px 6px; cursor: pointer; font-weight: 600; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-ghost-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .3); }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .5); }
.icon-btn { width: 36px; height: 36px; padding: 0; font-size: 18px; border-radius: 9px; cursor: pointer; }
input, select, textarea { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid rgba(94, 23, 235, .35); outline-offset: 1px; border-color: var(--purple); }
textarea { resize: vertical; min-height: 70px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span:not(.hint) { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field.invalid input, .field.invalid select { border-color: var(--danger); background: var(--danger-soft); }
.field .hint { font-size: 12px; color: var(--muted); }
.modal .field input, .modal .field select, .modal .field textarea { width: 100%; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------- Estructura de las vistas ---------- */
.app { flex: 1; padding: 20px; max-width: 1400px; width: 100%; margin: 0 auto; outline: none; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head h1 { font-size: 24px; color: var(--navy); }
.view-head h1 small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #ecebf2; }
.card + .card { margin-top: 16px; }
.card-pad { padding: 16px 18px; }
.card-title { font-size: 15px; color: var(--navy); display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border: 1px solid #ecebf2; position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--purple); }
.kpi.teal::before { background: var(--teal); }
.kpi.warn::before { background: var(--warn); }
.kpi.ok::before { background: var(--ok); }
.kpi.danger::before { background: var(--danger); }
.kpi-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 24px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-value.money { font-size: 18px; white-space: nowrap; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--purple-2); }
.chip.on { background: var(--purple); border-color: var(--purple); color: #fff; }
/* Estados */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.Borrador { background: #eeedf3; color: #57536b; }
.badge.Enviado { background: var(--info-soft); color: var(--info); }
.badge.Aprobado { background: var(--ok-soft); color: var(--ok); }
.badge.Rechazado { background: var(--danger-soft); color: var(--danger); }
.badge.trb { background: var(--purple-soft); color: var(--purple); }
.badge.off { background: #eee; color: #888; }
.badge.on { background: var(--teal-soft); color: var(--teal-dark); }

/* ---------- Tablas de datos ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
.data th.sortable { cursor: pointer; user-select: none; }
.data th.sortable:hover { color: var(--ink); }
.data th.sorted { color: var(--purple); }
.data th .sort-ind { margin-left: 4px; font-size: 10px; opacity: .45; }
.data th.sorted .sort-ind { opacity: 1; }
.data th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px; border-bottom: 2px solid var(--line); background: #faf9fd; white-space: nowrap; cursor: default; }
.data th.num { text-align: right; }
.data th.sortable { cursor: pointer; }
.data th.sortable:hover { color: var(--purple); }
.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tbody tr:hover { background: #fbfaff; }
.data tr.selected { background: #f4efff; }
.data tfoot td { font-weight: 800; color: var(--navy); background: #faf9fd; }
.data .notes { max-width: 340px; color: var(--muted); font-size: 12px; white-space: pre-line; }
.data .reject { color: var(--danger); font-size: 12px; }
.data td.actions { white-space: nowrap; text-align: right; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .field { min-width: 140px; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 16px; background: var(--purple-soft); border-bottom: 1px solid #ddd0fb; }
.bulkbar b { color: var(--purple); }
.group-row td { background: #f3f1fa; font-weight: 700; color: var(--navy); }
.bar { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--purple), var(--teal)); min-width: 2px; }
.bar-cell { width: 34%; }

/* ---------- Configuración ---------- */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.subtabs button { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 12px; font-weight: 600; cursor: pointer; }
.subtabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.key-box { font-family: ui-monospace, Menlo, monospace; background: var(--navy-deep); color: #9ff3ea; padding: 12px; border-radius: 9px; word-break: break-all; }
.status-line { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.status-dot.bad { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }

/* ---------- Modal ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 16px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 30px 80px rgba(0, 18, 43, .35); }
dialog.modal.wide { width: min(900px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(5, 10, 31, .55); backdrop-filter: blur(2px); }
.modal-card { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(100deg, #fff 60%, var(--purple-soft)); }
.modal-head h2 { font-size: 18px; color: var(--navy); }
.modal-x { background: none; border: 0; }
.modal-x:hover { background: var(--purple-soft); }
.modal-body { padding: 18px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: #faf9fd; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.form-error { color: var(--danger); margin: 0 20px; font-size: 13px; font-weight: 600; }
.form-error:empty { display: none; }
.alert { padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.alert.warn { background: var(--warn-soft); color: #8a5300; }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--info-soft); color: #1f4fa6; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 100; font-weight: 600; max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--teal-dark); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout-side { grid-template-columns: minmax(0, 1fr); }
  .user-badge, .brand-sub { display: none; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .main-nav { order: 3; flex-basis: 100%; }
  .brand-sub, .user-badge { display: none; }
  .app { padding: 14px 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* Celular: menú en una fila que se desliza, textos a 16px (iPhone no hace zoom al escribir) */
  .main-nav { flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .main-nav a { padding: 8px 10px; }
  input, select, textarea { font-size: 16px; }
  .view-head { align-items: stretch; }
  .view-head h1 { font-size: 20px; }
  .toolbar { width: 100%; }
  .toolbar .field { flex: 1 1 100%; }
  .toolbar .field select { width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 20px; }

  /* Ventanas a pantalla completa desde abajo */
  dialog.modal, dialog.modal.wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .modal-card { max-height: 92dvh; }
  .modal-foot .btn { flex: 1 1 auto; }
}
@media print {
  .topbar, .app-footer, .toolbar, .filters, .bulkbar, .env-banner, .row-actions { display: none !important; }
  .card { box-shadow: none; border: 0; }
}

/* Actividad: barras de consumo y sesión propia */
.usage-bar { display: inline-block; width: 140px; height: 8px; background: #ecebf2; border-radius: 99px; overflow: hidden; vertical-align: middle; }
.usage-bar i { display: block; height: 100%; background: var(--purple); border-radius: 99px; }
.data tr.current td { background: #f6f3ff; }

/* =====================================================================
   TSG · componentes propios
   ===================================================================== */
.data td.num, .data th.num { text-align: right; }
.data td { vertical-align: middle; }
.data tbody tr.clickable { cursor: pointer; }
.data td.neg, .neg { color: var(--danger); }
.data td.pos, .pos { color: var(--ok); }
.data td.sel, .data th.sel { width: 34px; text-align: center; }
.data .sub { display: block; font-size: 11px; color: var(--muted); }
.data .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.data tr.subtotal td { background: #f6f4fc; font-weight: 700; }
table.compact td, table.compact th { padding: 6px 8px; font-size: 13px; }
.table-more { padding: 12px; text-align: center; border-top: 1px solid var(--line); }

/* Barra de ejercicio (debajo de la barra superior) */
.ej-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 20px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(0, 31, 73, .03); position: sticky; top: 58px; z-index: 15; }
.ej-bar .ej-label { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ej-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.ej-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 12px; cursor: pointer; color: var(--navy); }
.ej-tabs button:hover { border-color: var(--purple-2); }
.ej-tabs button.on { background: linear-gradient(135deg, var(--purple), #7a3cf0); border-color: transparent; color: #fff; }
.ej-tabs button.cur::after { content: '•'; color: var(--teal); margin-left: 4px; }
.ej-tabs button.on.cur::after { color: #b9fff7; }
.ej-bar select { padding: 5px 8px; font-size: 13px; }
.ej-bar .ej-range { font-size: 12px; color: var(--muted); margin-left: auto; }

/* Encabezado de cada vista */
.view-head .kicker { font-size: 11px; font-weight: 800; color: var(--teal-dark); text-transform: uppercase; letter-spacing: .12em; margin-bottom: 2px; }
.search { min-width: 220px; }
.filters .field select, .filters .field input { min-width: 140px; }
.filters .grow { flex: 1; }
.chip-x { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 0 0 4px; font-weight: 800; }

/* Tablero */
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-grid + .dash-grid { margin-top: 16px; }
.dash-grid.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi-value.money { font-size: 20px; }
.kpi .trend { font-size: 12px; font-weight: 700; }
.kpi .trend.up { color: var(--ok); }
.kpi .trend.down { color: var(--danger); }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; }
.chart .grid line { stroke: #ecebf2; }
.chart .zero { stroke: #c9c6d6; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.chart-tip { position: fixed; pointer-events: none; background: var(--navy); color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12px; z-index: 90; box-shadow: 0 8px 20px rgba(0, 0, 0, .25); white-space: nowrap; }
.chart-tip b { display: block; margin-bottom: 2px; }
.bars-list { display: flex; flex-direction: column; gap: 8px; }
.bars-list .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; font-size: 13px; }
.bars-list .row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars-list .row .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.bars-list .row .bar { grid-column: 1 / -1; }
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: #faf9fd; border: 1px solid var(--line); font-size: 13px; }
.alert-item .ico { font-size: 16px; line-height: 1.2; }
.alert-item a { font-weight: 700; }
.alert-item.warn { background: var(--warn-soft); border-color: #f5d9a8; }
.alert-item.danger { background: var(--danger-soft); border-color: #f1c4c4; }
.alert-item.ok { background: var(--ok-soft); border-color: #bfe6cf; }

/* Formularios */
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-4 { grid-column: 1 / -1; }
.form-section { font-size: 11px; font-weight: 800; color: var(--teal-dark); text-transform: uppercase; letter-spacing: .1em; grid-column: 1 / -1; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-top: 4px; }
.field input.money, .field input.num { text-align: right; font-variant-numeric: tabular-nums; }
.field input.auto { background: #f7f6fb; }
.field input[readonly], .field select:disabled, .field input:disabled { background: #f1f0f5; color: var(--muted); cursor: not-allowed; }
.field .calc-val { padding: 8px 10px; border-radius: 9px; background: var(--purple-soft); color: var(--navy); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.field.bool { flex-direction: row; align-items: center; gap: 8px; padding-top: 18px; }
.field.bool > span:not(.hint) { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); font-weight: 600; }
.inline-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.summary-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; background: #faf9fd; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.summary-box div { display: flex; flex-direction: column; }
.summary-box span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.summary-box b { font-size: 15px; color: var(--navy); font-variant-numeric: tabular-nums; }
.summary-box b.big { font-size: 18px; color: var(--purple); }
.adj-list { display: flex; flex-direction: column; gap: 6px; }
.adj-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; }
.adj-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 2px dashed #d6d1ea; border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.over { background: var(--purple-soft); border-color: var(--purple-2); color: var(--purple); }
.dropzone input { display: none; }
.prov-new { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; padding: 10px; background: var(--teal-soft); border-radius: 10px; }

/* Badges de estado */
.badge.PAGADA, .badge.COBRADA, .badge.PAGADO, .badge.COMPENSADA, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.PENDIENTE, .badge.warn { background: var(--warn-soft); color: #a46300; }
.badge.PARCIAL { background: #e6f4f6; color: #0b7285; }
.badge.ing-TSG { background: #eef0f6; color: #4a4f63; }
.badge.ing-TTS { background: #efe9fb; color: #5b3cc4; }
.badge.VENCIDA, .badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info, .badge.planilla { background: var(--info-soft); color: var(--info); }
.badge.mute { background: #eeedf3; color: #57536b; }

/* Conciliación */
.cand { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.cand:hover { border-color: var(--purple-2); background: #fbf9ff; }
.cand.best { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.cand .meta { font-size: 12px; color: var(--muted); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.preview-table { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }

/* Listas editables */
.list-editor { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.list-editor .card { margin: 0 !important; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--purple-soft); color: var(--navy); font-size: 12px; font-weight: 600; }

/* Login de TSG */
.login-card .login-modules { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: -2px 0 4px; }
.login-card .login-modules span { font-size: 11px; font-weight: 700; color: var(--teal-dark); background: var(--teal-soft); padding: 2px 8px; border-radius: 999px; }

@media (max-width: 1100px) {
  .dash-grid, .dash-grid.even { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .ej-bar { padding: 8px 12px; top: 0; position: static; }
  .ej-bar .ej-range { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .prov-new { grid-template-columns: 1fr; }
  .search { min-width: 0; flex: 1 1 100%; }
}
@media print {
  .ej-bar { display: none !important; }
}

/* Ajustes finales */
.badge { background: #eeedf3; color: #4a4760; }
.badge.muted { background: #eeedf3; color: #8a8799; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
tr.row-danger td { background: #fff4f4; }
tr.total-row td { font-weight: 700; background: #f5f6fa; border-top: 2px solid var(--line, #dfe3ec); }
tr.muted td { color: #8a8799; }
.chart-wrap { width: 100%; }
.grid-1 { display: grid; gap: 12px; }
.about { text-align: center; }
.about h3 { margin: 10px 0 4px; color: var(--navy, #001f49); }
[hidden] { display: none !important; }
table.data td .mono { white-space: nowrap; }
/* Tablas más compactas para que entren las columnas sin desplazarse */
.app { max-width: 1680px; }
.data td { padding: 8px 7px; font-size: 13px; }
.data th { padding: 9px 7px; font-size: 10.5px; }
.data td .sub { font-size: 11px; }
.data td.num { white-space: nowrap; }
.data td.name { min-width: 135px; }

/* Órdenes de pago */
.op-list { max-height: 340px; overflow: auto; border: 1px solid var(--line, #e3e6ee); border-radius: 10px; }
.op-list table.data th { position: sticky; top: 0; z-index: 1; }
table.data tr.muted td { opacity: .55; }
/* Avisos por encima de las ventanas (popover) */
.toast[popover] { inset: auto auto 22px 50%; margin: 0; border: 0; overflow: visible; }
/* Menú: con Pagos entran todas las secciones en 1280 */
@media (max-width: 1400px) { .topbar { gap: 12px; } .main-nav { gap: 2px; } .main-nav a { padding: 8px 6px; font-size: 13.5px; } .main-nav a.active::after { left: 6px; right: 6px; } .user-badge { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

/* Leer comprobantes en PDF */
.pdf-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: #faf9fd; }
.pdf-bar label.btn { cursor: pointer; }
#pdfInfo .alert ul, #adjBox .alert ul { margin: 6px 0 6px 18px; padding: 0; }
/* Impresión de la orden de pago */
#printArea { display: none; }
@media print {
  body.printing-op > *:not(#printArea) { display: none !important; }
  body.printing-op #printArea { display: block; }
  .op-print { font: 12px/1.45 Arial, sans-serif; color: #111; }
  .op-print h1 { font-size: 18px; margin: 0; } .op-print h2 { font-size: 14px; margin: 18px 0 6px; }
  .op-print table { width: 100%; border-collapse: collapse; } .op-print th, .op-print td { border-bottom: 1px solid #bbb; padding: 4px 6px; text-align: left; }
  .op-print th { font-size: 10px; text-transform: uppercase; color: #555; } .op-print .n { text-align: right; }
  .op-print .tot td { font-weight: 700; border-top: 2px solid #111; } .op-print .muted { color: #666; }
  .op-top { display: flex; justify-content: space-between; } .op-right { text-align: right; }
  .op-anulada { color: #b00; font-weight: 700; font-size: 16px; }
  .op-firmas { margin-top: 60px; display: flex; gap: 50px; } .op-firmas div { border-top: 1px solid #111; padding-top: 4px; width: 200px; text-align: center; }
}

/* Retenciones y percepciones (maestros, parámetros, órdenes de pago y cobranzas) */
.imp-editor { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.imp-rows { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.imp-rows:empty { display: none; }
.imp-row { display: grid; grid-template-columns: minmax(0, 285px) minmax(0, 300px) 104px 32px; gap: 8px; align-items: center; }
.imp-row > [data-k="impuesto"] { grid-column: 1; } .imp-row > [data-k="jurisdiccion"] { grid-column: 2; }
.imp-row > .imp-pct { grid-column: 3; } .imp-row > [data-imp-del] { grid-column: 4; }
.imp-editor[data-pct="0"] .imp-row { grid-template-columns: minmax(0, 285px) minmax(0, 300px) 32px; }
.imp-editor[data-pct="0"] .imp-row > [data-imp-del] { grid-column: 3; }
.imp-pct { display: flex; align-items: center; gap: 4px; }
.field .imp-row .imp-pct input { width: 100%; min-width: 0; text-align: right; }
@media (max-width: 700px) { .imp-row, .imp-editor[data-pct="0"] .imp-row { grid-template-columns: 1fr 90px 32px; } .imp-row > * { grid-column: auto !important; } .imp-row > [data-k="jurisdiccion"] { grid-column: 1 / -1 !important; grid-row: 2; } }
.imp-editor:has(select:disabled) button { display: none; }
.ret-prov { border: 1px solid var(--line, #e3e6ee); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.ret-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.ret-head .spacer { flex: 1; }
.ret-tabla input.ret-input { width: 130px; text-align: right; }
.ret-tabla .sub { display: block; }
