:root {
  --brand: #0f766e;
  /* teal tienda */
  --brand-2: #115e59;
  --accent: #f59e0b;
  /* ámbar */
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
}

body {
  background: var(--bg);
  color: var(--text);
}

a {
  text-decoration: none;
}

.bg-brand {
  background: var(--brand) !important;
}

.text-brand {
  color: var(--brand) !important;
}

.card {
  border: 0;
  border-radius: 16px;
}

.shadow-soft {
  box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

.sidebar {
  width: 270px;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
}

.sidebar .brand {
  font-weight: 800;
  letter-spacing: .2px;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, .88);
  border-radius: 12px;
  padding: .6rem .8rem;
  margin: .15rem .2rem;
}

.sidebar .nav-link:hover {
  background: rgba(255, 255, 255, .12);
}

.sidebar .nav-link.active {
  background: rgba(255, 255, 255, .18);
  color: #fff;
}

.main {
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid rgba(2, 6, 23, .06);
}

.kpi {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
}

.badge-accent {
  background: rgba(245, 158, 11, .15);
  color: #92400e;
}

.btn-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-brand:hover {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
}

/* ---- Buttons (más pro) ---- */
.btn {
  border-radius: 12px;
}

.btn-sm {
  border-radius: 10px;
}

.btn-outline-secondary {
  border-color: rgba(2, 6, 23, .15);
}

.btn-outline-secondary:hover {
  border-color: rgba(2, 6, 23, .25);
}

.btn-soft {
  background: rgba(15, 118, 110, .10);
  border: 1px solid rgba(15, 118, 110, .18);
  color: var(--brand-2);
}

.btn-soft:hover {
  background: rgba(15, 118, 110, .14);
  border-color: rgba(15, 118, 110, .24);
  color: var(--brand-2);
}

/* ---- Tables (look admin) ---- */
.table-wrap {
  background: #fff;
  border-radius: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(2, 6, 23, .06);
}

.table thead th {
  background: rgba(2, 6, 23, .03);
  color: rgba(2, 6, 23, .72);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(2, 6, 23, .08) !important;
  padding-top: .8rem;
  padding-bottom: .8rem;
}

.table tbody td {
  border-color: rgba(2, 6, 23, .06);
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background: rgba(15, 118, 110, .04);
}

.table td code {
  background: rgba(2, 6, 23, .04);
  padding: .15rem .4rem;
  border-radius: .55rem;
}

/* Badges */
.badge {
  border-radius: 999px;
}

/* Small toolbar above tables */
.list-toolbar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

/* Pagination */
.pagination .page-link {
  border-radius: 12px !important;
  border-color: rgba(2, 6, 23, .10);
}

.pagination .page-item.active .page-link {
  background: var(--brand);
  border-color: var(--brand);
}

@media (max-width: 576px) {
  #receiptModal .modal-dialog {
    margin: .5rem;
  }

  #receiptModal iframe {
    height: 420px !important;
  }
}

/* =====================================================
   UTILITIES: Texto truncado con ellipsis
   ===================================================== */
.truncate-1 {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.truncate-sm  { max-width: 110px; }
.truncate-md  { max-width: 160px; }
.truncate-lg  { max-width: 220px; }
.truncate-xl  { max-width: 300px; }

/* Compatibilidad con nombres usados en vistas antiguas */
.truncate-mobile-sm { max-width: 110px; }
.truncate-mobile-md { max-width: 160px; }
.truncate-mobile-lg { max-width: 220px; }

/* =====================================================
   TABLES: Pista de scroll en móvil
   ===================================================== */
.table-scroll-hint {
  display: none;
  margin-top: .35rem;
  font-size: .78rem;
  color: var(--muted);
}

/* Tabla con cabecera sticky dentro de un contenedor con overflow-y */
.table-sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* =====================================================
   FILTER ACTIONS: Botonera de filtros
   ===================================================== */
.filter-actions {
  display: flex;
  gap: .5rem;
}

/* =====================================================
   KPIS / SUMMARY CARDS
   ===================================================== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(2,6,23,.06);
}

.kpi-card .kpi-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}

.kpi-card .kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.kpi-card .kpi-sub {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .15rem;
}

/* =====================================================
   STATUS BADGES
   ===================================================== */
.badge-open   { background: #dcfce7; color: #166534; }
.badge-closed { background: #f1f5f9; color: #475569; }
.badge-void   { background: #fee2e2; color: #991b1b; }
.badge-credit { background: #fef9c3; color: #854d0e; }
.badge-paid   { background: #dcfce7; color: #166534; }

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .35;
}

.empty-state .empty-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: .25rem;
}

/* =====================================================
   RESPONSIVE GLOBAL (≤ 768px)
   ===================================================== */
@media (max-width: 768px) {

  /* Toolbar */
  .list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .list-toolbar > .d-flex {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .list-toolbar .btn {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
  }

  /* Títulos en toolbar */
  .list-toolbar h4.mb-0,
  h4.mb-0 {
    font-size: 1.05rem;
  }

  /* Form controls más grandes para touch */
  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 16px !important; /* evita zoom en iOS */
  }

  .form-label {
    font-size: .78rem;
    margin-bottom: .28rem;
  }

  /* Card padding reducido */
  .card-body {
    padding: .9rem !important;
  }

  /* Table scroll hint visible */
  .table-scroll-hint {
    display: block;
  }

  /* Filter actions en columna */
  .filter-actions {
    flex-direction: column;
  }

  .filter-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  /* BTNs dentro de tablas no rompen layout */
  .table .btn {
    white-space: nowrap;
    font-size: .82rem;
    padding: .25rem .6rem;
  }

  /* KPIs en 2 columnas en móvil */
  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-card .kpi-value {
    font-size: 1.25rem;
  }
}

/* =====================================================
   RESPONSIVE GLOBAL (≤ 576px)
   ===================================================== */
@media (max-width: 576px) {
  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* =====================================================
   GENERAL BALANCE TABLE
   ===================================================== */
.balance-section-header {
  background: #0f766e;
  color: #fff;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  padding: .4rem .6rem;
  border-radius: 6px 6px 0 0;
}

/* =====================================================
   WEEKLY / DAILY CAPITAL
   ===================================================== */
.capital-section {
  border-left: 4px solid var(--brand);
  padding-left: 1rem;
}

.capital-total-box {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  border-radius: 18px;
  padding: 1.5rem;
  text-align: center;
}

.capital-total-box .capital-amount {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.capital-total-box .capital-label {
  font-size: .85rem;
  opacity: .85;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* =====================================================
   RECONCILE VIEW
   ===================================================== */
.reconcile-diff-ok   { background: #dcfce7; color: #166534; }
.reconcile-diff-bad  { background: #fee2e2; color: #991b1b; }
.reconcile-diff-warn { background: #fef9c3; color: #854d0e; }