/* ==========================================================================
   AutoTriage AI — Modern SaaS Design System
   ========================================================================== */

:root {
    --bg-base: #090d16;
    --bg-surface: #111827;
    --bg-card: rgba(19, 27, 44, 0.78);
    --bg-card-hover: rgba(26, 37, 60, 0.9);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.6);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --brand-primary: #6366f1;
    --brand-primary-hover: #4f46e5;
    --brand-glow: rgba(99, 102, 241, 0.35);

    --color-urgent: #ef4444;
    --color-urgent-bg: rgba(239, 68, 68, 0.14);
    --color-urgent-border: rgba(239, 68, 68, 0.3);

    --color-high: #f97316;
    --color-high-bg: rgba(249, 115, 22, 0.14);
    --color-high-border: rgba(249, 115, 22, 0.3);

    --color-medium: #f59e0b;
    --color-medium-bg: rgba(245, 158, 11, 0.14);
    --color-medium-border: rgba(245, 158, 11, 0.3);

    --color-low: #06b6d4;
    --color-low-bg: rgba(6, 182, 212, 0.14);
    --color-low-border: rgba(6, 182, 212, 0.3);

    --color-success: #10b981;
    --color-success-bg: rgba(16, 185, 129, 0.14);
    --color-success-border: rgba(16, 185, 129, 0.3);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px var(--border-subtle);
    --shadow-glow: 0 0 25px -5px var(--brand-glow);

    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.12), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(14, 165, 233, 0.1), transparent 45%);
    background-attachment: fixed;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */

.app-header {
    background: rgba(11, 16, 28, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 1.4rem;
    background: linear-gradient(135deg, #6366f1, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text {
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.logo-text strong {
    color: #818cf8;
}

.badge-ai {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.35);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.18);
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.3rem 0.8rem 0.3rem 0.4rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */

.main-content {
    flex: 1;
    padding: 2.2rem 1.5rem 4rem;
}

.content-container {
    max-width: 1240px;
    margin: 0 auto;
}

/* ==========================================================================
   Flash Alerts Stack
   ========================================================================== */

.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.flash-alert {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    animation: fadeIn 0.3s ease;
}

.flash-success {
    background: var(--color-success-bg);
    border-color: var(--color-success-border);
    color: #34d399;
}

.flash-danger {
    background: var(--color-urgent-bg);
    border-color: var(--color-urgent-border);
    color: #f87171;
}

.flash-warning {
    background: var(--color-medium-bg);
    border-color: var(--color-medium-border);
    color: #fbbf24;
}

.flash-info {
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
}

.flash-icon {
    font-weight: 700;
    font-size: 1.1rem;
}

.flash-text {
    flex: 1;
    font-size: 0.92rem;
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    font-size: 1.2rem;
    cursor: pointer;
}

.flash-close:hover {
    opacity: 1;
}

/* ==========================================================================
   Card System
   ========================================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    overflow: hidden;
}

.card-header {
    padding: 1.4rem 1.6rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h2, .card-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.65rem 1.2rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.84rem;
}

.btn-xs {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.85rem 1.6rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover));
    color: #fff;
    box-shadow: 0 4px 14px -3px var(--brand-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    transform: translateY(-1px);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

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

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.hidden {
    display: none !important;
}

/* Forms */
.styled-form {
    padding: 1.6rem;
}

.form-group {
    margin-bottom: 1.3rem;
    display: flex;
    flex-direction: column;
}

.form-row.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
}

label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

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

.form-input, .form-textarea, .form-select {
    width: 100%;
    background: rgba(11, 16, 28, 0.7);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.94rem;
    transition: all 0.2s ease;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-textarea {
    resize: vertical;
}

.textarea-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.field-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
}

/* Quick Presets */
.quick-examples {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-subtle);
}

.quick-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.preset-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    padding: 0.25rem 0.7rem;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.4);
}

/* ==========================================================================
   Badges System
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
}

.badge-category {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-priority-urgent {
    background: var(--color-urgent-bg);
    color: #f87171;
    border: 1px solid var(--color-urgent-border);
}

.badge-priority-high {
    background: var(--color-high-bg);
    color: #fb923c;
    border: 1px solid var(--color-high-border);
}

.badge-priority-medium {
    background: var(--color-medium-bg);
    color: #fbbf24;
    border: 1px solid var(--color-medium-border);
}

.badge-priority-low {
    background: var(--color-low-bg);
    color: #22d3ee;
    border: 1px solid var(--color-low-border);
}

.badge-status-open {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-status-in-progress {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-status-resolved {
    background: var(--color-success-bg);
    color: #34d399;
    border: 1px solid var(--color-success-border);
}

.badge-classification-completed {
    background: var(--color-success-bg);
    color: #34d399;
}

.badge-classification-pending {
    background: var(--color-medium-bg);
    color: #fbbf24;
}

.badge-classification-failed {
    background: var(--color-urgent-bg);
    color: #f87171;
}

.badge-confidence {
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.3);
}

.badge-muted {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

/* ==========================================================================
   Public Submission Page Layout
   ========================================================================== */

.portal-hero {
    text-align: center;
    max-width: 760px;
    margin: 0 auto 2.5rem;
}

.hero-chip {
    display: inline-block;
    padding: 0.3rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border-radius: var(--radius-full);
    border: 1px solid rgba(99, 102, 241, 0.3);
    margin-bottom: 1rem;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 0.8rem;
    background: linear-gradient(135deg, #ffffff 40%, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
}

.portal-grid {
    display: grid;
    grid-template-columns: 2fr 1.1fr;
    gap: 1.8rem;
    align-items: start;
}

/* Submitted confirmation card */
.submitted-card {
    margin-bottom: 2rem;
    border: 1px solid rgba(16, 185, 129, 0.4);
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.06), rgba(19, 27, 44, 0.85));
}

.submitted-header {
    padding: 1.2rem 1.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.status-indicator-ring {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    color: #34d399;
}

.pulsing-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulse 2s infinite;
}

.submitted-body {
    padding: 1.6rem;
}

.submitted-subject {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.triage-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.pill-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pill-label {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.ai-box {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    margin-bottom: 1.2rem;
}

.ai-box-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #a5b4fc;
    margin-bottom: 0.4rem;
}

.ai-box-content {
    font-size: 0.94rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.ai-box-reason {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.6rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: 0.5rem;
}

.submitted-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Sidebar info cards */
.info-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-card {
    padding: 1.4rem;
}

.info-card h3 {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

.category-list {
    list-style: none;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.cat-pill {
    font-size: 0.82rem;
    font-weight: 700;
    color: #a5b4fc;
    margin-bottom: 0.15rem;
}

.category-list p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

.priority-guide {
    margin-top: 0.8rem;
    font-size: 0.82rem;
    line-height: 2;
    color: var(--text-secondary);
}

/* ==========================================================================
   Dashboard View
   ========================================================================== */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    gap: 0.8rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.2rem;
    margin-bottom: 1.8rem;
}

.stat-card {
    padding: 1.4rem;
    display: flex;
    align-items: center;
    gap: 1.1rem;
}

.stat-icon {
    font-size: 1.8rem;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-data {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.text-urgent { color: var(--color-urgent); }
.text-warning { color: var(--color-medium); }
.text-success { color: var(--color-success); }

/* Distribution charts */
.distribution-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.2rem;
    margin-bottom: 1.8rem;
}

.breakdown-body {
    padding: 1.3rem 1.6rem 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.bar-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.bar-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
}

.bar-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.bar-count {
    color: var(--text-primary);
}

.progress-track {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fill-primary { background: linear-gradient(90deg, #6366f1, #818cf8); }
.fill-urgent { background: linear-gradient(90deg, #ef4444, #f87171); }
.fill-high { background: linear-gradient(90deg, #f97316, #fb923c); }
.fill-medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.fill-low { background: linear-gradient(90deg, #06b6d4, #22d3ee); }
.fill-status-open { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.fill-status-in-progress { background: linear-gradient(90deg, #a855f7, #c084fc); }
.fill-status-resolved { background: linear-gradient(90deg, #10b981, #34d399); }

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 0.85rem 1.2rem;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(11, 16, 28, 0.4);
}

.data-table td {
    padding: 1rem 1.2rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.ticket-id {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.82rem;
    color: #a5b4fc;
}

.subject-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.subject-link:hover {
    color: #818cf8;
}

.cell-customer {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.empty-cell {
    text-align: center;
    padding: 3rem !important;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.empty-icon {
    font-size: 2.5rem;
    opacity: 0.7;
}

/* ==========================================================================
   Tickets Queue Toolbar & Filter
   ========================================================================== */

.filter-card {
    margin-bottom: 1.2rem;
    padding: 1.2rem 1.4rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: flex-end;
}

.filter-item {
    display: flex;
    flex-direction: column;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 0.85rem;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0.6;
}

.input-with-icon .form-input {
    padding-left: 2.3rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.results-bar {
    margin-bottom: 0.8rem;
    padding: 0 0.4rem;
}

.pagination-footer {
    padding: 1rem 1.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Ticket Detail View
   ========================================================================== */

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--brand-primary);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 1rem 0 2rem;
    gap: 1.5rem;
}

.title-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.ticket-tag {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
    color: #a5b4fc;
}

.ticket-subject {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
}

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

.detail-main {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

.customer-info-bar {
    display: flex;
    gap: 1rem;
    padding: 0.8rem 1.6rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.85rem;
}

.customer-info-bar a {
    color: #818cf8;
    text-decoration: none;
}

.message-body {
    padding: 1.6rem;
}

.message-text {
    font-family: inherit;
    font-size: 0.96rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}

.ai-analysis-card {
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.ai-badge-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sparkle-icon {
    font-size: 1.2rem;
}

.confidence-meter {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.confidence-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.meter-bar {
    width: 80px;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #6366f1);
    border-radius: var(--radius-full);
}

.confidence-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.82rem;
    color: #38bdf8;
}

.ai-analysis-body {
    padding: 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 1.3rem;
}

.ai-metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border-subtle);
}

.ai-metric-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ai-metric-label {
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.ai-section h4 {
    font-size: 0.88rem;
    font-weight: 700;
    color: #c7d2fe;
    margin-bottom: 0.4rem;
}

.ai-text {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.override-form {
    padding: 1.4rem;
}

.override-hint {
    margin-top: 0.3rem;
    color: var(--color-high);
}

.meta-card {
    padding: 1.4rem;
}

.meta-card h4 {
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
}

.audit-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.82rem;
}

.audit-label {
    color: var(--text-muted);
}

/* ==========================================================================
   Auth Screens
   ========================================================================== */

.auth-wrapper {
    max-width: 440px;
    margin: 3rem auto;
}

.auth-card {
    padding: 2.2rem 2rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.8rem;
}

.auth-icon {
    font-size: 2.2rem;
    display: inline-block;
    margin-bottom: 0.6rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border-subtle);
}

.auth-footer a {
    color: #818cf8;
    text-decoration: none;
    font-weight: 600;
}

/* ==========================================================================
   404 Page
   ========================================================================== */

.notfound-wrapper {
    max-width: 520px;
    margin: 4rem auto;
    text-align: center;
}

.notfound-card {
    padding: 3rem 2rem;
}

.notfound-code {
    font-size: 4rem;
    font-weight: 900;
    font-family: var(--font-mono);
    background: linear-gradient(135deg, #ef4444, #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
    margin-bottom: 1rem;
    display: inline-block;
}

.notfound-card h2 {
    font-size: 1.4rem;
    margin-bottom: 0.8rem;
}

.notfound-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* ==========================================================================
   Animations & Responsive Utilities
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.76rem; }

/* Responsive */
@media (max-width: 980px) {
    .portal-grid, .detail-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .distribution-grid {
        grid-template-columns: 1fr;
    }
    .filter-grid {
        grid-template-columns: 1fr 1fr;
    }
    .search-item {
        grid-column: span 2;
    }
}

@media (max-width: 640px) {
    .form-row.two-cols {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .filter-grid {
        grid-template-columns: 1fr;
    }
    .search-item {
        grid-column: span 1;
    }
    .nav-container {
        flex-direction: column;
        gap: 0.8rem;
    }
}
