:root {
  --background: #f3f2ee;
  --foreground: #1c1c1c;
  --card: #fafaf7;
  --primary: #0061fe;
  --primary-foreground: #fafafa;
  --secondary: #e8e7e3;
  --muted: #e9e8e4;
  --muted-foreground: #7a7872;
  --destructive: #c23b2e;
  --success: #2f9d5a;
  --success-foreground: #fafafa;
  --ink: #161616;
  --ink-foreground: #f5f4f0;
  --border: #d4d3ce;
  --font: "Archivo", ui-sans-serif, system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  border-color: var(--border);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

img {
  max-width: 100%;
  display: block;
}

.display-xl {
  font-family: var(--font);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.035em;
  line-height: 0.86;
  font-stretch: 75%;
  margin: 0;
}

.display-md {
  font-family: var(--font);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  line-height: 0.9;
  font-stretch: 80%;
  margin: 0;
}

.label-mono {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.625rem;
}

.office-only {
  display: none;
}

.campo-only {
  display: block;
}

.shell {
  margin: 0 auto;
  min-height: 100vh;
  max-width: 520px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--background);
  padding-bottom: 6rem;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 2px solid var(--foreground);
  background: color-mix(in srgb, var(--background) 95%, transparent);
  padding: 1rem 1.25rem;
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
}

.topbar img {
  height: 2.25rem;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  object-position: left;
}

.btn-back {
  flex-shrink: 0;
  border: 2px solid var(--foreground);
  padding: 0.25rem 0.5rem;
}

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  margin: 0 auto;
  display: flex;
  max-width: 520px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 0.75rem;
  touch-action: pan-x;
  border-top: 2px solid var(--foreground);
  background: var(--ink);
}

.bottom-nav::-webkit-scrollbar {
  display: none;
}

.bottom-nav a {
  display: flex;
  flex: 0 0 auto;
  min-width: 5.75rem;
  height: 4.35rem;
  align-items: center;
  justify-content: center;
  border-right: 1px solid color-mix(in srgb, var(--ink-foreground) 15%, transparent);
  color: color-mix(in srgb, var(--ink-foreground) 60%, transparent);
  text-align: center;
  padding: 0 1.15rem;
  font-size: 0.62rem;
  scroll-snap-align: start;
  white-space: nowrap;
}

.bottom-nav a:last-child {
  border-right: 0;
}

.bottom-nav a.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.office-aside {
  display: none;
  position: sticky;
  top: 0;
  height: 100vh;
  width: 13rem;
  flex-shrink: 0;
  flex-direction: column;
  border-right: 2px solid var(--foreground);
  background: var(--ink);
  color: var(--ink-foreground);
}

.office-brand {
  border-bottom: 2px solid var(--foreground);
  background: var(--background);
  padding: 0.75rem;
}

.office-brand img {
  width: 100%;
  object-fit: contain;
}

.office-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 0.5rem;
}

.office-nav a {
  padding: 0.5rem;
  color: color-mix(in srgb, var(--ink-foreground) 65%, transparent);
  font-size: 0.65rem;
}

.office-nav a:hover {
  background: color-mix(in srgb, var(--ink-foreground) 10%, transparent);
  color: var(--ink-foreground);
}

.office-nav a.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.office-logout {
  padding: 0.75rem 0.5rem 0;
}

.office-logout-btn {
  width: 100%;
  min-height: 2.5rem;
  background: var(--destructive);
  color: #fff;
  border: 0;
  cursor: pointer;
}

.office-logout-btn:hover {
  background: #a83228;
}

.office-foot {
  border-top: 1px solid color-mix(in srgb, var(--ink-foreground) 15%, transparent);
  padding: 0.75rem;
  color: color-mix(in srgb, var(--ink-foreground) 40%, transparent);
  font-size: 0.6rem;
}

.office-head {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--foreground);
  background: color-mix(in srgb, var(--background) 95%, transparent);
  padding: 0.5rem 1.25rem;
  backdrop-filter: blur(8px);
}

.section {
  border-bottom: 2px solid var(--foreground);
  padding: 2rem 1.25rem;
}

.section:last-child {
  border-bottom: 0;
}

.section-pad {
  padding: 2rem 1.25rem;
}

.section-head {
  margin-bottom: 1.25rem;
}

.section-head.compact {
  margin-bottom: 0.5rem;
}

.section-head .kicker {
  color: var(--primary);
}

.section-head h2 {
  margin-top: 0.5rem;
  font-size: 2rem;
}

.section-head.compact h2 {
  margin-top: 0.125rem;
  font-size: 1rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  font-stretch: normal;
  line-height: 1.3;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--foreground);
  margin-top: 1.5rem;
}

.kpi {
  background: var(--background);
  padding: 1rem;
}

.kpi .num {
  font-size: 1.875rem;
}

.kpi .lbl {
  margin-top: 0.25rem;
  color: var(--muted-foreground);
}

.dash {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dash-new {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.dash-new .btn {
  min-height: 2.75rem;
}

.dash-hero {
  display: grid;
  gap: 0.75rem;
}

.dash-hero-item {
  border: 2px solid var(--foreground);
  padding: 1.15rem 1rem 1.25rem;
}

.dash-hero-item.is-pending {
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
}

.dash-hero-item.is-done {
  background: var(--ink);
  color: var(--ink-foreground);
  border-color: var(--ink);
}

.dash-hero-item.is-done .label-mono {
  color: color-mix(in srgb, var(--ink-foreground) 70%, transparent);
}

.dash-amount {
  margin: 0.4rem 0 0;
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.dash-sub {
  margin: 0.45rem 0 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.dash-hero-item.is-done .dash-sub {
  color: color-mix(in srgb, var(--ink-foreground) 72%, transparent);
}

.dash-grid {
  display: grid;
  gap: 0.75rem;
}

.dash-card {
  border: 2px solid var(--foreground);
  background: var(--card);
  padding: 1rem;
}

.dash-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.dash-card-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.dash-card-head a {
  color: var(--primary);
  flex-shrink: 0;
}

.dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.dash-stat,
.dash-fact {
  display: block;
  padding: 0.75rem 0.7rem 0.85rem;
  border: 2px solid var(--foreground);
  color: inherit;
}

.dash-stat.is-pending {
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.dash-stat.is-done {
  background: color-mix(in srgb, var(--success) 12%, var(--card));
}

.dash-fact.is-pending {
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.dash-fact.is-done {
  background: color-mix(in srgb, var(--success) 12%, var(--card));
}

.dash-count {
  margin: 0.35rem 0 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dash-eur {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dash-bar {
  margin-top: 0.85rem;
  height: 0.5rem;
  background: var(--secondary);
  border: 2px solid var(--foreground);
}

.dash-bar span {
  display: block;
  height: 100%;
  background: var(--success);
}

.dash-bar-lbl {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.dash-partial {
  display: block;
  margin-top: 0.75rem;
  padding: 0.55rem 0.7rem;
  border: 2px dashed var(--foreground);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--foreground);
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
}

.dash-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.dash-fact .dash-eur {
  font-size: 0.8rem;
}

a.dash-stat:hover,
a.dash-fact:hover,
.dash-partial:hover,
.dash-alert:hover {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.dash-alert {
  display: block;
  padding: 0.85rem 1rem;
  border: 2px solid var(--foreground);
  background: color-mix(in srgb, var(--destructive) 10%, var(--card));
  font-weight: 700;
  font-size: 0.9rem;
}

.dash .actions-2 {
  margin-top: 0;
}

.home-campo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.15rem 1.25rem 1rem;
  border-bottom: 0;
}

.home-campo-head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.home-campo-name {
  margin: 0;
  font-size: 1rem;
  color: var(--muted-foreground);
}

.home-campo-brand {
  flex: 1 1 auto;
  min-height: 6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-campo-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 94%;
  max-height: min(28dvh, 12rem);
  object-fit: contain;
  object-position: center;
}

.home-campo-marca {
  margin: 0;
  font-family: var(--font);
  font-weight: 900;
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  text-transform: uppercase;
  letter-spacing: -0.035em;
  line-height: 0.9;
  text-align: center;
}

.home-actions {
  display: grid;
  gap: 0.85rem;
  margin-top: 0;
  flex-shrink: 0;
}

.home-campo .home-actions {
  gap: 1.35rem;
}

.home-campo .btn {
  min-height: 3.5rem;
  font-size: 0.7rem;
}

@media (max-width: 959px) {
  .shell:has(.home-campo) {
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
  }

  .shell:has(.home-campo) .main {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }

  .shell:has(.home-campo) .body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 4.35rem;
  }

  .home-campo {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

}

.informe-page {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.informe-bar {
  padding-bottom: 0.75rem;
  margin-bottom: 0;
}

.informe-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.informe-print {
  width: auto;
  min-height: 2.25rem;
  height: 2.25rem;
  padding: 0 0.75rem;
  flex-shrink: 0;
}

.informe-filtros {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.65rem;
  margin-top: 0.65rem;
}

.informe-filtros .field {
  flex: 1 1 8.5rem;
  min-width: 7.5rem;
  margin: 0;
}

.informe-filtros .field + .field {
  margin-top: 0;
}

.informe-filtros .select {
  margin-top: 0.2rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
}

.informe-marca {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 2px solid var(--foreground);
  background: var(--card);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  min-height: 2.35rem;
  flex: 0 0 auto;
}

.informe-marca.is-on {
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
}

.informe-marca input {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.informe-rango {
  margin: 0;
  align-self: center;
  flex: 1 1 auto;
}

.informe-nota {
  margin: 0 0 0.5rem;
}

.informe-res .res-hero {
  gap: 0.5rem;
}

.informe-res .dash-hero-item {
  padding: 0.6rem 0.7rem 0.7rem;
}

.informe-res .dash-amount {
  margin-top: 0.2rem;
  font-size: 1.45rem;
}

.informe-res .dash-sub {
  margin-top: 0.25rem;
  font-size: 0.75rem;
}

.res-parts {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.res-parts li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.res-parts em {
  display: block;
  font-style: normal;
  opacity: 0.72;
  font-size: 0.68rem;
}

.dash-hero-item.is-done .res-parts {
  color: color-mix(in srgb, var(--ink-foreground) 82%, transparent);
}

.res-parts .is-rech {
  color: var(--destructive);
}

.dash-hero-item.is-done .res-parts .is-rech {
  color: color-mix(in srgb, #ff8a7a 90%, #fff);
}

.res-parts .is-sum {
  margin-top: 0.15rem;
  padding-top: 0.2rem;
  border-top: 1px solid color-mix(in srgb, currentColor 25%, transparent);
}

.res-hint {
  margin: 0.3rem 0 0;
  font-size: 0.7rem;
  color: var(--muted-foreground);
  line-height: 1.3;
}

.table tr.is-rech-row td {
  background: color-mix(in srgb, var(--destructive) 8%, var(--card));
}

.informe-res .dash-card {
  padding: 0.65rem 0.75rem;
}

.informe-res .dash-card-head {
  margin-bottom: 0.45rem;
}

.informe-res .dash-card-head h2 {
  font-size: 0.85rem;
}

.informe-res .res-split {
  margin-top: 0.5rem;
}

.res-year {
  margin-top: 0.5rem;
}

.res-year .dash-card-head h2 {
  font-size: 0.95rem;
}

.chart-year {
  min-height: 8rem;
}

.chart-year .chart-col-bars {
  min-height: 7rem;
}

.chart-col.is-now .chart-col-lbl {
  color: var(--primary);
}

.chart-col.is-now .chart-col-bars {
  border-bottom-color: var(--primary);
}

.informe-res .chart-legend {
  margin-top: 0.4rem;
}

.informe-listados {
  border-top: 2px solid var(--foreground);
  padding-top: 0.85rem;
}

.informe-listados h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.informe-listados h3 + .table-wrap,
.informe-listados h3 + .empty {
  margin-top: 0;
}

.informe-listados h3:not(:first-child) {
  margin-top: 1rem;
}

.dash-hero-item.is-loss {
  background: color-mix(in srgb, var(--destructive) 12%, var(--card));
}

.dash-hero-item.is-loss .dash-amount {
  color: var(--destructive);
}

.res-split {
  display: grid;
  gap: 0.5rem;
}

.chart-bars {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  min-height: 6.25rem;
}

.chart-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.chart-col-bars {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  min-height: 5.5rem;
  border-bottom: 2px solid var(--foreground);
}

.chart-bar {
  display: block;
  width: 42%;
  min-height: 0;
  background: var(--foreground);
}

.chart-bar.is-in {
  background: var(--primary);
}

.chart-bar.is-out {
  background: var(--ink);
}

.chart-col-lbl {
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--muted-foreground);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted-foreground);
}

.chart-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.25rem;
  vertical-align: -0.1rem;
  background: var(--ink);
}

.chart-swatch.is-in {
  background: var(--primary);
}

.chart-hbars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chart-hbar-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.chart-hbar-track {
  height: 0.5rem;
  border: 2px solid var(--foreground);
  background: var(--secondary);
}

.chart-hbar-track span {
  display: block;
  height: 100%;
  background: var(--primary);
  min-width: 0;
}

.chart-hbar-track span.is-presupuestos {
  background: var(--ink);
}

.chart-hbar-track span.is-rechazados {
  background: var(--destructive);
}

.chart-hbar-track span.is-cat {
  background: var(--foreground);
}

.informe-totales {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

.table tfoot td {
  border-top: 2px solid var(--foreground);
  font-weight: 700;
}

.informe-iva {
  margin-top: 0;
}

@media print {
  .topbar,
  .office-aside,
  .office-head,
  .bottom-nav,
  .no-print,
  .flash,
  .modal,
  .lightbox {
    display: none !important;
  }

  .shell,
  .main,
  .body {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .table {
    font-size: 11px;
  }
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  padding: 0 0.75rem;
  text-align: center;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-ghost {
  border: 2px solid var(--foreground);
  color: var(--foreground);
}

.btn-success {
  background: var(--success);
  color: var(--success-foreground);
}

.btn-danger {
  border: 2px solid var(--foreground);
  color: var(--destructive);
}

.btn-dash {
  border: 2px dashed var(--foreground);
}

.btn-sm {
  min-height: 3rem;
}

.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--foreground);
  border-bottom: 2px solid var(--foreground);
}

.doc-list li {
  border-bottom: 2px solid var(--foreground);
}

.doc-list li:last-child {
  border-bottom: 0;
}

.doc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 1rem 0;
  align-items: start;
}

.doc-row .meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.doc-row h3 {
  margin: 0.5rem 0 0;
  font-size: 1.125rem;
}

.doc-row .sub {
  margin: 0.25rem 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.doc-row .amt {
  text-align: right;
  flex-shrink: 0;
}

.badge {
  padding: 0.125rem 0.5rem;
}

.badge-borrador,
.badge-pendiente {
  background: var(--secondary);
  color: var(--foreground);
}

.badge-enviado,
.badge-emitida {
  background: var(--primary);
  color: var(--primary-foreground);
}

.badge-firmado,
.badge-aceptado,
.badge-procesado {
  background: var(--success);
  color: var(--success-foreground);
}

.badge-rechazado,
.badge-error {
  background: var(--destructive);
  color: #fff;
}

.badge-facturado {
  background: var(--ink);
  color: var(--ink-foreground);
}

.badge-facturado_parcial,
.badge-anticipo {
  background: color-mix(in srgb, var(--primary) 18%, var(--secondary));
  color: var(--foreground);
}

.badge-pendiente_cobro {
  background: var(--secondary);
  color: var(--foreground);
}

.badge-cobrada {
  background: var(--success);
  color: var(--success-foreground);
}

.acciones-doc form {
  margin: 0;
}

.gasto-foto-link {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  margin: 0.5rem 0;
  text-decoration: none;
  color: inherit;
  cursor: zoom-in;
}

.gasto-foto {
  display: block;
  max-height: 8rem;
  border: 2px solid var(--foreground);
  object-fit: contain;
  background: var(--card);
}

.gasto-foto-link:hover .gasto-foto,
.gasto-foto-link:focus-visible .gasto-foto {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.gasto-foto-hint {
  font-size: 0.65rem;
  color: var(--muted-foreground);
}

.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  padding: 4rem 1rem 1rem;
}

.lightbox.open {
  display: flex;
}

.lightbox.is-real {
  display: block;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.lightbox-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 81;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
}

.lightbox-bar .btn {
  background: var(--background);
  min-height: 2.5rem;
  height: 2.5rem;
  width: auto;
  padding: 0 0.85rem;
}

.lightbox-img {
  max-width: 100%;
  max-height: calc(100dvh - 5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  background: #fff;
}

.lightbox.is-real .lightbox-img {
  max-width: none;
  max-height: none;
  margin-top: 4rem;
  cursor: zoom-out;
}

.gasto-edit-row td {
  background: var(--card);
}

.acciones-doc .btn {
  min-height: 0;
  height: auto;
  line-height: 1.2;
  padding: 0.2rem 0.5rem;
  width: auto;
  font-size: 0.6rem;
}

.table td:last-child {
  vertical-align: middle;
  white-space: nowrap;
  width: 1%;
}

.table .acciones-doc {
  padding: 0;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 0.25rem;
}

.table .acciones-doc .btn {
  min-height: 0;
  height: auto;
  padding: 0.125rem 0.45rem;
}

.actions-2 .acciones-doc {
  grid-column: 1 / -1;
  padding: 0;
}

.actions-2 .acciones-doc .btn {
  min-height: 3.5rem;
  height: auto;
  flex: 1;
  font-size: inherit;
}

.flash {
  margin: 0.75rem 1.25rem 0;
  padding: 0.75rem;
  border: 2px solid var(--foreground);
  font-size: 0.875rem;
  font-weight: 600;
}

.flash-error {
  color: var(--destructive);
}

.flash-ok {
  color: var(--success);
}

.aviso-check {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--foreground);
  background: var(--card);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 600;
}

.aviso-check[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted-foreground);
}

.auth {
  margin: 0 auto;
  display: flex;
  min-height: 100vh;
  max-width: 520px;
  flex-direction: column;
  justify-content: center;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--background);
  padding: 2.5rem 1.25rem;
}

.auth img {
  margin: 0 auto;
  height: 3.5rem;
  width: auto;
  object-fit: contain;
}

.auth h1 {
  margin-top: 2rem;
  font-size: 2.4rem;
}

.auth .lead {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.field {
  display: block;
}

.field + .field {
  margin-top: 1.25rem;
}

.input,
.select,
.textarea {
  width: 100%;
  margin-top: 0.5rem;
  border: 2px solid var(--foreground);
  background: var(--card);
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 0;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.textarea {
  min-height: 8rem;
  resize: vertical;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.totals {
  background: var(--ink);
  color: var(--ink-foreground);
  padding: 1.5rem 1.25rem;
}

.totals .row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: color-mix(in srgb, var(--ink-foreground) 60%, transparent);
}

.totals .row + .row {
  margin-top: 0.5rem;
}

.totals .total {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid color-mix(in srgb, var(--ink-foreground) 20%, transparent);
}

.totals .total .num {
  font-size: 1.875rem;
  color: var(--primary-foreground);
}

.photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--foreground);
}

.photo {
  position: relative;
  aspect-ratio: 1;
  background: var(--secondary);
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo .x {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background: var(--background);
  padding: 0 0.375rem;
  font-size: 0.75rem;
}

.firma-canvas {
  width: 100%;
  height: 9rem;
  touch-action: none;
  border: 2px dashed var(--foreground);
  background: #fff;
}

.table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  border: 2px solid var(--foreground);
  text-align: left;
  table-layout: auto;
}

.table thead {
  background: var(--ink);
  color: var(--ink-foreground);
}

.table th {
  padding: 0.5rem 0.75rem;
  font-weight: 400;
}

.table td {
  padding: 0.5rem 0.75rem;
  vertical-align: top;
  font-size: 0.875rem;
  border-top: 2px solid var(--foreground);
  background: var(--card);
}

.table tbody tr:hover td {
  background: var(--secondary);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.chip {
  border: 1px solid var(--foreground);
  padding: 0.25rem 0.625rem;
  font-size: 0.65rem;
  background: var(--background);
}

.chip.active {
  background: var(--foreground);
  color: var(--background);
}

.suggest {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  border: 2px solid var(--foreground);
}

.suggest button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  text-align: left;
  border-top: 2px solid var(--foreground);
}

.suggest li:first-child button {
  border-top: 0;
}

.lineas-head,
.linea-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.5rem 4.5rem 5rem;
  gap: 0.5rem;
  align-items: center;
}

.lineas-head {
  border-bottom: 2px solid var(--foreground);
  padding: 0.375rem 0;
  color: var(--muted-foreground);
}

.linea-view {
  border-bottom: 1px solid var(--foreground);
  padding: 0.375rem 0;
}

.linea-view p {
  margin: 0;
  font-size: 0.875rem;
}

.right {
  text-align: right;
}

.sumas {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

.sumas .row {
  display: flex;
  justify-content: space-between;
}

.sumas .row.total {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 2px solid var(--foreground);
  font-weight: 600;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 1.25rem;
}

.modal.open {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 28rem;
  border: 2px solid var(--foreground);
  background: var(--background);
  padding: 1.25rem;
}

.grid-btns {
  display: grid;
  gap: 0.75rem;
}

.notas-box {
  border: 2px dashed var(--foreground);
  padding: 0.75rem;
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
}

.empty {
  border-top: 2px solid var(--foreground);
  border-bottom: 2px solid var(--foreground);
  padding: 1.5rem 0;
  color: var(--muted-foreground);
}

.hidden {
  display: none !important;
}

.space-y > * + * {
  margin-top: 1.25rem;
}

.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.error {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--destructive);
}

.ok {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--success);
}

@media (min-width: 960px) {
  .campo-only,
  .topbar,
  .bottom-nav {
    display: none !important;
  }

  .office-only {
    display: revert;
  }

  .shell {
    display: flex;
    max-width: none;
    border: 0;
    padding-bottom: 0;
  }

  .office-aside {
    display: flex;
  }

  .office-head {
    display: flex;
  }

  .main {
    flex: 1;
  }

  .body {
    margin: 0 auto;
    max-width: 56rem;
    padding: 1rem 1.25rem;
  }

  .body.wide {
    max-width: none;
    width: 100%;
  }

  .section {
    border-bottom: 1px solid var(--foreground);
    padding: 0 0 0.75rem;
    margin-bottom: 1rem;
  }

  .section-pad {
    padding: 0;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    margin-top: 0.75rem;
  }

  .dash-hero,
  .dash-grid {
    grid-template-columns: 1fr 1fr;
  }

  .informe-page .section.informe-bar {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .body.wide:has(.informe-page) {
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
  }

  .informe-filtros {
    flex-wrap: wrap;
    max-width: none;
  }

  .informe-filtros .field {
    flex: 0 1 11rem;
  }

  .res-hero,
  .res-split {
    grid-template-columns: 1fr 1fr;
  }

  .dash-hero.res-hero {
    grid-template-columns: repeat(3, 1fr);
  }

  .informe-res .res-split {
    grid-template-columns: 1fr 1fr;
  }

  .informe-res .dash-amount {
    font-size: 1.65rem;
  }

  .dash-amount {
    font-size: 2.35rem;
  }

  .shell:has(.dash) {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
  }

  .main:has(.dash) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
    min-width: 0;
  }

  .body:has(.dash) {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0.75rem 1.15rem 0.85rem;
    overflow: hidden;
  }

  .body:has(.dash) > .office-only {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .section.dash {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0;
    border-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(0.5rem, 1.2vh, 0.85rem);
  }

  .dash-top {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex: 0 0 auto;
  }

  .dash-top .dash-new {
    flex: 1 1 auto;
    min-width: 0;
  }

  .dash-when {
    margin: 0;
    flex: 0 0 auto;
    white-space: nowrap;
    text-align: right;
  }

  .dash-new .btn {
    min-width: 0;
    min-height: 2.35rem;
    height: 2.35rem;
  }

  .dash .dash-hero {
    flex: 1 1 0;
    min-height: 0;
  }

  .dash .dash-hero-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    padding: clamp(0.55rem, 1.4vh, 1rem) 1rem;
  }

  .dash .dash-amount {
    margin-top: 0.2rem;
    font-size: clamp(1.45rem, 3.2vh, 2.05rem);
  }

  .dash .dash-sub {
    margin-top: 0.25rem;
    font-size: 0.85rem;
  }

  .dash .dash-grid {
    flex: 1.2 1 0;
    min-height: 0;
  }

  .dash > .dash-card {
    flex: 1 1 0;
    min-height: 0;
  }

  .dash .dash-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    padding: clamp(0.55rem, 1.2vh, 0.9rem) 0.85rem;
  }

  .dash .dash-card-head {
    margin-bottom: 0.55rem;
    flex: 0 0 auto;
  }

  .dash .dash-card-head h2 {
    font-size: 1.05rem;
  }

  .dash .dash-split,
  .dash .dash-facts {
    flex: 1;
    min-height: 0;
  }

  .dash .dash-stat,
  .dash .dash-fact {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    height: 100%;
    padding: clamp(0.4rem, 1vh, 0.75rem) 0.7rem;
  }

  .dash .dash-count {
    margin-top: 0.2rem;
    font-size: clamp(1.35rem, 3vh, 1.85rem);
  }

  .dash .dash-eur {
    margin-top: 0.15rem;
    font-size: 0.95rem;
  }

  .dash .dash-bar {
    margin-top: 0.55rem;
    height: 0.4rem;
    flex: 0 0 auto;
  }

  .dash .dash-bar-lbl {
    margin-top: 0.3rem;
    flex: 0 0 auto;
  }

  .dash .dash-partial {
    margin-top: 0.4rem;
    padding: 0.35rem 0.55rem;
    flex: 0 0 auto;
  }

  .kpi {
    padding: 0.625rem 0.75rem;
  }

  .kpi .num {
    font-size: 1.25rem;
  }

  .actions-2 {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .btn,
  .btn-sm {
    min-height: 2.25rem;
    height: 2.25rem;
    padding: 0 1rem;
    font-size: 0.65rem;
  }

  .acciones-doc .btn,
  .table .acciones-doc .btn {
    min-height: 0;
    height: auto;
    padding: 0.125rem 0.45rem;
    font-size: 0.6rem;
  }

  .photos {
    grid-template-columns: repeat(4, 1fr);
  }

  .photo {
    aspect-ratio: 4 / 3;
  }

  .modal {
    align-items: center;
  }

  .office-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
  }

  .doc-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
  }

  .doc-hero .amt {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: none;
    letter-spacing: 0;
    font-stretch: normal;
  }
}

.gestoria-body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
}

.gestoria-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  border-bottom: 2px solid var(--foreground);
  background: var(--card);
}

.gestoria-brand img {
  height: 1.75rem;
  width: auto;
}

.gestoria-nav {
  display: flex;
  gap: 1rem;
}

.gestoria-nav a.active {
  color: var(--primary);
}

.gestoria-who {
  margin-left: auto;
}

.gestoria-out {
  color: var(--primary);
}

.gestoria-main {
  padding: 1.25rem;
  max-width: none;
}

.gestoria-head {
  margin-bottom: 1rem;
}

.gestoria-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 2px solid var(--foreground);
  background: var(--card);
}

.gestoria-filtros .field {
  min-width: 9rem;
}

.gestoria-buscar {
  flex: 2 1 14rem;
}

.gestoria-table {
  font-size: 0.8rem;
}

.gestoria-table th,
.gestoria-table td {
  padding: 0.45rem 0.5rem;
  vertical-align: middle;
}

.btn-toggle-contabilizado {
  min-width: 3.2rem;
  padding: 0.25rem 0.5rem;
  border: 2px solid var(--foreground);
  background: var(--card);
}

.btn-toggle-contabilizado.is-on {
  background: var(--success);
  color: var(--success-foreground);
  border-color: var(--success);
}

.input-referencia-contabilidad {
  width: 5.4rem;
  padding: 0.3rem 0.4rem;
  border: 2px solid var(--foreground);
  background: var(--background);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.gestoria-ver {
  color: var(--primary);
  cursor: pointer;
}

.gestoria-modal {
  max-width: 56rem;
  width: 96vw;
}

.gestoria-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.gestoria-modal iframe {
  width: 100%;
  height: min(70vh, 32rem);
  border: 2px solid var(--foreground);
  background: var(--muted);
}

.badge-anticipo {
  background: #17a2b8;
  color: #fff;
}

.badge-resto {
  background: #fd7e14;
  color: #fff;
}

.badge-enviada {
  background: var(--success);
  color: var(--success-foreground);
}

.table tr.is-enviada-row td,
.gasto-item.is-enviada {
  opacity: 0.62;
}
