:root{
  --bg:#f4f7fb;
  --bg-soft:#eef3f8;
  --card:#ffffff;
  --line:#e6ecf2;
  --line-strong:#d9e2ec;
  --text:#172b4d;
  --muted:#6b7c93;
  --primary:#1155cc;
  --primary-hover:#0e47aa;
  --primary-soft:#e8f0ff;
  --success:#1f9d55;
  --danger:#c62828;
  --warning:#f59e0b;
  --shadow:0 10px 30px rgba(16,24,40,.08);
  --radius:16px;
  --radius-sm:12px;
}

*{box-sizing:border-box}

html,body{
  margin:0;
  padding:0;
}

body{
  font-family:"Segoe UI",Arial,sans-serif;
  background:linear-gradient(180deg,var(--bg) 0%,var(--bg-soft) 100%);
  color:var(--text);
  padding:24px;
}

h1,h2,h3{
  margin:0 0 12px;
  color:var(--text);
}

p{
  color:var(--muted);
}

a{
  color:inherit;
  text-decoration:none;
}

form{
  margin:0;
}

.wrap,
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

.wrap{
  max-width:460px;
  margin:8vh auto;
  padding:28px;
}

.wrap h2{
  font-size:28px;
  margin-bottom:8px;
}

.top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
  margin-bottom:18px;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 12px;
  border-radius:999px;
  background:var(--primary-soft);
  color:var(--primary);
  font-size:13px;
  font-weight:600;
}

.menu{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin:14px 0 20px;
}

.filters,
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:12px;
  margin-bottom:18px;
}

input,
select,
textarea{
  width:100%;
  padding:12px 14px;
  border:1px solid var(--line-strong);
  border-radius:12px;
  background:#fff;
  color:var(--text);
  font-size:14px;
  outline:none;
  transition:border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

input:focus,
select:focus,
textarea:focus{
  border-color:var(--primary);
  box-shadow:0 0 0 4px rgba(17,85,204,.12);
}

textarea{
  resize:vertical;
  min-height:110px;
}

button,
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:11px 16px;
  border:0;
  border-radius:12px;
  background:var(--primary);
  color:#fff;
  font-weight:600;
  font-size:14px;
  cursor:pointer;
  transition:transform .15s ease, background .15s ease, box-shadow .15s ease;
  box-shadow:0 8px 18px rgba(17,85,204,.18);
}

button:hover,
.btn:hover{
  background:var(--primary-hover);
  transform:translateY(-1px);
}

button:disabled,
.btn:disabled{
  opacity:.65;
  cursor:not-allowed;
  transform:none;
}

.btn-secondary{
  background:#0f172a;
  box-shadow:0 8px 18px rgba(15,23,42,.18);
}

.btn-secondary:hover{
  background:#111827;
}

.err{
  margin-bottom:14px;
  padding:12px 14px;
  border:1px solid #ffd5d5;
  border-radius:12px;
  background:#fff2f2;
  color:var(--danger);
  font-size:14px;
}

.notice{
  margin-bottom:14px;
  padding:12px 14px;
  border:1px solid #d7f3df;
  border-radius:12px;
  background:#f2fff6;
  color:var(--success);
  font-size:14px;
}

.table-wrap{
  overflow:auto;
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  overflow:hidden;
}

.table-wrap table{
  min-width:1100px;
  margin:0;
  box-shadow:none;
}

th,td{
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  font-size:14px;
  vertical-align:top;
}

thead th{
  background:#f8fafc;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.04em;
  font-size:12px;
  font-weight:700;
}

tbody tr:nth-child(even){
  background:#fbfdff;
}

tbody tr:hover{
  background:#f5f9ff;
}

tbody tr:last-child td,
tfoot tr:last-child td{
  border-bottom:0;
}

.actions-inline{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}

.kpi{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(190px,1fr));
  gap:12px;
  margin:18px 0;
}

.kpi .card{
  padding:16px;
}

.kpi .label{
  color:var(--muted);
  font-size:13px;
  margin-bottom:6px;
}

.kpi .value{
  color:var(--text);
  font-size:24px;
  font-weight:700;
}

.page-title{
  margin-bottom:6px;
}

.subtle{
  color:var(--muted);
  font-size:14px;
}

.section-card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px;
  margin-bottom:18px;
}

.section-title{
  margin:0 0 14px;
}

.readonly-note{
  background:#f8fafc;
  border:1px dashed #cbd5e1;
}

.user-admin-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}

.user-admin-grid label,
.edit-user-form label{
  display:block;
  margin-bottom:6px;
  font-weight:600;
  color:var(--muted);
  font-size:13px;
}

.user-admin-permissions,
.user-admin-actions{
  grid-column:1 / -1;
}

.perm-title{
  display:block;
  margin-bottom:10px;
  font-weight:700;
}

.perm-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}

.perm-grid.compact{
  margin:10px 0;
}

.perm-card{
  display:flex;
  gap:10px;
  align-items:flex-start;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#f8fafc;
  cursor:pointer;
  font-weight:600;
}

.perm-card input{
  width:auto;
  margin-top:2px;
}

.role-pill{
  display:inline-flex;
  padding:5px 10px;
  border-radius:999px;
  background:var(--primary-soft);
  color:var(--primary);
  font-weight:700;
  font-size:12px;
}

.perm-chip-wrap{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.perm-chip{
  display:inline-flex;
  padding:5px 9px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
}

.perm-on{
  background:#ecfdf3;
  color:#067647;
}

.perm-off{
  background:#fff2f2;
  color:#b91c1c;
}

.edit-user-box summary{
  list-style:none;
}

.edit-user-box summary::-webkit-details-marker{
  display:none;
}

.edit-user-form{
  display:grid;
  gap:10px;
  margin-top:12px;
  min-width:320px;
}

.readonly-box{
  width:100%;
  min-height:46px;
  padding:12px 14px;
  border:1px solid var(--line-strong);
  border-radius:12px;
  background:#f8fafc;
  color:var(--text);
  font-size:14px;
  display:flex;
  align-items:center;
}

.readonly-box.multiline{
  min-height:90px;
  align-items:flex-start;
  white-space:normal;
  line-height:1.5;
}

.detail-item-full{
  grid-column:1 / -1;
}

.section-block-title{
  padding:10px 12px;
  border-radius:10px;
  display:inline-block;
  color:#0f172a;
  font-weight:700;
}

.block-ingresos{
  background:#dff7df;
  color:#166534;
}

.block-proveedor{
  background:#ffe3dc;
  color:#9a3412;
}

.block-consignaciones{
  background:#ffe3dc;
  color:#9a3412;
}

.block-transferencias{
  background:#ffe3dc;
  color:#9a3412;
}

.block-gastos{
  background:#ffd6cc;
  color:#991b1b;
}

.block-efectivo{
  background:#dff7df;
  color:#166534;
}

.block-pendientes{
  background:#ffd6cc;
  color:#991b1b;
}

.block-otros{
  background:#eef4ff;
  color:#0e47aa;
}

@media (max-width: 860px){
  body{
    padding:16px;
  }

  .top{
    flex-direction:column;
    align-items:stretch;
  }

  .wrap{
    margin:24px auto;
    padding:22px;
  }

  .filters,
  .grid,
  .user-admin-grid,
  .perm-grid{
    grid-template-columns:1fr;
  }

  button,
  .btn{
    width:100%;
  }

  .menu .btn{
    width:auto;
  }
}

.money-edit{
  text-align:right;
}

/* ===== Colores del formato original de arqueos ===== */

/* Verde fuerte: títulos principales de ingresos y efectivo */
.thverdeoscuro{
  background:#66F538 !important;
  color:#0b2e13 !important;
}

/* Verde claro: columnas internas de ingresos y efectivo */
.thverde{
  background:#CDFCCA !important;
  color:#0f3d1f !important;
}

/* Rojo/salmón fuerte: títulos generales de egresos y pendientes */
.egresoscolor{
  background:#FF6B4F !important;
  color:#ffffff !important;
}

/* Salmón claro: subencabezados y columnas de egresos */
.thazul{
  background:#FFC4B5 !important;
  color:#5a1f12 !important;
}

/* Encabezados neutros tipo secciones */
.section{
  background:#a2c4c9 !important;
  color:#0f172a !important;
  font-weight:700;
}

/* Totales */
.tfoot{
  background:#f3f3f3 !important;
  font-weight:700;
}

/* Diferencia */
.diff{
  background:#f4cccc !important;
  color:#a00000 !important;
  font-weight:700;
}

/* ===== Forzar colores del formato arqueo sobre celdas reales ===== */

#mainForm .thverdeoscuro,
#mainForm .thverdeoscuro th,
#mainForm .thverdeoscuro td{
  background:#66F538 !important;
  color:#0b2e13 !important;
}

#mainForm .thverde,
#mainForm .thverde th,
#mainForm .thverde td{
  background:#CDFCCA !important;
  color:#0f3d1f !important;
}

#mainForm .egresoscolor,
#mainForm .egresoscolor th,
#mainForm .egresoscolor td{
  background:#FF6B4F !important;
  color:#ffffff !important;
}

#mainForm .thazul,
#mainForm .thazul th,
#mainForm .thazul td{
  background:#FFC4B5 !important;
  color:#5a1f12 !important;
}

#mainForm .section,
#mainForm .section th,
#mainForm .section td{
  background:#a2c4c9 !important;
  color:#0f172a !important;
  font-weight:700;
}

#mainForm .tfoot,
#mainForm .tfoot th,
#mainForm .tfoot td{
  background:#f3f3f3 !important;
  color:#172b4d !important;
  font-weight:700;
}

#mainForm .diff,
#mainForm .diff th,
#mainForm .diff td{
  background:#f4cccc !important;
  color:#a00000 !important;
  font-weight:700;
}

