/* ═══════════════════════════════════════════════════════════════
   FarmaFiscal DCF – Design System  |  DCF Brand Theme
   Color primario  : Celeste    #1f75af
   Color secundario: Azul Negro #1A3059
   Tipografía primaria  : Roboto (títulos, botones, nav)
   Tipografía secundaria: Arial Nova Condensed (cuerpo, tablas)
   ═══════════════════════════════════════════════════════════════ */

/* Roboto se carga desde public/vendor/roboto/roboto.css con un <link> en las
   vistas (layout/header.php, auth/login.php, errors/404.php, errors/500.php).
   El @import a fonts.googleapis.com se retiró en la Fase 3 (F3-06): la CSP ya
   no autoriza ese origen y, al ser un @import, el navegador lo descargaba en
   cascada tras el CSS, retrasando el primer render. */

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
    /* ── Marca DCF ── */
    --ff-accent: #1f75af;
    /* Celeste primario     */
    --ff-accent-hover: #1868a0;
    --ff-accent-dark: #1A3059;
    /* Azul Negro secundario */
    --ff-accent-light: rgba(31, 117, 175, 0.10);
    --ff-accent-glow: rgba(31, 117, 175, 0.22);

    /* ── Fondos (tema claro profesional) ── */
    --ff-bg: #f0f4f9;
    --ff-sidebar-bg: #1A3059;
    /* Sidebar en Azul Negro */
    --ff-card-bg: #ffffff;
    --ff-card-hover: #f5f8fc;
    --ff-input-bg: #ffffff;

    /* ── Texto ── */
    --ff-text: #1A3059;
    /* Azul Negro para texto */
    --ff-text-muted: #4a6080;
    --ff-text-dim: #8097b1;

    /* ── Bordes ── */
    --ff-border: rgba(26, 48, 89, 0.13);
    --ff-border-accent: rgba(31, 117, 175, 0.30);

    /* ── Estados semánticos ── */
    --ff-success: #16a34a;
    --ff-warning: #d97706;
    --ff-danger: #dc2626;
    --ff-info: #1f75af;

    /* ── Layout ── */
    --sidebar-w: 260px;
    --topbar-h: 60px;

    /* ── Radios & Sombras ── */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 3px rgba(26, 48, 89, 0.08), 0 4px 16px rgba(26, 48, 89, 0.05);
    --shadow-lg: 0 8px 32px rgba(26, 48, 89, 0.14);

    /* ── Aliases de compatibilidad ── */
    --ff-bg-card: #ffffff;
    --ff-radius: 10px;
    --ff-accent-muted: rgba(31, 117, 175, 0.12);

    /* ── Clasificación AWARE (antibióticos) ── */
    --color-aware-acceso: #16a34a;
    --color-aware-precaucion: #d97706;
    --color-aware-reserva: #dc2626;
    --color-aware-otro: #6b7280;
}

/* ── Reset / Base ────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Arial Nova Cond', 'Arial Nova', 'Arial Narrow', Arial, sans-serif;
    background: var(--ff-bg);
    color: var(--ff-text);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Tipografía primaria Roboto para títulos y elementos de acción ── */
h1,
h2,
h3,
h4,
h5,
h6,
.ff-brand-name,
.ff-topbar-title,
.ff-card-title,
.ff-kpi-value,
.btn-ff,
.ff-nav-item,
.ff-sidebar-link,
.ff-nav-section,
.ff-label,
.ff-user-name {
    font-family: 'Roboto', sans-serif;
}

a {
    color: var(--ff-accent);
    text-decoration: none;
}

a:hover {
    color: var(--ff-accent-hover);
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(31, 117, 175, 0.22);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ff-accent);
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.ff-wrapper {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ── Sidebar (Azul Negro #1A3059) ────────────────────────────── */
.ff-sidebar {
    width: var(--sidebar-w);
    background: var(--ff-sidebar-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}

/* Brand */
.ff-brand {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}

.ff-brand-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    flex-shrink: 0;
}

.ff-brand-icon {
    width: 36px;
    height: 36px;
    background: rgba(31, 117, 175, 0.22);
    border: 1px solid rgba(31, 117, 175, 0.42);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    color: #7cc4f0;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.ff-brand-name {
    font-size: .9rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -.015em;
    line-height: 1.15;
}

.ff-brand-sub {
    font-size: .68rem;
    color: rgba(255, 255, 255, 0.50);
}

/* Nav */
.ff-nav {
    padding: .85rem 0;
    flex: 1;
}

.ff-nav-section {
    padding: .6rem 1.4rem .2rem;
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
}

.ff-nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    transition: color .15s;
}

.ff-nav-section-toggle:hover {
    color: rgba(255, 255, 255, 0.65);
}

.ff-nav-section-chevron {
    font-size: .7rem;
    transition: transform .2s ease;
}

.ff-nav-section-toggle[aria-expanded="true"] .ff-nav-section-chevron {
    transform: rotate(180deg);
}

.ff-nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem 1.4rem;
    color: rgba(255, 255, 255, 0.70);
    font-size: .845rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    position: relative;
    cursor: pointer;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
}

.ff-nav-item:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
}

.ff-nav-item.active {
    background: rgba(31, 117, 175, 0.25);
    color: #7cc4f0;
}

.ff-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #1f75af;
    border-radius: 0 2px 2px 0;
}

.ff-nav-item .nav-icon {
    font-size: .95rem;
    width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}

/* ff-sidebar-link — alias de ff-nav-item para contexto lateral */
.ff-sidebar-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem 1.4rem;
    color: rgba(255, 255, 255, 0.70);
    font-size: .845rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    text-decoration: none;
    cursor: pointer;
    width: 100%;
}

.ff-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
}

.ff-sidebar-link.active {
    background: rgba(31, 117, 175, 0.25);
    color: #7cc4f0;
}

/* Sidebar footer */
.ff-sidebar-footer {
    padding: .9rem 1.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}

.ff-user-card {
    display: flex;
    align-items: center;
    gap: .65rem;
}

.ff-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(31, 117, 175, 0.25);
    border: 1px solid rgba(31, 117, 175, 0.45);
    display: grid;
    place-items: center;
    color: #7cc4f0;
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.ff-user-name {
    font-size: .78rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.ff-user-role {
    font-size: .68rem;
    color: rgba(255, 255, 255, 0.50);
}

.ff-logout-btn {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.35);
    font-size: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: .2rem;
    transition: color .15s;
}

.ff-logout-btn:hover {
    color: #f87171;
}

/* ── Main area ───────────────────────────────────────────────── */
.ff-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Topbar */
.ff-topbar {
    height: var(--topbar-h);
    background: #ffffff;
    border-bottom: 1px solid var(--ff-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: .75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(26, 48, 89, 0.06);
}

.ff-topbar-title {
    font-size: .92rem;
    font-weight: 700;
    color: var(--ff-text);
    flex: 1;
}

.ff-topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    color: var(--ff-text-muted);
}

.ff-topbar-breadcrumb .sep {
    opacity: .4;
}

.ff-topbar-breadcrumb .current {
    color: var(--ff-text);
    font-weight: 500;
}

/* Content — fondo con sutil patrón hexagonal molecular */
.ff-content {
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    background-color: var(--ff-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='104' viewBox='0 0 60 104'%3E%3Cpath d='M30 68L2 52V20L30 4l28 16v32L30 68zm0-4L6 50V22L30 8l24 14v28L30 64z' fill='%231f75af' fill-opacity='0.035'/%3E%3C/svg%3E");
    background-size: 60px 104px;
}

/* ═══════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* ── KPI Cards ──────────────────────────────────────────────── */
.ff-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ff-kpi {
    background: var(--ff-card-bg);
    border: 1px solid var(--ff-border);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    display: flex;
    align-items: flex-start;
    gap: .9rem;
    box-shadow: var(--shadow-card);
    transition: transform .15s, box-shadow .15s;
}

.ff-kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.ff-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ff-kpi-icon.green {
    background: rgba(22, 163, 74, .12);
    color: #16a34a;
}

.ff-kpi-icon.blue {
    background: rgba(31, 117, 175, .12);
    color: #1f75af;
}

.ff-kpi-icon.amber {
    background: rgba(217, 119, 6, .12);
    color: #d97706;
}

.ff-kpi-icon.red {
    background: rgba(220, 38, 38, .12);
    color: #dc2626;
}

.ff-kpi-icon.purple {
    background: rgba(124, 58, 237, .12);
    color: #7c3aed;
}

.ff-kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ff-text);
}

.ff-kpi-label {
    font-size: .72rem;
    color: var(--ff-text-muted);
    margin-top: .2rem;
    font-family: 'Arial Nova Cond', 'Arial Nova', 'Arial Narrow', Arial, sans-serif;
}

/* ── Panel / Card ───────────────────────────────────────────── */
.ff-card {
    background: var(--ff-card-bg);
    border: 1px solid var(--ff-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.ff-card-header {
    padding: .9rem 1.2rem;
    border-bottom: 1px solid var(--ff-border);
    display: flex;
    align-items: center;
    gap: .65rem;
    flex-wrap: wrap;
}

.ff-card-title {
    font-size: .875rem;
    font-weight: 700;
    color: var(--ff-text);
    flex: 1;
}

.ff-card-body {
    padding: 1.2rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-ff {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem .95rem;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    border: 1px solid transparent;
    text-decoration: none;
    font-family: 'Roboto', sans-serif;
    line-height: 1.5;
}

.btn-ff:focus {
    outline: 2px solid var(--ff-accent-glow);
    outline-offset: 2px;
}

.btn-ff-primary {
    background: var(--ff-accent);
    color: #fff;
    border-color: var(--ff-accent);
}

.btn-ff-primary:hover {
    background: var(--ff-accent-hover);
    border-color: var(--ff-accent-hover);
    color: #fff;
}

.btn-ff-outline {
    background: transparent;
    color: var(--ff-text-muted);
    border-color: var(--ff-border);
}

.btn-ff-outline:hover {
    background: var(--ff-accent-light);
    color: var(--ff-accent);
    border-color: var(--ff-border-accent);
}

.btn-ff-danger {
    background: rgba(220, 38, 38, .10);
    color: var(--ff-danger);
    border-color: rgba(220, 38, 38, .28);
}

.btn-ff-danger:hover {
    background: var(--ff-danger);
    color: #fff;
}

.btn-ff-warning {
    background: rgba(217, 119, 6, .10);
    color: var(--ff-warning);
    border-color: rgba(217, 119, 6, .28);
}

.btn-ff-warning:hover {
    background: var(--ff-warning);
    color: #fff;
}

.btn-ff-sm {
    padding: .28rem .65rem;
    font-size: .77rem;
}

.btn-ff-xs {
    padding: .18rem .5rem;
    font-size: .72rem;
}

/* ── Tables ──────────────────────────────────────────────────── */
.ff-table-wrap {
    overflow-x: auto;
}

.ff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .845rem;
    font-family: 'Arial Nova Cond', 'Arial Nova', 'Arial Narrow', Arial, sans-serif;
}

.ff-table thead th {
    background: rgba(26, 48, 89, 0.04);
    color: var(--ff-text-muted);
    font-size: .685rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: .6rem 1rem;
    border-bottom: 2px solid var(--ff-border);
    white-space: nowrap;
    font-family: 'Roboto', sans-serif;
}

.ff-table tbody td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--ff-border);
    color: var(--ff-text);
    vertical-align: middle;
}

.ff-table tbody tr:last-child td {
    border-bottom: none;
}

.ff-table tbody tr:hover td {
    background: var(--ff-accent-light);
}

/* ── Badges ──────────────────────────────────────────────────── */
.ff-badge {
    display: inline-flex;
    align-items: center;
    padding: .18rem .52rem;
    border-radius: 20px;
    font-size: .69rem;
    font-weight: 600;
    white-space: nowrap;
    font-family: 'Roboto', sans-serif;
}

.ff-badge-success {
    background: rgba(22, 163, 74, .12);
    color: #15803d;
}

.ff-badge-danger {
    background: rgba(220, 38, 38, .12);
    color: #b91c1c;
}

.ff-badge-warning {
    background: rgba(217, 119, 6, .12);
    color: #b45309;
}

.ff-badge-info {
    background: rgba(31, 117, 175, .12);
    color: #1f75af;
}

.ff-badge-muted {
    background: rgba(26, 48, 89, .08);
    color: var(--ff-text-muted);
}

/* Status dot */
.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 5px;
}

.status-dot.on {
    background: var(--ff-success);
    box-shadow: 0 0 5px rgba(22, 163, 74, 0.5);
}

.status-dot.off {
    background: var(--ff-text-dim);
}

/* ── Forms ───────────────────────────────────────────────────── */
.ff-form-group {
    margin-bottom: 1rem;
}

.ff-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.ff-form-row.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.ff-label {
    display: block;
    font-size: .775rem;
    font-weight: 500;
    color: var(--ff-text-muted);
    margin-bottom: .35rem;
}

.ff-label .req {
    color: var(--ff-accent);
    margin-left: 2px;
}

.ff-input,
.ff-select,
.ff-textarea {
    width: 100%;
    background: var(--ff-input-bg);
    border: 1px solid var(--ff-border);
    border-radius: var(--radius-sm);
    color: var(--ff-text);
    padding: .48rem .75rem;
    font-size: .875rem;
    font-family: 'Arial Nova Cond', 'Arial Nova', 'Arial Narrow', Arial, sans-serif;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    -webkit-appearance: none;
}

.ff-input:focus,
.ff-select:focus,
.ff-textarea:focus {
    border-color: var(--ff-accent);
    box-shadow: 0 0 0 3px var(--ff-accent-glow);
}

.ff-input::placeholder,
.ff-textarea::placeholder {
    color: var(--ff-text-dim);
}

.ff-select option {
    background: #ffffff;
    color: var(--ff-text);
}

.ff-textarea {
    resize: vertical;
    min-height: 80px;
}

.ff-hint {
    font-size: .72rem;
    color: var(--ff-text-dim);
    margin-top: .25rem;
}

/* Search */
.ff-search {
    position: relative;
}

.ff-search .ff-input {
    padding-left: 2.15rem;
}

.ff-search-icon {
    position: absolute;
    left: .72rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ff-text-dim);
    font-size: .85rem;
    pointer-events: none;
}

/* ── Flash / Alert ───────────────────────────────────────────── */
.ff-alert {
    border-radius: var(--radius-sm);
    padding: .6rem 1rem;
    font-size: .845rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}

.ff-alert-success {
    background: rgba(22, 163, 74, .08);
    border: 1px solid rgba(22, 163, 74, .25);
    color: #15803d;
}

.ff-alert-danger {
    background: rgba(220, 38, 38, .08);
    border: 1px solid rgba(220, 38, 38, .25);
    color: #b91c1c;
}

.ff-alert-warning {
    background: rgba(217, 119, 6, .08);
    border: 1px solid rgba(217, 119, 6, .25);
    color: #b45309;
}

.ff-alert-info {
    background: rgba(31, 117, 175, .08);
    border: 1px solid rgba(31, 117, 175, .25);
    color: #1f75af;
}

/* ── Empty state ─────────────────────────────────────────────── */
.ff-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ff-text-muted);
}

.ff-empty-icon {
    font-size: 2.5rem;
    margin-bottom: .75rem;
    opacity: .35;
}

.ff-empty p {
    font-size: .85rem;
}

/* ═══════════════════════════════════════════════════════════════
   PAGE: Login  (standalone, sin sidebar)
   ═══════════════════════════════════════════════════════════════ */
.ff-login-page {
    min-height: 100vh;
    background: var(--ff-bg);
    display: flex;
    align-items: stretch;
}

.ff-login-brand {
    flex: 1;
    background: url('../assets/img/fondo.svg') center center / cover no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 3.5rem;
    position: relative;
    overflow: hidden;
}

.ff-login-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(234, 236, 240, 0.35);
}

.ff-login-brand::after {
    content: '';
    position: absolute;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, rgba(31, 117, 175, 0.22) 0%, transparent 65%);
    top: -80px;
    right: -60px;
    border-radius: 50%;
}

.ff-login-brand-content {
    position: relative;
    z-index: 1;
}

.ff-login-logo {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: rgba(31, 117, 175, 0.12);
    border: 1px solid rgba(31, 117, 175, 0.35);
    display: grid;
    place-items: center;
    color: #1f75af;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.ff-login-brand h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin-bottom: .4rem;
    color: #1A3059;
}

.ff-login-brand .text-accent {
    color: #1f75af !important;
}

.ff-login-brand p {
    font-size: .9rem;
    color: #4a6080;
    max-width: 360px;
    line-height: 1.65;
}

.ff-login-features {
    margin-top: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}

.ff-login-feature {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .845rem;
    color: #4a6080;
}

.ff-login-feature i {
    color: #1f75af;
    font-size: .9rem;
}

.ff-login-form-side {
    width: 420px;
    flex-shrink: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
    border-left: 1px solid var(--ff-border);
}

.ff-login-form-side h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: .35rem;
    color: var(--ff-text);
}

.ff-login-form-side .sub {
    font-size: .82rem;
    color: var(--ff-text-muted);
    margin-bottom: 2rem;
}

/* ═══════════════════════════════════════════════════════════════
   ERROR PAGES (404 / 500)
   ═══════════════════════════════════════════════════════════════ */
.ff-error-page {
    min-height: 100vh;
    background: var(--ff-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.ff-error-page::before {
    content: '';
    position: absolute;
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, var(--ff-accent-glow) 0%, transparent 65%);
    top: -120px;
    right: -100px;
    border-radius: 50%;
}

.ff-error-card {
    background: var(--ff-card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 3rem 3.5rem;
    max-width: 480px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 1;
}

.ff-error-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--ff-accent-light);
    color: var(--ff-accent);
    display: grid;
    place-items: center;
    font-size: 2rem;
    margin: 0 auto 1.5rem;
}

.ff-error-icon.is-danger {
    background: rgba(220, 38, 38, .12);
    color: var(--ff-danger);
}

.ff-error-code {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 3.25rem;
    line-height: 1;
    color: var(--ff-accent-dark);
    margin-bottom: .5rem;
}

.ff-error-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ff-text);
    margin-bottom: .6rem;
}

.ff-error-message {
    font-size: .88rem;
    color: var(--ff-text-muted);
    line-height: 1.65;
    margin-bottom: 2rem;
}

.ff-error-actions {
    display: flex;
    gap: .75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════ */
.text-accent {
    color: var(--ff-accent) !important;
}

.text-muted-ff {
    color: var(--ff-text-muted) !important;
}

.text-dim {
    color: var(--ff-text-dim) !important;
}

.text-danger {
    color: var(--ff-danger) !important;
}

.divider {
    border: none;
    border-top: 1px solid var(--ff-border);
    margin: 1rem 0;
}

.gap-075 {
    gap: .75rem !important;
}

.container-custom {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   LEGACY – Compatibilidad con estilos existentes
   ═══════════════════════════════════════════════════════════════ */

/* Clasificación AWARE de Antibióticos */
.badge-antibiotico[class*="aware_"] {
    color: #fff !important;
}

.badge-antibiotico.aware_1 {
    background-color: var(--color-aware-acceso) !important;
}

.badge-antibiotico.aware_2 {
    background-color: var(--color-aware-precaucion) !important;
}

.badge-antibiotico.aware_3 {
    background-color: var(--color-aware-reserva) !important;
}

.badge-antibiotico.aware_4 {
    background-color: var(--color-aware-otro) !important;
}

/* Tabla de despacho/carrito */
.cart-table {
    background: transparent !important;
}

.cart-table thead th {
    font-size: .75rem;
    color: var(--ff-accent) !important;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--ff-border) !important;
    background: transparent !important;
}

.cart-table> :not(caption)>*>* {
    background-color: transparent !important;
    color: var(--ff-text) !important;
    box-shadow: none !important;
}

/* Bootstrap overrides para tema claro */
.form-select,
.form-control {
    background: #ffffff !important;
    color: var(--ff-text) !important;
    border: 1px solid var(--ff-border) !important;
}

.form-select option {
    background: #ffffff;
    color: var(--ff-text);
}

::placeholder {
    color: var(--ff-text-dim) !important;
    opacity: 1;
}

.form-control::placeholder {
    color: var(--ff-text-dim) !important;
}

/* ── Sidebar overlay (fondo oscuro al abrir en mobile) ───────── */
.ff-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .48);
    z-index: 199;
}
.ff-sidebar-overlay.show { display: block; }

/* Botón de menú hamburguesa: oculto en desktop, visible en mobile */
.ff-menu-toggle { display: none; }

/* ── Responsive – Mobile First ───────────────────────────────── */
/* ≤900px: sidebar colapsado, layout de una columna             */
@media (max-width: 900px) {
    .ff-menu-toggle {
        display: inline-flex;
    }

    .ff-sidebar {
        transform: translateX(-100%);
    }

    .ff-sidebar.open {
        transform: translateX(0);
    }

    .ff-main {
        margin-left: 0;
    }

    .ff-login-brand {
        display: none;
    }

    .ff-login-form-side {
        width: 100%;
        min-width: 0;
        flex-shrink: 1;
    }

    .ff-form-row {
        grid-template-columns: 1fr;
    }

    .ff-form-row.cols-3 {
        grid-template-columns: 1fr;
    }

    .ff-content {
        padding: 1rem;
    }

    .ff-table-wrap {
        -webkit-overflow-scrolling: touch;
    }

    /* Área táctil mínima 44 px (WCAG 2.5.5) */
    .btn-ff {
        min-height: 44px;
        padding: .6rem 1rem;
    }

    .btn-ff-sm {
        min-height: 40px;
        padding: .42rem .85rem;
    }

    .btn-ff-xs {
        min-height: 36px;
        padding: .3rem .6rem;
    }

    .ff-logout-btn {
        min-width: 36px;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .alertaTemperatura {
        padding: 1rem;
        border-radius: 12px;
        margin-bottom: 1rem;
    }
}

/* ≤600px: portrait estándar (375–600 px) */
@media (max-width: 600px) {
    .ff-content {
        padding: .85rem;
    }

    .ff-topbar {
        padding: 0 .9rem;
        gap: .5rem;
    }

    .ff-topbar-title {
        font-size: .85rem;
    }

    /* KPI en 2 columnas */
    .ff-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: .7rem;
    }

    .ff-kpi-value {
        font-size: 1.4rem;
    }

    /* Inputs más grandes para teclado táctil */
    .ff-input,
    .ff-select,
    .ff-textarea {
        font-size: 1rem;
        padding: .6rem .8rem;
    }

    .ff-table thead th,
    .ff-table tbody td {
        padding: .55rem .65rem;
        font-size: .79rem;
    }

    .ff-card-header {
        flex-wrap: wrap;
    }

    /* Botones de acción en card-header: ancho completo */
    .ff-card-header .ms-auto {
        margin-left: 0 !important;
        width: 100%;
        justify-content: center;
    }

    .ff-nav-item,
    .ff-sidebar-link {
        padding: .7rem 1.4rem;
    }
}

/* ≤400px: pantallas muy pequeñas (iPhone SE, etc.) */
@media (max-width: 400px) {
    .ff-content {
        padding: .65rem;
    }

    .ff-kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: .55rem;
    }

    .ff-kpi {
        padding: .85rem;
        gap: .65rem;
    }

    .ff-kpi-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .ff-kpi-value {
        font-size: 1.25rem;
    }

    .ff-card-body {
        padding: .85rem;
    }

    .ff-login-form-side {
        padding: 2rem 1.5rem;
    }
}

/* TomSelect — tema claro */
.full .ts-control {
    background-color: #ffffff !important;
    color: var(--ff-text);
    border: 1px solid var(--ff-border) !important;
}

/* ── Alerta de temperatura ───────────────────────────────────── */
.alertaTemperatura {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}
.pendientes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}
@media (max-width: 600px) {
    .pendientes-grid { grid-template-columns: 1fr; }
}

/* ── Botones de acción en detalle de ingreso ───────────────────── */
.ff-detalle-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-left: auto;
}
.ff-detalle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    transition: background .2s;
    white-space: nowrap;
}
/* Estos botones son <a>, y `a:hover` (elemento + pseudoclase) tiene más
   especificidad que la clase: al pasar el mouse le ganaba al color: #fff de
   arriba y teñía el rótulo del color de acento, ilegible sobre el fondo
   sólido del botón. El texto se mantiene blanco en todos los estados. */
.ff-detalle-btn:hover,
.ff-detalle-btn:focus,
.ff-detalle-btn:active {
    color: #fff;
}

.ff-detalle-btn-form {
    display: inline;
}
@media (max-width: 600px) {
    .ff-detalle-actions {
        flex-direction: column;
        width: 100%;
        margin-left: 0;
        margin-top: .5rem;
    }
    .ff-detalle-btn,
    .ff-detalle-btn-form,
    .ff-detalle-volver {
        width: 100%;
    }
    .ff-detalle-btn-form .ff-detalle-btn {
        width: 100%;
    }
    .ff-detalle-volver {
        justify-content: center;
    }
}

option {
    background-color: #ffffff;
}

/* ── Catálogo: header título + botones ──────────────────────────── */
.ff-cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .5rem;
}
@media (max-width: 600px) {
    .ff-cat-header {
        flex-direction: column;
        align-items: stretch;
    }
    .ff-cat-actions {
        flex-direction: column !important;
        width: 100%;
    }
    .ff-cat-actions .btn-ff,
    .ff-cat-actions .ff-search {
        width: 100%;
    }
    .ff-cat-actions .ff-search .ff-input {
        width: 100%;
        max-width: 100%;
    }
}

/* ── Form page (vistas de formulario standalone: temperatura, etc.) ── */
.form-page-wrap {
    display: flex;
    justify-content: center;
    padding: 1rem 0 2rem;
}

.form-card {
    background: var(--ff-card-bg);
    border: 1px solid var(--ff-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 2rem 2.25rem;
    width: 100%;
}

.form-title {
    font-family: 'Roboto', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ff-text);
    text-align: center;
    margin-bottom: 1rem;
}

.form-title span {
    color: var(--ff-accent);
}

/* Grid de 2 columnas para formularios */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Grid de 3 columnas para formularios.
   Vivía solo dentro de app/views/despacho/form.php, así que las otras seis
   vistas que usan la clase (ajuste, rechazo, devolución, reclamo y el detalle
   de reclamo) creían maquetar en tres columnas y en realidad apilaban los
   campos. Se centraliza aquí, con el mismo punto de corte que .grid-2. */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* Grupo campo + label */
.field-group {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.field-group label {
    font-size: .78rem;
    font-weight: 500;
    color: var(--ff-text-muted);
    font-family: 'Roboto', sans-serif;
}

/* Input de búsqueda responsivo */
.ff-search-input-responsive {
    width: clamp(140px, 28vw, 220px);
}

@media (max-width: 900px) {
    .form-card {
        padding: 1.5rem 1.25rem;
        border-radius: var(--radius-md);
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .ff-search-input-responsive {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .form-page-wrap {
        padding: .5rem 0 1.5rem;
    }

    .form-card {
        padding: 1.25rem 1rem;
    }
}

/* ── Pie legal ────────────────────────────────────────────────
   Enlaces a la Política de Privacidad y a las Condiciones del Servicio al
   final de cada pantalla autenticada (app/views/layout/footer.php). Discreto
   a propósito: es una referencia permanente, no un elemento de navegación. */
.ff-legal-footer {
    margin-top: 2.5rem;
    padding: 1.25rem 0 .25rem;
    border-top: 1px solid var(--ff-border);
    font-size: .72rem;
    color: var(--ff-text-dim);
    text-align: center;
}

.ff-legal-footer a {
    color: var(--ff-text-dim);
    text-decoration: none;
}

.ff-legal-footer a:hover {
    color: var(--ff-accent);
    text-decoration: underline;
}

.ff-legal-footer .sep {
    margin: 0 .4rem;
    opacity: .6;
}

@media print {
    .ff-legal-footer {
        display: none;
    }
}

/* ── Visor de PDF propio (pdf-viewer.js) ──────────────────────────────────
   Documentos confidenciales (procedimientos, actas, expedientes): se pintan
   en <canvas> dentro de esta caja y no se ofrece descarga ni impresión desde
   la UI. Ver BaseController::streamPdfInline() para el porqué. */
.ff-visor-pdf {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    /* No es una barrera real contra la captura de pantalla, pero sí quita el
       reflejo de "seleccionar todo" / arrastrar sobre el lienzo. */
    user-select: none;
}

.ff-visor-pdf-estado {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--ff-text-muted);
    font-size: .9rem;
}

.ff-visor-pdf-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .6rem .8rem;
    background: var(--ff-surface-alt, #f8fafc);
    border: 1px solid var(--ff-border);
    border-radius: 10px;
}

.ff-visor-pdf-pagina {
    font-size: .82rem;
    color: var(--ff-text);
    min-width: 4.5rem;
    text-align: center;
}

.ff-visor-pdf-sep {
    width: 1px;
    height: 1.4rem;
    background: var(--ff-border);
    margin: 0 .2rem;
}

.ff-visor-pdf-aviso {
    margin-left: auto;
    font-size: .74rem;
    color: var(--ff-text-muted);
    display: flex;
    align-items: center;
    gap: .35rem;
}

.ff-visor-pdf-lienzo {
    display: flex;
    justify-content: center;
    overflow: auto;
    max-height: 78vh;
    padding: 1rem;
    background: #525659;
    border-radius: 10px;
}

.ff-visor-pdf-lienzo canvas {
    box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
    max-width: 100%;
    height: auto;
}

@media print {
    /* El navegador puede seguir imprimiendo el <canvas> tal cual esté en
       pantalla (con la marca de agua horneada); lo único que se retira es
       la barra de herramientas, que no aporta nada al papel. */
    .ff-visor-pdf-toolbar {
        display: none;
    }
}
