/* ============================================================
   BASE RESET & FONTS
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    background: #f4f6f9;
    color: #222;
    -webkit-text-size-adjust: 100%;
}

/* ============================================================
   LAYOUT — APP SHELL
   ============================================================ */
.fab-app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.fab-header {
    background: #00549c;
    color: #fff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,.25);
}

.fab-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: .5px;
    color: #fff;
    text-decoration: none;
}

.fab-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.fab-btn-logout {
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.5);
    color: #fff;
    border-radius: 6px;
    padding: 0.25rem 0.65rem;
    cursor: pointer;
    font-size: 0.82rem;
}
.fab-btn-logout:hover { background: rgba(255,255,255,.3); }

.fab-main {
    flex: 1;
    padding: 1rem;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   LOGIN
   ============================================================ */
.fab-login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80dvh;
    padding: 1rem;
}

.fab-login-card {
    background: #fff;
    border-radius: 14px;
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,.10);
}

.fab-login-title {
    text-align: center;
    color: #00549c;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.fab-login-sub {
    text-align: center;
    color: #777;
    font-size: 0.9rem;
    margin-bottom: 1.75rem;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.fab-form-wrap {
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
}

.fab-form-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #00549c;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e8eef5;
}

.fab-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.fab-field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.fab-input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    border: 1.5px solid #ccd5df;
    border-radius: 8px;
    background: #fff;
    color: #222;
    appearance: auto;
    transition: border-color .15s;
}
.fab-input:focus {
    outline: none;
    border-color: #00549c;
    box-shadow: 0 0 0 3px rgba(0,84,156,.15);
}

.fab-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.fab-btn-primary {
    display: block;
    width: 100%;
    padding: 0.85rem;
    margin-top: 1.25rem;
    background: #00549c;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}
.fab-btn-primary:hover:not(:disabled) { background: #003f78; }
.fab-btn-primary:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
   FEEDBACK MESSAGES
   ============================================================ */
.fab-error {
    background: #fff0f0;
    border: 1px solid #f5b3b3;
    color: #c0000c;
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.fab-ok {
    background: #f0fff4;
    border: 1px solid #9be3b3;
    color: #166c35;
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.fab-loading {
    text-align: center;
    color: #00549c;
    font-size: 0.95rem;
    padding: 2rem;
}

/* ============================================================
   BLAZOR ERROR UI
   ============================================================ */
#blazor-error-ui {
    background: #b32121;
    color: white;
    padding: 0.75rem 1rem;
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 999;
    font-size: 0.9rem;
}
#blazor-error-ui a.reload { color: #ffe; text-decoration: underline; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; font-size: 1.1rem; }

/* ============================================================
   SELECTOR DE CENTRO
   ============================================================ */
.fab-btn-centro {
    display: block;
    width: 100%;
    padding: 0.85rem;
    background: #fff;
    color: #00549c;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid #dde3ea;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    text-align: center;
}
.fab-btn-centro:hover {
    border-color: #00549c;
    box-shadow: 0 4px 12px rgba(0,84,156,.15);
}

/* ============================================================
   MENU INICIO
   ============================================================ */
.fab-menu-wrap {
    padding: 1rem 0;
    text-align: center;
}
.fab-menu-bienvenida {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 0.25rem;
}
.fab-menu-sub {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 1.5rem;
}
.fab-menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.fab-menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 2px solid #dde3ea;
    border-radius: 14px;
    padding: 1.5rem 1rem;
    text-decoration: none;
    color: #00549c;
    transition: border-color .15s, box-shadow .15s;
    gap: 0.5rem;
}
.fab-menu-card:hover {
    border-color: #00549c;
    box-shadow: 0 4px 12px rgba(0,84,156,.15);
}
.fab-menu-icon { font-size: 2rem; }
.fab-menu-label { font-size: 0.85rem; font-weight: 600; text-align: center; }

/* ============================================================
   REGISTRO ACUMULATIVO
   ============================================================ */
.fab-seccion-titulo {
    font-size: 0.85rem;
    font-weight: 700;
    color: #00549c;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 1.25rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e8eef5;
}

.fab-ultimos {
    background: #f5f8fc;
    border: 1px solid #dde3ea;
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}
.fab-ultimos-titulo {
    font-size: 0.8rem;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 0.6rem;
}
.fab-ultimos-vacio { font-size: 0.85rem; color: #999; }
.fab-loading-sm { font-size: 0.85rem; color: #00549c; }

.fab-registro-card {
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
}
.fab-registro-card:last-child { margin-bottom: 0; }
.fab-registro-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
}
.fab-registro-fecha { font-weight: 700; color: #00549c; }
.fab-registro-turno {
    background: #e8f0fb;
    color: #00549c;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.75rem;
}
.fab-registro-edu { color: #666; font-size: 0.78rem; }
.fab-registro-hechos { color: #333; line-height: 1.5; }

.fab-notas-titulo {
    font-size: 0.85rem;
    font-weight: 700;
    color: #00549c;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin: 1rem 0 0.5rem;
}
.fab-notas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.fab-nota-item { display: flex; flex-direction: column; gap: 0.25rem; }
.fab-nota-label { font-size: 0.75rem; font-weight: 600; color: #555; }
.fab-nota-select { padding: 0.5rem; }

.fab-field-check { flex-direction: row; align-items: center; gap: 0.75rem; margin-top: 0.5rem; }
.fab-check-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.95rem; }
.fab-checkbox { width: 20px; height: 20px; cursor: pointer; }
.fab-trasvase-aviso {
    font-size: 0.78rem;
    color: #c07000;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
    margin-top: 0.4rem;
}

/* ============================================================
   VISITAS / SALIDAS / LLAMADAS
   ============================================================ */
.fab-visita-activa {
    background: #fff8e1;
    border: 1.5px solid #ffc107;
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: box-shadow .15s;
}
.fab-visita-activa:hover { box-shadow: 0 3px 10px rgba(255,193,7,.35); }
.fab-va-nombre { font-weight: 700; color: #333; font-size: 0.95rem; margin-bottom: 0.3rem; }
.fab-va-info { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; font-size: 0.78rem; color: #666; }
.fab-va-supervisor { color: #00549c; font-weight: 600; }
.fab-va-hechos { font-size: 0.78rem; color: #555; margin-top: 0.35rem; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.fab-tipo-grupo { display: flex; gap: 0.5rem; }
.fab-tipo-btn {
    flex: 1;
    padding: 0.55rem;
    border: 1.5px solid #ccd5df;
    border-radius: 8px;
    background: #fff;
    color: #555;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.fab-tipo-btn.activo { background: #00549c; color: #fff; border-color: #00549c; }

.fab-menores-lista {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 220px;
    overflow-y: auto;
    border: 1.5px solid #ccd5df;
    border-radius: 8px;
    padding: 0.5rem;
}
.fab-menor-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background .1s;
}
.fab-menor-check:hover { background: #f0f4fa; }
.fab-menor-check.seleccionado { background: #e8f0fb; font-weight: 600; color: #00549c; }

.fab-visita-banner {
    background: #e8f5e9;
    border: 1.5px solid #a5d6a7;
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #166c35;
    margin-bottom: 1rem;
}
.fab-menor-tag {
    display: inline-block;
    background: #e8f0fb;
    color: #00549c;
    border-radius: 20px;
    padding: 0.2rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 600;
    margin: 0.15rem;
}
.fab-dinero-fila {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 0.75rem;
}
.fab-dinero-nombre { font-size: 0.88rem; color: #333; flex: 1; }
.fab-dinero-input { width: 90px; padding: 0.4rem 0.5rem; font-size: 0.95rem; text-align: right; }

/* Logo en login */
.fab-login-logo { display: block; max-width: 180px; margin: 0 auto 0.75rem; }
/* Logo en header */
.fab-header-logo { height: 28px; vertical-align: middle; }

/* ============================================================
   CUADRANTE DE MEDICACIÓN
   ============================================================ */
.fab-cuad-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 0.5rem 2rem;
    max-width: 100%;
}
.fab-cuad-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0 0.25rem;
}
.fab-cuad-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #00549c;
}
.fab-cuad-controles {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.fab-cuad-casa-wrap { margin: 0; }
.fab-cuad-semana-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.fab-cuad-nav-btn {
    padding: 0.4rem 0.75rem;
    border: 1.5px solid #ccd5df;
    border-radius: 7px;
    background: #fff;
    color: #333;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.fab-cuad-nav-btn:hover { background: #f0f4fa; }
.fab-cuad-hoy { background: #00549c; color: #fff; border-color: #00549c; }
.fab-cuad-hoy:hover { background: #003f78; }
.fab-cuad-semana-label {
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #444;
}
.fab-cuad-loading, .fab-cuad-vacio {
    text-align: center;
    color: #888;
    padding: 2rem 0;
    font-size: 0.9rem;
}

/* Tabla */
.fab-cuad-tabla-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1.5px solid #ccd5df;
}
.fab-cuad-tabla {
    border-collapse: collapse;
    width: 100%;
    min-width: 600px;
    font-size: 0.8rem;
}
.fab-cuad-tabla thead tr {
    background: #f0f4fa;
}
.fab-cuad-th-fijo {
    padding: 0.5rem 0.6rem;
    border: 1px solid #dde4ef;
    text-align: left;
    font-weight: 700;
    color: #333;
    white-space: nowrap;
}
.fab-cuad-th-dia {
    padding: 0.4rem 0.5rem;
    border: 1px solid #dde4ef;
    text-align: center;
    font-weight: 700;
    color: #00549c;
    font-size: 0.75rem;
    min-width: 80px;
}
.fab-cuad-th-fecha { font-weight: 400; font-size: 0.7rem; color: #666; }
.fab-cuad-hoy-col { background: #fff8e1 !important; }
.fab-cuad-td-texto {
    padding: 0.45rem 0.6rem;
    border: 1px solid #eef0f5;
    color: #222;
    white-space: normal;
}
.fab-cuad-td-dosis {
    padding: 0.45rem 0.6rem;
    border: 1px solid #eef0f5;
    color: #555;
    white-space: normal;
}
.fab-cuad-td-toma {
    padding: 0.45rem 0.3rem;
    border: 1px solid #eef0f5;
    text-align: center;
    font-weight: 700;
    color: #1b7a3e;
    background: #f0faf4;
    letter-spacing: 0.5px;
}
.fab-cuad-td-fin {
    padding: 0.45rem 0.3rem;
    border: 1px solid #eef0f5;
    text-align: center;
    font-weight: 700;
    color: #c07000;
    background: #fff8e1;
    font-size: 0.72rem;
}
.fab-cuad-td-nodía {
    padding: 0.45rem 0.3rem;
    border: 1px solid #eef0f5;
    text-align: center;
    color: #bbb;
}
.fab-cuad-td-vacio {
    padding: 0.45rem 0.3rem;
    border: 1px solid #eef0f5;
    background: #f8f8f8;
}

/* Footer */
.fab-cuad-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.25rem;
}
.fab-cuad-leyenda {
    font-size: 0.78rem;
    color: #666;
}
.fab-cuad-print-btn { font-size: 0.85rem; padding: 0.45rem 0.9rem; }

/* Ocultar controles al imprimir y mostrar tabla completa */
@media print {
    .fab-cuad-header, .fab-cuad-controles, .fab-cuad-footer, .fab-back-btn { display: none !important; }
    .fab-cuad-tabla-wrap { border: none; overflow: visible; }
    .fab-cuad-tabla { min-width: unset; font-size: 9pt; }
}

/* ============================================================
   HUCHA / DINERO DE BOLSILLO
   ============================================================ */
.fab-hucha-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 560px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}
.fab-hucha-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0 0.25rem;
}
.fab-hucha-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #00549c;
}
.fab-hucha-loading {
    text-align: center;
    color: #888;
    padding: 2rem 0;
}
.fab-hucha-search-wrap { width: 100%; }
.fab-hucha-search { width: 100%; box-sizing: border-box; }

/* Lista de saldos */
.fab-hucha-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 280px;
    overflow-y: auto;
    border: 1.5px solid #ccd5df;
    border-radius: 10px;
    padding: 0.5rem;
    background: #fafbfc;
}
.fab-hucha-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    cursor: pointer;
    transition: all .15s;
}
.fab-hucha-card:hover { background: #f0f4fa; border-color: #a0b8d4; }
.fab-hucha-card--sel { background: #e8f0fb; border-color: #00549c; }
.fab-hucha-card-nombre { font-size: 0.92rem; color: #222; font-weight: 600; }
.fab-hucha-card-saldo { font-size: 0.97rem; font-weight: 700; }

/* Colores pos/neg reutilizables */
.pos { color: #1b7a3e; }
.neg { color: #c0392b; }

/* Panel de detalle */
.fab-hucha-detalle {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #fff;
    border: 1.5px solid #ccd5df;
    border-radius: 12px;
    padding: 1rem;
}
.fab-hucha-saldo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e8eef5;
}
.fab-hucha-saldo-nombre { font-size: 1rem; font-weight: 700; color: #333; }
.fab-hucha-saldo-importe { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.fab-hucha-saldo-label { font-size: 0.78rem; color: #888; }

/* Formulario */
.fab-hucha-form { display: flex; flex-direction: column; gap: 0.6rem; }
.fab-hucha-tipo-wrap { display: flex; gap: 0.5rem; }
.fab-hucha-tipo-btn {
    flex: 1;
    padding: 0.6rem;
    border: 1.5px solid #ccd5df;
    border-radius: 8px;
    background: #fff;
    color: #555;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
}
.fab-hucha-tipo-btn.active-ing { background: #e8f5e9; color: #1b7a3e; border-color: #4caf50; }
.fab-hucha-tipo-btn.active-ret { background: #ffebee; color: #c0392b; border-color: #ef9a9a; }
.fab-hucha-obs { resize: vertical; min-height: 52px; }
.fab-hucha-guardar { width: 100%; margin-top: 0.25rem; }

/* Historial */
.fab-hucha-hist-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding-top: 0.25rem;
}
.fab-hucha-hist {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.4rem;
}
.fab-hucha-hist-row {
    display: grid;
    grid-template-columns: 70px 1fr 70px 70px;
    gap: 0.4rem;
    align-items: center;
    padding: 0.35rem 0.4rem;
    border-radius: 6px;
    font-size: 0.82rem;
    background: #fafbfc;
    border: 1px solid #f0f0f0;
}
.fab-hucha-hist-fecha { color: #888; font-size: 0.78rem; }
.fab-hucha-hist-concepto { color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fab-hucha-hist-imp { font-weight: 700; text-align: right; }
.fab-hucha-hist-saldo { color: #555; text-align: right; font-size: 0.78rem; }
.fab-hucha-hist-vacio { text-align: center; color: #aaa; font-size: 0.85rem; padding: 0.75rem 0; }
.fab-hucha-hist-row { cursor: pointer; transition: background .12s; }
.fab-hucha-hist-row:hover { background: #f0f4fa; }
.fab-hucha-hist-row--sel { background: #e8f0fb; border-color: #a0b8d4; }

/* Panel detalle movimiento */
.fab-hucha-mov-detalle {
    position: relative;
    background: #f8faff;
    border: 1.5px solid #a0b8d4;
    border-radius: 10px;
    padding: 1rem 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.fab-hucha-mov-cerrar {
    position: absolute;
    top: 0.5rem;
    right: 0.6rem;
    background: none;
    border: none;
    font-size: 1rem;
    color: #888;
    cursor: pointer;
    line-height: 1;
}
.fab-hucha-mov-cerrar:hover { color: #333; }
.fab-hucha-mov-fecha { font-size: 0.78rem; color: #888; }
.fab-hucha-mov-importe { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.fab-hucha-mov-concepto { font-size: 0.97rem; font-weight: 600; color: #222; }
.fab-hucha-mov-obs-label { font-size: 0.75rem; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: .04em; margin-top: 0.25rem; }
.fab-hucha-mov-obs { font-size: 0.88rem; color: #444; line-height: 1.45; white-space: pre-wrap; }
