/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --bg-app: #f5f5f7;
    --bg-panel: #ffffff;
    --text-main: #1d1d1f;
    --text-muted: #86868b;
    --border: #d2d2d7;
    --accent: #0071e3;
    --row-hover: #f5f8ff;
    
    /* Alturas */
    --header-height: 50px;
    --row-height: 32px; /* Un poco más compacta */
}

* { box-sizing: border-box; outline: none; }

body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-size: 11px; /* Letra ideal para datos densos */
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Sin scroll en el body */
    display: flex;
    flex-direction: column;
}

/* =========================================
   2. HEADER
   ========================================= */
header {
    height: var(--header-height);
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

header h1 { font-size: 14px; font-weight: 600; color: #000; margin: 0; }
.header-btn { background: transparent; border: none; color: var(--accent); cursor: pointer; font-weight: 500; }

/* =========================================
   3. CONTENEDOR PRINCIPAL
   ========================================= */
.container {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%; /* Asegura ancho total */
}

/* =========================================
   4. MENÚ & VISTAS
   ========================================= */
.menu-view { display: flex; justify-content: center; align-items: center; height: 100%; width: 100%; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; width: 100%; max-width: 1000px; }

.menu-card {
    background: var(--bg-panel); border-radius: 12px; padding: 30px; text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); cursor: pointer; transition: 0.2s; border: 1px solid rgba(0,0,0,0.05);
}
.menu-card:hover { transform: translateY(-5px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.menu-icon { font-size: 36px; display: block; margin-bottom: 10px; }

.section-view { display: none; flex-direction: column; height: 100%; width: 100%; }
.section-view.active { display: flex; }

/* Controles Superiores */
.controls-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-shrink: 0; }

.tabs-group { background: #e3e3e8; padding: 3px; border-radius: 6px; display: inline-flex; }
.tab-btn { padding: 4px 12px; border: none; background: transparent; border-radius: 4px; font-size: 11px; font-weight: 500; color: #555; cursor: pointer; }
.tab-btn.active { background: #fff; color: #000; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.action-btn { background: #1d1d1f; color: white; border: none; padding: 5px 14px; border-radius: 6px; font-size: 11px; cursor: pointer; }
.btn-green { background: #34c759; }

/* =========================================
   5. LA TABLA (AJUSTE AUTOMÁTICO AL 100%)
   ========================================= */
.table-frame {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    flex: 1; /* Ocupa todo el alto disponible */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* El scroll va dentro */
    width: 100%; /* Asegura que el marco use toda la pantalla */
}

/* Contenedor escroleable */
.table-scroll {
    flex: 1;
    overflow: auto; /* Scroll aquí */
    width: 100%;
}

.apple-table {
    width: 100%; /* FUERZA EL 100% DEL ANCHO */
    min-width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* DISTRIBUCIÓN FIJA */
    border-spacing: 0;
}

/* --- HEADER DE TABLA --- */
.apple-table thead th {
    position: sticky; top: 0; z-index: 10;
    background: #f5f5f7;
    text-align: left;
    padding: 8px 6px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid rgba(0,0,0,0.05);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- CUERPO DE TABLA --- */
.apple-table tbody tr {
    height: var(--row-height);
    border-bottom: 1px solid #f0f0f0;
}
.apple-table tbody tr:hover { background-color: var(--row-hover); }

.apple-table tbody td {
    padding: 0;
    border-right: 1px solid transparent;
    vertical-align: middle;
}
.apple-table tbody tr:hover td { border-right-color: #f0f0f0; }

/* --- INPUTS --- */
.apple-table input, .apple-table select {
    width: 100%;
    height: var(--row-height);
    border: none;
    background: transparent;
    padding: 0 6px;
    font-family: inherit;
    font-size: 11px;
    color: var(--text-main);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.apple-table input:focus, .apple-table select:focus {
    background: #fff;
    box-shadow: inset 0 0 0 2px var(--accent);
}

/* =========================================
   6. ANCHOS DE COLUMNAS (Clave para "Concepto")
   ========================================= */

/* Definimos ancho FIJO solo para lo que NO es concepto */
.w-xs { width: 35px; text-align: center; }    /* Checkbox */
.w-sm { width: 85px; }                        /* Fechas, Folios cortos */
.w-md { width: 130px; }                       /* Nombres, RFC, Estado */
.w-money { width: 95px; text-align: right; }  /* Dinero */

/* Alineación de inputs de dinero */
.w-money input { text-align: right; }
.w-xs input { text-align: center; }

/* IMPORTANTE:
   Las columnas <th> que NO tengan clase (como Concepto en tu HTML),
   automáticamente se estirarán para llenar todo el espacio sobrante
   gracias a table-layout: fixed y width: 100%.
*/

/* =========================================
   7. FOOTER
   ========================================= */
.pagination-footer {
    background: #fafafa;
    border-top: 1px solid var(--border);
    padding: 6px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.page-btn {
    background: #fff; border: 1px solid var(--border); padding: 2px 8px;
    border-radius: 4px; cursor: pointer; margin-left: 5px;
}