﻿:root {
    --page: #f4f4f4;
    --surface: #ffffff;
    --surface-strong: #f7f7f6;
    --ink: #1a1a1a;
    --muted: #6f6f6f;
    --line: #e6e6e6;
    --brand: #862518;
    --brand-dark: #660f03;
    --secondary: #6f6e6e;
    --danger: #862518;
    --shadow: 0 14px 34px rgba(26, 26, 26, 0.09);
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

form {
    min-height: 100vh;
}

.login-page {
    background: var(--page);
}

.login-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(430px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.login-brand,
.portal-brand,
.portal-user,
.toolbar,
.section-heading,
.year-filter {
    display: flex;
    align-items: center;
}

.login-brand,
.portal-brand {
    gap: 12px;
}

.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
}

.brand-logo {
    display: block;
    width: 168px;
    max-width: 42vw;
    height: auto;
    flex: 0 0 auto;
}

.login-brand .brand-logo {
    width: 176px;
}

.login-brand h1,
.toolbar h1,
.section-heading h2 {
    margin: 0;
    line-height: 1.15;
}

.login-brand h1 {
    font-size: 24px;
}

.login-brand p,
.toolbar p,
.portal-brand span,
.muted {
    margin: 4px 0 0;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 10px;
    margin-top: 28px;
}

.login-form label {
    font-size: 13px;
    font-weight: 600;
}

.login-password-panel {
    display: grid;
    gap: 10px;
}

.primary-action {
    margin-top: 8px;
}

.primary-action,
.primary-action td,
.primary-action input,
.primary-action[class*="dxbButton"],
.primary-action[class*="dxbButton"] td {
    background: var(--brand) !important;
    background-image: none !important;
    border-color: var(--brand) !important;
    color: #fff !important;
}

.primary-action:hover,
.primary-action:hover td,
.primary-action[class*="dxbButtonHover"],
.primary-action[class*="dxbButtonPressed"] {
    background: var(--brand-dark) !important;
    background-image: none !important;
    border-color: var(--brand-dark) !important;
    color: #fff !important;
}

.secondary-action,
.secondary-action td,
.secondary-action input,
.secondary-action[class*="dxbButton"],
.secondary-action[class*="dxbButton"] td {
    background: var(--brand) !important;
    background-image: none !important;
    border-color: var(--brand) !important;
    color: #fff !important;
}

.secondary-action:hover,
.secondary-action:hover td,
.secondary-action[class*="dxbButtonHover"],
.secondary-action[class*="dxbButtonPressed"] {
    background: var(--brand-dark) !important;
    background-image: none !important;
    border-color: var(--brand-dark) !important;
    color: #fff !important;
}

.form-error {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid #e2b6b6;
    border-radius: 6px;
    background: #fff2f2;
    color: #8f2f2f;
}

.form-info {
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid #b9d6c1;
    border-radius: 6px;
    background: #f0faf3;
    color: #2f6d42;
}

.form-info a {
    color: inherit;
    font-weight: 700;
}

.text-link {
    display: inline;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--brand);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.text-link:hover,
.text-link:focus {
    color: var(--brand-dark);
    outline: none;
}

.forgot-password-link {
    justify-self: start;
    margin-top: 2px;
}

.portal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px clamp(16px, 4vw, 40px);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
}

.portal-brand strong {
    display: block;
}

.portal-user {
    gap: 12px;
    justify-content: flex-end;
}

.message-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--brand);
    cursor: pointer;
}

.message-action:hover,
.message-action:focus {
    border-color: var(--brand);
    outline: none;
}

.message-action.has-unread {
    animation: messagePulse 1.8s ease-in-out infinite;
    border-color: var(--brand);
    background: #fff4f1;
}

.envelope-icon {
    position: relative;
    display: block;
    width: 24px;
    height: 17px;
    border: 2px solid #0078d4;
    border-radius: 4px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.envelope-icon::before,
.envelope-icon::after {
    content: "";
    position: absolute;
}

.envelope-icon::before {
    left: 2px;
    right: 2px;
    top: 2px;
    height: 10px;
    background:
        linear-gradient(35deg, transparent 47%, #0078d4 49%, #0078d4 54%, transparent 56%),
        linear-gradient(-35deg, transparent 47%, #0078d4 49%, #0078d4 54%, transparent 56%);
}

.envelope-icon::after {
    left: 3px;
    right: 3px;
    bottom: 2px;
    height: 7px;
    background:
        linear-gradient(145deg, transparent 47%, #8bbff0 49%, #8bbff0 54%, transparent 56%),
        linear-gradient(-145deg, transparent 47%, #8bbff0 49%, #8bbff0 54%, transparent 56%);
}

.message-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    display: inline-grid;
    min-width: 19px;
    height: 19px;
    place-items: center;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

@keyframes messagePulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(134, 37, 24, 0.24);
    }
    50% {
        box-shadow: 0 0 0 7px rgba(134, 37, 24, 0);
    }
}

.portal-main {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 26px 0 42px;
}

.toolbar {
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.toolbar h1 {
    font-size: 30px;
}

.year-filter {
    gap: 10px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.year-filter span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.kpi-grid,
.unit-grid {
    display: grid;
    gap: 14px;
}

.kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-bottom: 22px;
}

.kpi-card,
.unit-card,
.section-block {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    padding: 16px;
    box-shadow: 0 10px 24px rgba(26, 26, 26, 0.06);
}

.kpi-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--brand);
}

.kpi-card.kpi-units {
    background: linear-gradient(135deg, #ffffff 0%, #f2f7fa 100%);
}

.kpi-card.kpi-units::before {
    background: #2f6f8f;
}

.kpi-card.kpi-prescribed {
    background: linear-gradient(135deg, #ffffff 0%, #fff7ec 100%);
}

.kpi-card.kpi-prescribed::before {
    background: #c27a18;
}

.kpi-card.kpi-paid {
    background: linear-gradient(135deg, #ffffff 0%, #eff8f2 100%);
}

.kpi-card.kpi-paid::before {
    background: #2f8750;
}

.kpi-card.kpi-outstanding {
    background: linear-gradient(135deg, #ffffff 0%, #fff1ef 100%);
}

.kpi-card.kpi-outstanding::before {
    background: var(--danger);
}

.kpi-card.kpi-owner {
    background: linear-gradient(135deg, #ffffff 0%, #f3f1fb 100%);
}

.kpi-card.kpi-owner::before {
    background: #6b5aa8;
}

.kpi-card.kpi-profit {
    background: linear-gradient(135deg, #ffffff 0%, #eef7f5 100%);
}

.kpi-card.kpi-profit::before {
    background: #287c74;
}

.kpi-card span {
    position: relative;
    z-index: 1;
    display: block;
    min-height: 36px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.kpi-card strong {
    position: relative;
    z-index: 1;
    display: block;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
}

.kpi-card strong * {
    font-weight: 800;
}

.kpi-card.attention strong {
    color: var(--danger);
}

.section-block {
    margin-top: 18px;
    padding: 18px;
    overflow: hidden;
}

.section-heading {
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-heading h2 {
    font-size: 20px;
}

.unit-section-heading {
    align-items: flex-start;
}

.unit-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.unit-search {
    width: min(320px, 100%);
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.unit-search:focus {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 2px rgba(134, 37, 24, 0.13);
}

.unit-filter-group {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface-strong);
}

.unit-filter {
    min-height: 30px;
    padding: 0 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
}

.unit-filter.active,
.unit-filter:hover,
.unit-filter:focus {
    background: var(--brand);
    color: #fff;
    outline: none;
}

.unit-overview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -4px 0 14px;
}

.unit-overview span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-strong);
    color: var(--muted);
    font-size: 13px;
}

.unit-overview strong {
    color: var(--ink);
}

.unit-list-shell {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.unit-list-header,
.unit-row {
    display: grid;
    grid-template-columns: minmax(210px, 1.45fr) minmax(190px, 1.2fr) minmax(110px, 0.7fr) minmax(120px, 0.75fr) minmax(105px, 0.65fr) minmax(120px, 0.75fr);
    gap: 12px;
    align-items: center;
}

.unit-list-header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 14px;
    background: var(--surface-strong);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.unit-list {
    max-height: 540px;
    overflow: auto;
    background: var(--surface);
}

.unit-row {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
    transition: background-color 140ms ease, box-shadow 140ms ease;
}

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

.unit-row:hover,
.unit-row:focus {
    background: #fff8f6;
    outline: none;
}

.unit-row.selected {
    background: #fff4f1;
    box-shadow: inset 4px 0 0 var(--brand);
}

.unit-row.has-debt {
    box-shadow: inset 4px 0 0 rgba(134, 37, 24, 0.55);
}

.unit-row.selected.has-debt {
    box-shadow: inset 4px 0 0 var(--brand);
}

.unit-cell {
    min-width: 0;
}

.unit-cell strong,
.unit-cell small {
    display: block;
}

.unit-cell strong {
    overflow-wrap: anywhere;
}

.unit-cell small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
}

.unit-identity {
    display: grid;
    gap: 3px;
}

.unit-status {
    justify-self: start;
    margin-top: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 12px;
    font-style: normal;
    font-weight: 700;
}

.unit-status.occupied {
    background: #e8f4ec;
    color: #2f6d42;
}

.unit-status.vacant {
    background: #fff1df;
    color: #9a5a0d;
}

.unit-tenant strong {
    font-weight: 700;
}

.numeric {
    text-align: right;
}

.numeric.outstanding strong {
    color: var(--danger);
}

.unit-empty-state {
    display: none;
    padding: 22px 14px;
    color: var(--muted);
    text-align: center;
}

.unit-list.is-empty .unit-empty-state {
    display: block;
}

.unit-detail-shell {
    display: none;
}

.unit-detail-shell.is-visible {
    display: block;
}

.unit-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.unit-card {
    padding: 16px;
    background: var(--surface);
}

.unit-card-button {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.unit-card-button:hover,
.unit-card-button:focus {
    border-color: var(--brand);
    box-shadow: 0 10px 24px rgba(134, 37, 24, 0.14);
    outline: none;
    transform: translateY(-1px);
}

.unit-card-button.selected {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(134, 37, 24, 0.16);
}

.unit-card h3 {
    margin: 0 0 12px;
    font-size: 16px;
    line-height: 1.35;
}

.unit-card dl {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 6px 10px;
    margin: 0;
}

.unit-card dt {
    color: var(--muted);
    font-size: 13px;
}

.unit-card dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.selected-unit-summary {
    margin-top: 0;
}

.unit-summary-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.unit-summary-heading h3 {
    margin: 0;
    font-size: 17px;
    line-height: 1.25;
}

.unit-kpi-grid {
    margin-bottom: 0;
}

.clear-filter {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--brand);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.clear-filter:hover,
.clear-filter:focus {
    border-color: var(--brand);
    outline: none;
}

.toolbar-back {
    display: none;
}

.toolbar-chart {
    display: none;
}

.icon-action {
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--brand);
    cursor: pointer;
}

.icon-action:hover,
.icon-action:focus {
    border-color: var(--brand);
    outline: none;
}

.chart-icon {
    position: relative;
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    width: 22px;
    height: 20px;
    padding: 0 0 3px 4px;
}

.chart-icon::before,
.chart-icon::after {
    content: "";
    position: absolute;
    background: #7a7a7a;
}

.chart-icon::before {
    left: 2px;
    bottom: 3px;
    width: 1px;
    height: 16px;
}

.chart-icon::after {
    left: 2px;
    right: 0;
    bottom: 3px;
    height: 1px;
}

.chart-icon i {
    display: block;
    width: 5px;
    border-radius: 2px 2px 0 0;
    box-shadow: 0 1px 2px rgba(26, 26, 26, 0.18);
}

.chart-icon i:nth-child(1) {
    height: 8px;
    background: #c27a18;
}

.chart-icon i:nth-child(2) {
    height: 14px;
    background: #2f8750;
}

.chart-icon i:nth-child(3) {
    height: 18px;
    background: #6b5aa8;
}

.trend-popup {
    display: grid;
    gap: 16px;
    max-width: calc(100vw - 48px);
    padding: 4px 2px 2px;
    overflow-x: hidden;
}

.trend-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

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

.trend-legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-prescribed {
    background: #c27a18;
}

.legend-paid {
    background: #2f8750;
}

.legend-owner {
    background: #6b5aa8;
}

.trend-chart {
    position: relative;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    min-height: 270px;
    padding-top: 12px;
}

.trend-year {
    display: grid;
    grid-template-rows: 210px auto auto;
    gap: 7px;
    min-width: 0;
    text-align: center;
}

.trend-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    padding: 0 6px;
    border-bottom: 1px solid var(--line);
}

.trend-bar {
    display: block;
    width: 16px;
    min-height: 0;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
}

.trend-bar:hover,
.trend-bar:focus {
    filter: brightness(0.92);
}

.trend-prescribed {
    background: #c27a18;
}

.trend-paid {
    background: #2f8750;
}

.trend-owner {
    background: #6b5aa8;
}

.trend-year strong {
    font-size: 13px;
}

.trend-year small {
    color: var(--muted);
    font-size: 12px;
}

.trend-year .trend-owner-value {
    color: #6b5aa8;
    font-weight: 800;
}

.trend-empty {
    grid-column: 1 / -1;
    align-self: center;
    padding: 24px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
}

.trend-value-bubble {
    position: absolute;
    z-index: 3;
    display: none;
    min-width: 132px;
    max-width: 190px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 12px 28px rgba(26, 26, 26, 0.18);
    text-align: left;
    transform: translate(-50%, -100%);
    pointer-events: none;
}

.trend-value-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 10px;
    height: 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    transform: translateX(-50%) rotate(45deg);
}

.trend-value-bubble.is-visible {
    display: grid;
    gap: 2px;
}

.trend-value-bubble strong {
    color: var(--ink);
    font-size: 13px;
}

.trend-value-bubble span {
    color: var(--muted);
    font-size: 12px;
}

.trend-value-bubble em {
    color: var(--brand);
    font-size: 15px;
    font-style: normal;
    font-weight: 800;
}

.messages-shell {
    display: grid;
    gap: 16px;
    box-sizing: border-box;
    width: min(812px, calc(100vw - 48px));
    max-width: calc(100vw - 48px);
    height: 430px;
    min-height: 0;
    max-height: 430px;
    overflow: hidden;
}

.message-compose {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.message-list-view {
    display: grid;
    gap: 12px;
    grid-template-rows: auto auto minmax(240px, 1fr);
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.message-compose[hidden],
.message-detail-view[hidden],
.message-list-view[hidden] {
    display: none;
}

.message-list-toolbar {
    display: flex;
    justify-content: flex-end;
}

.message-compose-heading,
.message-card > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.message-compose h3,
.message-tab-panel h3 {
    margin: 0;
    font-size: 16px;
}

.portal-input,
.portal-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.portal-input {
    min-height: 36px;
    padding: 7px 10px;
}

.portal-textarea {
    min-height: 96px;
    padding: 9px 10px;
    resize: vertical;
}

.primary-html-action {
    justify-self: start;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--brand);
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.primary-html-action:hover,
.primary-html-action:focus {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    outline: none;
}

.message-secondary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--brand);
    border-radius: 6px;
    background: var(--surface);
    color: var(--brand);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.message-secondary-action:hover,
.message-secondary-action:focus {
    background: #eef5ff;
    border-color: var(--brand-dark);
    color: var(--brand-dark);
    outline: none;
}

.message-tabs {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.message-tab {
    min-height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.message-tab.active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.message-tab:hover,
.message-tab:focus {
    color: var(--brand-dark);
    outline: none;
}

.message-tab-panels {
    display: grid;
    gap: 14px;
    min-width: 0;
    min-height: 0;
    overflow: auto;
}

.message-tab-panel {
    display: grid;
    align-content: start;
    gap: 10px;
    min-width: 0;
    min-height: 260px;
}

.message-tab-panel[hidden] {
    display: none;
}

.message-card,
.message-empty {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px;
}

.message-card.unread {
    border-color: var(--brand);
    background: #fff8f6;
    box-shadow: inset 4px 0 0 var(--brand);
}

.message-card strong {
    overflow-wrap: anywhere;
}

.message-card small {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
}

.message-card p {
    margin: 8px 0;
    color: var(--ink);
    white-space: pre-wrap;
}

.message-detail-view {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: none;
    overflow: hidden;
}

.message-detail-body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 10px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.message-detail-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.message-detail-title {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.message-detail-title strong {
    color: var(--ink);
    font-size: 15px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.message-detail-title span,
.message-detail-meta {
    color: var(--muted);
    font-size: 12px;
}

.message-detail-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px 10px;
    max-width: 360px;
    line-height: 1.3;
    text-align: right;
}

.message-detail-meta span {
    white-space: nowrap;
}

.message-detail-meta .is-unread {
    color: #8a5b00;
    font-weight: 700;
}

.message-body-text {
    box-sizing: border-box;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 0;
    max-height: none;
    overflow: auto;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.message-pager {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    padding-top: 2px;
}

.message-page {
    min-width: 32px;
    min-height: 30px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.message-page:hover,
.message-page:focus {
    border-color: var(--brand);
    color: var(--brand);
    outline: none;
}

.message-page.active {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
    cursor: default;
}

.message-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(230px, auto);
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.message-row:hover,
.message-row:focus {
    border-color: var(--brand);
    background: #fff8f6;
    outline: none;
}

.message-row.unread {
    border-color: var(--brand);
    background: #fff8f6;
    box-shadow: inset 4px 0 0 var(--brand);
}

.message-row-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.message-row-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-row-main small,
.message-row-date,
.message-card-heading small {
    color: var(--muted);
    font-size: 12px;
}

.message-statuses,
.message-detail-statuses {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.message-detail-statuses {
    justify-content: flex-start;
}

.message-status {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border: 1px solid #d4dde7;
    border-radius: 999px;
    background: #f7fafc;
    color: #425466;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.message-status.warning {
    border-color: #f2c166;
    background: #fff8e5;
    color: #8a5b00;
}

.message-status.success {
    border-color: #9ad0a1;
    background: #f0fff2;
    color: #226b2f;
}

.message-status.attachment {
    border-color: #9bbfe5;
    background: #eef6ff;
    color: #005a9e;
}

.message-status.muted {
    border-color: #d7dde5;
    background: #f3f5f7;
    color: #7b8794;
}

.message-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.message-card-heading > div {
    display: grid;
    gap: 2px;
}

.message-hidden-detail,
.message-history-template {
    display: none;
}

.message-attachment-link {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid #9bbfe5;
    border-radius: 4px;
    background: #eef6ff;
    color: #005a9e;
    font-weight: 700;
    text-decoration: none;
}

.message-attachment-link:hover,
.message-attachment-link:focus {
    border-color: #005a9e;
    text-decoration: underline;
    outline: none;
}

.message-attachment-upload {
    display: grid;
    gap: 6px;
}

.message-attachment-upload > span {
    color: var(--muted);
    font-weight: 700;
}

.message-reply-action {
    justify-self: start;
}

.message-empty {
    display: grid;
    min-height: 220px;
    place-items: center;
    color: var(--muted);
    text-align: center;
}

.dxgvControl,
.dxgvTable {
    font: inherit;
}

.dxgvControl [class*="dxgvFocusedRow"],
.dxgvControl [class*="dxgvFocusedRow"] > td,
.dxgvControl [class*="dxgvSelectedRow"],
.dxgvControl [class*="dxgvSelectedRow"] > td {
    background: var(--brand) !important;
    background-color: var(--brand) !important;
    background-image: none !important;
    color: #fff !important;
}

.dxgvControl [class*="dxgvFocusedRow"] a,
.dxgvControl [class*="dxgvSelectedRow"] a {
    color: #fff !important;
}

@media (max-width: 1120px) {
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .unit-list-header {
        display: none;
    }

    .unit-list {
        max-height: 620px;
    }

    .unit-row {
        grid-template-columns: minmax(220px, 1.35fr) minmax(190px, 1fr) repeat(2, minmax(110px, 0.7fr));
    }

    .unit-row .unit-cell:nth-child(5),
    .unit-row .unit-cell:nth-child(6) {
        padding-top: 8px;
        border-top: 1px dashed var(--line);
    }
}

@media (max-width: 720px) {
    .portal-header,
    .toolbar,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .portal-user {
        justify-content: space-between;
    }

    .toolbar h1 {
        font-size: 24px;
    }

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

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

    .kpi-card {
        padding: 11px 12px;
    }

    .kpi-card::before {
        width: 4px;
    }

    .kpi-card span {
        min-height: 0;
        font-size: 12px;
        line-height: 1.25;
    }

    .kpi-card strong {
        margin-top: 4px;
        font-size: 18px;
        line-height: 1.15;
    }

    .unit-tools {
        justify-content: stretch;
    }

    .unit-search,
    .unit-filter-group {
        width: 100%;
    }

    .unit-filter-group {
        justify-content: stretch;
    }

    .unit-filter {
        flex: 1 1 0;
    }

    .unit-row {
        grid-template-columns: 1fr;
        gap: 9px;
    }

    .trend-chart {
        grid-template-columns: repeat(6, minmax(66px, 1fr));
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 6px;
    }

    .trend-year {
        grid-template-rows: 170px auto auto;
    }

    .trend-bars {
        padding: 0 3px;
    }

    .trend-bar {
        width: 12px;
    }

    .message-compose-heading,
    .message-card > div {
        align-items: flex-start;
        flex-direction: column;
    }

    .message-tabs {
        width: 100%;
    }

    .message-tab {
        flex: 1 1 0;
    }

    .message-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .message-statuses {
        justify-content: flex-start;
    }

    .message-detail-header {
        grid-template-columns: 1fr;
    }

    .message-detail-meta {
        justify-content: flex-start;
        max-width: none;
        text-align: left;
    }

    .messages-shell {
        max-width: calc(100vw - 36px);
    }

    .unit-row .unit-cell:nth-child(n) {
        padding-top: 0;
        border-top: 0;
    }

    .numeric {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
        text-align: left;
    }

    .numeric small {
        margin-top: 0;
        text-align: right;
    }

}

@media (max-width: 460px) {
    .portal-main {
        width: min(100% - 20px, 1280px);
        padding-top: 14px;
    }

    .login-panel,
    .section-block {
        padding: 14px;
    }

    .unit-card dl {
        grid-template-columns: 1fr;
    }
}

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