/* ============================================================
   VARIABLES Y RESET
   ============================================================ */
:root {
    --sas-green:      #006633;
    --sas-green-dark: #004d26;
    --sas-green-mid:  #2e7d52;
    --sas-green-light:#e8f5ee;
    --sas-green-pale: #f0faf4;
    --white:          #ffffff;
    --gray-bg:        #f4f5f6;
    --gray-light:     #e8e9eb;
    --gray-mid:       #b0b4ba;
    --gray-dark:      #6b7280;
    --text-main:      #1a2a3a;
    --text-sub:       #4a5568;
    --blue-badge:     #1565c0;
    --blue-light:     #e3f0fb;
    --orange:         #e65100;
    --orange-light:   #fff3e0;
    --red:            #b71c1c;
    --red-hover:      #c62828;
    --shadow-sm:      0 1px 4px rgba(0,0,0,.10);
    --shadow-md:      0 4px 16px rgba(0,0,0,.13);
    --radius:         8px;
    --radius-sm:      5px;
    --font:           Arial, Helvetica, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--gray-bg);
    color: var(--text-main);
    min-height: 100vh;
}
.hidden { display: none !important; }

/* ============================================================
   LOGIN
   ============================================================ */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--sas-green-dark) 0%, var(--sas-green) 60%, var(--sas-green-mid) 100%);
    padding: 1rem;
}
.login-box {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2.25rem 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    min-height: 50px;
}
.logo-ja  { max-height: 46px; max-width: 140px; object-fit: contain; }
.logo-sas { max-height: 46px; max-width: 160px; object-fit: contain; }
.logo-sep { width: 1px; height: 40px; background: var(--gray-light); }
.login-brand-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin-bottom: 1rem;
}
.brand-sas-text {
    background: var(--sas-green);
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    padding: .2rem .6rem;
    border-radius: 4px;
    letter-spacing: .05em;
}
.brand-sas-full { font-size: .75rem; color: var(--gray-dark); }
.login-box h1 {
    font-size: 1.35rem;
    color: var(--sas-green-dark);
    font-weight: 700;
    margin-bottom: .3rem;
}
.login-subtitle {
    font-size: .9rem;
    color: var(--gray-dark);
    margin-bottom: 1.75rem;
}
.login-footer {
    margin-top: 1.75rem;
    font-size: .72rem;
    color: var(--gray-mid);
    border-top: 1px solid var(--gray-light);
    padding-top: .9rem;
}

/* ============================================================
   CABECERA
   ============================================================ */
.app-header {
    background: var(--sas-green);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}
.h-left { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.h-logo {
    height: 38px; max-width: 120px; object-fit: contain;
    filter: brightness(0) invert(1); flex-shrink: 0;
}
.h-titles { display: flex; flex-direction: column; min-width: 0; }
.h-title { font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-sub   { font-size: .73rem; opacity: .85; white-space: nowrap; }
.h-right { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.h-user  {
    font-size: .85rem; font-weight: 600;
    background: rgba(255,255,255,.15);
    padding: .25rem .65rem; border-radius: 20px; white-space: nowrap;
}

/* ============================================================
   NAVEGACIÓN
   ============================================================ */
.app-nav {
    background: var(--sas-green-dark);
    display: flex;
    gap: 2px;
    padding: 0 .75rem;
    overflow-x: auto;
}
.nav-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.75);
    font-family: var(--font);
    font-size: .82rem;
    font-weight: 600;
    padding: .65rem 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: color .15s, border-color .15s, background .15s;
}
.nav-btn:hover { color: white; background: rgba(255,255,255,.07); }
.nav-btn.active { color: white; border-bottom-color: #7de8a8; }

/* ============================================================
   SELECTOR DE MES
   ============================================================ */
.month-bar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .55rem 1.25rem;
    gap: 1rem;
}
.mes-nav-btn {
    background: var(--sas-green-light);
    border: 1px solid var(--sas-green);
    color: var(--sas-green-dark);
    border-radius: var(--radius-sm);
    width: 36px; height: 36px;
    font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s; flex-shrink: 0;
}
.mes-nav-btn:hover { background: var(--sas-green); color: white; }
.mes-info {
    display: flex; align-items: center; gap: .65rem;
    flex: 1; justify-content: center; flex-wrap: wrap;
}
.mes-titulo {
    font-size: 1.05rem; font-weight: 700;
    color: var(--sas-green-dark); text-align: center;
}

/* ============================================================
   CONTENIDO PRINCIPAL
   ============================================================ */
.app-main {
    max-width: 960px;
    margin: 1.25rem auto;
    padding: 0 1rem 2rem;
}

/* ============================================================
   CARDS Y FORMULARIOS
   ============================================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.card h3 {
    font-size: .95rem;
    color: var(--sas-green-dark);
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--sas-green-light);
}
.form-row {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.form-row .fg { flex: 1; min-width: 150px; }
.fg { margin-bottom: .85rem; }
.fg label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: .3rem;
}
.fg input[type="text"],
.fg input[type="date"],
.fg input[type="password"],
.fg select,
#inp-usuario, #inp-password {
    width: 100%;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    font-family: var(--font);
    font-size: .88rem;
    color: var(--text-main);
    background: var(--white);
    transition: border-color .15s;
}
.fg input:focus, .fg select:focus,
#inp-usuario:focus, #inp-password:focus {
    outline: none;
    border-color: var(--sas-green);
    box-shadow: 0 0 0 3px rgba(0,102,51,.12);
}

/* ============================================================
   TABLA DE DESPLAZAMIENTOS
   ============================================================ */
.sec-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: .5rem;
}
.sec-header h2 { font-size: 1.05rem; color: var(--sas-green-dark); }
.sec-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.count-badge {
    background: var(--sas-green);
    color: white;
    font-size: .72rem;
    font-weight: 700;
    padding: .2rem .65rem;
    border-radius: 20px;
    white-space: nowrap;
}

.filters {
    display: flex;
    gap: .75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filters select {
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-sm);
    padding: .4rem .7rem;
    font-family: var(--font);
    font-size: .85rem;
    color: var(--text-main);
    background: var(--white);
    min-width: 200px;
}

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.desp-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: .88rem;
}
.desp-table thead th {
    background: var(--sas-green-light);
    color: var(--sas-green-dark);
    font-weight: 700;
    padding: .7rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--sas-green);
    white-space: nowrap;
}
.desp-table tbody tr {
    border-bottom: 1px solid var(--gray-light);
    transition: background .1s;
}
.desp-table tbody tr:hover { background: var(--gray-bg); }
.desp-table td { padding: .65rem 1rem; vertical-align: middle; }

.td-actions { width: 1%; white-space: nowrap; }
.td-btns    { display: flex; gap: .35rem; }

.btn-edit, .btn-del {
    background: transparent;
    border: 1.5px solid;
    border-radius: var(--radius-sm);
    min-width: 30px; height: 28px;
    padding: 0 .4rem;
    cursor: pointer;
    font-size: .82rem;
    line-height: 1;
    transition: background .12s;
}
.btn-edit { border-color: var(--blue-badge); color: var(--blue-badge); }
.btn-edit:hover { background: var(--blue-light); }
.btn-del  { border-color: var(--red); color: var(--red); }
.btn-del:hover  { background: #fdecea; }

.user-chip {
    display: inline-block;
    background: var(--sas-green-light);
    color: var(--sas-green-dark);
    border-radius: 20px;
    padding: .15rem .6rem;
    font-size: .78rem;
    font-weight: 600;
}

/* ============================================================
   ESTADO VACÍO
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-dark);
}
.empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state h3 { font-size: 1rem; margin-bottom: .5rem; color: var(--text-main); }
.empty-state p  { font-size: .88rem; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    border: none;
    border-radius: var(--radius-sm);
    padding: .55rem 1.1rem;
    font-family: var(--font);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary   { background: var(--sas-green); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--sas-green-dark); }
.btn-secondary { background: var(--gray-light); color: var(--text-main); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-mid); }
.btn-danger    { background: var(--red); color: white; }
.btn-danger:hover:not(:disabled) { background: var(--red-hover); }
.btn-outline-white {
    background: transparent;
    border: 1.5px solid rgba(255,255,255,.7);
    color: white;
}
.btn-outline-white:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.btn-sm   { padding: .35rem .75rem; font-size: .78rem; }
.btn-full { width: 100%; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-ov {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1rem;
}
.modal-box {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.modal-sm { max-width: 400px; }
.modal-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem .9rem;
    border-bottom: 1px solid var(--gray-light);
    flex-shrink: 0;
}
.modal-hdr h3 { font-size: 1rem; color: var(--sas-green-dark); }
.modal-close-btn {
    background: none; border: none;
    font-size: 1.1rem; color: var(--gray-dark);
    cursor: pointer; padding: .2rem .4rem;
    border-radius: 4px; line-height: 1;
    transition: background .1s;
}
.modal-close-btn:hover { background: var(--gray-light); }
.modal-body { padding: 1.1rem 1.4rem; flex: 1; }
.modal-ftr {
    padding: .9rem 1.4rem;
    border-top: 1px solid var(--gray-light);
    display: flex;
    justify-content: flex-end;
    gap: .65rem;
    flex-shrink: 0;
}
.warn-txt {
    background: #fff3e0;
    border-left: 4px solid var(--orange);
    padding: .65rem .9rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: .85rem;
    color: #7a3800;
    margin-bottom: 1rem;
}

/* ============================================================
   SPINNER
   ============================================================ */
.spinner-ov {
    position: fixed; inset: 0;
    background: rgba(255,255,255,.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 900;
}
.spinner-box {
    display: flex; flex-direction: column; align-items: center;
    gap: .75rem; background: white;
    padding: 1.5rem 2rem; border-radius: 10px;
    box-shadow: var(--shadow-md);
}
.spinner {
    width: 36px; height: 36px;
    border: 4px solid var(--sas-green-light);
    border-top-color: var(--sas-green);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.spinner-box span { font-size: .85rem; color: var(--gray-dark); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed; bottom: 1.5rem; left: 50%;
    transform: translateX(-50%);
    background: #1a2a3a; color: white;
    padding: .7rem 1.4rem; border-radius: 8px;
    font-size: .88rem; font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    z-index: 1000;
    white-space: normal; text-align: center;
    max-width: 90vw;
    animation: slideUp .25s ease;
}
.toast-success { background: var(--sas-green-dark); }
.toast-error   { background: var(--red); }
.toast-info    { background: var(--blue-badge); }
@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   ERROR MSG
   ============================================================ */
.error-msg {
    background: #fdecea; color: var(--red);
    border: 1px solid #f5c6c6;
    border-radius: var(--radius-sm);
    padding: .5rem .75rem; font-size: .83rem;
    margin-bottom: .75rem;
}

/* ============================================================
   PIE DE PÁGINA
   ============================================================ */
.app-footer {
    background: var(--sas-green-dark);
    display: flex; align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: .55rem 1.25rem;
    margin-top: 2rem;
}
.footer-logo {
    height: 26px; max-width: 90px; object-fit: contain;
    filter: brightness(0) invert(1); opacity: .75;
}

/* ============================================================
   INFORME PREVIEW (tabla dentro de la app)
   ============================================================ */
.informe-group {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    overflow: hidden;
}
.informe-group-header {
    background: var(--sas-green-light);
    color: var(--sas-green-dark);
    font-weight: 700;
    font-size: .9rem;
    padding: .6rem 1rem;
    border-bottom: 2px solid var(--sas-green);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.informe-group-count {
    font-size: .75rem;
    font-weight: 700;
    background: var(--sas-green);
    color: white;
    padding: .1rem .5rem;
    border-radius: 20px;
}
.informe-row {
    display: flex;
    align-items: center;
    padding: .5rem 1rem;
    border-bottom: 1px solid var(--gray-light);
    font-size: .86rem;
    gap: 1rem;
}
.informe-row:last-child { border-bottom: none; }
.dni-label {
    font-size: .75rem;
    font-weight: 400;
    color: var(--sas-green-mid);
    margin-left: .5rem;
}
.informe-fecha {
    font-weight: 600;
    color: var(--sas-green-dark);
    white-space: nowrap;
    min-width: 110px;
}
.informe-centro { color: var(--text-main); flex: 1; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
    .h-sub  { display: none; }
    .h-user { display: none; }
    .app-main { padding: 0 .6rem 1.5rem; }
    .card { padding: 1rem 1rem; }
    .form-row .fg { min-width: 100%; }
    .desp-table thead th:nth-child(3),
    .desp-table tbody td:nth-child(3) { display: none; }
}
