/* ContaSys - Estilo Responsive */
/* ============ IDENTIDAD DE MARCA (variables) ============ */
:root {
    --primary-navy: #616265;
    --primary-blue: #616265;
    --primary-blue-hover: #4e4e50;
    --secondary-blue: #fd7c0a;
    --background: #fcf7f2;
    --surface: #ffffff;
    --border: #d4cce8;
    --text-primary: #2e2e2e;
    --text-secondary: #6f6f6f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; }
body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: #fcf7f2;
    color: #2e2e2e;
    font-size: 14px;
}
/* ============ TOPBAR ============ */
.topbar {
    background: linear-gradient(135deg, #fd7c0a 0%, #616265 100%);
    color: #fff;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    flex-wrap: wrap;
    gap: 10px;
    position: relative;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar .logo {
    font-size: 17px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    flex-shrink: 0;
}
.empresa-info, .usuario-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
}
.empresa-nombre {
    background: rgba(255,255,255,.15);
    padding: 4px 10px;
    border-radius: 4px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.link-cambiar, .btn-logout {
    font-size: 12px;
    padding: 4px 10px;
    background: rgba(255,255,255,.2);
    border-radius: 4px;
}
.link-cambiar:hover, .btn-logout:hover { background: rgba(255,255,255,.3); }
.btn-menu {
    display: none;
    background: rgba(255,255,255,.2);
    border: 0;
    color: #fff;
    font-size: 22px;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
}
/* ============ NAVBAR ============ */
.navbar {
    background: #fff;
    padding: 0 18px;
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e4e4e4;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    flex-wrap: wrap;
}
.navbar > a, .navbar .dropdown > span {
    padding: 13px 14px;
    color: #616265;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    display: inline-block;
    user-select: none;
}
.navbar > a:hover, .navbar .dropdown:hover > span,
.navbar > a:focus, .navbar .dropdown.open > span { background: #fff4ea; }
.dropdown { position: relative; }
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    min-width: 220px;
    z-index: 100;
    border-radius: 0 0 6px 6px;
}
.dropdown:hover .dropdown-content,
.dropdown.open .dropdown-content { display: block; }
.dropdown-content a {
    display: block;
    padding: 10px 16px;
    color: #2e2e2e;
    text-decoration: none;
}
.dropdown-content a:hover { background: #fff4ea; color: #616265; }
/* ============ CONTENEDOR ============ */
.contenedor {
    padding: 18px;
    max-width: 1400px;
    margin: 0 auto;
}
/* ============ TARJETAS ============ */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    margin-bottom: 16px;
}
.card h2 { color: #616265; margin-bottom: 14px; font-size: 18px; }
.card h3 { color: #616265; margin-bottom: 12px; font-size: 16px; }
/* ============ FORMS ============ */
.form-grupo { margin-bottom: 12px; }
.form-grupo label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    color: #4e4e4e;
    font-size: 13px;
}
.form-grupo input,
.form-grupo select,
.form-grupo textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e8d5c4;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.form-grupo input:focus, .form-grupo select:focus, .form-grupo textarea:focus {
    border-color: #fd7c0a;
    outline: none;
    box-shadow: 0 0 0 2px rgba(108,63,200,.15);
}
.form-fila {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.form-fila .form-grupo {
    flex: 1;
    min-width: 180px;
}
/* ============ BOTONES ============ */
.btn {
    display: inline-block;
    padding: 10px 18px;
    background: linear-gradient(135deg, #fd7c0a, #616265);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: transform .1s;
    font-family: inherit;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(70,38,160,.25); }
.btn-sec { background: #fff; color: #616265; border: 1px solid #616265; }
.btn-sec:hover { background: #fff4ea; }
.btn-rojo { background: linear-gradient(135deg,#d63b50,#a52a3c); }
.btn-verde { background: linear-gradient(135deg,#27ae60,#1e8c4a); }
.btn-mini { padding: 5px 12px; font-size: 12px; }
/* ============ TABLAS ============ */
.tabla {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    display: table;
}
.tabla th {
    background: #616265;
    color: #fff;
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 12.5px;
    white-space: nowrap;
}
.tabla td {
    padding: 9px 12px;
    border-bottom: 1px solid #eee;
}
.tabla tbody tr:nth-child(even) { background: #fffbf7; }
.tabla tbody tr:hover { background: #fff4ea; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla tfoot td {
    background: #fff0e2;
    font-weight: 600;
    color: #616265;
    border-top: 2px solid #616265;
}
/* wrapper para scroll horizontal en móvil */
.card .tabla { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card .tabla > thead, .card .tabla > tbody, .card .tabla > tfoot { min-width: 100%; }
/* ============ ALERTAS ============ */
.alerta {
    padding: 12px 16px;
    border-radius: 5px;
    margin-bottom: 14px;
    border-left: 4px solid;
    font-size: 14px;
}
.alerta-info { background: #e7f0fd; border-color: #2c6ec4; color: #1a4a8f; }
.alerta-ok { background: #e3f7ec; border-color: #27ae60; color: #1d7c47; }
.alerta-error { background: #fce4e7; border-color: #d63b50; color: #97203a; }
.alerta-warn { background: #fef6e0; border-color: #d99a0b; color: #7a5a08; }
/* ============ LOGIN (dos columnas) ============ */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,#FD7C0A,#515256);
    padding: 20px;
}
.login-box {
    background: #fff;
    padding: 36px 32px;
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.login-logo { text-align: center; margin-bottom: 16px; }
.login-logo img {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 16px rgba(70,38,160,.25);
}
.login-box h1 {
    color: #616265;
    margin-bottom: 6px;
    text-align: center;
    font-size: 26px;
}
.login-sub {
    text-align: center;
    color: #6F6F6F;
    font-size: 14px;
    font-style: italic;
    margin-bottom: 26px;
}
.login-box .form-grupo label { font-size: 14px; }
.login-box .form-grupo input { padding: 13px 14px; font-size: 15px; }
.login-box .btn { padding: 14px; font-size: 16px; margin-top: 8px; }
/* Panel izquierdo: marca */
/* Panel derecho: tarjeta de acceso */
/* ============ DASHBOARD ============ */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stat {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid #fd7c0a;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.stat .label { color: #6f6f6f; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.stat .valor { font-size: 20px; font-weight: 600; color: #616265; margin-top: 5px; }
/* ============ UTILIDADES ============ */
.pie { text-align: center; padding: 16px; color: #888; font-size: 12px; }
.preview-foto { max-width: 200px; border-radius: 6px; margin-top: 10px; border: 1px solid #e8d5c4; }
.right { text-align: right; }
.center { text-align: center; }
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.tag-ok { background: #d8f5e3; color: #1d7c47; }
.tag-mal { background: #fce4e7; color: #97203a; }
.tag-info { background: #e7f0fd; color: #1a4a8f; }
/* ============ RESPONSIVE - TABLET <=900px ============ */
@media (max-width: 900px) {
    .btn-menu { display: inline-block; }
    .navbar {
        display: none;
        flex-direction: column;
        padding: 0;
        width: 100%;
    }
    .navbar.abierto { display: flex; }
    .navbar > a, .navbar .dropdown {
        width: 100%;
        border-bottom: 1px solid #fff4ea;
    }
    .navbar > a, .navbar .dropdown > span {
        padding: 14px 18px;
        display: block;
    }
    .dropdown-content {
        position: static;
        box-shadow: none;
        background: #fffaf6;
        min-width: 100%;
        border-radius: 0;
    }
    .dropdown:hover .dropdown-content { display: none; }
    .dropdown.open .dropdown-content { display: block; }
    .dropdown-content a {
        padding: 12px 30px;
        border-bottom: 1px solid #fff0e2;
    }
}
/* ============ RESPONSIVE - MÓVIL <=640px ============ */
@media (max-width: 640px) {
    body { font-size: 13.5px; }
    .topbar { padding: 10px 14px; gap: 8px; }
    .topbar .logo { font-size: 15px; }
    .logo-img { width: 32px; height: 32px; }
    .empresa-info, .usuario-info { font-size: 12px; }
    .empresa-nombre { max-width: 140px; font-size: 12px; }
    .contenedor { padding: 12px; }
    .card { padding: 14px; }
    .card h2 { font-size: 16px; }
    .card h3 { font-size: 15px; }
    .form-fila { flex-direction: column; gap: 0; }
    .form-fila .form-grupo { min-width: 100%; }
    form .btn { width: 100%; margin-bottom: 8px; }
    .grid-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 10px; }
    .stat { padding: 12px; }
    .stat .valor { font-size: 17px; overflow-wrap: anywhere; }
    .tabla th, .tabla td { padding: 8px 10px; font-size: 12.5px; }
    .flex-between { flex-direction: column; align-items: stretch; }
    .flex-between .btn { width: 100%; }
}
/* ============ RESPONSIVE - PEQUEÑO <=380px ============ */
@media (max-width: 380px) {
    .grid-stats { grid-template-columns: 1fr; }
    .topbar { padding: 8px 12px; }
    .topbar .logo span { display: none; }
}
/* ============ MODO OSCURO ============ */
html.tema-oscuro body {
    background: #1d1d1e;
    color: #f5e9de;
}
html.tema-oscuro .card {
    background: #2e2e2e;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
html.tema-oscuro .card h2,
html.tema-oscuro .card h3,
html.tema-oscuro .stat .valor {
    color: #ffcb9e;
}
html.tema-oscuro .navbar {
    background: #2e2e2e;
    border-bottom-color: #434344;
}
html.tema-oscuro .navbar > a,
html.tema-oscuro .navbar .dropdown > span {
    color: #ffcb9e;
}
html.tema-oscuro .navbar > a:hover,
html.tema-oscuro .navbar .dropdown:hover > span,
html.tema-oscuro .navbar .dropdown.open > span {
    background: #434344;
}
html.tema-oscuro .dropdown-content {
    background: #2e2e2e;
}
html.tema-oscuro .dropdown-content a {
    color: #f5e9de;
}
html.tema-oscuro .dropdown-content a:hover {
    background: #434344;
    color: #ffcb9e;
}
html.tema-oscuro .form-grupo label {
    color: #e0c8b2;
}
html.tema-oscuro .form-grupo input,
html.tema-oscuro .form-grupo select,
html.tema-oscuro .form-grupo textarea {
    background: #1d1d1e;
    color: #f5e9de;
    border-color: #434344;
}
html.tema-oscuro .form-grupo input:focus,
html.tema-oscuro .form-grupo select:focus {
    border-color: #ffcb9e;
}
html.tema-oscuro .tabla {
    background: #2e2e2e;
}
html.tema-oscuro .tabla td {
    border-bottom-color: #434344;
    color: #f5e9de;
}
html.tema-oscuro .tabla tbody tr:nth-child(even) {
    background: #232323;
}
html.tema-oscuro .tabla tbody tr:hover {
    background: #434344;
}
html.tema-oscuro .tabla tfoot td {
    background: #434344;
    color: #ffcb9e;
}
html.tema-oscuro .stat {
    background: #2e2e2e;
    border-left-color: #ffcb9e;
}
html.tema-oscuro .stat .label {
    color: #a2a3a4;
}
html.tema-oscuro .btn-sec {
    background: #2e2e2e;
    color: #ffcb9e;
    border-color: #ffcb9e;
}
html.tema-oscuro .alerta-info { background: #1f2a3d; color: #88b0e8; }
html.tema-oscuro .alerta-ok { background: #1f3a2a; color: #88e8a8; }
html.tema-oscuro .alerta-error { background: #3d1f25; color: #ff97a8; }
html.tema-oscuro .alerta-warn { background: #3d3220; color: #f0c870; }
/* Botón flotante de tema */
.btn-tema {
    background: rgba(255,255,255,.2);
    border: 0;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-tema:hover { background: rgba(255,255,255,.3); }
/* ============ IMPRESIÓN ============ */
/* Columnas y botones de navegación que no deben salir en papel */
@media print {
    .no-print { display: none !important; }
}
/* ============ CUADROS DE DIÁLOGO (MODALES) GENÉRICOS ============ */
/* Patrón reutilizable de "modal con iframe" (ver assets/js/modal_iframe.js).
   Usado en Compras, Bancos, Gastos, Vendedores, Fiscal, Libro Mayor, etc.
   para que las pantallas de creación se abran como cuadro de diálogo en
   vez de navegar a página completa. */
.cs-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.cs-modal-caja {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 1200px;
    height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.cs-modal-caja.cs-modal-angosta { max-width: 640px; height: auto; max-height: 92vh; }
.cs-modal-cerrar {
    display: flex;
    justify-content: flex-end;
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.cs-modal-cerrar button {
    background: none;
    border: 0;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: #888;
}
.cs-modal-caja iframe {
    flex: 1;
    width: 100%;
    border: 0;
}
/* ============ FECHAS dd/mm/aaaa (assets/js/fecha_ddmmaaaa.js) ============ */
input.fecha-visual { cursor: pointer; }
.fecha-cal {
    display: none;
    position: absolute;
    z-index: 4000;
    background: #fff;
    border: 1px solid #e8d5c4;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,.15);
    padding: 10px;
    font-size: 13px;
    user-select: none;
}
.fecha-cal.fecha-cal-abierto { display: block; }
.fecha-cal-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
    color: #616265;
}
.fecha-cal-nav {
    background: #fff4ea;
    color: #616265;
    border: 0;
    border-radius: 5px;
    width: 26px;
    height: 26px;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
}
.fecha-cal-nav:hover { background: #e0d4ff; }
.fecha-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}
.fecha-cal-diaSem {
    color: #9a92ab;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 0;
}
.fecha-cal-dia {
    padding: 6px 0;
    border-radius: 5px;
    cursor: pointer;
    color: #333;
}
.fecha-cal-dia:hover { background: #fff4ea; }
.fecha-cal-hoy { font-weight: 700; color: #616265; }
.fecha-cal-sel { background: #616265; color: #fff; }
.fecha-cal-sel:hover { background: #616265; }
.fecha-cal-pie {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}
.fecha-cal-pie button {
    background: none;
    border: 0;
    color: #fd7c0a;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
}
.fecha-cal-pie button:hover { text-decoration: underline; }
html.tema-oscuro .fecha-cal {
    background: #2e2e2e;
    border-color: #434344;
}
html.tema-oscuro .fecha-cal-nav {
    background: #434344;
    color: #ffcb9e;
}
html.tema-oscuro .fecha-cal-nav:hover { background: #4a3f66; }
html.tema-oscuro .fecha-cal-dia { color: #f5e9de; }
html.tema-oscuro .fecha-cal-dia:hover { background: #434344; }
html.tema-oscuro .fecha-cal-hoy { color: #ffcb9e; }
html.tema-oscuro .fecha-cal-sel { background: #fd7c0a; color: #fff; }
html.tema-oscuro .fecha-cal-pie { border-top-color: #434344; }
html.tema-oscuro .fecha-cal-pie button { color: #ffcb9e; }
/* ============ ADAPTACIÓN MÓVIL Y TÁCTIL (Entrega A) ============ */
/* El POS y el Restaurante (body.pagina-propia-movil) tienen su propio modo tablet y quedan fuera de estas reglas. */
img, video, canvas, svg { max-width: 100%; }
.contenido, .contenedor, .card { min-width: 0; }
.contenido h1, .contenido h2, .contenido h3, .card h2, .card h3 { overflow-wrap: anywhere; }
/* Contenedor con scroll propio para tablas anchas (lo crea header.php solo en pantallas <= 900px) */
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.tabla-scroll > table { min-width: 100%; }
@media (max-width: 900px) {
    /* Tablas: no se parte el texto de números/fechas y las columnas necesarias se conservan al deslizar */
    .tabla-scroll th, .tabla-scroll td { white-space: nowrap; }
    .tabla th, .tabla td { padding: 10px 10px; }
    /* Botones, filtros y campos cómodos al tacto (sin bloquear el zoom del usuario) */
    body:not(.pagina-propia-movil) .btn,
    body:not(.pagina-propia-movil) button:not(.btn-hamburguesa):not(.btn-topbar-mas):not(.nav-grupo-titulo):not(.btn-tema):not(.fecha-cal-nav),
    body:not(.pagina-propia-movil) input[type="submit"],
    body:not(.pagina-propia-movil) input[type="button"] { min-height: 44px; }
    body:not(.pagina-propia-movil) .btn-mini { min-height: 40px; padding: 8px 14px; }
    body:not(.pagina-propia-movil) .contenido input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
    body:not(.pagina-propia-movil) .contenido select,
    body:not(.pagina-propia-movil) .contenido textarea { min-height: 44px; font-size: 16px; max-width: 100%; }
    body:not(.pagina-propia-movil) .contenido input[type="checkbox"],
    body:not(.pagina-propia-movil) .contenido input[type="radio"] { width: 20px; height: 20px; }
    /* Formularios en línea y barras de filtros: se apilan y no se salen del ancho */
    .form-fila .form-grupo { min-width: min(100%, 180px); }
    .flex-between { gap: 8px; }
    .contenido form[style*="display:flex"], .contenido form[style*="display: flex"] { flex-wrap: wrap; }
    /* Ventanas (modales con iframe): pantalla completa y botón de cerrar táctil */
    .cs-modal-overlay { padding: 0; }
    .cs-modal-caja { max-width: 100%; height: 100vh; height: 100dvh; border-radius: 0; }
    .cs-modal-caja.cs-modal-angosta { height: auto; max-height: 100dvh; }
    .cs-modal-cerrar button { min-width: 44px; min-height: 44px; font-size: 30px; }
}
@media (max-width: 640px) {
    .contenedor, .contenido { padding: 12px; }
    .form-fila .form-grupo { min-width: 100%; }
}
@media print {
    .tabla-scroll { overflow: visible; }
}
@media (max-width: 640px) {
    .login-wrap { padding: 0; align-items: stretch; }
    .login-box {
        padding: 40px 28px;
        max-width: 100%;
        width: 100%;
        min-height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        box-shadow: none;
    }
    .login-logo img { width: 140px; height: 140px; }
    .login-box h1 { font-size: 26px; }
    .login-sub { font-size: 15px; margin-bottom: 30px; }
    .login-box .form-grupo input { padding: 15px 16px; font-size: 16px; }
    .login-box .btn { padding: 16px; font-size: 17px; }
}
