/* ══ Основа ══════════════════════════════════════════════════════════════ */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    background: #F1F5F9;
    color: #0F172A;
}

* { box-sizing: border-box; }

.boot-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

/* ══ Скелет на приложението ══════════════════════════════════════════════ */

.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-content {
    flex: 1;
    overflow: auto;
    padding: 20px 24px;
}

/* ══ Страничен панел ═════════════════════════════════════════════════════ */

.app-sidebar {
    width: 272px;
    flex-shrink: 0;
    background: #FFFFFF;
    border-right: 1px solid #E2E8F0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width .18s ease, margin-left .18s ease;
}

.app-sidebar.collapsed {
    width: 0;
    margin-left: -1px;
    border-right: none;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid #E2E8F0;
    flex-shrink: 0;
}

.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0F62FE, #0284C7);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.sidebar-logo-sub {
    font-size: 11px;
    color: #94A3B8;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0 24px;
}

.nav-zone { padding: 4px 8px; }

.nav-section-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #94A3B8;
    padding: 12px 10px 5px;
}

/* ══ Горна лента ═════════════════════════════════════════════════════════ */

.app-topbar {
    height: 62px;
    flex-shrink: 0;
    background: #FFFFFF;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
}

.topbar-center {
    flex: 0 1 auto;
    text-align: center;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 0;
    justify-content: flex-end;
}

.page-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-subtitle {
    font-size: 11.5px;
    color: #64748B;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.active-run {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border: 1px solid #E2E8F0;
    border-radius: 9px;
    background: #F8FAFC;
    cursor: pointer;
    max-width: 340px;
    transition: background .15s ease, border-color .15s ease;
}

.active-run:hover { background: #EFF6FF; border-color: #BFDBFE; }
.active-run.empty { cursor: default; opacity: .7; }
.active-run.empty:hover { background: #F8FAFC; border-color: #E2E8F0; }

.active-run-icon { font-size: 20px; color: #0F62FE; flex-shrink: 0; }
.active-run-body { min-width: 0; }

.active-run-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #94A3B8;
    line-height: 1.2;
}

.active-run-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.active-run-name.muted { font-weight: 400; color: #94A3B8; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
}

.topbar-user:hover { background: #F1F5F9; }
.topbar-user-name { font-size: 13px; font-weight: 500; }

/* ══ Навигация ═══════════════════════════════════════════════════════════ */

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: #334155;
    text-decoration: none;
    font-size: 13.5px;
    line-height: 1.3;
    transition: background .13s ease, color .13s ease;
}

.nav-item:hover { background: #F1F5F9; color: #0F172A; }

.nav-item.active {
    background: #EFF6FF;
    color: #0F62FE;
    font-weight: 600;
}

.nav-item.sub { padding-left: 22px; font-size: 13px; }

.nav-item .nav-icon { font-size: 18px; flex-shrink: 0; }
.nav-item .nav-label { min-width: 0; }

.nav-group { margin-bottom: 1px; }

.nav-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    color: #1E293B;
    user-select: none;
    transition: background .13s ease;
}

.nav-group-header:hover { background: #F1F5F9; }
.nav-group-header.child-active { color: #0F62FE; font-weight: 600; }
.nav-group-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group-items { padding: 1px 0 3px; }

/* ══ Вход ════════════════════════════════════════════════════════════════ */

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 100%);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #FFFFFF;
    border-radius: 14px;
    padding: 34px 32px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .35);
}

.login-logo {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0F62FE, #0284C7);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.login-title { text-align: center; font-size: 19px; font-weight: 700; }
.login-sub   { text-align: center; font-size: 12.5px; color: #64748B; margin-bottom: 22px; }

/* ══ Обобщаващи плочки ═══════════════════════════════════════════════════ */

.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-tile {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-left-width: 4px;
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: box-shadow .15s ease, transform .15s ease;
}

.stat-tile:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, .09); transform: translateY(-1px); }
.stat-tile.selected { box-shadow: 0 0 0 2px #0F62FE inset; }

.stat-tile-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748B;
}

.stat-tile-value { font-size: 25px; font-weight: 700; line-height: 1.15; }
.stat-tile-hint  { font-size: 11.5px; color: #94A3B8; }

/* ══ Таблица с резултати ═════════════════════════════════════════════════ */

.num-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta-pos { color: #B91C1C; font-weight: 600; }
.delta-neg { color: #1D4ED8; font-weight: 600; }
.delta-zero { color: #94A3B8; }
.mono { font-variant-numeric: tabular-nums; }

.row-match      { border-left: 3px solid #16A34A; }
.row-rounding   { border-left: 3px solid #D97706; }
.row-difference { border-left: 3px solid #DC2626; }
.row-only-nap   { border-left: 3px solid #0EA5E9; }
.row-only-acc   { border-left: 3px solid #7C3AED; }

.side-by-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 900px) {
    .side-by-side { grid-template-columns: 1fr; }
    .topbar-center { display: none; }
}

/* ══ Съобщение при грешка ════════════════════════════════════════════════ */

#blazor-error-ui {
    color: #FFFFFF;
    background: #B91C1C;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none;
    left: 0;
    padding: 0.8rem 1.2rem 0.8rem 1.2rem;
    position: fixed;
    width: 100%;
    z-index: 1200;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

#blazor-error-ui .reload { color: #FFFFFF; }
