/* ================================================================
   ALNOVA Portal · Obsidian Financial Theme
   Fonts: Syne (UI) · JetBrains Mono (data)
   ================================================================ */

:root {
    /* Backgrounds */
    --bg:         #070A12;
    --surface-0:  #0C1120;
    --surface-1:  #111B2E;
    --surface-2:  #182438;

    /* Borders */
    --border:      rgba(255,255,255,0.06);
    --border-mid:  rgba(255,255,255,0.11);
    --border-hi:   rgba(255,255,255,0.20);

    /* Accents */
    --blue:        #5B9CFF;
    --blue-dim:    rgba(91,156,255,0.10);
    --blue-glow:   0 0 28px rgba(91,156,255,0.22);

    --gold:        #F5A930;
    --gold-dim:    rgba(245,169,48,0.10);

    --green:       #2DD4A0;
    --green-dim:   rgba(45,212,160,0.10);

    --red:         #F87171;
    --red-dim:     rgba(248,113,113,0.10);

    /* Text */
    --text:        #DCE6F5;
    --text-muted:  #546C8C;
    --text-dim:    #2A3B52;

    /* Typography */
    --font-ui:   'Syne', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Geometry */
    --radius:    12px;
    --radius-sm: 8px;

    /* Shadows */
    --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 4px 24px rgba(0,0,0,0.45);
    --shadow-pop:  0 1px 0 rgba(255,255,255,0.05) inset, 0 8px 40px rgba(0,0,0,0.55);
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: var(--font-ui);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Ambient gradient background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(ellipse 70% 50% at 15% 0%, rgba(91,156,255,0.07) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 85% 100%, rgba(245,169,48,0.05) 0%, transparent 55%);
    pointer-events: none;
    z-index: 0;
}

#app { position: relative; z-index: 1; }

/* ── Loading screen ───────────────────────────────────────────── */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 1.25rem;
}

.loading-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-mid);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Blazor error banner ─────────────────────────────────────── */
#blazor-error-ui {
    background: var(--red-dim);
    border-top: 1px solid rgba(248,113,113,0.25);
    color: var(--red);
    bottom: 0; left: 0; right: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    display: none;
    z-index: 9999;
    font-size: 0.82rem;
    font-family: var(--font-ui);
    backdrop-filter: blur(12px);
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}
#blazor-error-ui .dismiss:hover { opacity: 1; }
#blazor-error-ui .reload {
    color: var(--red);
    font-weight: 600;
    margin-left: 0.5rem;
    text-decoration: underline;
}

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

/* ── Header ───────────────────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 54px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    background: rgba(7, 10, 18, 0.82);
    backdrop-filter: blur(20px) saturate(1.6);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    border-bottom: 1px solid var(--border);
}

/* Brand / logo */
.app-header-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-shrink: 0;
    text-decoration: none;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(140deg, #5B9CFF 0%, #3373E8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 18px rgba(91,156,255,0.28), 0 2px 4px rgba(0,0,0,0.3);
}

.app-header-brand h1 {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text);
    line-height: 1;
}

.app-header-brand .header-sub {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.01em;
    margin-top: 1px;
    display: none;
}

@media (min-width: 640px) {
    .app-header-brand .header-sub { display: block; }
}

/* Navigation */
.app-nav {
    display: flex;
    align-items: center;
    height: 54px;
    gap: 0;
}

.app-nav a {
    display: inline-flex;
    align-items: center;
    height: 54px;
    padding: 0 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.app-nav a:hover { color: var(--text); }

.app-nav a.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

/* ── Main content ──────────────────────────────────────────────── */
.app-main {
    flex: 1;
    padding: 1.75rem 2rem 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    transition: border-color 0.2s;
}

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

.card h2 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
    margin: 0 0 0.35rem;
}

.card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

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

.page-header-text h2 {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-header-text p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.52rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: var(--blue);
    color: #fff;
    border-color: transparent;
}
.btn-primary:hover:not(:disabled) {
    background: #6FAAFF;
    box-shadow: 0 0 22px rgba(91,156,255,0.32);
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-pdf {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-mid);
}
.btn-pdf:hover {
    color: var(--text);
    border-color: var(--border-hi);
    background: var(--surface-1);
}

/* Spinner inside button */
.btn-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.25);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    flex-shrink: 0;
}

/* ── File input ────────────────────────────────────────────────── */
.file-input {
    display: block;
    width: 100%;
    border: 1.5px dashed var(--border-mid);
    border-radius: var(--radius);
    padding: 2.75rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    background: var(--surface-1);
    position: relative;
    overflow: hidden;
}

.file-input::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 50%, rgba(91,156,255,0.06) 0%, transparent 65%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.file-input:hover {
    border-color: var(--blue);
    border-style: solid;
    box-shadow: var(--blue-glow);
}
.file-input:hover::after { opacity: 1; }

.file-input.drag-over {
    border-color: var(--green);
    background: var(--green-dim);
}

.file-input--selected {
    border-color: var(--green);
    border-style: solid;
    background: var(--green-dim);
}
.file-input--selected::after {
    background: radial-gradient(ellipse at 50% 50%, rgba(45,212,160,0.07) 0%, transparent 65%);
    opacity: 1;
}

.file-input-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    gap: 0.5rem;
}

/* ── Upload page ────────────────────────────────────────────────── */
.upload-wrapper {
    max-width: 520px;
    margin: 2.5rem auto 0;
}

.upload-icon-header {
    text-align: center;
    padding-bottom: 1.75rem;
}

.upload-icon-header h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
    margin: 0.75rem 0 0.4rem;
}

.upload-icon-header p {
    color: var(--text-muted);
    font-size: 0.83rem;
    line-height: 1.75;
}

.upload-icon-header code {
    font-family: var(--font-mono);
    font-size: 0.78em;
    background: var(--surface-2);
    border: 1px solid var(--border-mid);
    padding: 0.12em 0.45em;
    border-radius: 4px;
    color: var(--blue);
}

.upload-card { margin-bottom: 0; }

/* ── KPI Grid ───────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.875rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: var(--surface-0);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.25rem 1.1rem;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
    cursor: default;
}

/* Top accent bar */
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--blue) 0%, rgba(91,156,255,0.2) 100%);
}
.kpi-card.accent::before {
    background: linear-gradient(90deg, var(--gold) 0%, rgba(245,169,48,0.2) 100%);
}

/* Subtle corner glow */
.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 80px; height: 80px;
    background: radial-gradient(circle at 0% 0%, rgba(91,156,255,0.08), transparent 70%);
    pointer-events: none;
}
.kpi-card.accent::after {
    background: radial-gradient(circle at 0% 0%, rgba(245,169,48,0.06), transparent 70%);
}

.kpi-card:hover {
    border-color: var(--border-mid);
    transform: translateY(-2px);
    box-shadow: var(--shadow-pop);
}

.kpi-card .label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.65rem;
    position: relative;
    z-index: 1;
}

.kpi-card .value {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--blue);
    letter-spacing: -0.03em;
    line-height: 1;
    position: relative;
    z-index: 1;
}

.kpi-card.accent .value { color: var(--gold); }

/* ── Dashboard toolbar ──────────────────────────────────────────── */
.dashboard-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    align-self: flex-start;
    padding-top: 0.2rem;
}

/* ── Charts ─────────────────────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 360px;
    margin-top: 1.25rem;
}

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    border: 1px solid;
    line-height: 1.5;
}

.alert-success {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(45,212,160,0.20);
}
.alert-error {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(248,113,113,0.20);
}
.alert-info {
    background: var(--blue-dim);
    color: var(--blue);
    border-color: rgba(91,156,255,0.20);
}

/* ── Print / PDF ────────────────────────────────────────────────── */
@media print {
    :root {
        --bg:         #ffffff;
        --surface-0:  #ffffff;
        --surface-1:  #f8fafc;
        --surface-2:  #f1f5f9;
        --border:     #e2e8f0;
        --border-mid: #cbd5e1;
        --text:       #0f172a;
        --text-muted: #64748b;
        --blue:       #2563eb;
        --gold:       #d97706;
        --green:      #059669;
        --red:        #dc2626;
    }

    body::before { display: none; }
    .no-print, .app-nav { display: none !important; }

    .app-header {
        position: static;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: white;
        border-bottom: 1px solid #e2e8f0;
    }

    .app-main { padding: 1rem; }

    .card {
        box-shadow: none;
        border: 1px solid #e2e8f0;
        page-break-inside: avoid;
    }

    .kpi-card {
        box-shadow: none;
        border: 1px solid #e2e8f0;
        transform: none !important;
    }

    .kpi-card::after { display: none; }

    .chart-container { height: 260px; }

    canvas { background: white !important; }
}