:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #0ea5e9;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #f59e0b;
  --line: #e2e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Times New Roman", Times, serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, #dbeafe 0%, transparent 40%),
    radial-gradient(circle at left bottom, #fde68a 0%, transparent 35%),
    var(--bg);
}

h1,
h2,
h3,
button,
.btn {
  font-family: "Times New Roman", Times, serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.container {
  max-width: 1200px;
  margin: 1rem auto 2rem;
  padding: 0 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.auth-card {
  max-width: 480px;
  margin: 2rem auto;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.stack {
  display: grid;
  gap: 0.75rem;
}

.row-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.export-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.6rem;
  background: #fff;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--ink);
}

.btn-danger {
  background: var(--bad);
  color: #fff;
}

.btn-help {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 2px solid var(--brand);
  border-radius: 50%;
  background: #fff;
  color: #0369a1;
  font-size: 1.2rem;
}

.guide-dialog {
  width: min(36rem, calc(100vw - 2rem));
  max-height: min(80vh, 42rem);
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
}

.guide-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.guide-dialog-header,
.guide-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.guide-dialog-header {
  margin-bottom: 0.75rem;
}

.guide-dialog-header .small {
  margin: 0;
}

.guide-dialog-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.alert {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-weight: 600;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #bbf7d0;
}

.kpi-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi {
  border-radius: 10px;
  padding: 0.8rem;
  color: #fff;
}

.kpi span {
  display: block;
  opacity: 0.9;
}

.kpi strong {
  font-size: 1.2rem;
}

.kpi.ingresos {
  background: #15803d;
}

.kpi.gastos {
  background: #b91c1c;
}

.kpi.cajas {
  background: #1d4ed8;
}

.kpi.balance {
  background: #7c3aed;
}

.bulk-box-form {
  margin: 1rem 0;
}

.kpi.cash-expected {
  background: #166534;
  grid-column: span 2;
  border: 2px solid #86efac;
}

.kpi.cash-expected strong {
  display: block;
  font-size: 1.8rem;
  margin: 0.2rem 0;
}

.kpi.cash-expected small {
  opacity: 0.9;
}

tr.is-verified td {
  background: #e8f8ed;
}

#dashboard-ingresos-body tr:nth-child(even) td,
#cut-ingresos-body tr:nth-child(even) td {
  background: #f1f5f9;
}

#dashboard-ingresos-body tr.income-manager-verified td,
#cut-ingresos-body tr.income-manager-verified td {
  background: #fee2e2;
}

#dashboard-ingresos-body tr.income-owner-verified td,
#cut-ingresos-body tr.income-owner-verified td {
  background: #dcfce7;
}

#dashboard-gastos-body td:nth-child(2),
#dashboard-cajas-body td:nth-child(2) {
  width: 30%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.55rem;
  white-space: nowrap;
  font-size: 0.92rem;
}

th {
  background: #f8fafc;
}

.log-pagination {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

td code {
  display: block;
  max-width: 24rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 0.8rem;
}

.small {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.2rem 0;
}

.note {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.cut-meta-grid {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sheet-card {
  padding-bottom: 5.5rem;
}

.sheet-panel[hidden] {
  display: none;
}

.sheet-tabs {
  position: fixed;
  left: 50%;
  bottom: 0.85rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
  margin: 0;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 14px;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
  overflow-x: auto;
  z-index: 40;
  width: min(1200px, calc(100vw - 2rem));
}

.sheet-tab {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  background: #eef2ff;
  color: var(--ink);
  border-radius: 10px 10px 6px 6px;
  padding: 0.45rem 0.8rem;
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

body:has(.detail-navigation) .container {
  padding-bottom: 6rem;
}

.sheet-tab.is-active {
  background: #fff;
  border-color: #94a3b8;
  border-bottom-color: #fff;
  box-shadow: 0 -2px 0 0 var(--brand) inset;
}

.sheet-panel {
  margin-top: 0.25rem;
}

@media (min-width: 1201px) {
  body:has(.detail-navigation) .container {
    max-width: 1600px;
  }
}

@media (max-width: 900px) {
  .grid-two {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi.cash-expected {
    grid-column: span 1;
  }

  .sheet-tabs {
    width: calc(100vw - 1rem);
    bottom: 0.5rem;
    padding: 0.5rem;
  }

}
