/*
 * Fecha de actualizacion: 2026-07-20
 * Detalle: Sistema de diseno "Fundamenta UI v2" (tema claro profesional, unico).
 * Afecta: Shell autenticado (barra superior + menu de usuario + navegacion), tokens de
 *         marca reales tomados del logotipo (#1B588A / #467E3D), componentes base y wizard PROT.
 * Autoria: Desarrollador: Oscar Hernandez Perez / Asistente tecnico: Antigravity / IA
 * Historial:
 *   - 2026-07-20: Rediseno UI v2. Nuevos tokens de marca, fondo blueprint, barra superior
 *                 con menu de usuario arriba a la derecha y barra inferior con iconos (6 items).
 */

:root {
    /* Identidad Fundamenta (colores tomados del logotipo oficial) */
    --f-navy: #1b588a;
    --f-navy-600: #17507d;
    --f-navy-700: #123f64;
    --f-forest: #467e3d;
    --f-forest-600: #3b6d34;

    /* Lienzo y superficies (tema claro, profesional) */
    --f-bg: #eef2f7;
    --f-surface: #ffffff;
    --f-surface-2: #f6f9fc;
    --f-ink: #141f28;
    --f-muted: #5b6b7d;
    --f-line: #dbe3ee;
    --f-line-strong: #c4d0e0;

    /* Estados */
    --f-danger: #c0392b;
    --f-warning: #b45309;

    /* Tintes suaves derivados de marca */
    --f-soft-blue: #e8f0f8;
    --f-soft-green: #e9f3e5;
    --f-danger-soft: #fbecea;
    --f-warning-soft: #fdf3e2;

    /* Compatibilidad con reglas previas (re-mapeo a marca) */
    --f-blue: var(--f-navy);
    --f-green: var(--f-forest);

    /* Elevacion, foco y radios */
    --f-shadow-sm: 0 1px 2px rgba(20, 31, 40, 0.06), 0 1px 3px rgba(20, 31, 40, 0.05);
    --f-shadow: 0 8px 24px rgba(20, 31, 40, 0.08), 0 2px 6px rgba(20, 31, 40, 0.05);
    --f-shadow-lg: 0 20px 48px rgba(20, 31, 40, 0.18);
    --f-ring: 0 0 0 3px rgba(27, 88, 138, 0.20);
    --f-radius: 12px;
    --f-radius-sm: 9px;
    --f-radius-lg: 18px;
    --f-appbar-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Outfit, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--f-ink);
    background-color: var(--f-bg);
    background-image:
        linear-gradient(rgba(27, 88, 138, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(27, 88, 138, 0.035) 1px, transparent 1px);
    background-size: 27px 27px;
    background-position: center top;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Icono SVG en linea reutilizable (nav, menu de usuario, chips) */
.f-i {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.f-skip-link {
    position: fixed;
    top: -60px;
    left: 12px;
    z-index: 100;
    padding: 10px 14px;
    border-radius: 0 0 10px 10px;
    background: var(--f-navy);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transition: top 0.2s;
}

.f-skip-link:focus { top: 0; }

a { color: var(--f-blue); }

.f-shell {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 22px clamp(14px, 3vw, 26px) calc(90px + env(safe-area-inset-bottom, 0px));
}

.f-auth-shell {
    min-height: 100vh;
    display: grid;
    align-items: center;
    padding: 18px 14px;
}

.f-auth-card,
.f-panel,
.f-card {
    background: var(--f-surface);
    border: 1px solid var(--f-line);
    border-radius: var(--f-radius);
    box-shadow: var(--f-shadow-sm);
}

.f-panel + .f-panel { margin-top: 14px; }

.f-card {
    background: var(--f-surface-2);
    border-radius: var(--f-radius-sm);
    box-shadow: none;
    transition: border-color 0.15s;
}

.f-card:hover { border-color: var(--f-line-strong); }

.f-auth-card {
    width: min(468px, 100%);
    margin: 0 auto;
    padding: 26px;
    box-shadow: var(--f-shadow);
}

.f-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.f-brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, var(--f-navy), var(--f-navy-700));
    color: #fff;
    font-weight: 900;
    font-size: 1.2rem;
    box-shadow: 0 6px 16px rgba(27, 88, 138, 0.28);
}

.f-brand-title {
    font-weight: 800;
    line-height: 1.05;
}

.f-brand-subtitle {
    color: var(--f-muted);
    font-size: 0.86rem;
}

.f-title {
    font-size: clamp(1.42rem, 2.6vw, 1.72rem);
    line-height: 1.12;
    font-weight: 800;
    letter-spacing: -0.015em;
    margin: 0 0 8px;
}

.f-subtitle {
    color: var(--f-muted);
    line-height: 1.45;
    margin: 0 0 20px;
}

.f-section-title {
    font-size: 1.06rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0 0 12px;
    padding-left: 12px;
    border-left: 3px solid var(--f-forest);
}

.f-panel > h2 {
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0 0 12px;
}

.f-list { display: grid; gap: 2px; }

.f-field { margin-bottom: 14px; }

.f-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 7px;
}

.f-input,
.f-select,
.f-textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
    color: var(--f-ink);
    background: #fff;
}

.f-textarea { min-height: 104px; resize: vertical; }

.f-input:focus,
.f-select:focus,
.f-textarea:focus {
    outline: none;
    border-color: var(--f-navy);
    box-shadow: var(--f-ring);
}

.f-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 12px 0;
    color: #334155;
}

.f-check input { width: 20px; height: 20px; margin-top: 2px; }

.f-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    border: 1px solid transparent;
    border-radius: var(--f-radius-sm);
    padding: 11px 17px;
    font-weight: 700;
    font-size: 0.94rem;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.04s;
}

.f-btn:active { transform: translateY(1px); }
.f-btn:focus-visible { outline: none; box-shadow: var(--f-ring); }

.f-btn-primary { background: var(--f-navy); color: #fff; box-shadow: 0 1px 2px rgba(20, 31, 40, 0.14); }
.f-btn-primary:hover { background: var(--f-navy-600); }
.f-btn-secondary { background: var(--f-surface); color: var(--f-navy-700); border-color: var(--f-line-strong); }
.f-btn-secondary:hover { background: var(--f-soft-blue); border-color: var(--f-navy); }
.f-btn-ghost { background: transparent; color: #334155; border-color: var(--f-line); }
.f-btn-ghost:hover { background: var(--f-surface-2); }
.f-btn-danger { background: var(--f-danger); color: #fff; }
.f-btn-danger:hover { background: #a5342a; }
.f-btn-disabled { background: #cbd5e1; color: #475569; cursor: not-allowed; }
.f-btn-block { width: 100%; }
.f-btn-stacked {
    display: grid;
    gap: 1px;
    line-height: 1.05;
}
.f-btn-stacked small {
    font-size: 0.62rem;
    font-weight: 800;
    opacity: 0.82;
}

.f-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.f-header-line {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.f-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 4px 11px;
    background: var(--f-soft-blue);
    color: var(--f-navy-700);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    margin: 3px 4px 3px 0;
}

.f-filterbar,
.f-inline-form {
    display: grid;
    gap: 10px;
    margin: 14px 0;
}

.f-list-item,
.f-list-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px;
    margin: 10px 0;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    background: #fff;
    text-decoration: none;
    color: var(--f-ink);
}

.f-list-item span,
.f-list-row span {
    display: block;
    margin-top: 4px;
    color: var(--f-muted);
    font-size: 0.88rem;
}

.f-list-row > a {
    color: var(--f-ink);
    text-decoration: none;
}

.f-timeline {
    display: grid;
    gap: 10px;
}

.f-timeline-item {
    border-left: 3px solid var(--f-blue);
    padding: 8px 0 8px 12px;
}

.f-timeline-item span {
    display: block;
    color: var(--f-muted);
    font-size: 0.84rem;
    margin-top: 3px;
}

.f-alert {
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    border: 1px solid var(--f-line);
    background: #eef6ff;
}

.f-alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.f-alert-success { background: #ecfdf5; border-color: #bbf7d0; color: #166534; }
.f-alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ══════════════════════════════════════════════════
   BARRA SUPERIOR (APP BAR) + MENU DE USUARIO
   ══════════════════════════════════════════════════ */
.f-appbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(1.5) blur(12px);
    -webkit-backdrop-filter: saturate(1.5) blur(12px);
    border-bottom: 1px solid var(--f-line);
}

.f-appbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--f-navy) 0%, var(--f-forest) 52%, rgba(70, 126, 61, 0) 100%);
}

.f-appbar-inner {
    width: min(1200px, 100%);
    min-height: var(--f-appbar-h);
    margin: 0 auto;
    padding: 8px clamp(12px, 3vw, 24px);
    display: flex;
    align-items: center;
    gap: 14px;
}

.f-appbar-brand {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
}

.f-appbar-brand:focus-visible { outline: none; box-shadow: var(--f-ring); }

.f-appbar-logo {
    height: 32px;
    width: auto;
    display: block;
}

.f-primary-nav { display: none; }

@media (min-width: 920px) {
    .f-primary-nav {
        display: flex;
        align-items: center;
        gap: 3px;
        margin-left: 8px;
    }
}

.f-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 10px;
    color: var(--f-muted);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.f-nav-link .f-i { width: 19px; height: 19px; opacity: 0.9; }
.f-nav-link:hover { background: var(--f-soft-blue); color: var(--f-navy); }
.f-nav-link.is-active { background: var(--f-soft-blue); color: var(--f-navy-700); font-weight: 700; }
.f-nav-link.is-active .f-i { color: var(--f-navy); opacity: 1; }

.f-appbar-user { position: relative; flex: 0 0 auto; margin-left: auto; }

.f-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 5px 9px 5px 5px;
    border: 1px solid var(--f-line);
    border-radius: 999px;
    background: var(--f-surface);
    color: var(--f-ink);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.f-user-trigger:hover { border-color: var(--f-line-strong); box-shadow: var(--f-shadow-sm); }
.f-user-trigger[aria-expanded="true"] { border-color: var(--f-navy); box-shadow: var(--f-ring); }

.f-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--f-navy), var(--f-navy-700));
    color: #fff;
    font-weight: 800;
    font-size: 0.84rem;
    letter-spacing: 0.02em;
    flex: 0 0 auto;
}

.f-avatar-lg { width: 46px; height: 46px; font-size: 1.02rem; border-radius: 14px; }

.f-user-meta { display: none; }

@media (min-width: 720px) {
    .f-user-meta {
        display: grid;
        line-height: 1.12;
        text-align: left;
        max-width: 168px;
    }
}

.f-user-meta strong {
    font-size: 0.86rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.f-user-meta span { font-size: 0.72rem; color: var(--f-muted); }

.f-user-trigger .f-i {
    width: 16px;
    height: 16px;
    color: var(--f-muted);
    transition: transform 0.18s;
}

.f-user-trigger[aria-expanded="true"] .f-i { transform: rotate(180deg); }

.f-user-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 11px);
    width: 292px;
    max-width: calc(100vw - 24px);
    padding: 8px;
    background: var(--f-surface);
    border: 1px solid var(--f-line);
    border-radius: 16px;
    box-shadow: var(--f-shadow-lg);
    z-index: 60;
    animation: f-pop 0.16s ease-out;
}

.f-user-panel[hidden] { display: none; }

.f-user-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 10px 13px;
    border-bottom: 1px solid var(--f-line);
    margin-bottom: 6px;
}

.f-user-headmeta { min-width: 0; }
.f-user-headmeta strong { display: block; font-size: 0.95rem; line-height: 1.2; }
.f-user-headmeta > span {
    display: block;
    font-size: 0.78rem;
    color: var(--f-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.f-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    padding: 2px 9px 2px 6px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
}

.f-user-chip .f-i { width: 13px; height: 13px; }
.f-user-chip.is-ok { background: var(--f-soft-green); color: var(--f-forest-600); }
.f-user-chip.is-pending { background: var(--f-warning-soft); color: var(--f-warning); }

.f-user-panel a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-radius: 10px;
    color: var(--f-ink);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
}

.f-user-panel a .f-i { width: 19px; height: 19px; color: var(--f-muted); }
.f-user-panel a:hover { background: var(--f-surface-2); }
.f-user-panel a:hover .f-i { color: var(--f-navy); }

.f-user-divider { height: 1px; background: var(--f-line); margin: 7px 6px; }

.f-user-logout { color: var(--f-danger) !important; }
.f-user-logout .f-i { color: var(--f-danger) !important; }
.f-user-logout:hover { background: var(--f-danger-soft) !important; }

@keyframes f-pop {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.f-grid {
    display: grid;
    gap: 12px;
}

.f-grid-2,
.f-grid-3 {
    grid-template-columns: 1fr;
}

.f-panel {
    padding: 16px;
}

.f-card {
    padding: 14px;
}

.f-stat {
    font-size: 1.8rem;
    font-weight: 900;
    line-height: 1;
}

.f-muted { color: var(--f-muted); }
.f-small { font-size: 0.88rem; }

.f-progress {
    height: 10px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}

.f-progress > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--f-blue), var(--f-green));
}

.f-form-block {
    display: grid;
    gap: 14px;
}

.f-card-stack {
    display: grid;
    gap: 10px;
    margin: 12px 0;
}

.f-grid-span-2 { grid-column: span 2; }

.f-option-selected {
    border-color: var(--f-blue);
    background: #eff6ff;
}

.f-quick-create {
    margin-top: 14px;
}

.f-wizard-head {
    position: sticky;
    top: 74px;
    z-index: 10;
}

.f-progress-rail {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.f-progress-rail span {
    display: block;
    height: 100%;
    min-width: 2px;
    background: var(--f-green);
}

.f-progress-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    color: var(--f-muted);
    font-size: 0.88rem;
}

.f-step-strip {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(132px, 1fr);
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.f-step-strip a {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px;
    align-items: center;
    min-height: 54px;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    padding: 8px;
    color: var(--f-ink);
    text-decoration: none;
    background: #fff;
}

.f-step-strip a strong {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e2e8f0;
}

.f-step-strip a span {
    min-width: 0;
    overflow: hidden;
    font-size: 0.82rem;
    line-height: 1.15;
}

.f-step-strip a.is-active {
    border-color: var(--f-blue);
    background: #eff6ff;
}

.f-step-strip a.is-done strong {
    color: #fff;
    background: var(--f-green);
}

.f-criterion-card,
.f-suggestion-card {
    border: 1px solid var(--f-line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.f-criterion-title {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 10px;
    align-items: start;
    margin-bottom: 12px;
}

.f-criterion-title strong {
    display: grid;
    place-items: center;
    min-height: 34px;
    border-radius: 8px;
    background: #eaf2ff;
    color: var(--f-blue);
}

.f-segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0 14px;
}

.f-segmented label {
    min-width: 0;
}

.f-segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.f-segmented span {
    display: grid;
    place-items: center;
    min-height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    font-size: 0.86rem;
    font-weight: 800;
    background: #fff;
}

.f-segmented input:checked + span {
    border-color: var(--f-blue);
    color: var(--f-blue);
    background: #eff6ff;
}

.f-audio-panel {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.f-audio-row {
    display: grid;
    gap: 8px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 10px;
    background: #f8fafc;
}

.f-justification-text {
    min-height: 180px;
}

.f-suggestions {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.f-suggestion-card.is-critical {
    border-color: #fecaca;
    background: #fff7f7;
}

.f-badge-warning {
    background: #fffbeb;
    color: var(--f-warning);
}

.f-live-status {
    position: sticky;
    top: 136px;
    z-index: 11;
}

.f-option-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    background: #fff;
}

.f-option-card input {
    margin-top: 4px;
}

.f-option-card small {
    display: block;
    color: var(--f-muted);
    margin-top: 3px;
}

.f-option-disabled {
    opacity: 0.58;
}

.f-detail-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.f-detail-list > div {
    display: grid;
    gap: 2px;
    padding: 10px 0;
    border-bottom: 1px solid var(--f-line);
}

.f-detail-list span {
    color: var(--f-muted);
    font-size: 0.84rem;
}

.f-snapshot-tree {
    display: grid;
    gap: 10px;
}

.f-snapshot-node {
    border: 1px solid var(--f-line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.f-snapshot-node .f-snapshot-node {
    margin-top: 10px;
    background: #f8fafc;
}

.f-snapshot-node summary {
    cursor: pointer;
    overflow-wrap: anywhere;
}

.f-criteria-list {
    margin: 10px 0 0;
    padding-left: 22px;
    color: var(--f-ink);
}

.f-criteria-list li {
    margin-bottom: 8px;
    overflow-wrap: anywhere;
}

.f-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--f-line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -6px 20px rgba(20, 31, 40, 0.06);
}

@media (min-width: 920px) {
    .f-bottom-nav { display: none; }
}

.f-bottom-nav a {
    position: relative;
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 3px;
    padding: 8px 2px 7px;
    text-decoration: none;
    color: var(--f-muted);
    min-width: 0;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.f-bottom-nav a .f-i { width: 23px; height: 23px; }

.f-bottom-nav a.is-active { color: var(--f-navy); }

.f-bottom-nav a.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, var(--f-navy), var(--f-forest));
}

.f-bottom-nav a.is-active .f-i { color: var(--f-navy); }

.f-execution-mode .f-shell {
    width: min(1180px, 100%);
    padding: 10px 10px calc(112px + env(safe-area-inset-bottom, 0px));
}

.f-execution-mode .f-bottom-nav {
    display: none;
}

.f-terrain-head {
    position: sticky;
    top: 66px;
    z-index: 18;
    margin: -2px 0 10px;
    padding: 12px;
    border: 1px solid #cfe0f6;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(10px);
}

.f-terrain-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
}

.f-kicker {
    margin: 0 0 4px;
    color: var(--f-green);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.f-terrain-title {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.12;
}

.f-terrain-subtitle {
    margin: 4px 0 0;
    color: var(--f-muted);
    font-size: 0.88rem;
    line-height: 1.25;
}

.f-icon-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    background: #fff;
    color: var(--f-blue);
    font-weight: 900;
    cursor: pointer;
}

.f-terrain-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
}

.f-terrain-meta span,
.f-save-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 8px;
    background: #f1f5f9;
    color: #334155;
    font-size: 0.74rem;
    font-weight: 800;
}

.f-terrain-meta span[data-state="info"] {
    background: #e0f2fe;
    color: #075985;
}

.f-terrain-meta span[data-state="active"],
.f-terrain-meta span[data-state="online"],
.f-terrain-meta span[data-state="ready"],
.f-save-chip[data-state="saved"] {
    background: #dcfce7;
    color: #166534;
}

.f-terrain-meta span[data-state="offline"],
.f-terrain-meta span[data-state="danger"],
.f-save-chip[data-state="error"] {
    background: #fee2e2;
    color: #991b1b;
}

.f-terrain-meta span[data-state="warning"],
.f-save-chip[data-state="saving"] {
    background: #fef3c7;
    color: #92400e;
}

.f-terrain-meta span[data-global-save] {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.f-terrain-head.is-collapsed .f-terrain-subtitle,
.f-terrain-head.is-collapsed .f-terrain-meta,
.f-terrain-head.is-collapsed .f-progress-meta {
    display: none;
}

.f-activity-rail {
    position: sticky;
    top: 218px;
    z-index: 16;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(78px, 104px);
    gap: 6px;
    margin: 0 0 10px;
    padding: 6px 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    background: var(--f-bg);
}

.f-terrain-head.is-collapsed + .f-activity-rail {
    top: 144px;
}

.f-activity-rail a {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 5px;
    align-items: center;
    min-height: 34px;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    padding: 5px;
    color: var(--f-ink);
    text-decoration: none;
    background: #fff;
}

.f-activity-rail strong {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: #e2e8f0;
    font-size: 0.72rem;
}

.f-activity-rail span {
    min-width: 0;
    overflow: hidden;
    color: #334155;
    font-size: 0.64rem;
    line-height: 1.05;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.f-activity-rail a.is-active {
    border-color: var(--f-blue);
    background: var(--f-soft-blue);
}

.f-activity-rail a.is-done strong {
    color: #fff;
    background: var(--f-green);
}

.f-activity-rail a.is-partial strong {
    color: #075985;
    background: #bae6fd;
}

.f-activity-rail a.is-stale {
    border-color: #f59e0b;
}

.f-ucl-band {
    display: grid;
    gap: 3px;
    margin-bottom: 8px;
    padding: 8px 10px;
    border-left: 4px solid var(--f-blue);
    border-radius: 8px;
    background: #f8fbff;
}

.f-ucl-band span {
    color: var(--f-blue);
    font-size: 0.68rem;
    font-weight: 900;
}

.f-ucl-band strong {
    line-height: 1.18;
    font-size: 0.78rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.f-activity-sheet {
    display: grid;
    gap: 10px;
    padding: 10px;
    border: 1px solid #d7e3f4;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.f-activity-titlebar {
    display: grid;
    gap: 6px;
}

.f-activity-titlebar h2,
.f-zone-title h3 {
    margin: 0;
    line-height: 1.18;
}

.f-activity-titlebar h2 {
    font-size: 0.96rem;
    line-height: 1.16;
}

.f-activity-badges,
.f-ai-toolbar,
.f-audio-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.f-audio-label {
    font-size: 0.78rem;
    font-weight: 900;
    color: #334155;
}

.f-transcript-box {
    display: grid;
    gap: 4px;
    padding: 8px;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    background: #f0fdf4;
}

.f-transcript-box strong {
    color: #166534;
    font-size: 0.72rem;
    text-transform: uppercase;
}

.f-transcript-box p {
    margin: 0;
    color: #0f172a;
    font-size: 0.84rem;
    line-height: 1.32;
}

.f-badge-ok {
    background: var(--f-soft-green);
    color: #047857;
}

.f-badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.f-activity-controls {
    display: grid;
    gap: 10px;
}

.f-fieldset {
    min-width: 0;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--f-line);
    border-radius: 8px;
}

.f-fieldset legend {
    padding: 0 4px;
    color: #334155;
    font-size: 0.86rem;
    font-weight: 900;
}

.f-segmented-activity {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
}

.f-score-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.f-score-grid input {
    position: absolute;
    opacity: 0;
}

.f-score-grid span {
    display: grid;
    place-items: center;
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    font-weight: 900;
}

.f-score-grid input:checked + span {
    border-color: var(--f-green);
    background: var(--f-soft-green);
    color: #047857;
}

.f-compact-textarea {
    min-height: 64px;
}

.f-zone-title {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.f-zone-title span {
    color: var(--f-muted);
    font-size: 0.84rem;
}

.f-criteria-stack {
    display: grid;
    gap: 10px;
}

.f-criterion-row {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    background: #fbfdff;
}

.f-criterion-copy {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
}

.f-criterion-copy strong {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--f-soft-blue);
    color: var(--f-blue);
}

.f-criterion-copy p {
    margin: 0;
    line-height: 1.34;
    overflow-wrap: anywhere;
}

.f-criterion-input {
    min-height: 64px;
}

.f-criterion-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}

.f-btn-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 0.82rem;
}

.f-counter {
    margin: 0;
    color: var(--f-warning);
    font-size: 0.78rem;
    font-weight: 800;
}

.f-counter.is-ok {
    color: #047857;
}

.f-help-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 6px 0;
    padding: 7px 8px;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    background: #f0f9ff;
    color: #075985;
    font-size: 0.76rem;
    line-height: 1.25;
}

.f-help-note span {
    display: grid;
    place-items: center;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #0284c7;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 900;
}

.f-recording-status,
.f-ai-hint {
    min-width: 0;
    color: var(--f-muted);
    font-size: 0.76rem;
    font-weight: 800;
}

.f-recording-status[data-state="recording"] {
    color: #b91c1c;
}

.f-recording-status[data-state="danger"],
.f-ai-hint[data-state="blocked"] {
    color: #b91c1c;
}

.f-recording-status[data-state="saved"],
.f-ai-hint[data-state="ready"] {
    color: #047857;
}

.f-btn.is-recording {
    border-color: #ef4444;
    color: #b91c1c;
    background: #fee2e2;
}

.f-btn.is-loading {
    opacity: 0.95;
    cursor: wait;
    color: #fff;
    background: linear-gradient(90deg, #2563eb, #059669, #2563eb);
    background-size: 200% 100%;
    animation: f-ai-pulse 1.1s linear infinite;
}

.f-ai-toolbar [data-ai-op="activity_improve_writing"] {
    border: 1px solid #86efac;
    color: #065f46;
    background: #dcfce7;
}

.f-ai-toolbar [data-ai-op="activity_improve_writing"]:disabled {
    border-color: #fecaca;
    color: #991b1b;
    background: #fef2f2;
}

.f-justification-text.is-ai-working {
    filter: blur(0.6px);
    border-color: #60a5fa;
    background: repeating-linear-gradient(135deg, #f8fbff 0, #f8fbff 10px, #eff6ff 10px, #eff6ff 20px);
    animation: f-textarea-working 1.1s ease-in-out infinite;
}

.f-toast-stack {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    z-index: 80;
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.f-toast-stack .f-live-status {
    position: static;
    margin: 0;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.f-toast-stack .f-live-status.is-hiding {
    opacity: 0;
    transform: translateY(8px);
}

.f-evidence-panel {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 8px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #f8fbff;
}

.f-evidence-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.f-evidence-head > span {
    margin-right: auto;
    color: #1e3a8a;
    font-size: 0.78rem;
    font-weight: 900;
}

.f-evidence-head input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.f-evidence-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 96px));
    gap: 8px;
}

.f-evidence-thumb {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    background: #fff;
}

.f-evidence-thumb img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #e2e8f0;
}

.f-evidence-thumb figcaption {
    padding: 4px 6px;
    color: #475569;
    font-size: 0.68rem;
    font-weight: 800;
}

@keyframes f-ai-pulse {
    from { background-position: 0 0; }
    to { background-position: 200% 0; }
}

@keyframes f-textarea-working {
    0%, 100% { box-shadow: 0 0 0 rgba(37, 99, 235, 0); }
    50% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14); }
}

.f-justification-panel {
    padding-top: 4px;
}

.f-transcription-dialog {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: end center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.45);
}

.f-transcription-dialog[hidden] {
    display: none;
}

.f-transcription-dialog > div {
    width: min(560px, 100%);
    padding: 16px;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--f-shadow);
}

.f-transcription-dialog h3 {
    margin: 0 0 10px;
}

.f-dialog-context {
    margin: -2px 0 10px;
    padding: 8px;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.82rem;
    line-height: 1.25;
}

.f-review-gate {
    margin: 12px 0;
    padding: 12px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--f-muted);
}

.f-wizard-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 8px;
    padding: 10px max(10px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-right, 0px));
    border-top: 1px solid var(--f-line);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -8px 22px rgba(15, 23, 42, 0.10);
}

.f-live-status {
    top: 156px;
}

.f-disabled {
    opacity: 0.55;
    pointer-events: none;
}

.f-history-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.f-history-search,
.f-history-actions {
    grid-column: 1 / -1;
}

.f-history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.f-history-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.f-history-metrics .f-card {
    display: grid;
    gap: 4px;
    min-height: 82px;
    padding: 12px;
}

.f-history-metrics span,
.f-report-summary span {
    color: var(--f-muted);
    font-size: 0.74rem;
    font-weight: 800;
}

.f-history-metrics strong,
.f-report-summary strong {
    color: var(--f-ink);
    font-size: 1.3rem;
    line-height: 1;
}

.f-responsive-table {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    background: #fff;
}

.f-history-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.f-history-table th,
.f-history-table td {
    padding: 10px;
    border-bottom: 1px solid var(--f-line);
    text-align: left;
    vertical-align: top;
}

.f-history-table th {
    background: #f8fafc;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.f-history-table td small {
    display: block;
    margin-top: 3px;
    color: var(--f-muted);
    font-size: 0.72rem;
    line-height: 1.2;
}

.f-report-panel {
    margin-bottom: 12px;
}

.f-report-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.f-report-head p {
    margin: 0 0 4px;
    color: var(--f-green);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.f-report-head h1 {
    margin: 0;
    font-size: 1.42rem;
    line-height: 1.1;
}

.f-report-head span,
.f-report-note {
    color: var(--f-muted);
}

.f-report-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.f-report-summary div {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--f-line);
    border-radius: 8px;
    background: #f8fafc;
}

.f-report-note {
    margin: 12px 0 0;
    font-size: 0.8rem;
}

@media (min-width: 720px) {
    .f-shell { padding: 28px 26px calc(96px + env(safe-area-inset-bottom, 0px)); }
    .f-auth-card { padding: 30px; }
    .f-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .f-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .f-filterbar { grid-template-columns: 2fr 1fr 1fr auto; align-items: center; }
    .f-history-filters { grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; }
    .f-history-search { grid-column: span 3; }
    .f-history-actions { grid-column: span 3; }
    .f-history-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .f-report-summary { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .f-inline-form { grid-template-columns: 1fr auto; align-items: center; }
    .f-detail-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .f-execution-mode .f-shell { padding: 14px 18px 120px; }
    .f-activity-controls { grid-template-columns: 1.4fr 0.8fr; }
    .f-segmented-activity { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .f-criterion-row { grid-template-columns: minmax(240px, 0.86fr) minmax(320px, 1fr); align-items: start; }
    .f-activity-titlebar { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
    .f-transcription-dialog { place-items: center; }
}

@media (min-width: 920px) {
    .f-shell { padding-bottom: 44px; }
}

@media print {
    body {
        background: #fff;
    }

    .f-appbar,
    .f-topbar,
    .f-bottom-nav,
    .f-skip-link,
    .f-no-print {
        display: none !important;
    }

    .f-shell {
        width: 100%;
        padding: 0;
    }

    .f-panel,
    .f-card {
        box-shadow: none;
        border-color: #cbd5e1;
    }

    .f-print-table,
    .f-history-table {
        min-width: 0;
        font-size: 9pt;
    }

    .f-history-table th,
    .f-history-table td {
        padding: 5px;
    }
}
