:root {
  --mide-gold: #C8A977;
  --mide-taupe: #95785E;
  --mide-dark: #323E48;
  --mide-black: #1D1D1B;
  --mide-gray: #eaeaec;
  --mide-white: #ffffff;
  --text-secondary: #5f5e5a;
  --border: #e0dfdb;
  --radius: 8px;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--mide-gray);
  color: var(--mide-black);
}

a { color: inherit; text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

.card {
  background: var(--mide-white);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

.metric-card {
  background: #f4f3f0;
  border-radius: var(--radius);
  padding: 1rem;
  border-left: 3px solid var(--mide-gold);
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-secondary); font-weight: 400; padding: 6px 14px 6px 0; }
td { padding: 8px 14px 8px 0; border-top: 1px solid var(--border); }

.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.btn-primary {
  background: var(--mide-gold);
  border-color: var(--mide-gold);
  color: var(--mide-black);
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius);
}

.badge-success { background: #eaf3de; color: #3b6d11; }
.badge-warning { background: #faeeda; color: #854f0b; }
.badge-danger  { background: #fcebeb; color: #a32d2d; }
.badge-btn { border: none; cursor: pointer; font: inherit; }
.badge-btn:hover { filter: brightness(0.95); }

.xml-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fafaf8;
}
.xml-dropzone:hover { border-color: var(--mide-gold); }
.xml-dropzone-activo { border-color: var(--mide-gold); background: #f7f0e0; }
.xml-dropzone i { font-size: 22px; color: var(--text-secondary); }
.xml-dropzone-texto { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0 0; }

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(29,29,27,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
/* ===== Utilidades reutilizables (nuevo código las usa en vez de style="") ===== */
.field { display: block; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.btn-icon { padding: 3px 8px; font-size: 11px; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); font-size: 12px; }
.mt-1 { margin-top: 1rem; } .mb-1 { margin-bottom: 1rem; }

/* ===== Utilidades agregadas: reemplazan los patrones de style="" mas repetidos
   (ver auditoria — 573 de 943 usos de style="" inline en modules/ correspondian
   a estos 15 patrones exactos). Usar estas clases en vez de repetir style="". ===== */
.text-secondary { color: var(--text-secondary); }
.text-muted-sm { font-size: 11px; color: var(--text-secondary); }
.text-muted-block { font-size: 12px; color: var(--text-secondary); display: block; }
.text-muted-label { font-size: 12px; color: var(--text-secondary); margin: 0 0 4px; }
.input-field { width: 100%; padding: 8px; margin: 4px 0 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.input-field-lg { width: 100%; padding: 8px; margin: 4px 0 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.input-plain { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.actions-end { display: flex; gap: 8px; justify-content: flex-end; }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.d-inline { display: inline; }

/* ===== Tarjetas KPI estilo dashboard moderno (mockup-dashboard-kpi-iva) ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi-card {
  background: var(--mide-white); border-radius: 16px; padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.03);
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.kpi-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 14px;
}
.kpi-icon.oro { background: #f3e9d7; color: #a9793f; }
.kpi-icon.ambar { background: #faeeda; color: #854f0b; }
.kpi-icon.rojo { background: #f7e3e0; color: #a32d2d; }
.kpi-icon.verde { background: #eaf3de; color: #3b6d11; }
.kpi-label { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 6px; font-weight: 500; }
.kpi-valor { font-size: 26px; font-weight: 700; color: var(--mide-black); letter-spacing: -.01em; margin: 0; }
.kpi-nota { font-size: 11px; color: var(--text-secondary); margin-top: 8px; }
.kpi-tag { position: absolute; top: 20px; right: 20px; font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 100px; }
.kpi-tag.verde { background: #eaf3de; color: #3b6d11; }
.kpi-tag.rojo { background: #f7e3e0; color: #a32d2d; }

.iva-card { background: var(--mide-white); border-radius: 16px; padding: 22px; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.04); margin-bottom: 24px; }
.iva-bar-row { display: flex; align-items: center; height: 34px; border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.iva-seg { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; }
.iva-seg.subtotal { background: var(--mide-dark); }
.iva-seg.iva { background: var(--mide-gold); color: var(--mide-black); }
.iva-desglose { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.iva-item { padding: 14px 16px; border-radius: 12px; background: #faf9f7; border: 1px solid var(--border); }
.iva-item .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.iva-item.subtotal .dot { background: var(--mide-dark); }
.iva-item.iva .dot { background: var(--mide-gold); }
.iva-item.total .dot { background: #3b6d11; }
.iva-item-label { font-size: 11.5px; color: var(--text-secondary); display: flex; align-items: center; margin-bottom: 6px; }
.iva-item-valor { font-size: 18px; font-weight: 700; color: var(--mide-black); }
.iva-item-sub { font-size: 10.5px; color: var(--text-secondary); margin-top: 2px; }
@media (max-width: 640px) { .kpi-grid, .iva-desglose { grid-template-columns: 1fr; } }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 320px;
  background: var(--mide-white);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 2rem;
}

.login-card input {
  width: 100%;
  padding: 10px;
  margin: 4px 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sidebar {
  width: 220px;
  background: var(--mide-dark);
  padding: 1rem 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 0.75rem;
  color: #fff;
  font-weight: 600;
}

.sidebar-desktop a.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 1rem;
  font-size: 14px;
  color: var(--mide-gray);
}

.sidebar-desktop a.nav-item.active,
.sidebar-desktop a.nav-item:hover {
  background: rgba(200,169,119,0.18);
  color: var(--mide-gold);
}

.campana-btn {
  position: relative; background: none; border: none; color: var(--mide-gray);
  font-size: 18px; cursor: pointer; padding: 4px;
}
.campana-badge {
  position: absolute; top: -4px; right: -6px;
  background: #c0392b; color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 100px; min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 3px;
}
.alertas-panel {
  position: absolute; top: 54px; left: 12px; right: 12px; z-index: 60;
  background: var(--mide-white); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18);
  max-height: 60vh; overflow-y: auto; padding: 10px 0;
}
.alertas-panel-titulo { font-size: 12px; font-weight: 700; color: var(--mide-black); text-transform: uppercase; letter-spacing: .04em; padding: 4px 14px 8px; margin: 0; }
.alertas-vacio { font-size: 12.5px; color: var(--text-secondary); padding: 6px 14px 10px; margin: 0; }
.alerta-item { display: flex; align-items: flex-start; gap: 8px; padding: 9px 14px; font-size: 12.5px; color: var(--mide-black); text-decoration: none; line-height: 1.4; }
.alerta-item:hover { background: var(--mide-gray); }
.alerta-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.alerta-alta .alerta-dot { background: #c0392b; }
.alerta-media .alerta-dot { background: #d99a2b; }

/* Menú de usuario (avatar + nombre) anclado abajo del sidebar en escritorio */
.sidebar-desktop { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.usuario-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; border: none; cursor: pointer;
  background: rgba(255,255,255,0.04); padding: 12px 1rem; margin-top: auto;
  border-top: 1px solid rgba(255,255,255,0.12); color: #fff; text-align: left;
}
.usuario-btn:hover { background: rgba(255,255,255,0.08); }
.usuario-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--mide-gold); color: var(--mide-black);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.usuario-btn-info { flex: 1; min-width: 0; }
.usuario-btn-nombre { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-btn-rol { font-size: 11px; color: var(--mide-gray); text-transform: capitalize; }
.usuario-btn i.ti-chevron-up { color: var(--mide-gray); font-size: 16px; }
.usuario-panel {
  position: absolute; bottom: 64px; left: 12px; width: 220px; z-index: 60;
  background: var(--mide-white); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18);
  padding: 6px 0; font-size: 13px;
}
.usuario-panel a, .usuario-panel button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 14px; color: var(--mide-black);
  text-decoration: none; background: none; border: none; font-size: 13px; cursor: pointer; text-align: left;
}
.usuario-panel a:hover, .usuario-panel button:hover { background: var(--mide-gray); }
.usuario-panel .badge-mini { margin-left: auto; background: #c0392b; color: #fff; font-size: 10px; font-weight: 700; border-radius: 100px; min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 3px; }
.usuario-panel hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.usuario-avatar-mobile {
  position: relative;
  width: 28px; height: 28px; border-radius: 50%; background: var(--mide-gold); color: var(--mide-black);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11.5px; border: none; cursor: pointer;
}
.topbar-mobile-right { display: flex; align-items: center; gap: 12px; }

/* La barra inferior, el panel "Mas", y la franja superior de alertas solo existen en celular */
.tabbar-mobile, .mas-overlay, .topbar-mobile { display: none; }

/* min-width:0: sin esto una tabla ancha (Finanzas en un mes con muchos datos)
   estira .content y TODA la pagina se recorre a la derecha, sidebar incluido. */
.content { flex: 1; min-width: 0; padding: 1.5rem 2rem; }

/* ===== Responsivo: tablets y celulares ===== */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: relative; height: auto; padding: 0; overflow: visible; }
  .sidebar .logo { display: none; }

  /* En celular, la lista completa de escritorio se oculta -- la reemplaza
     la barra inferior de pulgar + el panel "Mas". */
  .sidebar-desktop { display: none; }

  .topbar-mobile {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--mide-dark); color: var(--mide-white);
    padding: 12px 16px;
  }
  .topbar-mobile-titulo { font-weight: 700; font-size: 15px; letter-spacing: .02em; }

  /* En celular el menu de usuario se abre bajo el topbar, no abajo del todo */
  .usuario-panel { position: absolute; top: 54px; bottom: auto; left: auto; right: 12px; width: 220px; }

  .tabbar-mobile {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 40;
    background: var(--mide-dark);
    border-top: 1px solid rgba(255,255,255,0.12);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab-mobile-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--mide-gray);
    font-size: 10.5px; padding: 6px 2px; text-decoration: none;
  }
  .tab-mobile-item i { font-size: 20px; }
  .tab-mobile-item.active { color: var(--mide-gold); }

  .mas-overlay {
    display: flex;
    align-items: flex-end;
    position: fixed; inset: 0; z-index: 50;
    background: rgba(0,0,0,0.4);
  }
  .mas-panel {
    background: var(--mide-white);
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .mas-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .mas-panel-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
  .mas-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-decoration: none; color: var(--mide-black); font-size: 11.5px; text-align: center;
  }
  .mas-item i { font-size: 22px; color: var(--mide-taupe); }

  /* Deja aire abajo para que la barra fija no tape el ultimo boton/fila de cada pagina */
  .content { padding: 1rem 1rem calc(1rem + 64px); }
  .card { overflow-x: auto; }
  table { font-size: 12px; }
}
@media (max-width: 640px) {
  /* La mayoria de las cuadriculas de tarjetas en la plataforma usan grid-template-columns
     inline (2, 3 o 4 columnas). En pantallas de celular las forzamos a 1 columna. */
  div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

/* ===== Vista de gastos por mes (includes/vista_gastos_mes.php) =====
   Componente compartido por gastos_fijos, egresos de proyecto y
   gastos_administrativos — un solo estilo, tres módulos. ===== */
.mes-selector { margin-bottom: 18px; }
.anio-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.meses-track { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.mes-pill {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 14px; border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--mide-white);
  cursor: pointer; min-width: 64px;
}
.mes-pill .nombre { font-size: 12px; font-weight: 600; color: var(--mide-black); text-transform: capitalize; }
.mes-pill .monto { font-size: 10.5px; color: var(--text-secondary); }
.mes-pill.activo { background: var(--mide-dark); border-color: var(--mide-dark); }
.mes-pill.activo .nombre, .mes-pill.activo .monto { color: var(--mide-white); }
.mes-pill.vacio { opacity: .4; cursor: default; }
.mes-pill.vacio .monto { visibility: hidden; }
.resumen-mes {
  display: flex; gap: 14px; flex-wrap: wrap;
  background: var(--mide-dark); color: var(--mide-white);
  border-radius: 12px; padding: 16px 18px; margin-bottom: 16px;
}
.resumen-item { flex: 1; min-width: 120px; }
.resumen-label { font-size: 11px; opacity: .65; }
.resumen-valor { font-size: 20px; font-weight: 700; margin-top: 2px; }
.filtro-row { display: flex; gap: 8px; margin-bottom: 14px; }
.proy-tag { font-size: 10.5px; background: var(--mide-gray); color: var(--mide-black); padding: 2px 8px; border-radius: 100px; }
.sin-proy { font-size: 10.5px; color: #aaa; }

/* Icono giratorio para botones en estado "Guardando..." / "Enviando..." (evita doble clic) */
@keyframes girar { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.ti-loader-2 { display: inline-block; animation: girar 0.8s linear infinite; }

/* Patrón de pestañas reutilizable (ya usado en proyecto_detalle.php) */
.tabbtn { border: none; background: transparent; padding: 8px 14px; font-size: 13px; cursor: pointer; border-radius: 8px; color: var(--text-secondary); white-space: nowrap; }
.tabbtn.activo { background: var(--mide-dark); color: #fff; }

/* Numeracion automatica de filas -- solo cuenta las visibles (respeta x-show/display:none) */
.tabla-numerada { counter-reset: fila-num; }
.tabla-numerada .fila-empleado { counter-increment: fila-num; }
.tabla-numerada .fila-num::before { content: counter(fila-num); color: var(--text-secondary); font-size: 12.5px; }


