/* Tokens de la app de Giro (infra/contable-agent/public/giro-theme.css): papel, superficie, tinta, filete, acento. */
@font-face {
  font-family: "Giro Display";
  src: url("/fonts/Montserrat-ExtraBold.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root, :root[data-theme="light"] {
  --paper: #FBFAF7;
  --surface: #FFFFFF;
  --surface-2: #F4F3EF;
  --ink: #16202B;
  --ink-2: #5A6672;
  --ink-3: #8A949E;
  --rule: #E3E6EA;
  --rule-2: #CED4DA;
  --accent: #1B3A5C;
  --accent-soft: #E8EEF5;
  --ok: #1F6B4A;
  --ok-bg: #E7F1EC;
  --wait: #96691A;
  --wait-bg: #F8F0DF;
  --bad: #A33A2E;
  --bad-bg: #F8EAE8;
  --focus: #2F6FB0;
  --on-ok: #FFFFFF;
  --shadow: 0 1px 2px rgba(22, 32, 43, .06), 0 8px 24px rgba(22, 32, 43, .05);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #11161C;
  --surface: #171E26;
  --surface-2: #1E2731;
  --ink: #E6EBF0;
  --ink-2: #9BA8B5;
  --ink-3: #6E7C8A;
  --rule: #2A3440;
  --rule-2: #3A4754;
  --accent: #8FB8E3;
  --accent-soft: #1C2A3A;
  --ok: #5FB68C;
  --ok-bg: #16291F;
  --wait: #D6A44C;
  --wait-bg: #2A2313;
  --bad: #E08C80;
  --bad-bg: #2B1A18;
  --focus: #6FA8E0;
  --on-ok: #11161C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Barra */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.marca { display: flex; align-items: center; gap: 9px; min-width: 0; }
.marca svg { width: 26px; height: 26px; border-radius: 6px; flex: none; }
.wordmark { font: 800 15px "Giro Display", "Segoe UI", sans-serif; letter-spacing: -.01em; white-space: nowrap; }
.empresa { min-width: 0; padding-left: 12px; border-left: 1px solid var(--rule); color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empresa:empty { display: none; }
.top-der { margin-left: auto; display: flex; align-items: center; gap: 12px; flex: none; }
.enlace-top { color: var(--ink-2); font-size: 13px; text-decoration: none; white-space: nowrap; }
.enlace-top:hover { color: var(--ink); }
.icono-btn { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 7px; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.icono-btn:hover { border-color: var(--rule-2); color: var(--ink); }
.icono-btn svg { width: 16px; height: 16px; }
.cuenta { position: relative; }
.avatar { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 650; cursor: pointer; }
.avatar:hover { border-color: var(--rule-2); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; max-width: calc(100vw - 32px); padding: 6px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.menu-nombre { margin: 0; padding: 6px 8px 0; font-weight: 600; overflow-wrap: anywhere; }
.menu-correo { margin: 0; padding: 0 8px 6px; color: var(--ink-2); font-size: 12.5px; overflow-wrap: anywhere; border-bottom: 1px solid var(--rule); }
.menu-correo:empty { display: none; }
.menu-item { display: block; width: 100%; margin-top: 4px; padding: 7px 8px; border: 0; border-radius: 6px; background: none; color: var(--ink); font-size: 13px; text-align: left; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }

/* Página */
.pagina { max-width: 1240px; margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 14px; }
.pagina > * { min-width: 0; }
.cabeza { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.cabeza h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; vertical-align: 1px; }
.chip[data-tono="ok"] { background: var(--ok-bg); color: var(--ok); }
.chip[data-tono="wait"] { background: var(--wait-bg); color: var(--wait); }
.chip[data-tono="error"] { background: var(--bad-bg); color: var(--bad); }
.acciones { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.periodo { display: inline-flex; align-items: stretch; height: 36px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
.periodo button { width: 32px; padding: 0; border: 0; background: none; color: var(--ink-2); font-size: 15px; cursor: pointer; }
.periodo button:hover:not(:disabled) { color: var(--ink); }
.periodo button:disabled { color: var(--rule-2); cursor: not-allowed; }
.periodo select { min-width: 9.5rem; padding: 0 8px; border: 0; border-inline: 1px solid var(--rule); background: var(--surface); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.periodo select:disabled { color: var(--ink-3); cursor: not-allowed; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13.5px; text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn:hover { border-color: var(--rule-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primario { background: var(--ok); border-color: var(--ok); color: var(--on-ok); font-weight: 600; }
.btn.primario:hover { filter: brightness(1.08); }
.btn.ancho { width: 100%; height: 40px; }

.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: none; padding: 9px 0 10px; border: 0; background: none; color: var(--ink-2); font-size: 13.5px; white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: var(--accent); }

.aviso { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--wait-bg); font-size: 13px; }
.aviso[data-tono="error"] { background: var(--bad-bg); color: var(--bad); }
.aviso strong { font-weight: 600; }
.aviso button { margin-left: auto; padding: 0; border: 0; background: none; color: var(--ink); font-weight: 600; text-decoration: underline; white-space: nowrap; cursor: pointer; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.kpis:empty { display: none; }
.kpi { min-width: 0; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.kpi small { display: block; color: var(--ink-2); font-size: 12px; }
.kpi b { display: block; margin-top: 1px; font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi i { display: block; color: var(--ink-3); font-size: 12px; font-style: normal; }

.panel { min-width: 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); overflow: hidden; }
.panel.relleno { padding: 14px; }
.panel h2 { margin: 0; font-size: 15px; font-weight: 650; }
.panel h3 { margin: 16px 0 6px; font-size: 13.5px; font-weight: 600; }
.pista { margin: 2px 0 10px; color: var(--ink-2); font-size: 13px; }
.nota { margin: 10px 0 0; color: var(--ink-2); font-size: 12.5px; }
.nota:empty { display: none; }
.pila { display: grid; gap: 14px; }
.plegable summary { font-size: 14px; font-weight: 600; cursor: pointer; }
.plegable[open] summary { margin-bottom: 8px; }
.fila-botones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* Tabla */
.panel-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.panel-cabeza strong { font-size: 13.5px; font-weight: 600; }
.buscar { width: 260px; max-width: 55%; height: 32px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); font-size: 13px; }
.buscar::placeholder { color: var(--ink-3); }
.table-wrap { max-height: 72vh; overflow: auto; }
#grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
#grid th { position: sticky; top: 0; z-index: 1; padding: 8px 12px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--rule); }
#grid td { padding: 9px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
#grid tbody tr:last-child td { border-bottom: 0; }
#grid tbody tr:hover td { background: var(--surface-2); }
#grid th.n, #grid td.n { text-align: right; font-variant-numeric: tabular-nums; }
#grid td.ncf { font-weight: 600; font-variant-numeric: tabular-nums; }
#grid td.sec { color: var(--ink-2); }
#grid td.cero { color: var(--ink-3); }
#grid td.corto { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
#grid tfoot td { position: sticky; bottom: 0; border-top: 1px solid var(--rule-2); border-bottom: 0; background: var(--surface-2); font-weight: 600; }
.tabla-vacia { margin: 0; padding: 20px 14px; color: var(--ink-2); font-size: 13.5px; text-align: center; }
.tabla-mas { display: flex; justify-content: center; padding: 10px; border-top: 1px solid var(--rule); }
.status { margin: 0; color: var(--ink-3); font-size: 12.5px; }
.status:empty { display: none; }

/* Estados */
.estado { display: grid; justify-items: center; gap: 8px; padding: 32px 16px 36px; text-align: center; }
.estado svg { width: 34px; height: 34px; color: var(--ink-3); }
.estado[data-tono="error"] svg { color: var(--bad); }
.estado h2 { font-size: 16px; }
.estado p { max-width: 460px; margin: 0; color: var(--ink-2); font-size: 13.5px; }
.estado .btn { margin-top: 6px; }

.esqueleto { display: grid; gap: 14px; }
.barra { display: block; height: 12px; margin: 10px 0; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--rule), var(--surface-2)); background-size: 200% 100%; animation: brillo 1.3s linear infinite; }
.barra.corta { width: 45%; margin: 2px 0 8px; }
.barra.alta { height: 22px; width: 75%; margin: 0; }
@keyframes brillo { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .barra { animation: none; } }

/* Valores para copiar en la DGII */
.dos-columnas { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.campo { min-width: 0; display: grid; gap: 3px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 12px; color: var(--ink-2); }
.campo label { font-size: 12px; color: var(--ink-2); }
.campo select, .campo input { height: 34px; padding: 0 8px; border: 1px solid var(--rule); border-radius: 7px; background: var(--paper); color: var(--ink); font-size: 13px; }
.copiar { display: inline-block; padding: 1px 6px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--ink); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: left; cursor: copy; user-select: text; }
.copiar:hover { border-color: var(--rule-2); background: var(--surface); }
.copiar.copiado { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.campo .copiar { margin-left: -6px; justify-self: start; }
.fc-check { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 10px; font-size: 13px; }
.tabla-simple { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla-simple th { padding: 6px 8px; color: var(--ink-2); font-size: 12px; font-weight: 500; text-align: left; border-bottom: 1px solid var(--rule); }
.tabla-simple td { padding: 5px 8px; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.tabla-simple tr:last-child td { border-bottom: 0; }
.tabla-simple td.n, .tabla-simple th.n { text-align: right; white-space: nowrap; }
.tabla-scroll { overflow-x: auto; }
.secuencia { margin: 0 0 10px; padding-left: 20px; color: var(--ink-2); font-size: 13px; }
.secuencia:empty { display: none; }
.cliente-card { margin-top: 10px; padding: 10px; border: 1px solid var(--rule); border-radius: 10px; }
.cliente-card h4 { margin: 0 0 8px; font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.cliente-card h4 small { color: var(--ink-2); font-weight: 400; }

/* Pendientes */
.conexion-cabeza { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.form-conexion { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; align-items: end; margin-top: 10px; }
.form-conexion label { display: grid; gap: 3px; font-size: 12px; color: var(--ink-2); }
.form-conexion input { height: 36px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 13.5px; }
.form-error { margin: 8px 0 0; color: var(--bad); font-size: 13px; }
.grupo-aviso { border-top: 1px solid var(--rule); padding: 8px 0; }
.grupo-aviso:first-of-type { border-top: 0; }
.grupo-aviso summary { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.pendientes-lista { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.pendientes-lista li { margin: 2px 0; overflow-wrap: anywhere; }
.pendientes-lista strong { color: var(--ink); font-weight: 600; }
.gastos { width: 100%; border-collapse: collapse; font-size: 13px; }
.gastos th { padding: 7px 10px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; }
.gastos td { padding: 7px 10px; border-top: 1px solid var(--rule); vertical-align: middle; }
.gastos td.n, .gastos th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gastos select { max-width: 15rem; height: 32px; padding: 0 6px; border: 1px solid var(--rule); border-radius: 7px; background: var(--paper); font-size: 12.5px; }
.gastos .btn { height: 32px; padding: 0 10px; font-size: 12.5px; }

/* Entrada */
.login-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 12px; padding: 24px; border: 1px solid var(--rule); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { margin: 8px 0 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.login-card .sub { margin: -8px 0 0; }
.login-opcion { display: grid; gap: 4px; }
.login-opcion .pista { margin: 0; font-size: 12.5px; }

@media (max-width: 640px) {
  .enlace-top, .empresa { display: none; }
  .cabeza { align-items: stretch; }
  .acciones { width: 100%; }
  .periodo { flex: 1 1 100%; height: 40px; }
  .periodo select { flex: 1; }
  .acciones .btn { flex: 1 1 100%; height: 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
  .kpi b { font-size: 19px; }
  .panel-cabeza { flex-direction: column; align-items: stretch; }
  .buscar { width: 100%; max-width: none; height: 36px; }
  .aviso button { margin-left: 0; }

  /* Cada comprobante es una ficha: NCF y monto arriba, y el resto con su nombre. */
  .table-wrap { max-height: none; overflow: visible; }
  #grid, #grid tbody, #grid tfoot { display: block; }
  #grid thead { display: none; }
  #grid tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; padding: 11px 14px; border-bottom: 1px solid var(--rule); }
  #grid tbody tr:last-child { border-bottom: 0; }
  #grid tbody tr:hover td { background: none; }
  #grid td { display: block; min-width: 0; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; text-align: left !important; }
  #grid td.corto { max-width: none; }
  #grid tbody td::before { content: attr(data-label); display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 400; }
  #grid tbody td.ncf { order: -2; }
  #grid tbody td.ncf::before, #grid tbody td.principal::before { display: none; }
  #grid tbody td.principal { order: -1; font-weight: 650; text-align: right !important; }
  #grid tbody td.cero, #grid tbody td.vacia { display: none; }
  #grid tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 10px 14px; background: var(--surface-2); }
  #grid tfoot td { position: static; border-top: 0; background: none; }
  #grid tfoot td.otra { display: none; }
  .gastos thead { display: none; }
  .gastos, .gastos tbody, .gastos tr, .gastos td { display: block; }
  .gastos tr { padding: 10px 0; border-top: 1px solid var(--rule); }
  .gastos td { padding: 2px 0; border: 0; text-align: left !important; }
  .gastos td:empty { display: none; }
  .gastos select { width: 100%; max-width: none; height: 36px; }
}
