/* Design system — Workflow panel (tema claro profesional por defecto) */
:root {
    --bg: #f4f6f9;
    --bg-subtle: #eef1f6;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #2563eb;
    --accent-soft: #eff6ff;
    --accent-hover: #1d4ed8;
    --accent-glow: rgba(37, 99, 235, 0.2);
    --success: #16a34a;
    --success-soft: #f0fdf4;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --error: #dc2626;
    --error-soft: #fef2f2;
    --sidebar-rail-w: 76px;
    --sidebar-w: 272px;
    --sidebar-workflow: #2563eb;
    --sidebar-conexion: #0891b2;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 20px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.08);
    --font: 'DM Sans', system-ui, -apple-system, sans-serif;
    --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body.app-guest {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 90% 60% at 50% -10%, rgba(37, 99, 235, 0.06), transparent 55%),
        linear-gradient(180deg, #ffffff 0%, var(--bg) 45%);
}

body.app-auth {
    background: var(--bg);
}

/* ——— App shell ——— */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ——— Sidebar rail (estrecho + desplegable) ——— */
.sidebar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 28px rgba(15, 23, 42, 0.05);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    overflow: hidden;
}

.sidebar--rail {
    width: var(--sidebar-rail-w);
    transition: width 0.24s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.24s ease;
}

.sidebar[data-active-section="workflow"] { --sidebar-accent-current: var(--sidebar-workflow); }
.sidebar[data-active-section="conexion"] { --sidebar-accent-current: var(--sidebar-conexion); }
.sidebar[data-active-section=""] { --sidebar-accent-current: var(--accent); }

.sidebar-accent {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--sidebar-accent-current, var(--accent)) 0%, transparent 85%);
    opacity: 0.85;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.25s ease;
}

.sidebar--rail:not(.is-expanded):not(:hover):not(.is-open) .sidebar-accent {
    opacity: 0.55;
}

.sidebar-expandable {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, max-width 0.24s ease, transform 0.2s ease;
    max-width: 220px;
    opacity: 1;
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-expandable {
    max-width: 0;
    opacity: 0;
    transform: translateX(-4px);
}

.sidebar-top {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.85rem 0.5rem 0.65rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-mobile-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: auto;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.sidebar-mobile-close:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.4rem;
    min-height: 48px;
    text-decoration: none;
    color: inherit;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.sidebar-brand:hover {
    background: var(--surface-hover);
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(145deg, #3b82f6 0%, var(--accent) 55%, #1d4ed8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.12rem;
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 0.96rem; letter-spacing: -0.02em; }
.brand-text small { font-size: 0.68rem; color: var(--text-muted); }

.sidebar-nav {
    position: relative;
    z-index: 2;
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem 0.45rem 0.5rem;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 99px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.sidebar-rail-sep {
    display: none;
    height: 1px;
    margin: 0.4rem 0.85rem 0.5rem;
    background: linear-gradient(90deg, transparent, var(--border) 20%, var(--border) 80%, transparent);
}

.sidebar--rail:not(.is-expanded):not(:hover):not(.is-open) .sidebar-rail-sep {
    display: block;
}

.sidebar--rail.is-expanded .sidebar-rail-sep,
.sidebar--rail.is-expanded .sidebar-rail-badge,
.sidebar--rail:not(.is-expanded):hover .sidebar-rail-sep,
.sidebar--rail:not(.is-expanded):hover .sidebar-rail-badge,
.sidebar--rail.is-open .sidebar-rail-sep,
.sidebar--rail.is-open .sidebar-rail-badge {
    display: none !important;
}

.sidebar-rail-badge {
    display: none;
    width: 28px;
    height: 18px;
    margin: 0 auto 0.35rem;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 18px;
    text-align: center;
    border-radius: 6px;
    color: var(--text-muted);
    background: var(--surface-2);
}

.sidebar-group--workflow .sidebar-rail-badge { color: var(--sidebar-workflow); background: rgba(37, 99, 235, 0.1); }
.sidebar-group--conexion .sidebar-rail-badge { color: var(--sidebar-conexion); background: rgba(8, 145, 178, 0.1); }
.sidebar-group.is-section-active .sidebar-rail-badge { box-shadow: 0 0 0 1px currentColor; }

.sidebar--rail:not(.is-expanded):not(:hover):not(.is-open) .sidebar-rail-badge {
    display: block;
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-rail-sep + .sidebar-group .sidebar-rail-badge {
    margin-top: 0.15rem;
}

.sidebar-group {
    margin-bottom: 0.5rem;
}

.sidebar-group + .sidebar-group {
    padding-top: 0.55rem;
    margin-top: 0.35rem;
    border-top: 1px solid var(--border);
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-group + .sidebar-group {
    border-top-color: transparent;
    padding-top: 0.2rem;
    margin-top: 0.15rem;
}

.sidebar-group-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.55rem 0.45rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.sidebar-group-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-muted);
    opacity: 0.5;
}

.sidebar-group--workflow .sidebar-group-dot { background: var(--sidebar-workflow); opacity: 1; }
.sidebar-group--conexion .sidebar-group-dot { background: var(--sidebar-conexion); opacity: 1; }

.sidebar-group--workflow.is-section-active .sidebar-group-title { color: var(--sidebar-workflow); }
.sidebar-group--conexion.is-section-active .sidebar-group-title { color: var(--sidebar-conexion); }

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-group-head {
    display: none;
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-group {
    margin-bottom: 0.2rem;
}

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0.55rem;
    margin: 0 0.15rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition), transform 0.15s ease;
}

.sidebar-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-link {
    justify-content: center;
    padding: 0.45rem;
    margin: 0 0.3rem;
}

.sidebar-link:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.sidebar-link-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.sidebar-link-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.sidebar-link:hover .sidebar-link-icon {
    background: var(--surface-2);
    color: var(--text);
}

.sidebar-link-text {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.sidebar-link-bar {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0.6);
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--transition), transform var(--transition);
}

.sidebar-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 600;
}

.sidebar-link.is-active .sidebar-link-icon {
    background: #fff;
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.15);
}

.sidebar-link.is-active .sidebar-link-bar {
    opacity: 1;
    transform: translateY(-50%) scaleY(1);
}

.sidebar-link.is-active .sidebar-link-icon {
    animation: sidebar-icon-pop 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes sidebar-icon-pop {
    0% { transform: scale(0.92); }
    55% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes sidebar-link-in {
    from { opacity: 0; transform: translateX(-6px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (min-width: 769px) {
    .sidebar--rail.is-expanded .sidebar-links .sidebar-link,
    .sidebar--rail:not(.is-expanded):hover .sidebar-links .sidebar-link,
    .sidebar--rail.is-peek:not(.is-expanded) .sidebar-links .sidebar-link {
        animation: sidebar-link-in 0.28s ease backwards;
    }

    .sidebar--rail.is-expanded .sidebar-links .sidebar-link:nth-child(1),
    .sidebar--rail:not(.is-expanded):hover .sidebar-links .sidebar-link:nth-child(1),
    .sidebar--rail.is-peek .sidebar-links .sidebar-link:nth-child(1) { animation-delay: 0.02s; }
    .sidebar--rail.is-expanded .sidebar-links .sidebar-link:nth-child(2),
    .sidebar--rail:not(.is-expanded):hover .sidebar-links .sidebar-link:nth-child(2),
    .sidebar--rail.is-peek .sidebar-links .sidebar-link:nth-child(2) { animation-delay: 0.05s; }
    .sidebar--rail.is-expanded .sidebar-links .sidebar-link:nth-child(3),
    .sidebar--rail:not(.is-expanded):hover .sidebar-links .sidebar-link:nth-child(3),
    .sidebar--rail.is-peek .sidebar-links .sidebar-link:nth-child(3) { animation-delay: 0.08s; }
    .sidebar--rail.is-expanded .sidebar-links .sidebar-link:nth-child(4),
    .sidebar--rail:not(.is-expanded):hover .sidebar-links .sidebar-link:nth-child(4),
    .sidebar--rail.is-peek .sidebar-links .sidebar-link:nth-child(4) { animation-delay: 0.11s; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar--rail,
    .sidebar-link,
    .sidebar-link-icon,
    .sidebar-expandable {
        transition: none !important;
        animation: none !important;
    }
}

.sidebar-group--conexion .sidebar-link.is-active {
    background: rgba(8, 145, 178, 0.08);
    color: #0e7490;
}

.sidebar-group--conexion .sidebar-link.is-active .sidebar-link-icon {
    color: var(--sidebar-conexion);
    box-shadow: 0 1px 4px rgba(8, 145, 178, 0.2);
}

.sidebar-group--conexion .sidebar-link.is-active .sidebar-link-bar {
    background: var(--sidebar-conexion);
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-link.is-active {
    background: transparent;
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-link.is-active .sidebar-link-icon {
    background: var(--accent-soft);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-group--conexion .sidebar-link.is-active .sidebar-link-icon {
    background: rgba(8, 145, 178, 0.12);
    box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.25);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.9;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.sidebar-footer {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    padding: 0.5rem 0.45rem 0.85rem;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-hover) 0%, #f1f5f9 100%);
}

.sidebar-pin {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: calc(100% - 0.2rem);
    margin: 0 0.1rem 0.5rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-pin {
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-left: auto;
    margin-right: auto;
    padding: 0;
    border-radius: 12px;
}

.sidebar-pin:hover {
    background: var(--accent-soft);
    border-color: #93c5fd;
    color: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.sidebar-pin:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sidebar--rail.is-pinned .sidebar-pin {
    background: var(--accent-soft);
    border-color: rgba(37, 99, 235, 0.35);
    color: var(--accent-hover);
}

.sidebar-pin-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
}

.sidebar--rail.is-pinned .sidebar-pin-icon {
    background: #fff;
}

.sidebar-pin .icon-unpin { display: none; }
.sidebar--rail.is-expanded .sidebar-pin .icon-pin { display: none; }
.sidebar--rail.is-expanded .sidebar-pin .icon-unpin { display: block; }

.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.45rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-user-card {
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.35rem;
    background: transparent;
    border: none;
    box-shadow: none;
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    margin-left: auto;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.sidebar-logout-btn:hover {
    background: var(--error-soft);
    color: var(--error);
    text-decoration: none;
}

.sidebar--rail:not(.is-expanded):not(:hover) .sidebar-logout-btn {
    margin-left: 0;
}

.user-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-tenant {
    font-size: 0.68rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Escritorio: expandir al hover (flotante) o fijado */
@media (min-width: 769px) {
    html.sidebar-pinned-init #app-sidebar,
    .sidebar--rail.is-expanded {
        width: var(--sidebar-w);
    }

    .sidebar--rail:not(.is-expanded):hover,
    .sidebar--rail.is-peek:not(.is-expanded) {
        position: fixed;
        left: 0;
        top: 0;
        width: var(--sidebar-w);
        height: 100vh;
        z-index: 250;
        box-shadow: 8px 0 48px rgba(15, 23, 42, 0.14);
    }

    .sidebar--rail.is-peek:not(.is-expanded) .sidebar-expandable {
        max-width: 220px;
        opacity: 1;
        transform: translateX(0);
    }

    .sidebar--rail:not(.is-expanded):hover .sidebar-expandable {
        max-width: 220px;
        opacity: 1;
        transform: translateX(0);
    }

    .sidebar-pin { display: flex; }
}

@media (max-width: 768px) {
    .sidebar-pin { display: none; }
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--accent-soft) 0%, #dbeafe 100%);
    color: var(--accent);
    border: 1px solid rgba(37, 99, 235, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
    flex-shrink: 0;
}

.sidebar--rail.is-pinned ~ .app-main {
    transition: flex 0.24s ease;
}

.user-meta { flex: 1; min-width: 0; }
.user-name {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-tenant {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-logout {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.user-logout:hover {
    color: var(--error);
    background: var(--error-soft);
}

.app-main {
    flex: 1;
    min-width: 0;
    background: var(--bg);
}

.app-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2.5rem 3rem;
}

.guest-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* ——— Page header ——— */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin-bottom: 1.75rem;
}

.page-eyebrow {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin: 0 0 0.35rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-desc {
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 52ch;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 1rem;
    transition: color var(--transition);
}
.back-link:hover { color: var(--accent); }

/* ——— Cards ——— */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.65rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.card > h2:first-child {
    padding-bottom: 0.75rem;
    margin-bottom: 1.15rem;
    border-bottom: 1px solid var(--border);
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.card h2:not(:first-child) { margin-top: 1.5rem; }

.card-flat {
    box-shadow: none;
    background: var(--surface-2);
    border-style: dashed;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.auth-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-card-intro {
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-brand h1 {
    margin: 0.75rem 0 0.25rem;
    font-size: 1.5rem;
}

.auth-brand .brand-mark {
    margin: 0 auto;
    width: 52px;
    height: 52px;
    font-size: 1.25rem;
}

.guest-main .card {
    box-shadow: var(--shadow-lg);
    border-color: var(--border);
}

/* ——— KPI & stat cards ——— */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    transition: border-color var(--transition), transform var(--transition);
}

.kpi-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.kpi-card.is-highlight {
    border-color: rgba(59, 130, 246, 0.4);
    background: linear-gradient(145deg, var(--accent-soft), transparent);
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ——— Feature cards (Conexión) ——— */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 900px) {
    .grid-3 { grid-template-columns: 1fr; }
}
.mobile-nav {
    display: none;
}

@media (max-width: 768px) {
    .grid { grid-template-columns: 1fr; }
    .app-content { padding: 1.25rem 1rem 2rem; }
    .mobile-nav {
        display: flex;
        gap: 0.35rem;
        overflow-x: auto;
        padding: 0.65rem 1rem;
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--border);
        -webkit-overflow-scrolling: touch;
    }
    .mobile-nav a {
        flex-shrink: 0;
        padding: 0.4rem 0.75rem;
        border-radius: 999px;
        font-size: 0.8rem;
        font-weight: 500;
        text-decoration: none;
        color: var(--text-secondary);
        background: var(--surface);
        border: 1px solid var(--border);
    }
    .mobile-nav a.is-active {
        background: var(--accent-soft);
        color: var(--accent-hover);
        border-color: rgba(37, 99, 235, 0.25);
    }
    .page-header h1 { font-size: 1.4rem; }
}

label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    font-weight: 400;
    cursor: pointer;
}

label:has(input[type="checkbox"]) input {
    width: auto;
    margin: 0;
    accent-color: var(--accent);
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    min-height: 140px;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.card-link:hover {
    border-color: rgba(37, 99, 235, 0.35);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-link .card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.card-link .card-icon svg { width: 22px; height: 22px; }

.card-link h2 { margin-top: 0; }

.card-link p {
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.mini-stats {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mini-stats li { padding: 0.2rem 0; }

/* ——— Timeline ——— */
.timeline-track {
    display: flex;
    align-items: stretch;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}

.timeline-step {
    flex: 1;
    min-width: 120px;
    text-align: center;
    padding: 1.25rem 0.75rem;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.timeline-step + .timeline-connector {
    flex: 0 0 24px;
    align-self: center;
    height: 2px;
    background: var(--border-strong);
    margin: 0 -4px;
    z-index: 0;
}

.timeline-step.is-highlight {
    border-color: var(--accent);
    background: linear-gradient(180deg, var(--accent-soft), var(--surface-2));
}

.step-icon {
    width: 36px;
    height: 36px;
    line-height: 36px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 2px solid var(--border-strong);
    margin: 0 auto 0.65rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.timeline-step.is-highlight .step-icon {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 16px var(--accent-glow);
}

.step-label {
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
}

.step-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Vertical timeline */
.timeline-vertical { list-style: none; padding: 0; margin: 0; }

.timeline-v-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0 1rem 1.75rem;
    border-left: 2px solid var(--border);
    margin-left: 0.75rem;
    position: relative;
}

.timeline-v-item.done { border-left-color: var(--success); }
.timeline-v-item.current { border-left-color: var(--accent); }
.timeline-v-item.highlight .tv-marker {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.tv-marker {
    position: absolute;
    left: -0.55rem;
    width: 1.1rem;
    height: 1.1rem;
    line-height: 1.1rem;
    text-align: center;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
    font-size: 0.6rem;
    font-weight: 700;
}

.tv-body time {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ——— Forms ——— */
label {
    display: block;
    margin: 0.85rem 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select, textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: #ffffff;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

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

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
}

legend { font-weight: 600; padding: 0 0.5rem; }

.checklist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.65rem;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 400;
    margin: 0;
    padding: 0.5rem 0.65rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.check-item input { width: auto; margin: 0; }

/* ——— Buttons ——— */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.15rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition), transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary, .btn {
    background: #ffffff;
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-secondary:hover, .btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-group .btn { margin-top: 0; }

/* ——— Alerts ——— */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-soft);
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background: var(--error-soft);
    color: #991b1b;
    border-color: #fecaca;
}

/* ——— Tables ——— */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead {
    background: var(--surface-2);
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: var(--surface-hover);
}

tbody tr:last-child td { border-bottom: none; }

code {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.8rem;
    padding: 0.15rem 0.4rem;
    background: var(--accent-soft);
    border-radius: 4px;
    color: var(--accent-hover);
}

/* ——— Badges ——— */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-completed, .badge-approved {
    background: var(--success-soft);
    color: #15803d;
    border-color: #bbf7d0;
}

.badge-failed, .badge-blocked {
    background: var(--error-soft);
    color: #b91c1c;
    border-color: #fecaca;
}

.badge-running, .badge-in_progress, .badge-review, .badge-pending, .badge-scheduled {
    background: var(--accent-soft);
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.badge-lead, .badge-budget, .badge-contract, .badge-technical, .badge-execution {
    background: var(--surface-2);
}

/* ——— Logs ——— */
.log-list {
    max-height: 360px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.log {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.log:last-child { border-bottom: none; }

.log time {
    color: var(--text-muted);
    margin-right: 0.5rem;
    font-size: 0.8rem;
}

.log-error { color: var(--error); }

/* ——— Misc ——— */
.muted { color: var(--text-secondary); font-size: 0.9rem; }

.stats { list-style: none; padding: 0; margin: 0; }
.stats li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.stats li:last-child { border-bottom: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.filters {
    margin-bottom: 1.25rem;
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.filters label { margin: 0; }
.filters select { max-width: 220px; }

.code-block {
    background: var(--surface-2);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    font-family: ui-monospace, monospace;
    color: var(--text-secondary);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 1.25rem;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all var(--transition);
}

.pagination a:hover {
    border-color: var(--accent);
    color: var(--text);
    text-decoration: none;
}

.pagination a.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.timeline-horizontal {
    display: flex;
    align-items: stretch;
    gap: 0;
    overflow-x: auto;
}

.timeline-horizontal .timeline-step { flex: 1; min-width: 110px; }
.timeline-horizontal .timeline-arrow {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    padding: 0 0.15rem;
    flex-shrink: 0;
}

.timeline-step-highlight {
    border-color: var(--accent) !important;
    background: linear-gradient(180deg, var(--accent-soft), var(--surface-2)) !important;
}

.timeline-step-highlight .step-icon {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}

/* ——— Modo oscuro (opcional) ——— */
[data-theme="dark"] {
    --bg: #0b0f14;
    --bg-subtle: #111820;
    --bg-elevated: #111820;
    --surface: #151d28;
    --surface-hover: #1a2433;
    --surface-2: #1e2836;
    --border: rgba(148, 163, 184, 0.12);
    --border-strong: rgba(148, 163, 184, 0.22);
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.12);
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.35);
    --success-soft: rgba(34, 197, 94, 0.12);
    --warning-soft: rgba(245, 158, 11, 0.12);
    --error-soft: rgba(239, 68, 68, 0.12);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] body.app-guest {
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.18), transparent),
        var(--bg);
}

[data-theme="dark"] .app-main {
    background:
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(99, 102, 241, 0.08), transparent),
        var(--bg);
}

[data-theme="dark"] .sidebar {
    box-shadow: none;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--bg);
}

[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .btn {
    background: var(--surface-2);
}

[data-theme="dark"] code { color: #93c5fd; background: var(--bg); }
[data-theme="dark"] a { color: #60a5fa; }
[data-theme="dark"] .sidebar-link.is-active { color: #93c5fd; }
[data-theme="dark"] .user-avatar { color: #93c5fd; border-color: transparent; }
[data-theme="dark"] tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
[data-theme="dark"] thead { background: var(--bg); }
[data-theme="dark"] .alert-success { color: #86efac; border-color: rgba(34, 197, 94, 0.25); }
[data-theme="dark"] .alert-error { color: #fca5a5; border-color: rgba(239, 68, 68, 0.25); }
[data-theme="dark"] .badge-completed,
[data-theme="dark"] .badge-approved { color: #86efac; }
[data-theme="dark"] .badge-failed,
[data-theme="dark"] .badge-blocked { color: #fca5a5; }
[data-theme="dark"] .badge-running,
[data-theme="dark"] .badge-in_progress,
[data-theme="dark"] .badge-review,
[data-theme="dark"] .badge-pending,
[data-theme="dark"] .badge-scheduled { color: #93c5fd; }
[data-theme="dark"] .mobile-nav a.is-active { color: #93c5fd; }
[data-theme="dark"] .card-link .card-icon { color: #93c5fd; }
[data-theme="dark"] .guest-main .card { box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45); }
[data-theme="dark"] .timeline-step { background: var(--surface-2); }
[data-theme="dark"] .step-icon { background: var(--bg); }

/* ——— Content topbar ——— */
.content-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 1.5rem;
    padding: 0.65rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
}

.breadcrumbs a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }

.bc-sep { color: var(--text-muted); opacity: 0.5; user-select: none; }
.bc-current { color: var(--text-secondary); font-weight: 500; }

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), border-color var(--transition), transform 0.1s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

.theme-toggle:active { transform: scale(0.95); }

/* ——— Scrollbar ——— */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ——— Animations ——— */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ——— Glass & accent cards ——— */
.card-glass {
    background: linear-gradient(135deg, #ffffff 0%, var(--accent-soft) 100%);
    border-color: #bfdbfe;
}

.card-accent {
    border-left: 3px solid var(--warning);
}

.stat-highlight {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0.5rem 0;
}

/* ——— Pipeline bar ——— */
.pipeline-summary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pipeline-summary-text {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.pipeline-total {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--accent);
}

.pipeline-bar {
    display: flex;
    height: 10px;
    border-radius: 99px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
    gap: 2px;
    padding: 2px;
}

.pipeline-segment {
    border-radius: 99px;
    min-width: 4px;
    transition: width 0.5s ease;
}

.stage-lead { --stage-color: #8b5cf6; }
.stage-budget { --stage-color: #3b82f6; }
.stage-contract { --stage-color: #06b6d4; }
.stage-technical { --stage-color: #f59e0b; }
.stage-execution { --stage-color: #22c55e; }

.pipeline-segment.stage-lead { background: #8b5cf6; }
.pipeline-segment.stage-budget { background: #3b82f6; }
.pipeline-segment.stage-contract { background: #06b6d4; }
.pipeline-segment.stage-technical { background: #f59e0b; }
.pipeline-segment.stage-execution { background: #22c55e; }

.kpi-card.stage-lead { border-left: 3px solid #8b5cf6; }
.kpi-card.stage-budget { border-left: 3px solid #3b82f6; }
.kpi-card.stage-contract { border-left: 3px solid #06b6d4; }
.kpi-card.stage-technical { border-left: 3px solid #f59e0b; }
.kpi-card.stage-execution { border-left: 3px solid #22c55e; }

.timeline-step.stage-lead .step-icon { border-color: #8b5cf6; color: #8b5cf6; }
.timeline-step.stage-budget .step-icon { border-color: #3b82f6; color: #3b82f6; }
.timeline-step.stage-contract .step-icon { border-color: #06b6d4; color: #06b6d4; }
.timeline-step.stage-technical .step-icon,
.timeline-step.stage-technical.timeline-step-highlight .step-icon {
    border-color: #f59e0b;
    background: #f59e0b !important;
    color: #fff !important;
}
.timeline-step.stage-execution .step-icon { border-color: #22c55e; color: #22c55e; }

.kpi-card-link {
    text-decoration: none;
    color: inherit;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.kpi-card-link:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-strong);
}

/* ——— Status banner ——— */
.status-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.status-banner--ok {
    background: var(--success-soft);
    border-color: rgba(34, 197, 94, 0.25);
}

.status-banner--warn {
    background: var(--warning-soft);
    border-color: rgba(245, 158, 11, 0.25);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    animation: pulse 2s ease infinite;
}

.status-banner--ok .status-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-banner--warn .status-dot { background: var(--warning); box-shadow: 0 0 8px var(--warning); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-banner .btn-sm { margin-left: auto; }

.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
    margin-top: 0;
}

/* ——— Card link accents ——— */
.card-link--sync .card-icon { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.card-link--nodes .card-icon { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.card-link--settings .card-icon { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

.mini-stats li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

/* ——— Empty state ——— */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.empty-state-icon svg { width: 100%; height: 100%; }

.empty-state h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin: 0 0 1.25rem;
    max-width: 36ch;
    margin-left: auto;
    margin-right: auto;
}

/* ——— Form panels (settings) ——— */
.form-panel {
    margin-bottom: 1.25rem;
}

.form-panel-header {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.form-panel-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.form-panel-icon svg { width: 22px; height: 22px; }

.form-panel-icon--clientify { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.form-panel-icon--stel { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.form-panel-icon--webhook { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.form-panel-icon--sync { background: rgba(34, 197, 94, 0.15); color: #4ade80; }

.form-panel-header h2 { margin: 0; font-size: 1.05rem; }
.form-panel-header p { margin: 0.25rem 0 0; font-size: 0.85rem; }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
}

@media (max-width: 768px) { .form-grid-2 { grid-template-columns: 1fr; } }

.copy-field {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.copy-field input {
    flex: 1;
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
}

.copy-btn {
    flex-shrink: 0;
    padding: 0 1rem;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition);
}

.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.is-copied { background: var(--success-soft); color: #15803d; border-color: var(--success); }

.rule-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.15rem;
    margin-bottom: 0.75rem;
}

.rule-card legend {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0;
}

.table-action {
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.table-action:hover { text-decoration: underline; }

.sidebar-link.is-active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.page-eyebrow {
    color: var(--accent);
}

[data-theme="dark"] .content-topbar {
    background: var(--surface);
    box-shadow: none;
}

/* Focus visible */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

.code-input {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.82rem;
    line-height: 1.45;
}

.form-sticky-footer {
    position: sticky;
    bottom: 0;
    padding: 1rem 0;
    margin-top: 0.5rem;
    background: linear-gradient(transparent, var(--bg) 30%);
    z-index: 10;
}

.rule-card label select { margin-top: 0.35rem; }

/* Login polish */
.guest-main {
    position: relative;
    overflow: hidden;
}

.guest-main::before {
    content: '';
    position: absolute;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.07), transparent 68%);
    top: -120px;
    right: -80px;
    pointer-events: none;
}

.guest-main::after {
    content: '';
    position: absolute;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.05), transparent 70%);
    bottom: -60px;
    left: -60px;
    pointer-events: none;
}

.guest-main .auth-card,
.guest-main .auth-brand {
    position: relative;
    z-index: 1;
}

.auth-form label:first-of-type { margin-top: 0; }

.auth-submit {
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.75rem;
    font-size: 1rem;
}

input::placeholder { color: var(--text-muted); opacity: 0.7; }

.badge-pending {
    background: var(--warning-soft);
    color: #b45309;
    border-color: #fde68a;
}

.kpi-card.is-highlight {
    border-color: #93c5fd;
    background: linear-gradient(145deg, #ffffff, var(--accent-soft));
}

[data-theme="dark"] .card-glass {
    background: linear-gradient(135deg, var(--accent-soft), transparent);
    border-color: rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .kpi-card.is-highlight {
    background: linear-gradient(145deg, var(--accent-soft), transparent);
}

[data-theme="dark"] .pipeline-bar { background: var(--bg); }
[data-theme="dark"] .rule-card { background: var(--bg); }
[data-theme="dark"] .sidebar-user-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}

[data-theme="dark"] .sidebar-accent {
    opacity: 0.7;
}

[data-theme="dark"] .sidebar-rail-badge {
    background: var(--surface-2);
}

[data-theme="dark"] .sidebar-footer {
    background: var(--bg);
}

/* ——— Usabilidad: accesibilidad ——— */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0.75rem;
    z-index: 1000;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    left: 0.75rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.required { color: var(--error); }

.field-hint {
    margin: 0.35rem 0 0.85rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.hide-mobile { display: revert; }

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
}

/* ——— Topbar acciones ——— */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.topbar-cta { white-space: nowrap; }

.topbar-logout {
    font-size: 0.82rem;
    color: var(--text-muted) !important;
}

.topbar-logout:hover { color: var(--error) !important; }

.content-topbar .breadcrumbs { flex: 1; min-width: 0; }

@media (max-width: 640px) {
    .topbar-cta:not(.btn-primary) { display: none; }
    .topbar-cta.btn-primary { padding: 0.45rem 0.65rem; font-size: 0.78rem; }
}

/* ——— Menú móvil / drawer ——— */
.mobile-topbar {
    display: none;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 150;
    backdrop-filter: blur(2px);
}

body.sidebar-open { overflow: hidden; }

@media (max-width: 768px) {
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.65rem 1rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 90;
    }

    .mobile-topbar-title {
        font-weight: 600;
        font-size: 0.95rem;
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
        color: var(--text);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background var(--transition);
    }

    .mobile-menu-btn:hover { background: var(--surface-hover); }

    .sidebar-mobile-close { display: flex; }

    .sidebar-brand { flex: 1; min-width: 0; }

    .sidebar-rail-sep,
    .sidebar-rail-badge { display: none !important; }

    .sidebar-accent { opacity: 1; width: 4px; }

    .sidebar--rail {
        position: fixed;
        left: 0;
        top: 0;
        width: min(var(--sidebar-w), 88vw) !important;
        transform: translateX(-105%);
        transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
        z-index: 200;
        box-shadow: 12px 0 48px rgba(15, 23, 42, 0.18);
    }

    .sidebar--rail .sidebar-expandable {
        max-width: 220px;
        opacity: 1;
        transform: none;
    }

    .sidebar--rail.is-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    .sidebar-backdrop[hidden] { display: none; }

    .page-actions.hide-mobile { display: none; }
}

/* ——— FAB móvil ——— */
.mobile-fab {
    display: none;
}

@media (max-width: 768px) {
    .mobile-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        right: 1.25rem;
        bottom: 1.25rem;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--accent);
        color: #fff;
        font-size: 1.75rem;
        font-weight: 300;
        line-height: 1;
        text-decoration: none;
        box-shadow: 0 4px 20px var(--accent-glow);
        z-index: 80;
        transition: transform 0.15s, background var(--transition);
    }

    .mobile-fab:hover {
        background: var(--accent-hover);
        color: #fff;
        text-decoration: none;
        transform: scale(1.05);
    }

    .app-content { padding-bottom: 5rem; }
}

/* ——— Toasts ——— */
.toast-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(400px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    box-shadow: var(--shadow-lg);
    background: var(--surface);
    pointer-events: auto;
    animation: toastIn 0.35s ease backwards;
}

.toast.is-dismissed {
    animation: toastOut 0.28s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(12px); }
}

.toast--success {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.toast--error {
    border-color: #fecaca;
    background: #fef2f2;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text);
}

.toast--success .toast-message { color: #166534; }
.toast--error .toast-message { color: #991b1b; }

.toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text);
}

[data-theme="dark"] .toast { background: var(--surface); }
[data-theme="dark"] .toast--success { background: var(--success-soft); border-color: rgba(34, 197, 94, 0.3); }
[data-theme="dark"] .toast--error { background: var(--error-soft); border-color: rgba(239, 68, 68, 0.3); }
[data-theme="dark"] .toast--success .toast-message { color: #86efac; }
[data-theme="dark"] .toast--error .toast-message { color: #fca5a5; }

/* ——— Filtros y búsqueda ——— */
.filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem !important;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.chip:hover {
    border-color: var(--border-strong);
    color: var(--text);
    text-decoration: none;
}

.chip.is-active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    border-color: #93c5fd;
    font-weight: 600;
}

.search-field {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 340px;
}

.search-field input {
    padding-left: 2.5rem;
    margin: 0;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}

/* ——— Tablas interactivas ——— */
.table-row-link {
    cursor: pointer;
}

.table-row-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.table-row-link:hover td {
    background: var(--accent-soft);
}

.table-actions {
    white-space: nowrap;
    text-align: right;
}

.table-actions .btn { margin-top: 0; }

.table-hint {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
    text-align: center;
}

.row-title { font-weight: 600; }

.log-empty { padding: 1rem; margin: 0; }

/* ——— Stepper horizontal ——— */
.stage-stepper {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0.25rem 0 1.25rem;
    margin-bottom: 0.5rem;
    scrollbar-width: thin;
}

.stage-step {
    flex: 1;
    min-width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
    opacity: 0.45;
    transition: opacity var(--transition);
}

.stage-step.is-done,
.stage-step.is-current { opacity: 1; }

.stage-step-dot {
    width: 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--surface-2);
    border: 2px solid var(--border-strong);
    color: var(--text-muted);
}

.stage-step.is-current .stage-step-dot {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.stage-step.is-done .stage-step-dot {
    background: var(--success-soft);
    border-color: var(--success);
    color: var(--success);
}

.stage-step-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.2;
    max-width: 8ch;
}

.stage-step.is-current .stage-step-label { color: var(--accent-hover); }

@media (min-width: 769px) {
    .stage-step-label { font-size: 0.72rem; max-width: none; }
}

.card-sticky-panel {
    position: sticky;
    top: 1rem;
    align-self: start;
}

/* ——— Formularios estructurados ——— */
.form-layout .form-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.form-layout .form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 1rem;
}

.form-section-title {
    margin: 0 0 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.form-layout label:first-of-type { margin-top: 0; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

.form-actions .btn { margin-top: 0; }

/* ——— Botón loading ——— */
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    left: 50%;
    top: 50%;
    margin: -9px 0 0 -9px;
}

.btn-secondary.is-loading::after {
    border-color: rgba(15, 23, 42, 0.15);
    border-top-color: var(--accent);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Badge etapas con color en tema claro */
/* Fases del proceso */
.badge-phase-inicio { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge-phase-planificacion { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-phase-preparacion { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.badge-phase-ejecucion { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-phase-cierre { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

.pipeline-segment.phase-inicio { background: #8b5cf6; }
.pipeline-segment.phase-planificacion { background: #3b82f6; }
.pipeline-segment.phase-preparacion { background: #06b6d4; }
.pipeline-segment.phase-ejecucion { background: #f59e0b; }
.pipeline-segment.phase-cierre { background: #22c55e; }

.kpi-card.phase-inicio { border-left: 3px solid #8b5cf6; }
.kpi-card.phase-planificacion { border-left: 3px solid #3b82f6; }
.kpi-card.phase-preparacion { border-left: 3px solid #06b6d4; }
.kpi-card.phase-ejecucion { border-left: 3px solid #f59e0b; }
.kpi-card.phase-cierre { border-left: 3px solid #22c55e; }

/* Departamentos */
.badge.dept-sales, .dept-sales { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge.dept-engineering, .dept-engineering { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.badge.dept-legal, .dept-legal { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }
.badge.dept-operations, .dept-operations { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

/* Pasos (legado + nuevos) */
.badge-lead_entry, .badge-lead { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge-quote, .badge-budget { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-contract { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.badge-technical_visit, .badge-technical { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.badge-licenses { background: #faf5ff; color: #7e22ce; border-color: #e9d5ff; }
.badge-logistics { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.badge-installation, .badge-execution { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge-legalization { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge-installation_complete { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-invoicing, .badge-closed { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }

/* Matriz proceso */
.process-matrix-wrap { overflow-x: auto; margin: 0 -0.25rem; }
.process-matrix {
    display: grid;
    grid-template-columns: 140px repeat(5, minmax(120px, 1fr));
    gap: 2px;
    min-width: 800px;
    font-size: 0.78rem;
}
.process-matrix-header,
.process-matrix-row { display: contents; }
.process-matrix-corner,
.process-matrix-phase,
.process-matrix-dept,
.process-matrix-cell {
    padding: 0.65rem 0.5rem;
    border: 1px solid var(--border);
    background: var(--surface);
}
.process-matrix-corner {
    background: var(--surface-2);
    font-weight: 600;
    border-radius: var(--radius-sm) 0 0 0;
}
.process-matrix-phase {
    background: var(--accent-soft);
    text-align: center;
}
.process-matrix-phase strong { display: block; font-size: 0.82rem; }
.process-phase-duration { display: block; font-size: 0.68rem; color: var(--text-muted); }
.process-milestone { display: block; font-size: 0.65rem; color: var(--accent-hover); margin-top: 0.25rem; }
.process-matrix-dept {
    background: var(--surface-2);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.process-matrix-cell {
    vertical-align: top;
    min-height: 64px;
}
.dept-sales .process-matrix-dept { border-left: 3px solid #3b82f6; }
.dept-engineering .process-matrix-dept { border-left: 3px solid #f59e0b; }
.dept-legal .process-matrix-dept { border-left: 3px solid #8b5cf6; }
.dept-operations .process-matrix-dept { border-left: 3px solid #22c55e; }
.process-step-card {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.4rem 0.45rem;
    margin-bottom: 0.35rem;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.process-step-num {
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    background: var(--surface);
    font-weight: 700;
    font-size: 0.65rem;
    flex-shrink: 0;
}
.process-step-name { line-height: 1.25; font-weight: 500; }
.process-step-milestone { color: var(--error); font-size: 0.6rem; }
.process-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.8rem;
}

/* Tablero departamentos (detalle expediente) */
.dept-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
@media (max-width: 1100px) { .dept-board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .dept-board { grid-template-columns: 1fr; } }

.dept-column {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}
.dept-column-header {
    padding: 0.65rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.dept-column.dept-sales .dept-column-header { background: #eff6ff; color: #1d4ed8; }
.dept-column.dept-engineering .dept-column-header { background: #fff7ed; color: #c2410c; }
.dept-column.dept-legal .dept-column-header { background: #faf5ff; color: #7e22ce; }
.dept-column.dept-operations .dept-column-header { background: #f0fdf4; color: #15803d; }

.dept-steps { list-style: none; margin: 0; padding: 0.35rem; }
.dept-step {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 0.82rem;
}
.dept-step.is-done { opacity: 0.75; }
.dept-step.is-active { background: var(--accent-soft); border: 1px solid #bfdbfe; }
.dept-step-num {
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
    background: var(--surface-2);
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.dept-step.is-done .dept-step-num { background: var(--success-soft); color: var(--success); }
.dept-step-body { flex: 1; min-width: 0; }
.dept-step-body time { display: block; font-size: 0.72rem; }
.dept-step-check { color: var(--success); font-weight: 700; }

.advance-step-form {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface-2);
}
.advance-step-row { display: flex; flex-direction: column; gap: 0.5rem; }
.advance-step-row .btn { align-self: flex-start; }

.chip-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 0.35rem;
}
.chip-sm { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
.filter-toolbar .filter-chips { margin-bottom: 0.5rem; }

/* ——— UX v7: layout global ——— */
.app-content {
    max-width: 1280px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 2rem);
}

.page-body {
    flex: 1;
}

.page-header-main { min-width: 0; }

.page-header .page-desc a {
    color: var(--accent);
    text-decoration: none;
}
.page-header .page-desc a:hover { text-decoration: underline; }

.section-intro {
    margin: -0.5rem 0 1.25rem;
    font-size: 0.9rem;
}

.results-summary {
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header-row h2 {
    margin: 0;
    padding: 0;
    border: none;
}

.card > h2:first-child:not(.form-section-title) {
    padding-bottom: 0.75rem;
    margin-bottom: 1.15rem;
    border-bottom: 1px solid var(--border);
}

/* Footer */
.app-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.app-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.app-footer a:hover { color: var(--accent); }

.app-footer-sep { opacity: 0.4; }

/* Stat grid (Conexión / dashboard) */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color var(--transition), transform var(--transition);
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
}

.stat-card-link:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    text-decoration: none;
}

.stat-card-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent);
}

.stat-card-icon svg {
    width: 22px;
    height: 22px;
}

.stat-card-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Entity picker (sync) */
.entity-picker { margin-bottom: 1.25rem; }

.entity-picker-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
    flex-wrap: wrap;
}

.entity-picker-toolbar .muted { flex: 1; }

.entity-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
}

.entity-chip { cursor: pointer; margin: 0; }

.entity-chip input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.entity-chip-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.85rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-align: center;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
}

.entity-chip input:checked + .entity-chip-inner {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-hover);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.entity-chip input:focus-visible + .entity-chip-inner {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.entity-chip-icon { font-size: 1.25rem; }

.sync-form-options { margin-bottom: 1rem; }

.help-list {
    margin: 0;
    padding-left: 1.15rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.help-list li { margin-bottom: 0.5rem; }

.help-list a { color: var(--accent); }

/* Logs */
.log-list-tall { max-height: 420px; }

.log-error, .log.log-error { color: var(--error); }

.badge-log-error { background: var(--error-soft); color: #991b1b; border-color: #fecaca; }
.badge-log-warning { background: var(--warning-soft); color: #b45309; border-color: #fde68a; }
.badge-log-info { background: var(--accent-soft); color: #1d4ed8; border-color: #bfdbfe; }
.badge-log-debug { background: var(--surface-2); color: var(--text-muted); }

.code-truncate {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

/* Settings nav */
.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.65rem 1rem !important;
    margin-bottom: 1.25rem;
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface) !important;
}

.settings-nav a {
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: all var(--transition);
}

.settings-nav a:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

/* Password field */
.password-field {
    position: relative;
    display: flex;
}

.password-field input {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
}

.password-toggle:hover {
    color: var(--text);
    background: var(--surface-2);
}

/* Collapsible filters */
.filter-chips-collapsible {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.chip-toggle {
    border: 1px dashed var(--border-strong);
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
}

.chip-toggle[aria-expanded="true"] .chip-chevron {
    transform: rotate(180deg);
    display: inline-block;
}

.filter-chips-extra {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    width: 100%;
}

.filter-chips-extra:not([hidden]) {
    margin-top: 0.35rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border);
}

/* Card links polish */
.card-link {
    position: relative;
    overflow: hidden;
}

.card-link::after {
    content: '→';
    position: absolute;
    right: 1.25rem;
    bottom: 1.25rem;
    font-size: 1.1rem;
    color: var(--text-muted);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity var(--transition), transform var(--transition);
}

.card-link:hover::after {
    opacity: 1;
    transform: translateX(0);
    color: var(--accent);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* Print */
@media print {
    .sidebar, .mobile-topbar, .mobile-nav, .mobile-fab, .content-topbar, .app-footer, .theme-toggle, .sidebar-pin, .panel-hero { display: none !important; }
    .app-content { max-width: none; padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
}

/* ——— UX v8: refinamiento panel ——— */
:root {
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --ring: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

body.app-auth .app-main {
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -30%, rgba(37, 99, 235, 0.07), transparent 50%),
        radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.035) 1px, transparent 0);
    background-size: 100% 100%, 22px 22px;
    background-position: 0 0, 0 0;
}

/* Topbar con saludo */
.content-topbar {
    gap: 1rem 1.25rem;
    flex-wrap: wrap;
    padding: 0.75rem 1.15rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .content-topbar {
    background: rgba(21, 29, 40, 0.9);
}

.topbar-greeting {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    padding-right: 0.75rem;
    margin-right: 0.25rem;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar-greeting-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.topbar-greeting-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.content-topbar .breadcrumbs {
    flex: 1;
    min-width: 140px;
}

/* Panel hero */
.panel-hero {
    position: relative;
    margin-bottom: 1.5rem;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid rgba(37, 99, 235, 0.15);
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 48%, #ffffff 100%);
    box-shadow: var(--shadow);
}

.panel-hero-glow {
    position: absolute;
    width: 280px;
    height: 280px;
    right: -80px;
    top: -120px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.12), transparent 70%);
    pointer-events: none;
}

.panel-hero-inner {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.35rem 1.5rem;
}

.panel-hero-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-hover);
    background: var(--accent-soft);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    margin-bottom: 0.5rem;
}

.panel-hero-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.panel-hero-subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 42ch;
}

.panel-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

[data-theme="dark"] .panel-hero {
    background: linear-gradient(135deg, var(--surface) 0%, rgba(37, 99, 235, 0.08) 100%);
    border-color: rgba(59, 130, 246, 0.2);
}

/* Page titles */
.page-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.page-eyebrow {
    font-weight: 700;
    letter-spacing: 0.06em;
}

/* Sidebar refinado — ver bloque principal .sidebar-link */

/* KPI mejorados */
.kpi-card {
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
    opacity: 0.6;
}

.kpi-card.phase-inicio::before { background: #8b5cf6; opacity: 1; }
.kpi-card.phase-planificacion::before { background: #3b82f6; opacity: 1; }
.kpi-card.phase-preparacion::before { background: #06b6d4; opacity: 1; }
.kpi-card.phase-ejecucion::before { background: #f59e0b; opacity: 1; }
.kpi-card.phase-cierre::before { background: #22c55e; opacity: 1; }

.kpi-value {
    font-variant-numeric: tabular-nums;
}

/* Cards */
.card {
    border-radius: var(--radius);
    transition: box-shadow var(--transition), border-color var(--transition);
}

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

.card-glass {
    background: linear-gradient(145deg, #ffffff 0%, #f8fbff 50%, #ffffff 100%);
}

/* Tablas */
.table-wrap {
    box-shadow: inset 0 1px 0 var(--border);
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-2);
    box-shadow: 0 1px 0 var(--border);
}

tbody tr:nth-child(even) {
    background: rgba(248, 250, 252, 0.6);
}

[data-theme="dark"] tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Login split */
.guest-main {
    padding: 1.5rem;
}

.auth-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    width: 100%;
    max-width: 920px;
    align-items: center;
}

.auth-panel {
    padding: 1rem 2rem 1rem 0;
}

.auth-panel h1 {
    margin: 1rem 0 0.5rem;
    font-size: 2rem;
    letter-spacing: -0.03em;
}

.auth-tagline {
    color: var(--text-secondary);
    margin: 0 0 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
}

.auth-features {
    list-style: none;
    margin: 0;
    padding: 0;
}

.auth-features li {
    position: relative;
    padding: 0.45rem 0 0.45rem 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-features li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.75rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.brand-mark-lg {
    width: 56px;
    height: 56px;
    font-size: 1.35rem;
}

.auth-card {
    max-width: none;
    box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
    .auth-layout {
        grid-template-columns: 1fr;
        max-width: 400px;
    }
    .auth-panel {
        text-align: center;
        padding: 0 0 0.5rem;
    }
    .auth-features {
        display: none;
    }
    .brand-mark-lg { margin: 0 auto; }
    .panel-hero-inner { flex-direction: column; align-items: flex-start; }
    .panel-hero-title { font-size: 1.15rem; }
}

/* Empty state */
.empty-state {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-strong);
}

/* Status banner */
.status-banner {
    border-radius: var(--radius);
}

/* Process matrix polish */
.process-matrix-phase {
    background: linear-gradient(180deg, var(--accent-soft), var(--surface));
}

.process-step-card:hover {
    border-color: var(--accent);
    background: #fff;
}

/* Dept board cards */
.dept-column {
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.dept-column:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Buttons micro */
.btn {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: linear-gradient(180deg, #3b82f6 0%, var(--accent) 100%);
}

.btn:focus-visible {
    box-shadow: var(--ring);
}

/* Animación contenido */
.content-topbar {
    animation: fadeUp 0.35s ease backwards;
}

.page-body > * {
    animation: fadeUp 0.4s ease backwards;
}

.page-body > .panel-hero { animation-delay: 0.03s; }
.page-body > .page-header { animation-delay: 0.05s; }
.page-body > .card,
.page-body > .grid,
.page-body > .kpi-grid,
.page-body > .stat-grid,
.page-body > .filter-toolbar { animation-delay: 0.08s; }

.app-footer {
    animation: fadeUp 0.4s ease 0.12s backwards;
}

.app-footer-brand { font-weight: 600; color: var(--text-secondary); }
.app-footer-copy { color: var(--text-muted); }

/* ——— UX v9: subnav, tooltips, expediente ——— */
.section-subnav {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0.35rem;
    margin: -0.5rem 0 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.section-subnav::-webkit-scrollbar { display: none; }

.section-subnav-link {
    flex-shrink: 0;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.section-subnav-link:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.section-subnav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.15);
}

/* Tooltips sidebar colapsado */
@media (min-width: 769px) {
    .sidebar--rail:not(.is-expanded):not(:hover):not(.is-peek) [data-tooltip] {
        position: relative;
    }

    .sidebar--rail:not(.is-expanded):not(:hover):not(.is-peek) [data-tooltip]::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%) translateX(-6px);
        padding: 0.45rem 0.75rem;
        background: var(--text);
        color: #fff;
        font-size: 0.78rem;
        font-weight: 500;
        white-space: nowrap;
        border-radius: 8px;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.16s, transform 0.16s;
        z-index: 300;
        box-shadow: var(--shadow-lg);
    }

    .sidebar--rail:not(.is-expanded):not(:hover):not(.is-peek) [data-tooltip]::before {
        content: '';
        position: absolute;
        left: calc(100% + 6px);
        top: 50%;
        transform: translateY(-50%);
        border: 5px solid transparent;
        border-right-color: var(--text);
        opacity: 0;
        transition: opacity 0.16s;
        z-index: 301;
        pointer-events: none;
    }

    .sidebar--rail:not(.is-expanded):not(:hover):not(.is-peek) [data-tooltip]:hover::after,
    .sidebar--rail:not(.is-expanded):not(:hover):not(.is-peek) [data-tooltip]:focus-visible::after {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }

    .sidebar--rail:not(.is-expanded):not(:hover):not(.is-peek) [data-tooltip]:hover::before,
    .sidebar--rail:not(.is-expanded):not(:hover):not(.is-peek) [data-tooltip]:focus-visible::before {
        opacity: 1;
    }
}

/* Resumen expediente */
.case-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem 2rem;
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border);
}

.case-summary-title {
    margin: 0.25rem 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.case-summary-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.case-summary-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
}

.case-summary-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.case-summary-actions { justify-content: center; }

/* Anillo progreso */
.progress-ring {
    position: relative;
    width: 96px;
    height: 96px;
}

.progress-ring-svg { display: block; }

.progress-ring-track {
    stroke: var(--surface-2);
}

.progress-ring-fill {
    stroke: var(--accent);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease;
}

.progress-ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.progress-ring-value {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--accent-hover);
    font-variant-numeric: tabular-nums;
}

.progress-ring-sublabel {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.progress-ring-label {
    margin: 0.35rem 0 0;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Completar paso — selector */
.card-accent-panel {
    border-left: 4px solid var(--accent);
    background: linear-gradient(90deg, var(--accent-soft) 0%, var(--surface) 12%);
}

.advance-step-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.advance-step-option { margin: 0; cursor: pointer; }

.advance-step-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.advance-step-option-inner {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.advance-step-option input:checked + .advance-step-option-inner {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: var(--ring);
}

.advance-step-option input:focus-visible + .advance-step-option-inner {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.advance-step-option-num {
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 50%;
    background: var(--surface-2);
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.advance-step-option input:checked + .advance-step-option-inner .advance-step-option-num {
    background: var(--accent);
    color: #fff;
}

.advance-step-option-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.advance-step-option-text strong { font-size: 0.95rem; }

.dept-step.is-ready { border-left: 3px solid var(--accent); }
.dept-step.is-ready .dept-step-ready {
    font-size: 0.72rem;
    color: var(--accent-hover);
    font-weight: 600;
}

.dept-step.is-current {
    background: var(--accent-soft);
    border: 1px solid #bfdbfe;
}

/* Historial timeline */
.timeline-log .log-item {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.timeline-log .log-item:last-child { border-bottom: none; }

.log-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 0.35rem;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.log-body { flex: 1; min-width: 0; }

.log-body time {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.settings-nav a.is-active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    border-color: rgba(37, 99, 235, 0.2);
}

.filter-toolbar {
    position: relative;
}

.filter-toolbar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(90deg, transparent, var(--surface));
    pointer-events: none;
    opacity: 0;
}

@media (max-width: 768px) {
    .filter-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.25rem; }
    .filter-toolbar::after { opacity: 1; }
    .case-summary { flex-direction: column; align-items: stretch; }
    .case-summary-side { flex-direction: row; justify-content: space-between; }
    .topbar-greeting { display: none; }
}

[data-theme="dark"] .case-summary {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
}

[data-theme="dark"] .sidebar--rail:not(.is-expanded):not(:hover) [data-tooltip]::after {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

[data-theme="dark"] .sidebar--rail:not(.is-expanded):not(:hover) [data-tooltip]::before {
    border-right-color: var(--surface-2);
}
