:root {
  --bg: #0b1220;
  --card: #0E1A2F;
  --muted: #9db2d0;
  --text: #eaf2ff;
  --accent: #4EA1FF;
  --green: #00E0A4;
  --red: #EA5455;
  --yellow: #FF9F43;
  --blue: #4EA1FF;
  --border: #22314f;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px;
}

h1, h2 {
  margin: 12px 0 16px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img {
  height: 34px;
}
.brand .subtitle {
  color: var(--muted);
  font-size: .9rem;
}

.cardLogin,
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.btn {
  background: var(--accent);
  color: #001a33;
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .06s ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn.small {
  padding: 6px 10px;
  font-size: .9rem;
}
.btn.outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

label {
  display: block;
  margin: 8px 0 4px;
  color: var(--muted);
}

input {
  width: 100%;
  padding: 10px 12px;
  background: #0f1626;
  color: var(--text);
  border: 1px solid #1e2a44;
  border-radius: 10px;
}

.center {
  text-align: center;
}
.msg {
  margin-top: 8px;
}
.muted {
  color: var(--muted);
  font-size: .9rem;
}

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

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

.kpi {
  border-radius: 14px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0));
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.kpi .kpi-title {
  color: var(--muted);
  font-size: .92rem;
}
.kpi .kpi-value {
  font-size: 2.2rem;
  font-weight: 800;
  margin-top: 6px;
  display: -webkit-box;
  /*-webkit-line-clamp: 2;*/
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi::after {
  content: '';
  position: absolute;
  inset: auto auto 0 0;
  height: 4px;
  width: 100%;
  background: var(--accent);
  opacity: .35;
}
.kpi-green::after { background: var(--green); }
.kpi-red::after { background: var(--red); }
.kpi-yellow::after { background: var(--yellow); }
.kpi-blue::after { background: var(--blue); }

.filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: end;
}
.filters .btn {
  grid-column: span 1;
}

.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  position: sticky;
  top: 0;
  background: #0e1524;
  z-index: 1;
}
th, td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #1e2a44;
  white-space: nowrap;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.space-between {
  justify-content: space-between;
}
.loadmore {
  margin: 10px auto 0;
  display: block;
}

/* Responsive */
@media (max-width: 720px) {
  .container { padding: 12px; }
  .filters { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .btn { font-size: 0.85rem; padding: 8px 12px; }
}

/* Balance Fiscal */
.balance-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 12px;
}
.checkSmall{
  margin: 0;
  padding: 0;
  width: 16px;
  height: 16px;
}
.col {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.col:hover {
  background: rgba(255,255,255,0.06);
}
.col h3 {
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.col .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.9rem;
}
.col .row:last-child {
  border-bottom: none;
}
.col .row span:first-child {
  color: var(--muted);
}
.col .row span:last-child {
  font-weight: 700;
}
.col-ingreso h3 { color: var(--green); }
.col-egreso h3 { color: var(--red); }
.col-diferencia h3 { color: var(--blue); }
.col-diferencia .row span:last-child.negative {
  color: var(--green);
}

/* Filtros Balance */
.balance-filters {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.balance-filters label {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 8px 0 0;
}
.balance-filters select,
.balance-filters input {
  padding: 8px 12px;
  background: #0f1626;
  color: var(--text);
  border: 1px solid #1e2a44;
  border-radius: 8px;
  font-size: 0.9rem;
}
.balance-filters button {
  padding: 8px 14px;
  font-size: 0.9rem;
}

/* Separación KPIs → Balance */
#kpiGrid + .card {
  margin-top: 24px;
}

/* Certificado vencido */
.kpi-cert-expired-long .kpi-value {
  color: var(--yellow) !important;
  font-size: 1.8rem;
  font-weight: 700;
}
.kpi-cert-expired-long::before {
  content: "⚠️";
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1.2rem;
  opacity: 0.8;
}

/* 🍔 Menú hamburguesa */
.client-actions {
  position: relative;
  display: inline-block;
}
.hamburger-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
}
.hamburger-btn:hover {
  background: rgba(78, 161, 255, 0.15);
  color: var(--accent);
}
.hamburger-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  min-width: 180px;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  padding: 8px 0;
}
.hamburger-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.hamburger-menu a,
.hamburger-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.15s;
}
.hamburger-menu a:hover,
.hamburger-menu button:hover {
  background: rgba(78, 161, 255, 0.15);
  color: var(--accent);
}

/* Árbol de directorios */
.tree-view {
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
  white-space: pre;
}

.status-ok { 
    background: rgba(0, 224, 164, 0.15); 
    color: var(--green); 
}
    
.status-warn { 
    background: rgba(255, 159, 67, 0.15); 
    color: var(--yellow); 
    }
.status-missing { 
    background: rgba(234, 84, 85, 0.15); 
    color: var(--red); 
}

.cardLogin{ 
    background:var(--card); 
    border-radius:16px; 
    padding:16px; 
    box-shadow:0 8px 30px rgba(0,0,0,.25); 
    margin-bottom:18px; 
    border:1px solid var(--border); 
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}


.tabs {
            display: flex;
            cursor: pointer;
        }
        .tabs div {
            padding: 10px 20px;
            background-color: #f0f0f0;
            border: 1px solid #ccc;
            margin-right: 2px;
            border-radius: 4px 4px 0 0;
        }
        .tabs div.active {
            background-color: #007bff;
            color: white;
            border-color: #007bff;
        }
        .tab-content {
            border: 1px solid #ccc;
            padding: 20px;
            display: none;
            margin-top: 10px;
        }
        .tab-content.active {
            display: block;
        }
        textarea {
            width: 100%;
            height: 200px;
            padding: 10px;
            font-family: monospace;
            font-size: 14px;
            background-color: #f9f9f9;
            border: 1px solid #ccc;
            border-radius: 4px;
            resize: vertical;
        }
/* Balance Fiscal */
.balance-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* Tres columnas por defecto */
  gap: 16px;
  margin-top: 12px;
}
.col {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  /* Opcional: Evita que las columnas se compriman demasiado */
  min-width: 0;
}
.col:hover {
  background: rgba(255,255,255,0.06);
}
.col h3 {
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.col .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.9rem;
}
.col .row:last-child {
  border-bottom: none;
}
.col .row span:first-child {
  color: var(--muted);
}
.col .row span:last-child {
  font-weight: 700;
}
.col-ingreso h3 { color: var(--green); }
.col-egreso h3 { color: var(--red); }
.col-diferencia h3 { color: var(--blue); }
.col-diferencia .row span:last-child.negative {
  color: var(--green);
}

/* Filtros Balance */
.balance-filters {
  display: flex;
  flex-wrap: wrap; /* Permite que los elementos se envuelvan */
  gap: 12px; /* Espacio entre elementos */
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.balance-filters label {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 8px 0 0; /* Espacio a la derecha */
  white-space: nowrap; /* Evita que el texto se rompa */
  flex-shrink: 0; /* No se encoge */
}
.balance-filters select,
.balance-filters input {
  padding: 8px 12px;
  background: #0f1626;
  color: var(--text);
  border: 1px solid #1e2a44;
  border-radius: 8px;
  font-size: 0.9rem;
  flex: 1; /* Ocupa espacio disponible */
  min-width: 120px; /* Ancho mínimo para select/input */
  max-width: 100%; /* No exceda el ancho del contenedor */
}
.balance-filters button {
  padding: 8px 14px;
  font-size: 0.9rem;
  flex-shrink: 0; /* Botón no se encoge */
}

/* Responsive */
@media (max-width: 720px) {
  .container { padding: 12px; }
  .filters { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .btn { font-size: 0.85rem; padding: 8px 12px; }

  /* Balance Fiscal Responsive */
  .balance-columns {
    grid-template-columns: 1fr; /* Una columna en móviles */
  }

  .balance-filters {
    flex-direction: column; /* Apila los elementos verticalmente */
    align-items: stretch; /* Estira los elementos al ancho */
  }
  .balance-filters label {
    margin-bottom: 4px; /* Espacio debajo de la etiqueta */
  }
  .balance-filters select,
  .balance-filters input {
    min-width: auto; /* Ignora el ancho mínimo */
  }
}

/* ✅ Estilos para Modal de Rechazo */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  width: 100%;
  max-width: 600px;
  margin: 0 1rem;
}

.modal-content {
  background: var(--card);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  overflow: hidden;
  border: 1px solid var(--border);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background-color: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.instructions {
  margin-bottom: 1rem;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text);
}

.counter {
  float: right;
  font-weight: normal;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  min-height: 120px;
  background-color: #0f1626;
  color: var(--text);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 161, 255, 0.25);
}

.modal-footer {
  padding: 0;
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* Botones del modal */
.modal-footer .btn {
  padding: 0.6rem 1.25rem;
  font-size: 1rem;
}

.modal-footer .btn.outline {
  background: var(--card);
  border-color: var(--muted);
  color: var(--muted);
}

.modal-footer .btn.outline:hover {
  background: rgba(255,255,255,0.06);
}

.modal-footer .btn.primary {
  background-color: var(--red);
  border-color: var(--red);
  color: white;
}

.modal-footer .btn.primary:hover:not(:disabled) {
  background-color: #d63a3a;
  border-color: #d63a3a;
}

.modal-footer .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* =========================================
   Estilos migrados de Admin/actualizar.php
   ========================================= */

.page-title {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--text);
}

.form-group {
    margin-bottom: 20px;
}

/* Sobrescritura específica para inputs file/text si es necesario, 
   o confiar en el estilo global 'input'. 
   En actualizar.php tenían estilos específicos. */
input[type="file"],
input[type="text"] {
    width: 100%;
    padding: 12px;
    background: #0f1626;
    color: var(--text);
    border: 1px solid #1e2a44;
    border-radius: 10px;
    font-size: 1rem;
}

/* Status messages */
.status {
    padding: 16px;
    border-radius: 10px;
    margin-top: 20px;
    display: none;
}
.status.success { background: rgba(0, 224, 164, 0.15); color: var(--green); border-left: 4px solid var(--green); }
.status.error { background: rgba(234, 84, 85, 0.15); color: var(--red); border-left: 4px solid var(--red); }
.status.info { background: rgba(78, 161, 255, 0.15); color: var(--accent); border-left: 4px solid var(--accent); }

/* Example box */
.example {
    background: rgba(78, 161, 255, 0.1);
    border-left: 4px solid var(--accent);
    padding: 12px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.95rem;
    margin: 12px 0;
}
.note {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 6px;
}
.backup-list {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--muted);
}
.backup-item {
    display: block;
    margin: 4px 0;
    padding: 4px 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

/* Top menu buttons (mini dashboard) */
.top-menu {
    display: flex;
    gap: 8px;
    align-items: center;
}
.top-menu .btn {
    padding: 6px 12px;
    font-size: 0.9rem;
    border-radius: 8px;
    background: rgba(78, 161, 255, 0.15);
    color: var(--accent);
    border: none;
    transition: background 0.2s;
}
.top-menu .btn:hover {
    background: rgba(78, 161, 255, 0.25);
}

/* Ajuste específico para header que necesita borde y padding específico 
   Se usa .header-bar para diferenciar del .header global si es necesario, 
   o se reutiliza .header con modificadores.
   Aquí aplicamos estilos a .header cuando se usa en este contexto, 
   o simplemente agregamos las reglas que faltan.
*/
.header.with-border {
    padding: 12px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    gap: 16px;
    justify-content: space-between;
}
/* Estilos para el botón de volver en el header */
.header .btn-back {
    padding: 6px 12px;
    font-size: 0.9rem;
    border-radius: 8px;
    background: rgba(78, 161, 255, 0.15);
    color: var(--accent);
    border: none;
    transition: background 0.2s;
}
.header .btn-back:hover {
    background: rgba(78, 161, 255, 0.25);
}