/* ==========================================
   CSS Variables & Design Tokens
   ========================================== */
:root {
    /* Color Palette - Black, White, Red */
    --bg-dark: #050505;
    --bg-darker: #000000;

    --accent-primary: #ff2d2d; /* Red */
    --accent-secondary: #ffffff; /* White */
    --accent-tertiary: #b30000; /* Deep red */

    --text-main: #f8f8f8;
    --text-muted: #a1a1aa;

    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-highlight: rgba(255, 255, 255, 0.18);

    /* Status Colors */
    --success: #ffffff;
    --warning: #ff7a7a;
    --danger: #ff2d2d;

    /* Structure */
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 8px;

    /* Shadows & Glows */
    --glow-primary: 0 0 20px rgba(255, 45, 45, 0.4);
    --glow-secondary: 0 0 30px rgba(255, 255, 255, 0.25);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-y: auto;
    min-height: 100vh;
}

body.modal-open {
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', sans-serif;
}

/* ==========================================
   Background & Ambient Effects
   ========================================== */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background:
        linear-gradient(120deg, rgba(255, 45, 45, 0.12), transparent 60%),
        radial-gradient(circle at 15% 15%, rgba(255, 255, 255, 0.08), transparent 40%),
        #050505;
}

.app-background::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: 0.35;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.3;
    animation: float 20s infinite alternate;
}

.orb-1 {
    top: -10%;
    left: -10%;
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, rgba(255,45,45,0.35) 0%, transparent 70%);
}

.orb-2 {
    bottom: -20%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%);
    animation-delay: -5s;
}

.orb-3 {
    top: 40%;
    left: 40%;
    width: 25vw;
    height: 25vw;
    background: radial-gradient(circle, rgba(179,0,0,0.2) 0%, transparent 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 5%) scale(1.1); }
}

/* ==========================================
   Layout
   ========================================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: clamp(18px, 3vw, 32px) clamp(18px, 4vw, 40px);
    gap: clamp(16px, 2vw, 24px);
}

/* ==========================================
   Header (Glassmorphism)
   ========================================== */
.glass-header {
    background: rgba(5, 5, 5, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;
    padding: clamp(14px, 2.2vw, 18px) clamp(16px, 2.6vw, 32px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: var(--accent-primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #0a0a0a;
    box-shadow: 0 0 0 6px rgba(255, 45, 45, 0.2);
}

.brand h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.brand span {
    color: var(--accent-primary);
    font-weight: 300;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-profile img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--glass-highlight);
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-profile img:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--glow-primary);
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    padding: 12px 24px;
    border-radius: 999px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    border: none;
    outline: none;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--glass-highlight);
    border-color: var(--text-main);
}

.btn-primary {
    background: var(--accent-primary);
    color: #0a0a0a;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.2), transparent 40%, rgba(0,0,0,0.2));
    opacity: 0;
    transition: var(--transition-smooth);
}

.btn-primary:hover::before {
    opacity: 1;
}

.btn-glow {
    box-shadow: 0 12px 30px rgba(255, 45, 45, 0.35);
}

.btn-glow:hover {
    box-shadow: 0 0 40px rgba(255, 45, 45, 0.6);
    transform: translateY(-2px);
}

/* ==========================================
   Main Content Layout
   ========================================== */
.main-content {
    flex: 1;
    display: flex;
}

.matching-workspace {
    display: grid;
    grid-template-columns: minmax(280px, 320px) 1fr minmax(280px, 320px);
    gap: 28px;
    width: 100%;
    height: auto;
    align-items: start;
}

.panel {
    min-height: 0;
    min-width: 0;
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 1200px) {
    .app-container {
        padding: 24px;
    }

    .matching-workspace {
        grid-template-columns: minmax(240px, 280px) 1fr minmax(240px, 280px);
        gap: 20px;
    }

    .center-panel {
        padding: 20px;
        gap: 20px;
    }
}

@media (max-width: 1100px) {
    .matching-workspace {
        grid-template-columns: minmax(220px, 260px) 1fr minmax(220px, 260px);
        gap: 18px;
    }

    .panel-header h2 {
        font-size: 16px;
    }
}

@media (max-width: 980px) {
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }

    .app-container {
        height: auto;
        min-height: 100vh;
    }

    .main-content {
        min-height: auto;
    }

    .matching-workspace {
        grid-template-columns: 1fr;
        height: auto;
    }

    .center-panel {
        align-content: start;
        order: 1;
    }

    .panel {
        order: 2;
    }

    .matches-preview {
        max-height: 380px;
    }

    .panel-toggle {
        display: inline-flex;
    }
}

@media (max-height: 820px) {
    .center-panel {
        align-content: start;
    }

    .status-ring {
        width: 96px;
        height: 96px;
    }

    .ring-inner {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }

    #run-matching-btn {
        padding: 14px 36px;
        font-size: 14px;
    }
}

@media (max-width: 720px) {
    .app-container {
        padding: 18px;
        gap: 18px;
    }

    .glass-header {
        flex-wrap: wrap;
        gap: 16px;
        padding: 16px 20px;
    }

    .brand h1 {
        font-size: 22px;
    }

    .logo-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .header-actions .btn {
        flex: 1 1 180px;
        justify-content: center;
    }

    .btn {
        padding: 10px 18px;
        font-size: 13px;
    }

    #run-matching-btn {
        width: 100%;
        padding: 16px 24px;
        font-size: 14px;
        position: sticky;
        bottom: 12px;
        z-index: 20;
    }

    .center-panel {
        padding-bottom: 44px;
    }

    .status-ring {
        width: 96px;
        height: 96px;
        margin-bottom: 12px;
    }

    .ring-inner {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }

    .match-modal__panel {
        padding: 18px;
    }

    .match-modal__grid {
        grid-template-columns: 1fr;
    }

    .form-modal__panel {
        padding: 18px;
    }

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

    .panel-action {
        padding: 6px 10px;
        font-size: 11px;
    }

    .engine-status h3 {
        font-size: 20px;
    }

    .engine-status p {
        font-size: 13px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .match-details {
        flex-direction: column;
        gap: 14px;
    }

    .match-pair {
        gap: 6px;
    }

    .match-person {
        width: 100%;
        justify-content: space-between;
    }

    .match-person.donor {
        flex-direction: row;
        text-align: left;
    }

    .match-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .match-value {
        text-align: left;
    }
}

@media (max-width: 520px) {
    .brand {
        gap: 12px;
    }

    .panel-header {
        padding: 16px 18px;
    }

    .list-container {
        padding: 12px;
    }

    .person-card {
        padding: 12px;
        gap: 12px;
    }

    .avatar {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .analysis-meta {
        padding: 14px;
    }

    .stat-value {
        font-size: 18px;
    }

    .match-result-card {
        padding: 14px;
    }
}

@media (max-width: 400px) {
    .glass-header {
        padding: 14px 16px;
    }

    .brand h1 {
        font-size: 20px;
    }

    .btn {
        padding: 9px 14px;
        font-size: 12px;
    }

    #run-matching-btn {
        padding: 14px 18px;
        letter-spacing: 0.08em;
    }
}

/* ==========================================
   Glass Panels (Left & Right Columns)
   ========================================== */
.glass-panel {
    background: rgba(7, 7, 7, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.panel-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-action {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.panel-action:hover {
    background: var(--glass-highlight);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.panel-toggle {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.panel-toggle i {
    transition: var(--transition-fast);
}

.panel-toggle:hover {
    background: var(--glass-highlight);
    border-color: var(--text-main);
}

.panel.is-collapsed .list-container {
    display: none;
}

.panel.is-collapsed .panel-header {
    border-bottom: none;
}

.panel.is-collapsed .panel-toggle i {
    transform: rotate(-90deg);
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header h2 i {
    color: var(--accent-primary);
}

.badge {
    background: rgba(255, 45, 45, 0.1);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-secondary);
    border: 1px solid rgba(255, 45, 45, 0.5);
}

.list-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar */
.list-container::-webkit-scrollbar { width: 6px; }
.list-container::-webkit-scrollbar-track { background: transparent; }
.list-container::-webkit-scrollbar-thumb {
    background: var(--glass-highlight);
    border-radius: 10px;
}
.list-container::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Cards */
.person-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.person-card:hover {
    background: rgba(255, 45, 45, 0.06);
    border-color: rgba(255, 45, 45, 0.4);
    transform: translateX(4px);
}

.person-card.is-highlighted {
    border-color: rgba(255, 45, 45, 0.7);
    box-shadow: 0 0 22px rgba(255, 45, 45, 0.35);
    background: rgba(255, 45, 45, 0.08);
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.recipient-card .avatar {
    background: rgba(255, 45, 45, 0.12);
    color: #ff9a9a;
    border: 1px solid rgba(255, 45, 45, 0.4);
}

.donor-card .avatar {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-secondary);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.info {
    flex: 1;
}

.info h4 {
    font-size: 15px;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-main);
}

.traits {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-family: 'Space Mono', monospace;
}

.trait-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--glass-highlight);
    color: var(--text-muted);
    font-weight: 500;
}

.trait-blood {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.2);
}

.trait-hla {
    color: var(--accent-secondary);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-date-mark {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 10px;
    font-family: 'Space Mono', monospace;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.card-date-mark i {
    font-size: 9px;
    opacity: 0.7;
    color: var(--accent-primary);
}

/* ==========================================
   Center Panel (Engine & Results)
   ========================================== */
.center-panel {
    display: grid;
    grid-template-rows: auto auto auto auto;
    gap: 28px;
    padding: 24px;
    position: relative;
    align-content: center;
    min-width: 0;
}

.engine-status {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.status-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    position: relative;
    box-shadow: 0 0 25px rgba(255, 45, 45, 0.35);
}

.status-ring::before {
    content: '';
    position: absolute;
    inset: 4px;
    background: var(--bg-dark);
    border-radius: 50%;
    z-index: 1;
}

.ring-inner {
    position: relative;
    z-index: 2;
    width: 86px;
    height: 86px;
    background: rgba(7, 7, 7, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: var(--accent-primary);
    box-shadow: inset 0 0 18px rgba(255, 45, 45, 0.2);
}

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes counter-spin { 100% { transform: rotate(-360deg); } }

.engine-status h3 {
    font-size: 26px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: 'Space Mono', monospace;
    color: var(--accent-secondary);
    -webkit-text-fill-color: unset;
}

.engine-status p {
    color: var(--text-muted);
    font-size: 15px;
}

#run-matching-btn {
    padding: 18px 48px;
    font-size: 16px;
    border-radius: 40px;
    z-index: 10;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#run-matching-btn i {
    margin-right: 10px;
    font-size: 18px;
}

/* Matching state animation */
.is-matching .status-ring {
    animation: spin 1s linear infinite;
    border-color: rgba(255, 45, 45, 0.8);
    box-shadow: 0 0 50px rgba(255, 45, 45, 0.45);
}
.is-matching .ring-inner {
    color: white;
    text-shadow: 0 0 20px white;
}
.is-matching .engine-status h3 {
    background: none;
    color: var(--accent-primary);
    -webkit-text-fill-color: var(--accent-primary);
    text-shadow: 0 0 15px rgba(255, 45, 45, 0.6);
}

/* Matches Preview Panel */
.matches-preview {
    width: 100%;
    max-height: 0;
    opacity: 0;
    transform: translateY(12px) scaleY(0.98);
    transform-origin: top center;
    transition:
        max-height 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0.35s ease,
        transform 0.35s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: none;
}

.matches-preview.is-open {
    max-height: min(640px, 70vh);
    opacity: 1;
    transform: translateY(0) scaleY(1);
    pointer-events: auto;
}

.matches-list {
    flex: 1;
    overflow-y: auto;
    padding: clamp(12px, 1.8vw, 16px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.matches-list::-webkit-scrollbar { width: 6px; }
.matches-list::-webkit-scrollbar-track { background: transparent; }
.matches-list::-webkit-scrollbar-thumb { background: var(--glass-highlight); border-radius: 10px; }

.match-result-card {
    background: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    padding: clamp(14px, 1.8vw, 16px);
    position: relative;
    overflow: hidden;
}

.match-result-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--accent-primary);
    box-shadow: 0 0 15px rgba(255, 45, 45, 0.4);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.match-score {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 45, 45, 0.08);
    border: 2px solid var(--accent-primary);
    color: var(--accent-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 0 20px rgba(255, 45, 45, 0.25);
}

.score-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.match-action {
    background: rgba(255, 45, 45, 0.12);
    color: var(--accent-primary);
    border: 1px solid rgba(255, 45, 45, 0.4);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.match-action:hover {
    background: var(--accent-primary);
    color: var(--bg-dark);
    box-shadow: var(--glow-primary);
}

.match-pair {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.pair-label {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 10px;
    color: var(--text-muted);
}

.pair-name {
    color: var(--accent-secondary);
    font-weight: 600;
}

.pair-sep {
    color: var(--accent-primary);
    font-weight: 700;
}

.match-details {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.3);
    border-radius: var(--border-radius-sm);
    padding: 16px;
}

.match-meta {
    margin-top: 14px;
    display: grid;
    gap: 10px;
}

.match-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.match-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
}

.match-value {
    font-size: 12px;
    color: var(--accent-secondary);
    font-family: 'Space Mono', monospace;
    text-align: right;
    word-break: break-word;
}

.match-factors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.factor-chip {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 45, 45, 0.12);
    color: var(--accent-secondary);
    border: 1px solid rgba(255, 45, 45, 0.35);
    font-family: 'Space Mono', monospace;
}

.match-person {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 40%;
}

.match-person.donor {
    flex-direction: row-reverse;
    text-align: right;
}

.match-person .avatar {
    width: 40px;
    height: 40px;
    font-size: 13px;
}

.match-person h5 {
    font-size: 14px;
    margin-bottom: 4px;
    font-weight: 500;
}

.match-person span {
    font-size: 12px;
    color: var(--text-muted);
}

.match-link {
    color: var(--success);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.match-link i {
    animation: pulse 2s infinite;
}

.match-link::after {
    content: '';
    position: absolute;
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--success), transparent);
    z-index: -1;
}

/* Match Review Modal */
.match-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 200;
}

.match-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.match-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
}

.match-modal__panel {
    position: relative;
    width: min(760px, 92vw);
    max-height: 90vh;
    background: rgba(7, 7, 7, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 24px;
    padding: 22px 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55);
    transform: translateY(18px) scale(0.98);
    transition: transform 0.3s ease;
    overflow: hidden;
    z-index: 1;
}

.match-modal.is-open .match-modal__panel {
    transform: translateY(0) scale(1);
}

.match-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.match-modal__header h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.match-modal__header p {
    font-size: 12px;
    color: var(--text-muted);
}

.match-modal__close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.match-modal__close:hover {
    background: var(--glass-highlight);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.match-modal__content {
    display: grid;
    gap: 18px;
    overflow-y: auto;
    max-height: calc(90vh - 120px);
    padding-right: 4px;
}

.match-modal__score {
    display: flex;
    align-items: center;
    gap: 14px;
}

.match-modal__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.match-modal__block {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 14px 16px;
}

.match-modal__block h4 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-family: 'Space Mono', monospace;
}

.match-modal__name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.match-modal__meta {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
    word-break: break-word;
}

.match-modal__factors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Add Record Modal */
.form-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 220;
}

.form-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.form-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
}

.form-modal__panel {
    position: relative;
    width: min(820px, 94vw);
    max-height: 90vh;
    background: rgba(7, 7, 7, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 24px;
    padding: 22px 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55);
    transform: translateY(18px) scale(0.98);
    transition: transform 0.3s ease;
    overflow: hidden;
    z-index: 1;
}

.form-modal.is-open .form-modal__panel {
    transform: translateY(0) scale(1);
}

.form-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.form-modal__header h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.form-modal__header p {
    font-size: 12px;
    color: var(--text-muted);
}

.form-modal__close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.form-modal__close:hover {
    background: var(--glass-highlight);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.form-modal__form {
    display: grid;
    gap: 18px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
    padding-right: 4px;
}

.form-section h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-family: 'Space Mono', monospace;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 12px;
    color: var(--text-muted);
}

.form-field input,
.form-field select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    color: var(--text-main);
    padding: 10px 12px;
    font-size: 13px;
    font-family: 'Space Grotesk', sans-serif;
    outline: none;
    transition: var(--transition-fast);
}

.form-field input[type="date"] {
    padding-right: 38px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f8f8f8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4.5' width='18' height='16' rx='2'/><line x1='8' y1='3' x2='8' y2='7'/><line x1='16' y1='3' x2='16' y2='7'/><line x1='3' y1='10' x2='21' y2='10'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
}

.form-field input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    cursor: pointer;
}

.form-field select option {
    color: #0a0a0a;
    background: #f8f8f8;
}

.form-field input:focus,
.form-field select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(255, 45, 45, 0.2);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-message {
    min-height: 18px;
    font-size: 12px;
    color: var(--text-muted);
}

.form-message.is-error {
    color: #ff7a7a;
}

.form-message.is-success {
    color: #a4f4d1;
}

.is-hidden {
    display: none;
}

@keyframes pulse {
    0% { opacity: 0.5; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); text-shadow: 0 0 15px var(--success); }
    100% { opacity: 0.5; transform: scale(0.9); }
}

.hidden {
    display: none !important;
}

/* Animations for list items */
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.person-card {
    animation: slideIn 0.4s ease forwards;
    opacity: 0;
}

/* ==========================================
   Analysis Meta & Stats
   ========================================== */
.analysis-meta {
    width: 100%;
    padding: 18px 18px;
    gap: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(7, 7, 7, 0.9);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-secondary);
    font-family: 'Space Mono', monospace;
}

.sync-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.sync-info i {
    color: var(--accent-primary);
}
