/* ============================================================================
   Caldén v0.1 - estilos base
   Paleta: verde calden (arbol nativo argentino) + grises calidos
   Resolucion target: 1366x768 (regla feedback_resolucion_default_1366x768)
   ============================================================================ */

:root {
    --c-primary:        #2d6a4f;   /* verde calden oscuro */
    --c-primary-hover:  #1b4332;
    --c-primary-light:  #95d5b2;
    --c-accent:         #e9c46a;   /* dorado calido */
    --c-bg:             #f7f5f1;   /* beige claro */
    --c-bg-card:        #ffffff;
    --c-border:         #d8d3c8;
    --c-text:           #1f2937;
    --c-text-muted:     #6b7280;
    --c-danger:         #c0392b;
    --c-warn:           #d97706;
    --c-ok:             #15803d;

    --radius:  6px;
    --shadow:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.10);

    --topbar-h: 56px;
    --footer-h: 36px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-bg);
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Sin spinner en inputs number (regla feedback_inputs_numero_sin_spinner) */
input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ================= TOPBAR ================= */
.topbar {
    height: var(--topbar-h);
    background: var(--c-primary);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-shadow: var(--shadow);
}
.topbar-brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 18px;
    margin-right: 32px;
}
.topbar-brand i { font-size: 22px; }
/* Logo de la clinica en el topbar (JPG fondo blanco -> chip sobre el verde) */
.topbar-logo {
    height: 34px; width: auto;
    background: #fff;
    padding: 2px 5px;
    border-radius: 4px;
    display: block;
}
.topbar-nav { display: flex; gap: 4px; flex: 1; min-width: 0; }
.topbar-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    color: #fff; opacity: .85;
    border-radius: var(--radius);
    text-decoration: none;
    white-space: nowrap;   /* "Control horario" no se parte en dos renglones */
}
.topbar-link:hover { background: rgba(255,255,255,.12); opacity: 1; text-decoration: none; }
.topbar-toggle {
    display: none;   /* solo visible en mobile (ver breakpoints) */
    align-items: center; justify-content: center;
    background: transparent; border: 0; cursor: pointer;
    color: #fff; font-size: 24px; line-height: 1;
    padding: 4px 8px; border-radius: var(--radius);
}
.topbar-toggle:hover { background: rgba(255,255,255,.12); }
.topbar-user {
    display: flex; align-items: center; gap: 10px;
    font-size: 13px;
}
.badge-rol {
    background: var(--c-accent);
    color: var(--c-text);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

/* ================= BREADCRUMB =================
   Cinta bajo la topbar con el camino hasta la pantalla actual. Es el "volver":
   cada eslabon anterior es un link, el ultimo (la pantalla actual) no. */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 10px 32px 0;
    font-size: 13px;
}
.breadcrumb-link {
    color: var(--c-text-muted);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.breadcrumb-link:hover {
    color: var(--c-primary);
    background: rgba(0,0,0,.04);
    text-decoration: underline;
}
.breadcrumb-sep {
    color: var(--c-border);
    font-size: 11px;
}
.breadcrumb-actual {
    color: var(--c-text);
    font-weight: 600;
    white-space: nowrap;
}
/* Con breadcrumb arriba, el titulo no necesita tanto aire propio */
.breadcrumb + .main-content,
.breadcrumb + .flash-container + .main-content { padding-top: 12px; }

@media (max-width: 720px) {
    .breadcrumb { padding: 8px 16px 0; font-size: 12px; }
}

/* ================= MAIN ================= */
.main-content {
    flex: 1;
    padding: 24px 32px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}
.page-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.page-subtitle { margin: 0 0 24px; color: var(--c-text-muted); }

/* ================= CARDS ================= */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.card-action {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    transition: transform .12s ease, box-shadow .12s ease;
}
.card-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.card-action--disabled {
    opacity: .65;
    cursor: not-allowed;
}
.card-action--disabled:hover {
    transform: none;
    box-shadow: var(--shadow);
}
.card-action i { font-size: 26px; color: var(--c-primary); }
.card-action h2 { margin: 12px 0 4px; font-size: 16px; font-weight: 600; }
.card-action p { margin: 0; color: var(--c-text-muted); font-size: 13px; }
.card-badge {
    position: absolute; top: 12px; right: 12px;
    background: var(--c-bg);
    color: var(--c-text-muted);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--c-border);
}

/* ================= LOGIN =================
   Imagen a sangre + velo + card flotante. El fondo va en un div propio (y no como
   background del main) para poder ponerle el velo encima sin teñir el card. */
.login-main {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    /* Sin min-height propio: body ya es flex column con min-height 100vh y este main
       lleva flex:1, asi que ocupa todo lo que sobra sobre el footer global. Ponerle
       100vh acá empujaba el footer fuera de pantalla y aparecia scroll de mas. */
    overflow: hidden;
}
.login-bg, .login-bg-veil {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.login-bg {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Color de respaldo mientras carga la imagen (o si el archivo no existe) */
    background-color: var(--c-primary-hover);
}
/* Oscurece la foto lo justo para que el card y el pie se lean siempre */
.login-bg-veil {
    background: linear-gradient(115deg, rgba(8,20,16,.78) 0%, rgba(8,20,16,.50) 48%, rgba(8,20,16,.28) 100%);
}
.login-card {
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,.97);
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 12px;
    padding: 36px 32px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 60px rgba(0,0,0,.38);
}
.login-brand {
    text-align: center;
    margin-bottom: 24px;
}
.login-brand i { font-size: 40px; color: var(--c-primary); }
.login-logo { display: block; width: 100%; max-width: 260px; height: auto; margin: 0 auto 4px; border-radius: 3px; }
.login-brand h1 { margin: 8px 0 4px; font-size: 26px; }
.login-subtitle { margin: 0; color: var(--c-text-muted); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .btn-primary { justify-content: center; padding: 10px; font-size: 15px; }
.login-trust {
    display: flex; align-items: center; gap: 6px;
    margin: 20px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--c-border);
    color: var(--c-text-muted);
    font-size: 12px;
    line-height: 1.35;
}
.login-trust i { color: var(--c-ok); font-size: 14px; flex: none; }
.login-footer-text {
    text-align: center;
    margin-top: 10px;
    color: var(--c-text-muted);
    font-size: 12px;
}
/* En pantallas bajas (1366x768) el card no tiene que forzar scroll */
@media (max-height: 780px) {
    .login-main { padding: 16px; }
    .login-card { padding: 24px 28px 18px; }
    .login-logo { max-width: 200px; }
    .login-brand { margin-bottom: 16px; }
}

/* ================= FIELDS ================= */
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--c-text); }
.field input, .field select, .field textarea {
    padding: 8px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(45,106,79,.15);
}
.field--narrow input { max-width: 120px; }
.field--date input { max-width: 140px; }

.password-wrapper { position: relative; }
.password-wrapper input { width: 100%; padding-right: 38px; }
.password-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: transparent; border: 0; padding: 6px 8px;
    color: var(--c-text-muted); cursor: pointer;
    font-size: 16px;
}
.password-toggle:hover { color: var(--c-primary); }

/* ================= BUTTONS ================= */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 14px; font-weight: 500;
    border: 0; cursor: pointer;
    font-family: inherit;
    transition: background .12s;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-secondary { background: #fff; color: var(--c-text); border: 1px solid var(--c-border); }
.btn-secondary:hover { background: var(--c-bg); }
.btn-danger { background: var(--c-danger); color: #fff; }

/* ================= ALERTS ================= */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 13px;
    display: flex; align-items: center; gap: 8px;
}
.alert-error { background: #fdecea; color: var(--c-danger); border: 1px solid #f5c6cb; }
.alert-ok    { background: #ecfdf3; color: var(--c-ok);     border: 1px solid #bbf7d0; }
.alert-warn  { background: #fef3c7; color: var(--c-warn);   border: 1px solid #fde68a; }

/* ================= FOOTER ================= */
.footer-global {
    min-height: var(--footer-h);
    background: #1b4332;
    color: #c8d4cd;
    display: flex; align-items: center; justify-content: center;
    flex-wrap: wrap;
    gap: 6px 10px; font-size: 12px;
    padding: 4px 12px;
}
.footer-global .sep { opacity: .4; }
.footer-global .footer-by { opacity: .7; font-style: italic; }
.footer-global .footer-jst { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.footer-global .footer-jst:hover { text-decoration: underline; }
/* Logos JPG/PNG con fondo blanco: chip blanco para que se vean intencionales sobre el verde */
.footer-global .footer-logo {
    height: 22px;
    width: auto;
    background: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.18);
    display: block;
}

/* ================= PAGE HEADER ================= */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.page-actions { display: flex; gap: 8px; }
.back-link {
    display: inline-flex; align-items: center;
    margin-right: 6px;
    color: var(--c-text-muted);
}
.back-link:hover { color: var(--c-primary); text-decoration: none; }
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
    margin-left: 8px;
    vertical-align: middle;
}
.badge-baja   { background: #fdecea; color: var(--c-danger); border: 1px solid #f5c6cb; }
.badge-ok     { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-info   { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }
.badge-warn   { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-danger { background: #fdecea; color: var(--c-danger); border: 1px solid #f5c6cb; }
.badge-draft  { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }
.muted-small { color: var(--c-text-muted); font-size: 12px; }
.card-pendiente {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-warn);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 10px;
}
.card-pendiente-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; flex-wrap: wrap;
}
.card-pendiente-header h3 { margin: 0; font-size: 16px; }
.card-pendiente-header p { margin: 4px 0 0; }
.card-pendiente-detalle {
    margin: 10px 0;
    padding: 10px 12px;
    background: var(--c-bg);
    border-radius: var(--radius);
    color: var(--c-text);
    font-size: 13px;
}
.card-pendiente-actions {
    display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap;
}

/* ================= FILTERS ================= */
.filters {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 14px;
}
.filters .field { gap: 4px; }
.filters-actions { display: flex; gap: 6px; }
.radio-row { display: flex; gap: 14px; align-items: center; padding-top: 6px; }
.radio-row label, .check-inline { display: inline-flex; align-items: center; gap: 5px; font-weight: 400; cursor: pointer; }
.check-inline { padding-top: 6px; }

/* Barra de progreso (regeneracion de tarjetas en segundo plano) */
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar {
    flex: 1;
    height: 18px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 9px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--c-primary), var(--c-primary-light));
    transition: width .4s ease;
}
.progress-pct { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }

/* Aclaracion chica debajo de un campo (ej. de donde sale el combo de familiar) */
.field-hint { color: var(--c-text-muted); font-size: 12px; font-weight: 400; margin-top: 3px; }
/* Grilla anidada dentro de un campo --wide (alta al vuelo del familiar) */
.form-grid--sub {
    margin: 0; padding: 10px; gap: 10px;
    background: var(--c-bg); border: 1px dashed var(--c-border); border-radius: var(--radius);
}

/* Filtro por color de fila (Control horario). Los tildes van juntos y envuelven
   a dos lineas en 1366x768 antes que empujar el resto de los filtros. */
.check-group { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.check-group .check-inline { padding-top: 0; white-space: nowrap; }
.field--filtro-color { flex: 1 1 340px; min-width: 260px; }
/* Muestra del color que pinta cada fila en la grilla (ver table.grid tbody tr.row-*) */
.dot {
    width: 10px; height: 10px; border-radius: 3px;
    border: 1px solid var(--c-border); flex: none;
}
.dot--warn   { background: #fff8e6; border-color: #e6cf8a; }
.dot--baja   { background: #ffffff; border-color: #c7cdd4; }
.dot--franco { background: #f7f8fa; border-color: #c7cdd4; }

/* Fila de encabezado de grupo (legajo) en la grilla de "todos" */
table.grid tr.grp-row td {
    background: #eef3ef;
    padding: 7px 10px;
    border-top: 2px solid var(--c-border);
    font-size: 13px;
}
table.grid tr.grp-row .grp-sector { color: var(--c-text-muted); font-size: 12px; margin-left: 8px; }

/* Pestañas de vista (Control diario / Ausentismo) dentro del form */
.vista-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); margin-bottom: 16px; }
.vista-tabs .tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}
/* Resumen de ausentismo: chips con totales */
.aus-stats { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 14px; }
.aus-stats .stat {
    display: inline-flex; align-items: baseline; gap: 6px;
    padding: 6px 12px; border-radius: var(--radius);
    background: var(--c-bg); border: 1px solid var(--c-border);
}
.aus-stats .stat b { font-size: 18px; }
.aus-stats .stat.inj b { color: var(--c-danger); }

/* ================= TABLERO DE PRESENTISMO ================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.kpi-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-text-muted);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.kpi-card > i { font-size: 28px; opacity: .9; }
.kpi-card b { display: block; font-size: 26px; line-height: 1.1; }
.kpi-card span { font-size: 12px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .3px; }
.kpi-danger { border-left-color: var(--c-danger); } .kpi-danger > i { color: var(--c-danger); }
.kpi-warn   { border-left-color: #d97706; }        .kpi-warn > i   { color: #d97706; }
.kpi-info   { border-left-color: #2563eb; }        .kpi-info > i   { color: #2563eb; }

.chart-card {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 16px;
}
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--c-text-muted); }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.dot-inj { background: var(--c-danger); }
.dot-tarde { background: #f59e0b; }

/* columnas por día */
.chart-cols { display: flex; align-items: flex-end; gap: 2px; height: 184px; }
.chart-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-stack { width: 72%; max-width: 22px; height: 160px; display: flex; flex-direction: column-reverse;
    border-radius: 3px 3px 0 0; overflow: hidden; background: var(--c-bg); }
.seg { width: 100%; }
.seg-inj { background: var(--c-danger); }
.seg-tarde { background: #f59e0b; }
.chart-col:hover .bar-stack { outline: 2px solid var(--c-primary-light); }
.col-label { font-size: 9px; color: var(--c-text-muted); margin-top: 4px; }

/* fila de 2 tarjetas (sector + top legajos) */
.tablero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* barras horizontales por sector */
.bars-h { display: flex; flex-direction: column; gap: 8px; }
.bar-h-row { display: grid; grid-template-columns: 130px 1fr 78px; align-items: center; gap: 10px; }
.bar-h-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-h-track { background: var(--c-bg); border-radius: 4px; height: 18px; overflow: hidden; }
.bar-h-fill { background: var(--c-danger); height: 100%; border-radius: 4px; min-width: 2px; }
.bar-h-val { font-size: 12px; text-align: right; }
.bar-h-val small { color: var(--c-text-muted); }
@media (max-width: 900px) { .tablero-row { grid-template-columns: 1fr; } }

/* ================= GRID / TABLA ================= */
.table-wrapper {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: auto;
    max-height: calc(100vh - 320px);
}
table.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.grid thead th {
    background: #ecf0eb;
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    color: var(--c-text);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 1;
}
table.grid tbody td {
    padding: 7px 10px;
    border-bottom: 1px solid #eee;
}
/* Orden por columna (tablesort.js): th.sortable-col */
table.grid.sortable thead th.sortable-col {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    white-space: nowrap;
}
table.grid.sortable thead th.sortable-col:hover { color: var(--c-primary); }
table.grid.sortable thead th.sortable-col::after {
    content: '\2195';            /* ↕ */
    margin-left: 6px;
    font-size: 11px;
    opacity: .35;
}
table.grid.sortable thead th.sorted-asc::after  { content: '\2191'; opacity: 1; }  /* ↑ */
table.grid.sortable thead th.sorted-desc::after { content: '\2193'; opacity: 1; }  /* ↓ */

/* Orden server-side por link (ej. Personal, paginado): th > a.th-sort */
table.grid thead th a.th-sort {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    display: inline-block;
}
table.grid thead th a.th-sort:hover { color: var(--c-primary); text-decoration: none; }
table.grid thead th a.th-sort::after { content: '\2195'; margin-left: 6px; font-size: 11px; opacity: .35; }
table.grid thead th.sorted-asc  a.th-sort::after { content: '\2191'; opacity: 1; }
table.grid thead th.sorted-desc a.th-sort::after { content: '\2193'; opacity: 1; }
table.grid tbody tr:hover {
    background: #f5faf6;
}
table.grid tbody tr.row-baja {
    color: var(--c-text-muted);
}
table.grid tbody tr.row-baja strong { color: var(--c-text-muted); }
table.grid tbody tr.row-warn {
    background: #fff8e6;
}
table.grid tbody td.cell-warn {
    color: var(--c-danger);
    font-weight: 700;
}
/* Franco (dia de descanso del ciclo): fila apagada, distinta de la ausencia */
table.grid tbody tr.row-franco {
    background: #f7f8fa;
    color: var(--c-text-muted);
}
table.grid tbody tr.row-franco strong { color: #6b7280; }

/* Chips de novedad en la grilla de Control horario. El estilo lo decide
   TarjetaDiaria.NovedadDelDia.getCssClass(), no el JSP. */
.nov {
    display: inline-block;
    padding: 1px 7px;
    margin: 0 3px 2px 0;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .2px;
    white-space: nowrap;
}
.nov--firme     { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }
.nov--franco    { background: #e7ecf3; color: #374151; border: 1px solid #c7d2de; }
.nov--plus      { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.nov--pendiente { background: #f3f4f6; color: #6b7280; border: 1px dashed #cbd5e1; font-style: italic; }
.nov--rechazada { background: #fdecea; color: #9ca3af; border: 1px solid #f5c6cb; text-decoration: line-through; }
.col-num { text-align: right; font-variant-numeric: tabular-nums; }
.col-icon { text-align: center; }
.col-actions { text-align: right; white-space: nowrap; }
.text-ok { color: var(--c-ok); }
.btn-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: var(--radius);
    color: var(--c-primary); background: transparent;
    border: 0; cursor: pointer; text-decoration: none;
}
.btn-link:hover { background: var(--c-primary-light); color: var(--c-primary-hover); }

.empty-state {
    background: var(--c-bg-card);
    border: 1px dashed var(--c-border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--c-text-muted);
}
.empty-state i { font-size: 36px; display: block; margin-bottom: 8px; }
.empty-state h2 { margin: 8px 0; color: var(--c-text); }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
}
.page-info { font-size: 13px; color: var(--c-text-muted); }

/* ================= TABS ================= */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    border-bottom: 2px solid var(--c-border);
    margin-bottom: 16px;
}
.tab {
    padding: 10px 16px;
    color: var(--c-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tab:hover { color: var(--c-primary); text-decoration: none; }
.tab.tab-active {
    color: var(--c-primary);
    border-bottom-color: var(--c-primary);
}
/* Separador entre las solapas propias del form y las que llevan a la ficha */
.tabs-sep {
    width: 1px;
    align-self: center;
    height: 20px;
    margin: 0 8px;
    background: var(--c-border);
}
/* Solapa que NO es un panel de esta pantalla: navega a la ficha del legajo.
   Va punteada para que se note que se sale del formulario. */
.tab-link { font-weight: 400; border-bottom: 2px dotted var(--c-border); }
.tab-link:hover { border-bottom-color: var(--c-primary); }
.tab-content {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 20px 24px;
}

/* ================= INFO GRID (detalle) ================= */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px 24px;
}
.info-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
}
.info-row > span {
    font-size: 12px;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.info-row > strong { font-size: 14px; }
.info-row--wide { grid-column: 1 / -1; }
.muted-block {
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--c-bg);
    border-left: 3px solid var(--c-primary-light);
    color: var(--c-text-muted);
    font-size: 13px;
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ================= FORM ================= */
.form-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px 18px;
}
.field--wide  { grid-column: 1 / -1; }
.field--narrow { max-width: 200px; }
.field--date  { max-width: 200px; }
.field textarea {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}
.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

#formTabs .tab {
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
}
.subgroup {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin: 0;
}
.subgroup legend {
    padding: 0 6px;
    font-size: 12px;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.subgroup-inline {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.checkbox-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 8px 0;
}
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}
.checkbox input[type=checkbox] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--c-primary);
}
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
    padding: 16px 20px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text);
    text-transform: uppercase;
    letter-spacing: .3px;
    margin: 24px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--c-border);
}
.grid--editable input[type=time] {
    padding: 4px 6px;
    border: 1px solid var(--c-border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    width: 100px;
}
.grid--editable input[type=time]:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px rgba(45,106,79,.15);
}

/* ================= FLASH ================= */
.flash-container {
    position: sticky;
    top: var(--topbar-h);
    z-index: 9;
    padding: 10px 24px 0;
    pointer-events: none;
}
.flash-container .alert {
    pointer-events: auto;
    box-shadow: var(--shadow-lg);
    margin: 0 auto 0;
    max-width: 600px;
}

/* ================= TOPBAR MENU / SUBMENU ================= */
.topbar-link.is-disabled {
    opacity: .5;
    pointer-events: none;
}
.topbar-menu {
    position: relative;
}
.topbar-menu .topbar-link {
    border: 0;
    background: transparent;   /* sino el <button> hereda el gris buttonface y queda blanco sobre gris */
    color: #fff;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}
.topbar-submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    min-width: 200px;
    padding: 6px 0;
    box-shadow: var(--shadow-lg);
    z-index: 10;
}
.topbar-menu.open .topbar-submenu { display: block; }
.topbar-submenu a {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    color: var(--c-text);
    text-decoration: none;
    font-size: 13px;
}
.topbar-submenu a:hover { background: var(--c-bg); text-decoration: none; }
.topbar-submenu a.is-disabled { opacity: .55; pointer-events: none; }

/* ================= FICHA DEL LEGAJO: credenciales, vacunas, adjuntos ================= */

/* Contador al lado del nombre de la solapa */
.tab-count {
    background: var(--c-primary-light);
    color: var(--c-primary-hover);
    border-radius: 9px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
}

/* Chip de estado (vencimientos, cobertura de vacunas). La clase la elige el
   modelo (getEstadoCssClass()), el JSP solo la imprime. */
.chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.chip--ok      { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.chip--aviso   { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.chip--critico { background: #ffedd5; color: #9a3412; border: 1px solid #fdba74; }
.chip--vencido { background: #fdecea; color: #991b1b; border: 1px solid #f5c6cb; }
.chip--neutro  { background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; }

/* Barra de filtros de las pantallas de reporte */
.filtros-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}

/* Alta/edición embebida en una solapa de la ficha */
.form-inline {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 12px 0 4px;
}
.form-inline .field { min-width: 150px; }
.alta-block {
    margin-top: 16px;
    border-top: 1px dashed var(--c-border);
    padding-top: 10px;
}
.alta-block > summary,
.inline-edit > summary {
    cursor: pointer;
    color: var(--c-primary);
    font-weight: 600;
    font-size: 13px;
    list-style: none;
}
.alta-block > summary::-webkit-details-marker,
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit { display: inline-block; }
.inline-edit[open] {
    position: relative;
}
.inline-edit[open] > .form-inline {
    position: absolute;
    right: 0;
    z-index: 20;
    width: 620px;
    max-width: 90vw;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 14px 16px;
    text-align: left;
}

/* ================= FIRMA EN PANTALLA (notificación de vacaciones) ================= */
.firma-wrap {
    margin: 16px 0 4px;
    max-width: 660px;
}
.firma-canvas {
    display: block;
    width: 100%;
    height: 220px;
    background: #fff;
    border: 2px dashed var(--c-border);
    border-radius: var(--radius);
    cursor: crosshair;
    touch-action: none;          /* si no, en tablet el dedo scrollea en vez de firmar */
}
.firma-linea {
    margin-top: 6px;
    text-align: center;
    font-size: 12px;
    color: var(--c-text-muted);
}

/* ================= BREAKPOINTS (cascada 1366 -> 1024 -> 768 -> 480) =================
   Desktop default 1366x768 (HD) intacto; debajo de eso, adaptaciones progresivas.
   Requiere viewport width=device-width (ver header.jsp). */
/* Los 10 accesos del menu piden ~1550px con el nombre de la clinica y el del
   usuario en pantalla: en 1366 (la resolucion de referencia) NO entran y la barra
   desbordaba. Antes de colapsar a ☰ se recorta lo prescindible: el texto de la
   marca (el logo ya identifica) y el nombre del usuario (queda icono + rol). */
@media (max-width: 1560px) {
    .topbar { padding: 0 16px; }
    .topbar-brand { margin-right: 18px; }
    .topbar-brand > span { display: none; }
    .topbar-user-nombre { display: none; }
    .topbar-nav { gap: 2px; }
    .topbar-link { padding: 8px 10px; }
}
@media (max-width: 1340px) {
    /* Topbar compacta: fila 1 = marca + boton ☰. El nav y el usuario se ocultan
       y se despliegan en vertical al tocar el ☰ (clase .nav-open). */
    .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 4px; }
    .topbar-brand { margin-right: auto; }
    .topbar-brand > span { display: inline; }   /* con el menu plegado hay lugar de sobra */
    .topbar-toggle { display: inline-flex; order: 1; }
    .topbar-nav {
        order: 3; flex-basis: 100%;
        flex-direction: column; align-items: stretch; gap: 2px;
        display: none;
    }
    .topbar-user {
        order: 4; flex-basis: 100%;
        justify-content: flex-end; font-size: 12px;
        display: none; padding-top: 6px;
        border-top: 1px solid rgba(255,255,255,.15);
    }
    .topbar-user-nombre { display: inline; }
    .topbar.nav-open .topbar-nav,
    .topbar.nav-open .topbar-user { display: flex; }
    /* Con los 10 accesos + el submenu de Maestros el panel mide ~500px: en un
       telefono bajo taparia toda la pantalla, asi que scrollea adentro. */
    .topbar.nav-open .topbar-nav { max-height: 70vh; overflow-y: auto; }
    .topbar-nav .topbar-link { padding: 10px 10px; }
    /* Submenu Maestros: inline e indentado, sobre el verde (texto claro) */
    .topbar-submenu {
        position: static; box-shadow: none; border: 0; min-width: 0;
        background: transparent; padding: 2px 0 4px 30px;
    }
    .topbar-submenu a { color: #eaf2ed; padding: 9px 10px; }
    .topbar-submenu a:hover { background: rgba(255,255,255,.12); }
}
@media (max-width: 1024px) {
    .main-content { padding: 16px; }
    .filters { grid-template-columns: 1fr 1fr; }
    .filters-actions { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
    body { min-height: auto; }
    .main-content { padding: 14px 12px; }
    .filters { grid-template-columns: 1fr; }
    .page-actions { width: 100%; flex-wrap: wrap; }
    .table-wrapper { max-height: none; }
}
@media (max-width: 480px) {
    .login-card { padding: 28px 20px 20px; }
    .info-grid, .form-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 19px; }
}
