/* ==========================================================================
   CỔNG TRI THỨC & SA BÀN VẬN HÀNH NHÀ MÁY XẺ SẤY LONG MỸ (3TN SOLUTION)
   DESIGN SYSTEM STYLESHEET (style.css)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* --- 1. CSS CUSTOM PROPERTIES / VARIABLES --- */
:root {
    /* Surfaces & Layout */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-bright: #cbd5e1;
    --border-focus: #059669;

    /* Typography */
    --text: #0f172a;
    --text-dim: #64748b;
    --text-muted: #94a3b8;
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Brand Primary: Forest Green (Mộc & Sinh thái) */
    --forest: #059669;
    --forest-dim: rgba(5, 150, 105, 0.08);
    --forest-border: rgba(5, 150, 105, 0.25);
    --forest-glow: rgba(5, 150, 105, 0.25);

    /* Brand Secondary: Wood Amber (Gỗ sấy & Cấp nhiệt) */
    --wood: #d97706;
    --wood-dim: rgba(217, 119, 6, 0.08);
    --wood-border: rgba(217, 119, 6, 0.25);
    --wood-glow: rgba(217, 119, 6, 0.25);

    /* Accent & Semantic Colors */
    --indigo: #4f46e5;
    --indigo-dim: rgba(79, 70, 229, 0.08);
    --indigo-border: rgba(79, 70, 229, 0.2);

    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.08);
    --blue-border: rgba(59, 130, 246, 0.2);

    --amber: #f59e0b;
    --amber-dim: rgba(245, 158, 11, 0.08);
    --amber-border: rgba(245, 158, 11, 0.2);

    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.08);
    --red-border: rgba(239, 68, 68, 0.2);

    --purple: #a855f7;
    --purple-dim: rgba(168, 85, 247, 0.08);

    /* Radii & Shadows */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.35s ease;
}

/* --- 2. CSS RESET & GLOBAL BASICS --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 14px;
}

body {
    font-family: var(--font-sans);
    background: radial-gradient(ellipse at bottom right, #f1f5f9, var(--bg));
    color: var(--text);
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: grid-template-columns 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

body.sidebar-collapsed {
    grid-template-columns: 0px 1fr !important;
}

body.sidebar-collapsed aside.app-sidebar,
body.sidebar-collapsed .app-sidebar {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

code, kbd, samp, pre {
    font-family: var(--font-mono);
}


/* Universal Navigation Drawer & Sidebar Toggle Controls (Desktop Collapse & Mobile Drawer) */
.mobile-nav-toggle,
.sidebar-toggle-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border, #CBD5E1);
    background: var(--surface, #FFFFFF);
    color: var(--text, #0F172A);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s ease);
    margin-right: 12px;
    flex-shrink: 0;
}

.mobile-nav-toggle:hover,
.sidebar-toggle-btn:hover {
    background: #F1F5F9;
    color: var(--forest, #059669);
    border-color: var(--forest, #059669);
}

.mobile-sidebar-close,
.sidebar-close-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border, #CBD5E1);
    background: #F1F5F9;
    color: var(--text-dim, #475569);
    font-size: 0.95rem;
    cursor: pointer;
    margin-left: auto;
    transition: all var(--transition-fast, 0.15s ease);
}

.mobile-sidebar-close:hover,
.sidebar-close-btn:hover {
    background: #FEE2E2;
    color: #DC2626;
    border-color: #FCA5A5;
}

.sidebar-backdrop {
    display: none;
}

/* --- 3. LAYOUT: APP SIDEBAR --- */
aside.app-sidebar,
.app-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    width: 280px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 50;
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), padding 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, visibility 0.25s ease;
}

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

.sidebar-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--forest), #047857);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
    flex-shrink: 0;
}

.sidebar-brand-text h1 {
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--text), var(--forest));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-brand-text p {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin-top: 2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-grow: 1;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--text-dim);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin: 1.25rem 0 0.4rem 0.5rem;
}

.nav-link,
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-dim);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
}

.nav-link:hover,
.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border);
}

.nav-link.active,
.nav-link.active-page,
.nav-item.active,
.nav-item.active-page {
    background: var(--forest-dim);
    color: var(--forest);
    border-color: var(--forest-border);
    font-weight: 700;
    position: relative;
}

.nav-item.active-page::before,
.nav-link.active-page::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 3px;
    background: var(--forest);
    border-radius: 0 4px 4px 0;
}

.nav-icon {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    opacity: 0.85;
}

.nav-link.active .nav-icon,
.nav-link.active-page .nav-icon,
.nav-item.active .nav-icon,
.nav-item.active-page .nav-icon {
    opacity: 1;
    color: var(--forest);
}

.nav-counter {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    background: #f1f5f9;
    color: var(--text-dim);
}

.nav-link.active .nav-counter,
.nav-link.active-page .nav-counter,
.nav-item.active .nav-counter,
.nav-item.active-page .nav-counter {
    background: rgba(5, 150, 105, 0.15);
    color: var(--forest);
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-meta-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    margin-bottom: 0.25rem;
}

.meta-row:last-child {
    margin-bottom: 0;
}

.meta-label {
    color: var(--text-dim);
}

.meta-val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text);
}

/* --- 4. LAYOUT: APP MAIN --- */
main.app-main,
.app-main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

/* Top Bar */
.top-bar {
    background: rgba(248, 250, 252, 0.88);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 40;
}

.breadcrumb-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.breadcrumb-root {
    color: var(--text-dim);
    font-weight: 600;
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.breadcrumb-current {
    font-weight: 700;
    color: var(--text);
    background: linear-gradient(135deg, var(--text), var(--forest));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quick-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-link {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: all var(--transition-fast);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-link:hover {
    color: var(--text);
    border-color: var(--border-bright);
    background: #ffffff;
    box-shadow: var(--shadow-xs);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* --- 5. CARDS & HEADERS --- */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

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

.card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-normal);
    position: relative;
}

.card:hover {
    border-color: var(--border-bright);
    box-shadow: var(--shadow-sm);
}

.header-banner {
    padding: 2rem 2.25rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.header-banner::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(5, 150, 105, 0.06), transparent 70%);
    pointer-events: none;
}

.header-banner h1 {
    font-size: 2.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #0f172a, var(--forest), var(--wood));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
    line-height: 1.25;
}

.header-banner .subtitle {
    color: var(--text-dim);
    font-size: 1.05rem;
    font-weight: 500;
    max-width: 820px;
    line-height: 1.6;
}

.banner-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

.banner-stat-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.85rem;
    box-shadow: var(--shadow-xs);
}

.banner-stat-icon {
    font-size: 1.1rem;
}

.banner-stat-label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
}

.banner-stat-val {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text);
}

.glass-card h2 {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.glass-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* --- 6. BADGES --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
    line-height: 1.3;
}

.badge-forest {
    background: var(--forest-dim);
    color: var(--forest);
    border-color: var(--forest-border);
}

.badge-wood {
    background: var(--wood-dim);
    color: var(--wood);
    border-color: var(--wood-border);
}

.badge-amber {
    background: var(--amber-dim);
    color: var(--amber);
    border-color: var(--amber-border);
}

.badge-indigo {
    background: var(--indigo-dim);
    color: var(--indigo);
    border-color: var(--indigo-border);
}

.badge-blue {
    background: var(--blue-dim);
    color: var(--blue);
    border-color: var(--blue-border);
}

.badge-red {
    background: var(--red-dim);
    color: var(--red);
    border-color: var(--red-border);
}

/* --- 6.1. MULTI-PAGE STAGE HERO BANNER & IDENTIFIERS --- */
.station-hero-banner {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 60%, #f1f5f9 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem 2.25rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.station-hero-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--forest), var(--wood), var(--indigo));
}

.station-hero-banner::after {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle, rgba(5, 150, 105, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

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

.station-badge-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.station-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 800;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.75px;
    background: var(--forest-dim);
    color: var(--forest);
    border: 1px solid var(--forest-border);
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.1);
}

.station-badge.badge-stage-1 {
    background: rgba(5, 150, 105, 0.12);
    color: #047857;
    border-color: rgba(5, 150, 105, 0.3);
}

.station-badge.badge-stage-2 {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
    border-color: rgba(217, 119, 6, 0.3);
}

.station-badge.badge-stage-3 {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
    border-color: rgba(59, 130, 246, 0.3);
}

.station-badge.badge-stage-4 {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.3);
}

.station-badge.badge-stage-5 {
    background: rgba(168, 85, 247, 0.12);
    color: #7e22ce;
    border-color: rgba(168, 85, 247, 0.3);
}

.station-badge.badge-stage-6 {
    background: rgba(79, 70, 229, 0.12);
    color: #4338ca;
    border-color: rgba(79, 70, 229, 0.3);
}

.station-hero-banner h1,
.station-hero-banner .station-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.25;
    margin-bottom: 0.6rem;
    letter-spacing: -0.02em;
}

.station-hero-banner h1 span.gradient-text,
.station-hero-banner .station-title span.gradient-text {
    background: linear-gradient(135deg, var(--forest), #047857);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.station-hero-banner .subtitle,
.station-hero-banner .station-subtitle {
    color: var(--text-dim);
    font-size: 0.98rem;
    font-weight: 500;
    line-height: 1.6;
    max-width: 900px;
    margin-bottom: 1.5rem;
}

/* --- 6.2. VSM PROCESS FLOW NAVIGATOR (TOP FLOW HEADER - FLUID RESPONSIVE) --- */
.vsm-flow-navigator {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.45rem 0.65rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 65px;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.flow-nav-track {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.flow-nav-track::-webkit-scrollbar {
    display: none;
}

.flow-nav-node {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-md);
    background: #f8fafc;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-dim);
    transition: all var(--transition-fast);
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
}

.flow-nav-node:hover {
    background: #f1f5f9;
    border-color: var(--border-bright);
    color: var(--text);
    transform: translateY(-1px);
}

.flow-node-step {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 800;
    font-family: var(--font-mono);
    background: #e2e8f0;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.flow-node-content {
    display: flex;
    flex-direction: column;
    text-align: left;
    min-width: 0;
    overflow: hidden;
}

.flow-node-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-node-sub {
    font-size: 0.64rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-node-arrow {
    color: var(--text-muted);
    font-size: 0.6rem;
    margin-left: auto;
    opacity: 0.4;
    flex-shrink: 0;
}

/* Flow Node States */
.flow-nav-node.active {
    background: #ffffff;
    border-color: var(--forest);
    box-shadow: 0 3px 12px rgba(5, 150, 105, 0.2);
    transform: translateY(-1px);
}

.flow-nav-node.active .flow-node-step {
    background: var(--forest);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.35);
}

.flow-nav-node.active .flow-node-title {
    color: var(--forest);
    font-weight: 800;
}

.flow-nav-node.active .flow-node-sub {
    color: var(--forest);
    font-weight: 600;
}

.flow-nav-node.active .flow-node-arrow {
    color: var(--forest);
    opacity: 0.9;
}

/* Specific stage color accents for active */
.flow-nav-node.active.stage-1-active {
    border-color: #059669;
    box-shadow: 0 3px 12px rgba(5, 150, 105, 0.25);
}
.flow-nav-node.active.stage-1-active .flow-node-step { background: #059669; }
.flow-nav-node.active.stage-1-active .flow-node-title { color: #047857; }

.flow-nav-node.active.stage-2-active {
    border-color: #d97706;
    box-shadow: 0 3px 12px rgba(217, 119, 6, 0.25);
}
.flow-nav-node.active.stage-2-active .flow-node-step { background: #d97706; }
.flow-nav-node.active.stage-2-active .flow-node-title { color: #b45309; }

.flow-nav-node.active.stage-3-active {
    border-color: #2563eb;
    box-shadow: 0 3px 12px rgba(37, 99, 235, 0.25);
}
.flow-nav-node.active.stage-3-active .flow-node-step { background: #2563eb; }
.flow-nav-node.active.stage-3-active .flow-node-title { color: #1d4ed8; }

.flow-nav-node.active.stage-4-active {
    border-color: #dc2626;
    box-shadow: 0 3px 12px rgba(220, 38, 38, 0.25);
}
.flow-nav-node.active.stage-4-active .flow-node-step { background: #dc2626; }
.flow-nav-node.active.stage-4-active .flow-node-title { color: #b91c1c; }

.flow-nav-node.active.stage-5-active {
    border-color: #9333ea;
    box-shadow: 0 3px 12px rgba(147, 51, 234, 0.25);
}
.flow-nav-node.active.stage-5-active .flow-node-step { background: #9333ea; }
.flow-nav-node.active.stage-5-active .flow-node-title { color: #7e22ce; }

.flow-nav-node.active.stage-6-active {
    border-color: #4f46e5;
    box-shadow: 0 3px 12px rgba(79, 70, 229, 0.25);
}
.flow-nav-node.active.stage-6-active .flow-node-step { background: #4f46e5; }
.flow-nav-node.active.stage-6-active .flow-node-title { color: #4338ca; }

.flow-nav-node.completed {
    background: #f0fdf4;
    border-color: rgba(5, 150, 105, 0.25);
}
.flow-nav-node.completed .flow-node-step {
    background: rgba(5, 150, 105, 0.15);
    color: var(--forest);
}
.flow-nav-node.completed .flow-node-title {
    color: #065f46;
}

/* --- 6.3. STRUCTURED META STAT GRID (ROBUST & RESILIENT) --- */
.meta-stat-grid,
.station-meta-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    margin-top: 1.25rem;
    width: 100%;
}

.meta-stat-card,
.station-meta-item {
    display: flex;
    flex-direction: column;
    padding: 0.9rem 1.15rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
    min-height: 100px;
    justify-content: flex-start;
}

.meta-stat-card:hover,
.station-meta-item:hover {
    border-color: var(--border-bright);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.meta-stat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.meta-stat-icon,
.meta-item-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.meta-stat-icon.icon-cycle, .meta-item-icon.icon-cycle {
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue);
}

.meta-stat-icon.icon-raci, .meta-item-icon.icon-raci {
    background: rgba(5, 150, 105, 0.12);
    color: var(--forest);
}

.meta-stat-icon.icon-risk, .meta-item-icon.icon-risk {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
}

.meta-stat-icon.icon-output, .meta-item-icon.icon-output {
    background: rgba(217, 119, 6, 0.12);
    color: var(--wood);
}

.meta-stat-label,
.meta-item-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dim);
}

.meta-stat-main,
.meta-item-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.meta-stat-sub,
.meta-item-sub {
    display: block;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    line-height: 1.35;
}

/* --- 6.2. PAGE NAVIGATION FOOTER BAR (PREV / NEXT STAGE) --- */
.page-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.25rem;
    margin-top: 3rem;
    margin-bottom: 2rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.page-nav-bar.nav-start-only {
    justify-content: flex-end;
}

.page-nav-bar.nav-end-only {
    justify-content: flex-start;
}

.btn-page-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-lg);
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.92rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    cursor: pointer;
    min-width: 220px;
}

.btn-page-nav:hover {
    background: var(--surface-hover);
    border-color: var(--forest);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--forest);
}

.btn-page-nav.btn-primary,
.btn-page-nav.btn-next {
    background: linear-gradient(135deg, var(--forest), #047857);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.25);
    justify-content: flex-end;
    text-align: right;
    margin-left: auto;
}

.btn-page-nav.btn-primary:hover,
.btn-page-nav.btn-next:hover {
    background: linear-gradient(135deg, #047857, #065f46);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.35);
    color: #ffffff;
    transform: translateY(-2px);
}

.btn-page-nav.btn-prev {
    justify-content: flex-start;
    text-align: left;
}

.btn-nav-content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.btn-nav-direction {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    opacity: 0.8;
}

.btn-nav-title {
    font-size: 0.95rem;
    font-weight: 800;
}

.btn-page-nav .btn-nav-icon {
    font-size: 1.15rem;
    transition: transform var(--transition-fast);
}

.btn-page-nav:hover .fa-arrow-left,
.btn-page-nav:hover .icon-prev {
    transform: translateX(-4px);
}

.btn-page-nav:hover .fa-arrow-right,
.btn-page-nav:hover .icon-next {
    transform: translateX(4px);
}

/* --- 7. SOP STEPPER COMPONENT --- */
.sop-stepper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stepper-stage-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.stepper-stage-btn {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: left;
    position: relative;
    box-shadow: var(--shadow-xs);
}

.stepper-stage-btn:hover {
    border-color: var(--border-bright);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stepper-stage-btn.active {
    background: #ffffff;
    border-color: var(--forest);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15), 0 6px 16px rgba(5, 150, 105, 0.12);
    transform: translateY(-2px);
}

.stage-btn-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.stage-btn-number {
    font-size: 0.72rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-dim);
    background: #f1f5f9;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
}

.stepper-stage-btn.active .stage-btn-number {
    background: var(--forest);
    color: #ffffff;
}

.stage-btn-icon {
    font-size: 1.3rem;
}

.stage-btn-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.stepper-stage-btn.active .stage-btn-title {
    color: var(--forest);
}

.stage-btn-meta {
    font-size: 0.72rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: auto;
}

/* Active Stage Details Card */
.stage-details-container {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
}

.stage-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.stage-title-group h3 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.stage-title-group p {
    font-size: 0.85rem;
    color: var(--text-dim);
}

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

/* Substeps Grid & Card */
.substeps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.25rem;
}

.substep-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    transition: all var(--transition-normal);
    position: relative;
    box-shadow: var(--shadow-xs);
}

.substep-card:hover {
    border-color: var(--forest-border);
    box-shadow: var(--shadow-md);
}

.substep-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.substep-badge {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--forest);
    background: var(--forest-dim);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--forest-border);
}

.substep-raci {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-dim);
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
}

.substep-action {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.5;
}

.substep-meta-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    font-size: 0.78rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.substep-meta-item {
    display: flex;
    gap: 0.5rem;
    line-height: 1.4;
}

.substep-meta-label {
    font-weight: 700;
    color: var(--text-dim);
    flex-shrink: 0;
}

.substep-meta-val {
    color: var(--text);
}

.substep-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.5rem;
}

.btn-evidence {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-md);
    background: var(--forest-dim);
    color: var(--forest);
    border: 1px solid var(--forest-border);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-evidence:hover {
    background: var(--forest);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.25);
}

/* Evidence Thumbnail Overlays */
.evidence-thumb-badge {
    position: absolute;
    top: 0.65rem;
    left: 0.65rem;
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    letter-spacing: 0.5px;
}

.btn-thumb-zoom {
    position: absolute;
    bottom: 0.65rem;
    right: 0.65rem;
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-thumb-zoom:hover {
    background: var(--forest);
    border-color: var(--forest);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.4);
    transform: translateY(-1px);
}

/* --- 8. CALCULATORS COMPONENT --- */
.calc-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.calc-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.calc-tab-btn {
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

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

.calc-tab-btn.active {
    background: var(--forest-dim);
    color: var(--forest);
    border-color: var(--forest-border);
}

.calc-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
    align-items: start;
}

.calc-inputs-col {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.calc-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.calc-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.calc-label-hint {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 500;
}

.calc-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.calc-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #ffffff;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    transition: all var(--transition-fast);
    outline: none;
}

.calc-input:focus {
    border-color: var(--forest);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.calc-unit-addon {
    position: absolute;
    right: 0.85rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-dim);
    pointer-events: none;
}

.calc-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #ffffff;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    transition: all var(--transition-fast);
    outline: none;
    cursor: pointer;
}

.calc-select:focus {
    border-color: var(--forest);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.calc-result-box {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border: 2px solid var(--forest-border);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 5rem;
}

.calc-result-title {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.calc-result-main {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.calc-result-number {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--forest);
    line-height: 1;
}

.calc-result-unit {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dim);
}

.calc-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.calc-breakdown-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
}

.calc-breakdown-row .label {
    color: var(--text-dim);
}

.calc-breakdown-row .val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text);
}

/* --- 9. LEXICON & DATA EXPLORER --- */
.lexicon-search-bar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    outline: none;
    transition: all var(--transition-fast);
}

.search-input:focus {
    border-color: var(--forest);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.chip-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip-btn {
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: #ffffff;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip-btn:hover {
    border-color: var(--border-bright);
    color: var(--text);
}

.chip-btn.active {
    background: var(--forest);
    color: #ffffff;
    border-color: var(--forest);
}

.lexicon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.lexicon-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-xs);
}

.lexicon-card:hover {
    border-color: var(--forest-border);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.lexicon-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.lexicon-term {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text);
}

.lexicon-def {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.5;
}

.lexicon-ref {
    margin-top: auto;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* Data Table Container & Table */
.data-table-container {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.table-overflow-wrapper {
    overflow-x: auto;
    max-height: 520px;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: left;
}

.data-table thead th {
    background: #f8fafc;
    color: var(--text-dim);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

.data-table tbody tr:nth-child(even) {
    background: #fbfcfe;
}

.data-table tbody tr:hover {
    background: rgba(5, 150, 105, 0.04);
}

.data-table td {
    padding: 0.75rem 1rem;
    color: var(--text);
    white-space: nowrap;
}

.data-table td.mono-cell {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.data-table td.numeric-cell {
    font-family: var(--font-mono);
    text-align: right;
    font-weight: 600;
}

.table-pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.25rem;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* --- 10. MODAL LIGHTBOX --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.evidence-img-container {
    flex: 1;
    background: #090d16;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 1.5rem;
    min-height: 480px;
    position: relative;
}

.evidence-img-container img {
    max-width: 100%;
    max-height: 78vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform var(--transition-fast);
}

.evidence-meta-panel {
    width: 380px;
    flex-shrink: 0;
    background: #ffffff;
    border-left: 1px solid var(--border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
}

.evidence-meta-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.3;
}

.evidence-meta-desc {
    font-size: 0.88rem;
    color: var(--text-dim);
    line-height: 1.6;
}

.evidence-meta-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.evidence-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.evidence-meta-row .label {
    font-weight: 600;
    color: var(--text-dim);
}

.evidence-meta-row .val {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
}

.btn-close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text);
    cursor: pointer;
    z-index: 20;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.btn-close-modal:hover {
    background: #ffffff;
    transform: scale(1.08);
    box-shadow: var(--shadow-md);
}

/* --- 11. MAT TRẬN RACI & CÁC KHỐI ĐẶC THÙ --- */
.raci-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.raci-table th, .raci-table td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
}

.raci-table th {
    background: #f8fafc;
    font-weight: 700;
    color: var(--text);
}

.raci-badge-r { background: rgba(239, 68, 68, 0.12); color: #dc2626; font-weight: 800; padding: 0.2rem 0.5rem; border-radius: 4px; }
.raci-badge-a { background: rgba(217, 119, 6, 0.12); color: #b45309; font-weight: 800; padding: 0.2rem 0.5rem; border-radius: 4px; }
.raci-badge-c { background: rgba(59, 130, 246, 0.12); color: #2563eb; font-weight: 800; padding: 0.2rem 0.5rem; border-radius: 4px; }
.raci-badge-i { background: rgba(100, 116, 139, 0.12); color: #475569; font-weight: 800; padding: 0.2rem 0.5rem; border-radius: 4px; }

/* Grid Helpers */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

/* --- 12. RESPONSIVE MEDIA QUERIES --- */
@media (max-width: 1200px) {
    .calc-grid {
        grid-template-columns: 1fr;
    }
    .calc-result-box {
        position: static;
    }
    .stepper-stage-bar {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    body {
        grid-template-columns: 1fr;
    }

    /* Off-canvas Sidebar Drawer for Tablet & Mobile (Galaxy Z Fold 5 Unfolded & Folded) */
    aside.app-sidebar,
    .app-sidebar {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 320px !important;
        max-width: 86vw !important;
        height: 100vh !important;
        z-index: 1000 !important;
        background: #ffffff !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
        transform: translateX(-105%) !important;
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
        overflow-y: auto !important;
        border-right: 1px solid var(--border) !important;
    }

    aside.app-sidebar.mobile-open,
    .app-sidebar.mobile-open {
        transform: translateX(0) !important;
    }

    /* Mobile Backdrop Overlay */
    .sidebar-backdrop {
        display: block !important;
        position: fixed !important;
        inset: 0 !important;
        background: rgba(15, 23, 42, 0.65) !important;
        backdrop-filter: blur(4px) !important;
        -webkit-backdrop-filter: blur(4px) !important;
        z-index: 999 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.25s ease !important;
    }

    .sidebar-backdrop.mobile-open {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Hamburger Toggle Button */
    .mobile-nav-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        min-width: 38px;
        border-radius: var(--radius-md);
        border: 1px solid var(--border);
        background: #ffffff;
        color: var(--text);
        font-size: 1.15rem;
        cursor: pointer;
        flex-shrink: 0;
        margin-right: 0.5rem;
        box-shadow: var(--shadow-xs);
        transition: all var(--transition-fast);
    }

    .mobile-nav-toggle:hover,
    .mobile-nav-toggle:active {
        background: var(--surface-hover);
        border-color: var(--forest);
        color: var(--forest);
    }

    /* Sidebar Close Button */
    .mobile-sidebar-close {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: var(--radius-md);
        border: 1px solid var(--border);
        background: #f1f5f9;
        color: var(--text-dim);
        font-size: 1.1rem;
        cursor: pointer;
        margin-left: auto;
        transition: all var(--transition-fast);
    }

    .mobile-sidebar-close:hover {
        background: #fee2e2;
        color: #dc2626;
        border-color: #fca5a5;
    }

    .modal-content {
        flex-direction: column;
        max-height: 95vh;
    }

    .evidence-meta-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 240px;
    }

    .evidence-img-container {
        min-height: 320px;
    }

    .content-area {
        padding: 1.25rem;
    }

    .top-bar {
        padding: 0.65rem 1.25rem;
    }

    .breadcrumb-area {
        min-width: 0;
        flex: 1;
        overflow: hidden;
        white-space: nowrap;
    }

    .breadcrumb-current {
        max-width: 260px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .station-header-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-nav-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-page-nav {
        min-width: 100%;
        justify-content: center;
    }

    .flow-nav-track {
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .flow-nav-node {
        flex: 0 0 auto;
        min-width: 135px;
    }
}

/* Tablet Portrait & Large Phone Breakpoint (<= 860px) */
@media (max-width: 860px) {
    /* Universal Mobile Grid Collapse (Covers all 2-col, 3-col, 4-col grids and inline styles) */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1.2fr"],
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns: repeat(2"],
    div[style*="grid-template-columns:repeat(2"],
    div[style*="grid-template-columns: repeat(3"],
    div[style*="grid-template-columns:repeat(3"],
    div[style*="grid-template-columns: repeat(4"],
    div[style*="grid-template-columns:repeat(4"],
    .grid-2,
    .grid-3,
    .grid-4,
    .calc-grid,
    .substeps-grid,
    .responsive-grid,
    .evidence-grid {
        grid-template-columns: 1fr !important;
    }

    /* Collapse auto-fit grids with minmax >= 260px to prevent overflow */
    div[style*="minmax(360px"],
    div[style*="minmax(320px"],
    div[style*="minmax(300px"],
    div[style*="minmax(280px"],
    div[style*="minmax(260px"] {
        grid-template-columns: 1fr !important;
    }

    /* Flex headers with badges wrap cleanly so badges never crush titles into vertical letter columns */
    div[style*="display: flex; justify-content: space-between"],
    div[style*="display:flex; justify-content:space-between"],
    div[style*="display:flex;justify-content:space-between"],
    .substep-top {
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
    }

    /* Ensure all tables are horizontally scrollable */
    table {
        max-width: 100%;
    }

    .table-container,
    .data-table-container,
    div[style*="overflow-x: auto"] {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .lexicon-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile Breakpoint (<= 640px): Galaxy Z Fold 5 Cover Screen & Narrow Phones */
@media (max-width: 640px) {
    .stepper-stage-bar {
        grid-template-columns: 1fr;
    }

    .banner-stats-row {
        flex-direction: column;
    }

    .station-meta-bar,
    .meta-stat-grid {
        grid-template-columns: 1fr;
    }

    .content-area {
        padding: 0.75rem;
    }

    /* Specific optimization for Galaxy Z Fold 5 Cover Screen (374px - 400px) */
    .top-bar {
        padding: 0.5rem 0.65rem;
        gap: 0.35rem;
        min-height: 52px;
    }

    .mobile-nav-toggle {
        width: 36px;
        height: 36px;
        min-width: 36px;
        margin-right: 0.25rem;
    }

    .breadcrumb-area {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        min-width: 0;
        flex: 1;
        overflow: hidden;
        white-space: nowrap;
    }

    /* Hide intermediate breadcrumbs so words NEVER wrap vertically */
    .breadcrumb-separator {
        display: none !important;
    }

    .breadcrumb-area > span:not(.breadcrumb-current):not(.breadcrumb-root),
    .breadcrumb-area > a:not(.breadcrumb-current):not(.breadcrumb-root) {
        display: none !important;
    }

    .breadcrumb-root {
        font-size: 0.78rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .breadcrumb-root span.root-text {
        display: none;
    }

    .breadcrumb-current {
        font-size: 0.78rem;
        max-width: 135px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
    }

    /* Compact Quick-links: icons only, no wrapping */
    .top-actions {
        gap: 0.25rem;
    }

    .quick-links {
        gap: 0.25rem;
    }

    .quick-links .btn-link {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
        border-radius: var(--radius-sm);
    }

    .quick-links .btn-link span.btn-text {
        display: none !important;
    }

    #fullscreenToggleBtn {
        display: none !important;
    }

    .flow-nav-node {
        flex: 0 0 auto;
        min-width: 120px;
        padding: 0.35rem 0.45rem;
    }

    .header-banner {
        padding: 1rem;
    }

    .header-banner h1 {
        font-size: 1.35rem;
    }

    .station-hero-banner {
        padding: 1rem;
    }

    .station-hero-banner h1,
    .station-hero-banner .station-title {
        font-size: 1.35rem;
    }

    .calc-container {
        padding: 0.85rem;
    }

    .calc-tabs {
        width: 100%;
        display: flex;
    }

    .calc-tab-btn {
        flex: 1;
        text-align: center;
        justify-content: center;
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }

    /* Sub-input grids inside calculators */
    div[style*="grid-template-columns: 1fr 1fr; gap: 1rem"],
    div[style*="grid-template-columns: 1fr 1fr; gap: 0.5rem"],
    div[style*="grid-template-columns: 1fr 1.2fr; gap: 0.5rem"] {
        grid-template-columns: 1fr !important;
        gap: 0.6rem !important;
    }

    /* Card padding optimization for narrow screen */
    .card,
    .substep-card,
    .glass-card {
        padding: 0.85rem !important;
    }

    /* Status badge sizing inside cards */
    .substep-badge,
    .status-badge {
        font-size: 0.68rem !important;
        white-space: nowrap !important;
    }

    /* Ensure text wrapping doesn't break letter-by-letter */
    h1, h2, h3, h4, h5, p, strong, span {
        overflow-wrap: break-word;
    }
}
