html, body {
    font-family: Roboto, "Segoe UI", Arial, sans-serif;
}

/* Страницы входа и ошибок (без MudBlazor) */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f2f4f7;
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .08);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-card h1 {
    font-size: 22px;
    font-weight: 500;
    margin: 0;
}

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: #444;
}

.login-card input {
    font-size: 15px;
    padding: 10px 12px;
    border: 1px solid #c8ccd2;
    border-radius: 6px;
}

.login-card input:focus {
    outline: 2px solid #2E5C8A;
    border-color: #2E5C8A;
}

.login-card button {
    font-size: 15px;
    padding: 10px;
    border: 0;
    border-radius: 6px;
    background: #2E5C8A;
    color: #fff;
    cursor: pointer;
}

.login-error {
    background: #fdecec;
    color: #8a1f1f;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
}

/* Сообщение Blazor о сбое */
#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

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

.text-right {
    text-align: right;
}

/* ───────── Общий стиль рабочих страниц ───────── */
.mud-main-content {
    background: #f5f7fa;
    min-height: 100vh;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.page-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.filter-bar > * {
    flex: 0 1 auto;
    min-width: 170px;
    max-width: 260px;
}

/* Кнопки в строке фильтров не сжимаются и не наезжают на поля */
.filter-bar > .mud-button-root,
.filter-bar > .mud-button-group-root,
.filter-bar > .mud-icon-button {
    flex: none;
    min-width: auto;
    max-width: none;
}

.filter-bar > .mud-input-control,
.filter-bar > .mud-select {
    margin-top: 0;
}

.filter-wide,
.filter-bar > .filter-wide {
    flex: 1 1 320px;
    min-width: 260px;
    max-width: 420px;
}

.num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: right;
}

.money-in {
    color: #1b7f3b;
}

.money-out {
    color: #c62828;
}

.warn {
    color: #b26a00;
}

.select-hint {
    margin-left: 8px;
    font-size: 12px;
    color: #8a929c;
}

.muted {
    color: #8a929c;
}

.nowrap {
    white-space: nowrap;
}

.purpose {
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #5f6b7a;
    font-size: 13px;
}

/* ───────── Карточки показателей ───────── */
.kpi-card {
    padding: 16px 18px;
    height: 100%;
    border-radius: 10px !important;
    background: #fff;
}

.kpi-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #5f6b7a;
}

.kpi-value {
    font-size: 24px;
    font-weight: 500;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.kpi-note {
    margin-top: 4px;
    font-size: 12px;
    color: #8a929c;
}

.panel {
    padding: 16px;
    border-radius: 10px !important;
    background: #fff;
}

.panel-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 8px;
}

/* ───────── Отчеты (ДДС, ОПиУ) ───────── */
.report-wrap {
    overflow: auto;
    max-height: 72vh;
    background: #fff;
    border: 1px solid #e3e7ec;
    border-radius: 10px;
}

.report {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-size: 13.5px;
}

.report th, .report td {
    padding: 7px 12px;
    border-bottom: 1px solid #eef1f4;
}

.report thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    font-weight: 500;
    color: #5f6b7a;
    text-align: right;
    z-index: 2;
    white-space: nowrap;
}

.report .report-title-col {
    position: sticky;
    left: 0;
    background: inherit;
    text-align: left;
    min-width: 280px;
    z-index: 1;
}

.report thead .report-title-col {
    z-index: 3;
    background: #f8fafc;
}

.report tbody tr {
    background: #fff;
}

.report tbody tr:hover {
    background: #f4f8fd;
}

.report .report-total-col {
    font-weight: 500;
    background: #fafbfc;
}

.report .r-section td {
    background: #eef3f9;
    font-weight: 500;
    color: #2E5C8A;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: .04em;
}

.report .r-group td {
    font-weight: 500;
}

.report .r-subtotal td {
    font-weight: 500;
    background: #f8fafc;
}

.report .r-total td {
    font-weight: 600;
    background: #eef3f9;
}

.report .r-balance td {
    font-weight: 500;
    color: #2E5C8A;
    background: #fbfcfe;
}

.report .r-percent td {
    color: #5f6b7a;
    font-style: italic;
}

.report-link {
    cursor: pointer;
    color: inherit;
}

.report-link:hover {
    color: #2E5C8A;
    text-decoration: underline;
}

/* ───────── Платежный календарь ───────── */
.day-negative {
    background: #fdecec !important;
}

.overdue {
    color: #c62828;
    font-size: 12px;
}

.edit-panel {
    padding: 16px;
    border-radius: 10px !important;
    border-left: 4px solid #2E5C8A;
    margin-bottom: 12px;
}

/* ═════════════ Макет: темное меню и верхняя панель ═════════════ */
body, .mud-typography {
    font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
}

.topbar {
    border-bottom: 1px solid #e6eaf0;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 4px;
}

.month-select {
    width: 210px;
}

.month-select .mud-input-outlined-border {
    border-color: #dfe4ec;
}

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

.user-chip:hover {
    background: #f1f4f9;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

.menu-notice {
    display: flex;
    flex-direction: column;
    max-width: 300px;
    font-size: 13px;
    white-space: normal;
}

.menu-notice span {
    color: #6b778a;
}

.sidebar {
    background: #14213D !important;
    border-right: 0 !important;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 22px;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
}

.sidebar-logo-icon {
    display: inline-flex;
    color: #4F8BFF;
}

.side-nav {
    padding: 0 12px;
}

.side-nav .mud-nav-link {
    border-radius: 8px;
    margin: 2px 0;
    color: #C7D2E5;
    padding: 9px 12px;
    font-size: 14.5px;
}

.side-nav .mud-nav-link .mud-nav-link-icon {
    color: #9FB0CC;
}

.side-nav .mud-nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.side-nav .mud-nav-link.active {
    background: #2F6FED !important;
    color: #fff !important;
}

.side-nav .mud-nav-link.active .mud-nav-link-icon {
    color: #fff;
}

.side-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 24px 24px 8px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    color: #8696B3;
    font-size: 13px;
}

.side-companies {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0 12px 24px;
}

.side-company {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: #C7D2E5;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    justify-content: flex-start;
    font-family: inherit;
    line-height: 1.3;
    box-sizing: border-box;
}

.side-company .dot {
    flex: none;
}

.side-company-name {
    flex: 1;
    min-width: 0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-company:hover {
    background: rgba(255, 255, 255, .06);
}

.side-company.active {
    background: rgba(79, 139, 255, .18);
    color: #fff;
}

.muted-link {
    color: #8696B3;
}

.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: none;
}

.main {
    background: #F4F6FA;
    min-height: 100vh;
}

.main-inner {
    padding: 24px 24px 40px;
}

.page-header .mud-typography-h5 {
    font-weight: 600;
}

/* ═════════════ Главная ═════════════ */
.dash {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 16px;
    align-items: start;
}

.dash-main, .dash-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.kpi-row.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.dash-row {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.dash-row.wide-left {
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
}

.dash-row.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dash-row.three {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr);
}

@media (max-width: 1400px) {
    .dash {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .dash-row.wide-left, .dash-row.three, .dash-row.two {
        grid-template-columns: 1fr;
    }

    .kpi-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.card {
    background: #fff;
    border: 1px solid #E6EAF0;
    border-radius: 12px;
    padding: 16px 18px;
    min-width: 0;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.card-head h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: #1F2A3D;
}

.card-hint {
    font-weight: 400;
    font-size: 12px;
    color: #8a929c;
    margin-left: 6px;
}

.card-link {
    font-size: 13px;
    color: #2F6FED;
    text-decoration: none;
}

.empty {
    color: #8a929c;
    padding: 28px 8px;
    text-align: center;
    font-size: 14px;
}

/* Карточки показателей */
.dkpi {
    background: #fff;
    border: 1px solid #E6EAF0;
    border-radius: 12px;
    padding: 16px 18px;
}

.dkpi-head {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #4A5568;
    font-size: 14px;
}

.dkpi-icon, .recent-icon, .tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    flex: none;
}

.tone-green { background: #E3F5EC; color: #1F9D5B; }
.tone-red { background: #FDE8E8; color: #E5484D; }
.tone-blue { background: #E6EEFE; color: #2F6FED; }
.tone-purple { background: #F1E8FD; color: #8B3FD9; }
.tone-orange { background: #FEF0E1; color: #E07B12; }
.tone-gray { background: #EEF1F5; color: #5F6B7A; }

.dkpi-value {
    font-size: 26px;
    font-weight: 600;
    margin: 12px 0 4px;
    font-variant-numeric: tabular-nums;
    color: #1F2A3D;
    white-space: nowrap;
}

.dkpi-change {
    font-size: 14px;
    font-weight: 500;
}

.dkpi-change.good { color: #1F9D5B; }
.dkpi-change.bad { color: #E5484D; }

.dkpi-note {
    font-size: 13px;
    color: #8a929c;
}

/* Последние операции */
.recent-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #F0F2F6;
}

.recent-row:last-child {
    border-bottom: 0;
}

.recent-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
}

.recent-body {
    flex: 1;
    min-width: 0;
}

.recent-title {
    font-size: 14px;
    font-weight: 500;
    color: #1F2A3D;
}

.recent-sub {
    font-size: 13px;
    color: #6B778A;
}

.recent-date {
    font-size: 12px;
    color: #9AA3AF;
    margin-top: 2px;
}

.recent-amount {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Уведомления */
.notice {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #F0F2F6;
}

.notice:last-child {
    border-bottom: 0;
}

.notice.no-link {
    cursor: default;
}

.notice:not(.no-link):hover .notice-title {
    color: #2F6FED;
}

.notice-icon {
    display: inline-flex;
    padding-top: 1px;
}

.level-error { color: #E5484D; }
.level-warning { color: #F0A202; }
.level-info { color: #2F6FED; }
.level-success { color: #1F9D5B; }

.notice-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.notice-title {
    font-size: 14px;
    font-weight: 500;
    color: #1F2A3D;
}

.notice-text {
    font-size: 13px;
    color: #6B778A;
}

.notice-when {
    font-size: 12px;
    color: #9AA3AF;
    margin-top: 2px;
}

/* Мини-таблицы */
.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    table-layout: fixed;
}

.mini-table th {
    text-align: left;
    font-weight: 500;
    color: #8a929c;
    font-size: 12px;
    padding: 6px 4px;
    border-bottom: 1px solid #EEF1F5;
}

.mini-table td {
    padding: 8px 4px;
    border-bottom: 1px solid #F3F5F8;
}

.mini-table th:first-child, .mini-table td:first-child {
    width: 50%;
}

.mini-table .group-row td {
    font-weight: 600;
    background: #F8FAFC;
}

.mini-table .total-row td {
    font-weight: 700;
    background: #EEF3F9;
}

.mini-table .indent {
    padding-left: 20px;
    color: #4A5568;
}

.mini-table tr.clickable {
    cursor: pointer;
}

.mini-table tr.clickable:hover td {
    background: #F4F8FD;
}

/* ═════════════ Графики ═════════════ */
.chart-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.chart-grid {
    stroke: #EEF1F5;
    stroke-width: 1;
}

.chart-zero {
    stroke: #C9D1DC;
    stroke-width: 1;
}

.chart-axis {
    fill: #8A929C;
    font-size: 11px;
}

.chart-value {
    fill: #5F6B7A;
    font-size: 10px;
}

.chart-hit {
    cursor: crosshair;
}

.chart-hit:hover {
    fill: rgba(47, 111, 237, .15);
}

.chart-legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: #4A5568;
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.donut {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.donut-svg {
    flex: none;
}

.donut-center {
    font-size: 17px;
    font-weight: 600;
    fill: #1F2A3D;
}

.donut-sub {
    font-size: 11px;
    fill: #8A929C;
}

.donut-legend {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.donut-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.donut-legend-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #4A5568;
}

.donut-legend-pct {
    font-variant-numeric: tabular-nums;
    color: #1F2A3D;
    font-weight: 500;
}

/* ═════════════ Плитки (настройки, отчеты) ═════════════ */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
    border: 1px solid #E6EAF0;
    border-radius: 12px;
    padding: 18px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, border-color .15s;
}

.tile:hover {
    border-color: #C7D6F5;
    box-shadow: 0 4px 16px rgba(31, 42, 61, .06);
}

.tile-title {
    font-size: 15px;
    font-weight: 600;
    color: #1F2A3D;
}

.tile-text {
    font-size: 13px;
    color: #6B778A;
}

.color-pick {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #d5dbe4;
    cursor: pointer;
}

.color-swatch.active {
    box-shadow: 0 0 0 2px #1F2A3D;
}

/* ═════════════ Трекер задач ═════════════ */
.tabs {
    display: flex;
    gap: 22px;
    border-bottom: 1px solid #E6EAF0;
}

.tab {
    border: 0;
    background: transparent;
    padding: 8px 2px 10px;
    font-size: 14px;
    color: #6B778A;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab.active {
    color: #2F6FED;
    font-weight: 600;
    border-bottom-color: #2F6FED;
}

.task-search {
    max-width: 260px;
}

.task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.task-table th {
    text-align: left;
    font-weight: 500;
    color: #6B778A;
    font-size: 12.5px;
    padding: 10px 8px;
    border-bottom: 1px solid #EEF1F5;
}

.task-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #F3F5F8;
    vertical-align: middle;
}

.task-table tbody tr {
    cursor: pointer;
}

.task-table tbody tr:hover td {
    background: #F7FAFE;
}

.task-title {
    color: #1F2A3D;
    font-weight: 500;
}

.task-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #22A06B;
}

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.prio-high { background: #FDE8E8; color: #D12E34; }
.prio-medium { background: #FEF0E1; color: #C2680C; }
.prio-low { background: #E3F5EC; color: #1A8A4F; }

.st-overdue { background: #FDE8E8; color: #D12E34; }
.st-progress { background: #E6EEFE; color: #2F6FED; }
.st-planned { background: #EEF1F5; color: #5F6B7A; }
.st-done { background: #E3F5EC; color: #1A8A4F; }
.st-cancelled { background: #EEF1F5; color: #9AA3AF; text-decoration: line-through; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    margin-right: 8px;
    vertical-align: middle;
}

.task-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    font-size: 13px;
}

.progress {
    height: 6px;
    background: #EEF1F5;
    border-radius: 99px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 99px;
}

.tone-bar-green { background: #22A06B; }
.tone-bar-blue { background: #2F6FED; }
.tone-bar-red { background: #E5484D; }

.link-btn {
    border: 0;
    background: transparent;
    color: #2F6FED;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
}

/* Календарь задач */
.tcal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}

.tcal-nav {
    border: 0;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #4A5568;
    padding: 2px 8px;
    border-radius: 6px;
}

.tcal-nav:hover {
    background: #F1F4F9;
}

.tcal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.tcal-wd {
    font-size: 11.5px;
    color: #8A929C;
    padding: 4px 0;
}

.tcal-day {
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 5px 0 3px;
    font-size: 13px;
    color: #1F2A3D;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: 38px;
}

.tcal-day:hover {
    background: #F1F4F9;
}

.tcal-day.other {
    color: #B6BEC9;
}

.tcal-day.today span:first-child {
    background: #2F6FED;
    color: #fff;
    border-radius: 6px;
    padding: 1px 6px;
}

.tcal-day.selected {
    box-shadow: inset 0 0 0 1.5px #2F6FED;
}

.tcal-dots {
    display: flex;
    gap: 2px;
    height: 6px;
}

.dot.small {
    width: 5px;
    height: 5px;
}
