:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --card: #ffffff;
    --muted: #000000;
    --text: #0f172a;
    --line: #e2e8f0;
    --accent: #2563eb;
    --danger: #ef4444;
    --good: #22c55e;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --r: 16px;
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    font-family: Poppins, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
    background:
        radial-gradient(1200px 700px at 10% 10%, rgba(37, 99, 235, 0.08), transparent 55%),
        radial-gradient(900px 600px at 90% 25%, rgba(34, 197, 94, 0.05), transparent 55%),
        linear-gradient(180deg, #f8fbff, #eef4ff 40%, #f8fafc 100%);
    color: var(--text);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

.dup-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    vertical-align: middle;
}

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

.logo {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
    background: linear-gradient(135deg, rgba(37, 99, 235, 1), rgba(34, 197, 94, 1));
    box-shadow: 0 10px 24px rgba(37, 99, 235, .18);
}

.title {
    font-weight: 800;
    font-size: 14px;
    line-height: 1.1
}

.subtitle {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px
}

.auth {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end
}

.user {
    color: var(--text);
    font-size: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
}

.btn {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: .15s transform, .15s background, .15s opacity, .15s box-shadow;
    user-select: none;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.btn:hover {
    transform: translateY(-1px);
    background: #f8fafc;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.btn:active {
    transform: translateY(0px);
    opacity: .95
}

.btn.ghost {
    background: transparent
}

.btn.danger {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px;
}

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

.tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap
}

.tab {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
}

.tab.active {
    background: #eff6ff;
    color: var(--accent);
    border-color: rgba(37, 99, 235, .28);
}

.tabTitle {
    color: var(--muted);
    font-size: 12px;
    padding-left: 8px
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end
}

.filters {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    border-radius: var(--r);
    padding: 12px;
    box-shadow: var(--shadow);
}

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

@media(max-width:900px) {
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }

    .span2 {
        grid-column: 1 / -1 !important
    }
}

.field label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin: 0 0 6px
}

.field input,
.field select {
    width: 100%;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #b8d5f0;
    color: var(--text);
    outline: none;
}

.field input:focus,
.field select:focus {
    border-color: rgba(37, 99, 235, .45);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
}

.field input::placeholder {
    color: #94a3b8
}

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

.status {
    color: var(--muted);
    font-size: 12px
}

.totals {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.pill {
    border: 1px solid var(--line);
    background: #ffffff;
    padding: 8px 10px;
    border-radius: 999px;
    color: var(--text);
    font-size: 12px;
}

.card {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: var(--r);
    padding: 12px;
    box-shadow: var(--shadow);
    margin: 12px 0;
}

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

.cardHead h2 {
    margin: 0;
    font-size: 14px
}

.cardHeadRight {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center
}

.hint {
    color: var(--muted);
    font-size: 12px
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px
}

.check input {
    accent-color: var(--accent)
}

.form {
    margin-top: 8px
}

.form .field {
    min-width: 0
}

.span2 {
    grid-column: span 2
}
.tableWrap {
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow-x: auto;
    overflow-y: auto;
    max-width: 100%;
    max-height: 70vh;
    background: #ffffff;
}

table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}
thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody td {
    padding: 10px;
    font-size: 12px;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}

tbody tr:hover td {
    background: #f8fbff;
}

tbody td[contenteditable="true"] {
    outline: none;
}

tbody td.cell-active {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, .75);
    background: #eff6ff;
}

/* opcional: scrollbar bonito */
.tableWrap::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

.tableWrap::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.tableWrap::-webkit-scrollbar-track {
    background: #f8fafc;
}

.actionRow {
    display: flex;
    gap: 8px
}

.smallBtn {
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
}

.smallBtn:hover {
    background: #f8fafc
}

.smallBtn.danger {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca
}

.smallBtn.ghost {
    background: transparent
}

.loginView {
    min-height: calc(100vh - 74px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.loginCard {
    width: min(520px, 96vw);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 22px;
    padding: 18px;
    box-shadow: var(--shadow);
}

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

.loginHint {
    color: var(--muted);
    font-size: 12px;
    margin: 12px 0 0
}

.modal {
    width: min(520px, 92vw);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #ffffff;
    color: var(--text);
    box-shadow: var(--shadow);
    padding: 0;
}

.modal::backdrop {
    background: rgba(15, 23, 42, .35);
}

.modalHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}

.modalHead h3 {
    margin: 0;
    font-size: 14px
}

.modalBody {
    padding: 12px
}

.modalFoot {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 10px
}

.iconBtn {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
}

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

.msg {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted)
}

/* ===== REPORTES ===== */

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

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

.reportKpi {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 12px;
}

.kpiLabel {
    color: var(--muted);
    font-size: 12px;
}

.kpiValue {
    font-size: 22px;
    font-weight: 800;
    margin-top: 6px;
    color: var(--text);
}

.kpiHint {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}

.reportGrid2 {
    
    grid-template-columns: 1.2fr .8fr;
    gap: 12px;
    margin-top: 12px;
}

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

.reportCard {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: 12px;
}

.reportCardHead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

#repChart {
    width: 100%;
    height: auto;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #f8fafc;
}

.reportTables {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

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

.miniTable thead th {
    text-align: left;
    font-size: 12px;
    padding: 8px;
    border-bottom: 1px solid var(--line);
}

.miniTable tbody td {
    font-size: 12px;
    padding: 8px;
    border-bottom: 1px solid rgba(15, 23, 42, .06);
}

.miniTitle {
    font-weight: 800;
    margin-bottom: 6px;
}

/* ===== Adjuntos / comprobantes ===== */
.attachPreview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.attachChip {
    border: 1px solid rgba(148, 163, 184, .35);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
}

.attachChip b {
    font-weight: 600
}

.attachChip button {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    opacity: .75;
}

.attachChip button:hover {
    opacity: 1
}

.attachmentsList {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.attachmentRow {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 12px;
    padding: 10px 12px;
    background: #ffffff;
}

.attachmentRow .meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.attachmentRow .meta .name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 520px;
}

.attachmentRow .meta .sub {
    font-size: 12px;
    opacity: .75;
}

.attachmentRow .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attachView {
    margin-top: 12px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 16px;
    padding: 12px;
    background: #ffffff;
}

.attachView img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
}

.attachView iframe {
    width: 100%;
    height: 420px;
    border: 0;
    border-radius: 12px;
}

/* Fondo oscuro transparente */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* oculto */
.hidden {
  display: none;
}

/* Caja centrada */
.loader-box {
  width: 25vw;
  min-width: 260px;
  max-width: 380px;

  background: #ffffff;
  border-radius: 18px;
  padding: 25px 20px;

  text-align: center;

  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  animation: fadeIn 0.25s ease;
}

/* Spinner */
.loader-spinner {
  width: 60px;
  height: 60px;
  margin: 0 auto 15px;

  border-radius: 50%;
  border: 5px solid #e5e7eb;
  border-top-color: #2563eb;

  animation: spin 1s linear infinite;
}

/* Textos */
.loader-box h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #111827;
}

.loader-box p {
  margin: 8px 0 15px;
  font-size: 0.9rem;
  color: #6b7280;
}

/* Barra progreso */
.loader-progress {
  width: 100%;
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

#loaderBar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  transition: width 0.3s ease;
}

/* porcentaje */
#loaderPercent {
  display: block;
  margin-top: 10px;
  font-weight: 600;
  color: #1d4ed8;
}

/* animaciones */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}



/*dialog ver editar gasto*/
.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.detail-dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(980px, 95vw);
  max-height: 92vh;
  overflow: hidden;
}

.detail-card {
  background: #fff;
  color: #1f2937;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.detail-body {
  padding: 20px;
  overflow: auto;
}

.detail-section {
  margin-bottom: 22px;
}

.detail-section h4 {
  margin: 0 0 12px;
  font-size: 15px;
  color: #111827;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-item label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
}

.detail-item input,
.detail-item select,
.detail-item textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: #111827;
}

.detail-item textarea {
  min-height: 90px;
  resize: vertical;
}

.detail-readonly {
  background: #f3f4f6 !important;
}

.attach-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
}


/*ITEM DE AGREGAR ID DE INGRESOS*/
.span2 {
  grid-column: span 2;
}

.folio-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #1f2937;
  font-size: 13px;
}

.folio-chip button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.columns-dialog {
  width: min(520px, 92vw);
  border: none;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  background: #fff;
  color: #1f2937;
}

.columns-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.columns-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #e5e7eb;
}

.columns-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.columns-panel {
  padding: 16px 18px;
  max-height: 60vh;
  overflow-y: auto;
}

.columns-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid #e5e7eb;
}

.btn-close {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.column-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  cursor: pointer;
}

.column-option input {
  transform: scale(1.1);
}


.dashboardCards {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.dashCard {
  background: #fff;
  border: 1px solid #e7e7e7;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,.05);
}

.dashCard span {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}

.dashCard strong {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
}

@media (max-width: 900px) {
  .dashboardCards {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

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