:root {
  --brand: #1f3b73;
  --brand-2: #2d5aa8;
  --brand-soft: #eef3fb;
  --sidebar-width: 250px;
  --page-bg: #f4f6fa;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--page-bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(45, 90, 168, 0.18), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(31, 59, 115, 0.22), transparent 45%),
    linear-gradient(135deg, #f8fafc 0%, #e8eef8 100%);
}

.login-card {
  width: min(430px, 100%);
  border: 0;
  border-radius: 18px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #172c57 0%, #1f3b73 100%);
  color: #dbe5f5;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand i {
  font-size: 1.4rem;
}

.sidebar-nav {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar .nav-link {
  color: #c9d6ee;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.93rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar .nav-link i {
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 10px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.header-company {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-company .form-select {
  min-width: 190px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
}

.page-content {
  padding: 22px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-header h1 {
  font-size: 1.45rem;
  margin: 0;
  font-weight: 700;
}

.page-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.stat-card {
  border-left: 4px solid var(--brand-2);
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table {
  font-size: 0.88rem;
  margin-bottom: 0;
}

.table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.table tbody tr.selected {
  background: #eaf1fd !important;
}

.table td,
.table th {
  vertical-align: middle;
}

.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.actions-cell {
  white-space: nowrap;
  text-align: right;
}

.actions-cell .btn {
  --bs-btn-padding-y: 0.2rem;
  --bs-btn-padding-x: 0.45rem;
  --bs-btn-font-size: 0.8rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-bar .form-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 3px;
  font-weight: 600;
}

.filter-bar .form-control,
.filter-bar .form-select {
  font-size: 0.86rem;
}

.pagination-info {
  color: var(--muted);
  font-size: 0.85rem;
}

.provider-picker {
  position: relative;
}

.provider-picker .provider-results {
  position: absolute;
  z-index: 1055;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
  display: none;
}

.provider-picker .provider-results.show {
  display: block;
}

.provider-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.86rem;
}

.provider-option:hover,
.provider-option.active {
  background: var(--brand-soft);
}

.badge-soft-success {
  background: #dcfce7;
  color: #166534;
}

.badge-soft-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-soft-secondary {
  background: #e2e8f0;
  color: #334155;
}

.badge-soft-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-soft-info {
  background: #dbeafe;
  color: #1e40af;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}

.empty-state i {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 8px;
  opacity: 0.5;
}

.loading-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.modal-content {
  border: 0;
  border-radius: 16px;
}

/* Confirmacion: se abre sobre otro modal, por eso usa su propio fondo/backdrop. */
.modal.confirm-modal {
  background: rgba(15, 23, 42, 0.55);
  z-index: 2000;
}

.modal.confirm-modal .modal-dialog {
  max-width: 430px;
}

.modal.confirm-modal .modal-content {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35);
}

.modal.confirm-modal .modal-header {
  border-bottom: 0;
  padding-bottom: 0;
}

.modal.confirm-modal .modal-body {
  padding-top: 8px;
}

.modal.confirm-modal .modal-footer {
  border-top: 0;
  padding-top: 0;
}

.modal-header {
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  border-top: 1px solid var(--border);
}

.payment-summary {
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 14px 16px;
}

.payment-summary .label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.payment-summary .value {
  font-weight: 700;
  font-size: 1.05rem;
}

.payment-lines-table input,
.payment-lines-table select {
  font-size: 0.82rem;
}

.payment-lines-table td {
  padding: 4px;
}

.payment-lines-table .form-control,
.payment-lines-table .form-select {
  min-width: 90px;
}

.ncr-list {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}

.ncr-list .form-check {
  margin-bottom: 4px;
}

.doc-chip {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  margin: 2px 4px 2px 0;
  font-size: 0.8rem;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .page-content {
    padding: 16px;
  }
}

@media print {
  .sidebar,
  .app-header,
  .page-header .btn,
  .filter-bar,
  .pagination-info {
    display: none !important;
  }
  .app-main {
    margin-left: 0;
  }
}
