/* ╔══════════════════════════════════════════════════════════╗
   ║  RiskAsistan Tools — Design System v1.2 (SSoT Bridge)   ║
   ║  Standalone CSS for /static/tools/* pages               ║
   ║  Glassmorphism Dark Mode • Premium Enterprise           ║
   ║  ──────────────────────────────────────────────────────  ║
   ║  SSoT: Loaded AFTER tokens.css + components.css.        ║
   ║  Token aliases bridge --space-md → tokens.css --space-4 ║
   ║  Fallback values ensure standalone rendering.           ║
   ║  SECTIONS:                                              ║
   ║   §1  Design Tokens (:root)         L7-85              ║
   ║   §2  Reset & Base                  L87-109            ║
   ║   §3  Background / Layout           L111-164           ║
   ║   §4  Navigation                    L166-217           ║
   ║   §5  Header / Badge / Title        L219-286           ║
   ║   §6  Glass Cards                   L288-343           ║
   ║   §7  Grid / Layout Utils           L345-380           ║
   ║   §8  Form Controls                 L382-440           ║
   ║   §9  Range Slider                  L442-495           ║
   ║   §10 Buttons                       L497-578           ║
   ║   §11 Results / Scores              L580-637           ║
   ║   §12 Risk Matrix                   L639-714           ║
   ║   §13 Checklist                     L716-768           ║
   ║   §14 Progress Bar                  L770-791           ║
   ║   §15 Stat Cards / Tags / Toast     L793-920           ║
   ║   §16 Footer / Animations           L922-970           ║
   ║   §17 Print                         L972-997           ║
   ║   §18 Responsive (1024/768/480)     L999-end           ║
   ╚══════════════════════════════════════════════════════════╝ */

/* ─── CSS Variables / Design Tokens ─── */
/* SSoT BRIDGE: tools.css token names → tokens.css canonical values.
   tools.css consumers (15 HTML) use var(--space-4) etc.
   Actual values cascade from tokens.css (:root in suite/tokens.css).
   If tokens.css is loaded first, these re-declarations are overridden
   by tokens.css :root (same specificity, load order wins).
   Fallback values ensure standalone rendering if tokens.css is absent. */
:root {
    /* Colors — tools-domain only */
    --bg-primary: var(--color-surface-1, #0a0e1a);
    --bg-secondary: var(--color-surface-2, #111827);
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-input-focus: rgba(255, 255, 255, 0.08);

    --text-primary: var(--color-text-1, #f1f5f9);
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: var(--color-text-3, rgba(255, 255, 255, 0.45));
    --text-accent: #60a5fa;

    --border-color: var(--color-border, rgba(255, 255, 255, 0.08));
    --border-focus: rgba(96, 165, 250, 0.4);
    --border-glass: rgba(255, 255, 255, 0.1);

    /* Accent Colors per Sector */
    --accent-isg: #ef4444;
    --accent-legal: #8b5cf6;
    --accent-finance: #f59e0b;
    --accent-health: #10b981;
    --accent-food: #f97316;
    --accent-env: #22c55e;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;

    /* Gradients */
    --grad-isg: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    --grad-legal: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --grad-finance: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    --grad-health: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    --grad-blue: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --grad-cyan: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);

    /* Glass */
    --glass-blur: 20px;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

    /* Radii directly rely on --r-* from tokens.css */
    /* Spacing directly relies on --space-* from tokens.css */
    /* Typography directly relies on --text-* from tokens.css */
    /* Transitions directly rely on --dur-* from tokens.css */


    /* Active accent (overridden per tool) */
    --accent: var(--accent-blue);
    --accent-grad: var(--grad-blue);
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Animated Background ─── */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(96, 165, 250, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.8;
    }
}

/* ─── Tool Page Layout ─── */
.tool-page {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6);
    min-height: 100vh;
}
.tool-page,
.tool-page * {
    min-width: 0;
}

/* ─── Top Navigation Bar ─── */
.tool-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: var(--glass-border);
    border-radius: var(--r-xl);
    margin-bottom: var(--space-8);
    box-shadow: var(--glass-shadow);
}

.tool-topbar {
    width: min(1200px, calc(100% - 32px));
    margin: 24px auto 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: linear-gradient(135deg, rgba(10, 14, 26, 0.78), rgba(15, 23, 42, 0.64));
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(var(--copper-rgb), 0.18);
    border-radius: var(--r-xl);
    box-shadow: 0 18px 44px rgba(2, 6, 23, 0.28);
}

.tool-nav-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px 10px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(10, 14, 26, 0.74), rgba(15, 23, 42, 0.56));
    border: 1px solid rgba(96, 165, 250, 0.16);
    box-shadow: 0 14px 34px rgba(2, 6, 23, 0.24);
    backdrop-filter: blur(16px);
    text-decoration: none;
    color: #e2e8f0;
    font-weight: 700;
    font-size: var(--text-sm);
    max-width: 100%;
}

.tool-nav-brand-image {
    height: 42px;
    width: auto;
    max-width: 220px;
    display: block;
    object-fit: contain;
}

.tool-nav-brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(96, 165, 250, 0.12);
    border: 1px solid rgba(96, 165, 250, 0.18);
    color: #dbeafe;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.tool-nav-links {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    min-width: 0;
}

.tool-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    transition: all var(--dur-fast) var(--ease-out);
    border: 1px solid transparent;
}

.tool-back,
.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 700;
    transition: all var(--dur-fast) var(--ease-out);
    border: 1px solid transparent;
}

.tool-nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-glass-hover);
    border-color: var(--border-glass);
}

.tool-back:hover,
.back-link:hover {
    color: var(--text-primary);
    background: var(--bg-glass-hover);
    border-color: var(--border-glass);
}

.tool-nav-link.active {
    color: var(--accent);
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.2);
}

.tool-badge-bar {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-left: auto;
}

.tool-topbar .tool-badge {
    margin-bottom: 0;
}

.tool-badge-ai {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(96, 165, 250, 0.26);
    color: #93c5fd;
}

/* ─── Tool Header ─── */
.tool-header,
.ps-hero,
.engine-hero,
.fk-hero,
.mev-hero {
    margin-bottom: var(--space-12);
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(var(--copper-rgb), 0.08), rgba(10, 14, 26, 0.56));
    border: 1px solid rgba(var(--copper-rgb), 0.14);
    border-radius: var(--r-xl);
    padding: clamp(20px, 3vw, 34px);
    box-shadow: 0 18px 46px rgba(2, 6, 23, 0.26);
}

.tool-header::before,
.ps-hero::before,
.engine-hero::before,
.fk-hero::before,
.mev-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(var(--copper-rgb), 0.14), transparent 38%),
        radial-gradient(circle at bottom left, rgba(56, 189, 248, 0.08), transparent 32%);
    pointer-events: none;
}

.tool-header {
    text-align: center;
}

.tool-header > *,
.ps-hero > *,
.engine-hero > *,
.fk-hero > *,
.mev-hero > * {
    position: relative;
    z-index: 1;
}

.tool-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-4);
    background: rgba(96, 165, 250, 0.1);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 999px;
    font-size: var(--text-xs);
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-4);
}

.tool-badge-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.3);
    }
}

.tool-title {
    font-size: var(--text-3xl);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tool-title .highlight {
    background: var(--accent-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tool-subtitle {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* ─── Glass Card — Glassmorphism 2.0 ─── */
/* BEM mapping: extends .card (components.css) with glass + depth layers */
.glass-card {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--r-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-card-glass);
    transition:
        transform var(--dur-slow) var(--ease-spring),
        box-shadow var(--dur-base) var(--ease-out),
        border-color var(--dur-base) var(--ease-out);
    will-change: transform, box-shadow;
}

/* Gradient accent top border — subtle copper shimmer */
.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 5%;
    right: 5%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--copper-rgb), 0.3), transparent);
    border-radius: 1px;
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-out);
}

.glass-card:hover {
    border-color: rgba(var(--copper-rgb), 0.15);
    transform: translateY(-3px) scale(1.005);
    box-shadow: var(--shadow-card-glass-hover);
}

.glass-card:hover::before {
    opacity: 1;
}

.glass-card:active {
    transform: translateY(0) scale(1);
}

.glass-card-static {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--r-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-card-glass);
}

.ps-form,
.ps-multiplier-box,
.fk-section,
.engine-panel,
.tool-surface {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-card-glass);
}

/* Gradient accent top border for static cards too */
.glass-card-static::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--copper-rgb), 0.2), transparent);
    border-radius: 1px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-lg);
    font-size: 1.5rem;
    background: var(--accent-grad);
}

.card-title {
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.card-description {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

/* ─── Layout Grids ─── */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.row {
    display: flex;
    gap: var(--space-4);
    align-items: center;
}

.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ─── Form Controls ─── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    padding: var(--space-4);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--r-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    transition: all var(--dur-fast) var(--ease-out);
    outline: none;
    width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(255,255,255,0.5)' viewBox='0 0 16 16'%3E%3Cpath d='M8 10.5l-5-5h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ─── Range Slider ─── */
.range-slider {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transition: background var(--dur-fast) var(--ease-out);
}

.range-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
    transition: all var(--dur-fast) var(--ease-out);
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.7);
}

.range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
}

.range-value {
    text-align: center;
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--accent);
    font-family: var(--font-mono);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-6);
    border: none;
    border-radius: var(--r-md);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--dur-base) var(--ease-out);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-grad);
    color: white;
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(96, 165, 250, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--r-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.btn-full {
    width: 100%;
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
}

/* ─── Result Display ─── */
.result-panel {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--r-xl);
    padding: var(--space-8);
    margin-top: var(--space-6);
    animation: fadeInUp 0.4s ease;
}

.result-panel.danger {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.2);
}

.result-panel.warning {
    background: rgba(245, 158, 11, 0.05);
    border-color: rgba(245, 158, 11, 0.2);
}

.result-panel.info {
    background: rgba(96, 165, 250, 0.05);
    border-color: rgba(96, 165, 250, 0.2);
}

.result-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.result-score {
    font-size: 3rem;
    font-weight: 800;
    font-family: var(--font-mono);
    text-align: center;
    margin: var(--space-4) 0;
}

.result-score.low {
    color: #10b981;
}

.result-score.medium {
    color: #f59e0b;
}

.result-score.high {
    color: #ef4444;
}

.result-score.critical {
    color: #dc2626;
    text-shadow: 0 0 20px rgba(220, 38, 38, 0.5);
}

/* ─── Risk Matrix — Interactive Heatmap v2.0 ─── */
.matrix-container {
    display: grid;
    grid-template-columns: 40px repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr) 40px;
    gap: 5px;
    aspect-ratio: 1.1;
    max-width: 620px;
    margin: 0 auto;
    perspective: 800px;
}

.matrix-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: var(--text-sm);
    font-weight: 800;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.3s ease,
                border-color 0.25s ease,
                filter 0.25s ease;
    border: 2px solid transparent;
    min-height: 64px;
    overflow: hidden;
    isolation: isolate;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    will-change: transform, box-shadow;
}
/* Inner glow layer (pseudo) */
.matrix-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.12) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}
/* Ripple ring on click */
.matrix-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 2px solid rgba(255,255,255,0.6);
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
    z-index: 2;
}

.matrix-cell:hover {
    transform: scale(1.1) translateY(-2px);
    z-index: 3;
    filter: brightness(1.2);
}
.matrix-cell:hover::before {
    opacity: 1;
}

/* Pulse animation for hovered cell */
@keyframes cellPulse {
    0%, 100% { box-shadow: var(--cell-glow), 0 0 0 0 var(--cell-glow-color); }
    50%      { box-shadow: var(--cell-glow), 0 0 0 8px transparent; }
}
.matrix-cell:hover {
    animation: cellPulse 1.5s ease-in-out infinite;
}

/* Selected state — ripple burst */
@keyframes rippleBurst {
    0%   { opacity: 0.7; transform: scale(0.6); }
    100% { opacity: 0;   transform: scale(1.3); }
}
.matrix-cell.selected {
    border-color: rgba(255,255,255,0.9);
    transform: scale(1.12) translateY(-3px);
    z-index: 4;
    filter: brightness(1.3);
}
.matrix-cell.selected::after {
    animation: rippleBurst 0.5s ease-out forwards;
}

/* Cross-highlight: when JS adds these classes on hover */
.matrix-cell.row-highlight,
.matrix-cell.col-highlight {
    filter: brightness(1.15);
    border-color: rgba(255,255,255,0.15);
}
.matrix-cell.cross-dim {
    filter: brightness(0.6);
    opacity: 0.7;
}

/* ── Risk Level Heatmap Colors (Radial Gradient) ── */
.matrix-cell.risk-1 {
    background: radial-gradient(circle at 50% 40%, rgba(16,185,129,0.5) 0%, rgba(16,185,129,0.2) 100%);
    color: #6ee7b7;
    --cell-glow: 0 4px 20px rgba(16,185,129,0.35);
    --cell-glow-color: rgba(16,185,129,0.25);
    box-shadow: var(--cell-glow);
}
.matrix-cell.risk-2 {
    background: radial-gradient(circle at 50% 40%, rgba(34,197,94,0.5) 0%, rgba(34,197,94,0.2) 100%);
    color: #86efac;
    --cell-glow: 0 4px 20px rgba(34,197,94,0.35);
    --cell-glow-color: rgba(34,197,94,0.25);
    box-shadow: var(--cell-glow);
}
.matrix-cell.risk-3 {
    background: radial-gradient(circle at 50% 40%, rgba(245,158,11,0.55) 0%, rgba(245,158,11,0.2) 100%);
    color: #fde68a;
    --cell-glow: 0 4px 22px rgba(245,158,11,0.4);
    --cell-glow-color: rgba(245,158,11,0.3);
    box-shadow: var(--cell-glow);
}
.matrix-cell.risk-4 {
    background: radial-gradient(circle at 50% 40%, rgba(239,68,68,0.55) 0%, rgba(239,68,68,0.22) 100%);
    color: #fca5a5;
    --cell-glow: 0 4px 24px rgba(239,68,68,0.4);
    --cell-glow-color: rgba(239,68,68,0.3);
    box-shadow: var(--cell-glow);
}
.matrix-cell.risk-5 {
    background: radial-gradient(circle at 50% 40%, rgba(220,38,38,0.65) 0%, rgba(220,38,38,0.28) 100%);
    color: #fecaca;
    --cell-glow: 0 6px 28px rgba(220,38,38,0.5);
    --cell-glow-color: rgba(220,38,38,0.35);
    box-shadow: var(--cell-glow);
    animation: dangerPulse 2.5s ease-in-out infinite;
}
/* Critical cells always subtly pulse */
@keyframes dangerPulse {
    0%, 100% { box-shadow: 0 6px 28px rgba(220,38,38,0.4); }
    50%      { box-shadow: 0 6px 36px rgba(220,38,38,0.65), inset 0 0 12px rgba(220,38,38,0.15); }
}

/* Score transition animation */
.score-animate {
    transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes scorePopIn {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}
.score-pop {
    animation: scorePopIn 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

.matrix-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 600;
    transition: color 0.2s ease;
}
.matrix-label.label-highlight {
    color: rgba(255,255,255,0.85);
    text-shadow: 0 0 8px rgba(255,255,255,0.3);
}

.matrix-label.vertical {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

/* ─── Checklist ─── */
.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4);
    border-radius: var(--r-md);
    transition: all var(--dur-fast) var(--ease-out);
    cursor: pointer;
}

.checklist-item:hover {
    background: var(--bg-glass-hover);
}

.checklist-checkbox {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid var(--border-glass);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-fast) var(--ease-out);
    margin-top: 2px;
}

.checklist-item.checked .checklist-checkbox {
    background: var(--accent);
    border-color: var(--accent);
}

.checklist-item.checked .checklist-checkbox::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: 700;
}

.checklist-text {
    flex: 1;
}

.checklist-text h4 {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: 2px;
}

.checklist-text p {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ─── Progress Bar ─── */
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    background: var(--accent-grad);
}

.progress-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

/* ─── Stat Cards ─── */
.stat-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-4);
    background: var(--bg-glass);
    border: var(--glass-border);
    border-radius: var(--r-lg);
    text-align: center;
}

.stat-mini-value {
    font-size: var(--text-2xl);
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--accent);
}

.stat-mini-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ─── Tags / Badges ─── */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 600;
}

.tag-low {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-medium {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.tag-high {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.tag-critical {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(220, 38, 38, 0.4);
    animation: tagPulse 2s ease infinite;
}

@keyframes tagPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.3);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);
    }
}

/* ─── Notification Toast ─── */
.toast {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    padding: var(--space-4) var(--space-6);
    background: var(--bg-secondary);
    border: var(--glass-border);
    border-left: 4px solid var(--accent);
    border-radius: var(--r-md);
    color: var(--text-primary);
    font-size: var(--text-sm);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: var(--z-top, 9999);
    animation: slideIn 0.3s ease;
    max-width: 380px;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.warning {
    border-left-color: #f59e0b;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ─── Footer ─── */
.tool-footer {
    text-align: center;
    padding: var(--space-12) 0 var(--space-6);
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.tool-footer a {
    color: var(--accent);
    text-decoration: none;
}

.tool-footer a:hover {
    text-decoration: underline;
}

/* ─── Animations ─── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

.animate-delay-1 {
    animation-delay: 0.1s;
    opacity: 0;
}

.animate-delay-2 {
    animation-delay: 0.2s;
    opacity: 0;
}

.animate-delay-3 {
    animation-delay: 0.3s;
    opacity: 0;
}

.animate-delay-4 {
    animation-delay: 0.4s;
    opacity: 0;
}

/* ─── Print / PDF ─── */
@media print {
    body {
        background: white;
        color: #1a1a1a;
    }

    .bg-gradient,
    .tool-nav,
    .tool-footer,
    .btn {
        display: none;
    }

    .glass-card,
    .glass-card-static {
        background: white;
        border: 1px solid #ddd;
        box-shadow: none;
        backdrop-filter: none;
    }

    .matrix-cell {
        border: 1px solid #ccc;
    }
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .tool-page {
        padding: var(--space-4);
    }

    .tool-topbar {
        width: calc(100% - 16px);
        margin: 12px auto 16px;
        padding: var(--space-4);
    }

    .tool-nav {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }

    .tool-nav-brand {
        justify-content: center;
    }

    .tool-nav-links {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-2);
    }

    .tool-badge-bar {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }

    .tool-nav-link {
        flex: 1 1 auto;
        text-align: center;
    }

    .tool-back,
    .back-link {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .tool-title {
        font-size: var(--text-2xl);
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }

    .grid-4 {
        grid-template-columns: 1fr;
    }

    .glass-card,
    .glass-card-static {
        padding: var(--space-4);
        box-shadow: var(--shadow-md);
    }

    /* Disable hover lift on touch — no hover state on mobile */
    .glass-card:hover {
        transform: none;
    }

    .row {
        flex-direction: column;
    }

    .matrix-container {
        max-width: 100%;
    }

    .matrix-cell {
        min-height: 45px;
        font-size: var(--text-xs);
    }

    .tool-nav-brand-image {
        height: 34px;
        max-width: 180px;
    }

    .tool-nav-brand-badge {
        font-size: 9px;
        min-height: 22px;
        padding: 0 7px;
    }
}

@media (max-width: 480px) {
    .tool-title {
        font-size: var(--text-xl);
    }

    .tool-subtitle {
        font-size: var(--text-sm);
    }

    .btn {
        padding: var(--space-2) var(--space-4);
        font-size: var(--text-xs);
    }

    .tool-nav-link {
        width: 100%;
    }

    .tool-topbar {
        width: calc(100% - 12px);
        margin: 8px auto 14px;
        padding: var(--space-3);
    }
}

/* ─── Ultra-narrow (Galaxy Fold, ≤360px) ─── */
@media (max-width: 360px) {
    .tool-page {
        padding: var(--space-2);
    }

    .glass-card,
    .glass-card-static {
        padding: var(--space-2);
        border-radius: var(--r-md);
    }

    .card-icon {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    .matrix-container {
        grid-template-columns: 28px repeat(5, 1fr);
    }

    .matrix-cell {
        min-height: 36px;
        font-size: 9px;
    }

    .form-input,
    .form-select,
    .form-textarea {
        padding: var(--space-2);
        font-size: var(--text-xs);
    }

    .result-score {
        font-size: 2rem;
    }

    .toast {
        right: var(--space-2);
        left: var(--space-2);
        max-width: none;
    }
}

/* ─── A11Y: Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    .glass-card,
    .glass-card-static,
    .glass-card:hover,
    .card,
    .card:hover,
    .btn,
    .btn-primary:hover {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
        transform: none !important;
    }
}

/* ─── UX Hardening Pass: overflow, mobile and dense result cards ─── */
.tool-page {
    width: min(100%, 1200px);
    padding-inline: clamp(14px, 3vw, var(--space-6)) !important;
}

.tool-nav,
.tool-topbar {
    align-items: center !important;
}

.tool-nav-links {
    justify-content: flex-end;
}

.tool-nav-link,
.tool-back,
.back-link,
.btn,
.tool-btn,
.fb-btn {
    min-height: 38px;
    white-space: nowrap;
}

.glass-card,
.glass-card-static,
.tool-card,
.result-card,
.nace-card,
.req-item {
    overflow-wrap: anywhere;
    word-break: normal;
}

.tool-card {
    min-height: 230px;
    display: flex !important;
    flex-direction: column;
}

.tool-card-desc {
    flex: 1;
}

.tool-card-tags {
    margin-top: auto;
}

.tool-card-title,
.tool-card-desc,
.tool-card-tag,
.nace-title,
.sector-desc,
.req-val {
    min-width: 0;
}

.search-box,
.nace-input-wrapper {
    position: relative;
    z-index: 2;
}

.search-input,
.nace-input,
.fb-input,
.tool-input,
.form-input,
.form-control,
input[type="text"],
input[type="search"],
input[type="number"],
textarea,
select {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-input,
.nace-input {
    box-shadow: 0 14px 34px rgba(2, 6, 23, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.035) !important;
}

.results-container,
.tool-results,
.result-list {
    position: relative;
    z-index: 1;
}

.nace-card {
    display: grid !important;
    grid-template-columns: minmax(98px, 150px) minmax(0, 1fr);
    align-items: start !important;
    gap: clamp(12px, 2vw, var(--space-lg)) !important;
}

.nace-code-badge {
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nace-content {
    min-width: 0;
}

.feedback-row,
.feedback-form {
    align-items: stretch !important;
}

.feedback-form {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.feedback-form .fb-btn {
    justify-content: center;
}

.requirement-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
}

@media (max-width: 760px) {
    .tool-nav,
    .tool-topbar {
        align-items: stretch !important;
    }

    .tool-nav-brand {
        width: 100%;
        justify-content: center;
    }

    .tool-nav-brand-image {
        max-width: min(72vw, 220px);
    }

    .tool-nav-links {
        width: 100%;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tool-nav-link {
        width: 100%;
        white-space: normal;
        text-align: center;
    }

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

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

@media (max-width: 520px) {
    .tool-page {
        padding-inline: 12px !important;
    }

    .tool-nav-links {
        grid-template-columns: 1fr;
    }

    .tool-card {
        min-height: 0;
    }

    .search-input,
    .nace-input {
        font-size: clamp(1rem, 5vw, 1.2rem) !important;
        letter-spacing: normal !important;
        text-align: left !important;
    }
}

