* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f7fb;
  color: #18324a;
  font-size: 13px;
}

a {
  text-decoration: none;
  color: #0d5c95;
}

small {
  color: #6d7f91;
  font-size: 12px;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 21px;
}

h3 {
  font-size: 18px;
}

p {
  line-height: 1.45;
}

img {
  max-width: 100%;
  height: auto;
}

/* LOGIN */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(184, 48, 42, .10), transparent 35%),
    linear-gradient(135deg, #f4f7fb, #eef1f5);
}

.login-card {
  width: min(390px, 92vw);
  background: #fff;
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, .16);
  border-top: 5px solid #c53a37;
}

/* FORMULARIOS */

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 9px 11px;
  border: 1px solid #cfdae7;
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
}

label {
  display: block;
  margin: 9px 0 5px;
  font-weight: 700;
  font-size: 13px;
}

button,
.btn {
  background: #b8302a;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-block;
  max-width: 100%;
}

button:hover,
.btn:hover {
  filter: brightness(.96);
}

.btn-secondary {
  background: #294e7a;
}

.btn-success {
  background: #1f8b4c;
}

.btn-light {
  background: #eef3f9;
  color: #18324a;
}

/* LAYOUT GENERAL */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-width: 0;
  max-width: 100%;
}

.sidebar {
  background: #151a21;
  color: #fff;
  padding: 18px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.brand img {
  width: 46px;
  height: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 9px;
  padding: 4px;
}

.brand strong {
  display: block;
  font-size: 14px;
}

.brand small {
  display: block;
  color: #aebfd0;
  font-size: 11px;
}

.sidebar nav {
  display: grid;
  gap: 7px;
}

.sidebar nav a {
  color: #dce8f5;
  padding: 9px 11px;
  border-radius: 10px;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  background: #b8302a;
  color: #fff;
}

.content {
  padding: 20px;
  min-width: 0;
  max-width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.topbar-badge {
  background: #fff;
  border: 1px solid #dce6f0;
  border-radius: 14px;
  padding: 9px 12px;
  min-width: 210px;
  text-align: right;
  box-shadow: 0 10px 24px rgba(11, 48, 79, .05);
}

/* TARJETAS */

.card {
  background: #fff;
  border: 1px solid #dce6f0;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 24px rgba(11, 48, 79, .05);
  margin-bottom: 16px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
}

.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.full {
  grid-column: 1 / -1;
}

.check {
  display: flex;
  align-items: center;
}

.check input {
  width: auto;
  margin-right: 8px;
}

/* TABLAS */

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 850px;
}

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

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid #e6edf4;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: #f9fbfd;
}

/* ALERTAS */

.alert {
  padding: 11px 13px;
  border-radius: 12px;
  margin-bottom: 13px;
}

.success {
  background: #eaf8ef;
  color: #1f6d39;
}

.error {
  background: #fdecec;
  color: #8a2b2b;
}

/* BADGES */

.badge {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.badge.pendiente {
  background: #fff3cd;
  color: #7b5b00;
}

.badge.parcial {
  background: #dfeeff;
  color: #15507a;
}

.badge.pagado {
  background: #d7f5df;
  color: #1a6a33;
}

.badge.cancelado {
  background: #f0e1e1;
  color: #7a2020;
}

.badge.active {
  background: #d7f5df;
  color: #1a6a33;
}

.badge.inactive {
  background: #f1f4f7;
  color: #617284;
}

/* PANELES Y KPIS */

.calc-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  background: #f8fbfe;
  border: 1px solid #e1ebf3;
  border-radius: 14px;
  padding: 13px;
}

.calc-panel span {
  display: block;
  color: #6d7f91;
  margin-bottom: 4px;
}

.calc-panel strong {
  font-size: 20px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  background: #fff;
  border: 1px solid #dce6f0;
  border-radius: 15px;
  padding: 14px;
}

.kpi span {
  color: #6d7f91;
  display: block;
  margin-bottom: 8px;
}

.kpi strong {
  font-size: 23px;
}

.subkpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.mini-kpi {
  background: #f8fbfe;
  border: 1px solid #e1ebf3;
  border-radius: 14px;
  padding: 13px;
}

.progress-list {
  display: grid;
  gap: 10px;
}

.progress-item {
  display: grid;
  gap: 6px;
}

.progress-track {
  height: 9px;
  background: #eef3f7;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #295a92;
  border-radius: 999px;
}

.stat-list {
  display: grid;
  gap: 9px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  background: #f8fbfe;
  border: 1px solid #e1ebf3;
  border-radius: 12px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 16px;
}

.info-box {
  background: #f8fbfe;
  border: 1px solid #e1ebf3;
  border-radius: 14px;
  padding: 13px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.list-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.list-actions .btn,
.list-actions a {
  white-space: nowrap;
}

.muted {
  color: #6d7f91;
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* RECIBO HTML */

.receipt-page {
  max-width: 1120px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #d2dde9;
  border-radius: 20px;
  overflow: hidden;
}

.receipt-header {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  background: #f5f8fc;
}

.receipt-header-left {
  padding: 18px;
  border-right: 1px solid #dce6f0;
}

.receipt-header-right {
  padding: 18px;
  background: #264f7e;
  color: #fff;
}

.receipt-header-right .pill {
  background: #fff;
  color: #1b3654;
}

.receipt-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.receipt-brand img {
  width: 86px;
  max-height: 78px;
  object-fit: contain;
}

.receipt-body {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
}

.receipt-left {
  padding: 18px;
}

.receipt-right {
  padding: 18px;
  background: #eef4fb;
}

.receipt-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 10px;
}

.pill {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: #dbe6f4;
  border-radius: 999px;
  padding: 8px 12px;
  margin-bottom: 7px;
  font-weight: 700;
}

.pill.dark {
  background: #275180;
  color: #fff;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.receipt-table th,
.receipt-table td {
  border-bottom: 1px solid #d6e0ea;
  padding: 8px 7px;
}

.receipt-table th {
  background: #f7fafc;
}

.right {
  text-align: right;
}

.tiny {
  font-size: 11px;
  color: #5c7086;
}

.danger-text {
  color: #b8302a;
  font-weight: 700;
}

/* CLIENTES */

.clients-scroll {
  max-height: 560px;
  overflow: auto;
  border: 1px solid #e6edf4;
  border-radius: 14px;
  background: #fff;
}

.clients-scroll table {
  min-width: 760px;
}

.clients-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f9fbfd;
  box-shadow: 0 1px 0 #e6edf4;
}

.compact-table th,
.compact-table td {
  padding: 7px 8px;
  font-size: 12px;
  line-height: 1.18;
}

.clients-table th:nth-child(1),
.clients-table td:nth-child(1) {
  width: 78px;
  white-space: normal;
}

.clients-table th:nth-child(2),
.clients-table td:nth-child(2) {
  width: 230px;
}

.clients-table th:nth-child(3),
.clients-table td:nth-child(3) {
  width: 95px;
}

.clients-table th:nth-child(4),
.clients-table td:nth-child(4) {
  width: 90px;
}

.clients-table th:nth-child(5),
.clients-table td:nth-child(5) {
  width: 70px;
  white-space: nowrap;
}

.clients-table th:nth-child(6),
.clients-table td:nth-child(6) {
  width: 120px;
  white-space: nowrap;
}

.clients-table th:nth-child(7),
.clients-table td:nth-child(7) {
  width: 70px;
  white-space: nowrap;
}

.clients-table th:nth-child(8),
.clients-table td:nth-child(8) {
  width: 82px;
}

.client-name-cell strong {
  font-size: 12px;
  font-weight: 700;
}

.client-name-cell small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.15;
  color: #6d7f91;
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: flex-start;
}

.mini-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef3f9;
  color: #18324a;
  border-radius: 7px;
  padding: 4px 6px;
  font-size: 10.5px;
  line-height: 1;
  font-weight: 700;
  text-align: center;
  width: auto;
  min-width: 48px;
  max-width: 90px;
  white-space: nowrap;
}

.mini-link:hover {
  background: #dfe8f2;
}

/* PRINT */

@media print {
  body {
    background: #fff;
  }

  .shell {
    display: block;
  }

  .sidebar,
  .topbar,
  .btn {
    display: none !important;
  }

  .content {
    padding: 0;
  }

  .receipt-page {
    border: none;
    border-radius: 0;
  }
}

/* RESPONSIVE GENERAL */

@media (max-width: 1200px) {
  .content {
    padding: 18px;
  }

  .split,
  .split-2,
  .panel-grid,
  .receipt-body,
  .receipt-header {
    grid-template-columns: 1fr;
  }

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

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

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

  .clients-scroll table,
  .table-wrap table {
    min-width: 800px;
  }
}

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

  .split,
  .split-2,
  .panel-grid,
  .calc-panel,
  .kpis,
  .subkpis,
  .receipt-body,
  .receipt-header {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-badge {
    text-align: left;
    min-width: auto;
  }

  .clients-scroll {
    max-height: 520px;
  }

  .clients-scroll table {
    min-width: 800px;
  }
}

/* TABLETS Y LAPTOPS PEQUE���AS */

@media (max-width: 900px) {
  .shell {
    display: block;
  }

  .sidebar {
    padding: 14px;
  }

  .sidebar nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .sidebar nav a {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .brand {
    margin-bottom: 12px;
  }

  .content {
    padding: 14px;
  }

  .topbar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-badge {
    width: 100%;
    text-align: left;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .kpis,
  .subkpis,
  .calc-panel {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 15px;
    border-radius: 14px;
  }

  .clients-scroll {
    max-height: 500px;
  }
}

/* CELULARES */

@media (max-width: 600px) {
  body {
    font-size: 12.5px;
  }

  .content {
    padding: 10px;
  }

  .sidebar {
    padding: 10px;
  }

  .brand img {
    width: 42px;
  }

  .brand strong {
    font-size: 13px;
  }

  h1 {
    font-size: 23px;
  }

  h2 {
    font-size: 19px;
  }

  h3 {
    font-size: 16px;
  }

  .card {
    padding: 12px;
    border-radius: 13px;
  }

  input,
  select,
  textarea {
    font-size: 13px;
    padding: 9px 10px;
  }

  button,
  .btn {
    width: 100%;
    text-align: center;
    padding: 9px 10px;
  }


.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-link {
  width: auto;
  min-width: 46px;
  max-width: 88px;
  padding: 4px 5px;
  font-size: 10px;
}

  .table-wrap table,
  .clients-scroll table {
    min-width: 720px;
  }

  th,
  td {
    padding: 7px 7px;
    font-size: 12px;
  }

  .compact-table th,
  .compact-table td {
    font-size: 11.5px;
    padding: 7px;
  }

  .login-card {
    width: 94vw;
    padding: 22px;
  }
}

/* CELULARES MUY ANGOSTOS */

@media (max-width: 420px) {
  body {
    font-size: 12px;
  }

  .content {
    padding: 8px;
  }

  .card {
    padding: 10px;
  }

  .table-wrap table,
  .clients-scroll table {
    min-width: 680px;
  }

  .receipt-page {
    border-radius: 12px;
  }
}



/* =========================================================
   FIX FINAL: botones compactos dentro de tablas
========================================================= */

table .btn,
table button,
table a.btn,
table .mini-link,
table .action-menu-btn {
  width: auto !important;
  min-width: auto !important;
  max-width: none !important;
  padding: 4px 7px !important;
  font-size: 10px !important;
  line-height: 1.1 !important;
  border-radius: 7px !important;
  white-space: nowrap !important;
}

table .action-cell {
  width: 76px;
  min-width: 76px;
  max-width: 90px;
  padding-left: 5px;
  padding-right: 5px;
}

table .action-cell form {
  margin: 0;
  display: inline;
}

table .action-cell button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* Bot���n PDF / Ver / Recibo PDF */
table a.btn-light,
table .btn-light {
  padding: 4px 7px !important;
  font-size: 10px !important;
  border-radius: 7px !important;
}

/* En m���vil, los botones normales pueden ser ancho completo,
   pero los botones de tabla NO */
@media (max-width: 600px) {
  table .btn,
  table button,
  table a.btn,
  table .mini-link,
  table .action-menu-btn {
    width: auto !important;
    padding: 4px 6px !important;
    font-size: 10px !important;
  }

  table .action-cell {
    width: 72px;
    min-width: 72px;
  }
}

/* Nuevo recibo más angosto */
.invoice-form-card {
    max-width: 620px;
    width: 100%;
    margin-left: 0;
    margin-right: auto;
    padding: 16px 18px !important;
}

.invoice-form-card input,
.invoice-form-card select,
.invoice-form-card textarea {
    padding: 7px 10px !important;
    min-height: 34px;
    font-size: 12.5px;
}

.invoice-form-card label {
    margin: 7px 0 4px;
    font-size: 12px;
}

.invoice-form-card .form-grid {
    gap: 8px 12px;
}

.invoice-form-card h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.invoice-form-card p,
.invoice-form-card small,
.invoice-form-card .muted {
    font-size: 11.5px;
}

.invoice-form-card button,
.invoice-form-card .btn {
    width: auto !important;
    padding: 8px 11px !important;
    font-size: 12px;
}

.invoices-layout {
    grid-template-columns: 620px minmax(0, 1fr);
    align-items: start;
}

@media (max-width: 1200px) {
    .invoices-layout {
        grid-template-columns: 1fr;
    }

    .invoice-form-card {
        max-width: 100%;
    }
}


/* Recibos: columnas más anchas */
.invoices-table th:nth-child(1),
.invoices-table td:nth-child(1) {
    min-width: 100px;
    width: 100px;
    white-space: nowrap;
}

.invoices-table th:nth-child(4),
.invoices-table td:nth-child(4) {
    min-width: 90px;
    width: 90px;
    white-space: nowrap;
    text-align: center;
}

/* Acciones de pagos */
.payment-action-links {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 118px;
}

.mini-link.edit {
  background: #d97706;
  color: #fff;
}

.mini-link.edit:hover {
  background: #b45309;
}

.edit-payment-card {
  border-top: 4px solid #d97706;
}
