@import url('material-icons/css/MaterialIcons.css');
@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');

:root {
    /* Background colors */
    --color-bg-white: white;
    --color-bg-white-hover: rgb(245, 245, 245);

    --color-bg-secondary: rgb(240, 240, 240);
    --color-bg-secondary-hover: rgb(228, 228, 228);

    --color-bg-dark: rgb(87, 83, 77);
    --color-bg-dark-hover: rgb(117, 113, 107);

    --color-bg-dark-secondary: rgb(46, 46, 46);
    --color-bg-dark-secondary-hover: rgb(63, 63, 63);

    --color-bg-transparent: transparent;

    /* Border colors */
    --color-border: rgb(225, 225, 225);

    /* Text colors */
    --color-text: rgb(10, 10, 10);
    --color-text-secondary: rgb(117, 113, 107);
    --color-text-muted: rgb(172, 172, 172);
    --color-text-muted2: rgba(172, 172, 172, 0.5);
    --color-text-white: rgb(240, 240, 240);

    /* Status colors */
    --color-success: #26b050;
    --color-error: #e50000;
    --color-warning: #b32121;
    --color-amber: #f0ad4e;
    --color-amber-text: #c48b00;

    /* Semantic state backgrounds */
    --color-info-bg: #e7f3ff;
    --color-info-text: #0066cc;
    --color-info-border: #b3d9ff;
    --color-success-bg: #d4edda;
    --color-success-text: #155724;
    --color-success-border: #c3e6cb;
    --color-error-bg: #f8d7da;
    --color-error-text: #721c24;
    --color-error-border: #f5c6cb;
    --color-warning-bg: #fff3cd;
    --color-attention-row-bg: #fffdf0; /* пастельная подсветка строк, ждущих действия */
    --color-warning-text: #856404;
    --color-warning-border: #ffc107;

    /* Shadows */
    --shadow-dropdown: 0 0px 20px rgba(0, 0, 0, 0.05);

    /* Палитра графиков (teal/terra — те же, что у status-badge) */
    --color-teal: #3d6b64;
    --color-terra: #b2552d;
    --chart-fill: rgba(87, 83, 77, 0.1); /* заливка под линией = --color-bg-dark с прозрачностью */
}

body {
    font-family: "Roboto Flex", sans-serif;
    font-weight: 400;
    color: var(--color-text);
    margin: 0px;
}

/* 
 *  # text
 */

div,
span,
p,
a,
label {
    font-size: 14px;
}

h3 {
    font-weight: 500;
}

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

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

/* Ряд плиток StatCard (шапки-сводки страниц); отступы вокруг ряда задаёт страница */
.stat-cards-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

textarea {
    border: 1px solid var(--color-border);
    box-sizing: border-box;
}

textarea:focus {
    border: 1px solid var(--color-text-muted);
    outline: none;
}

.input:focus {
    border: 1px solid var(--color-text-muted);
    outline: none;
}

.note {
    font-size: 0.9em;
    color: var(--color-text-secondary);
    overflow-wrap: anywhere;
}

.note-box {
    background: var(--color-bg-white-hover);
    border: 1px solid var(--color-border);
    padding: 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.warning-box {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    padding: 12px 16px;
    border-radius: 4px;
    color: var(--color-warning-text);
}

.sync-success { background-color: var(--color-success-bg); color: var(--color-success-text); border: 1px solid var(--color-success-border); padding: 8px 12px; border-radius: 4px; }
.sync-error { background-color: var(--color-error-bg); color: var(--color-error-text); border: 1px solid var(--color-error-border); padding: 8px 12px; border-radius: 4px; }


/* 
 *  # scroll
 */
*::-webkit-scrollbar {
    width: 8px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--color-bg-secondary);
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-bg-secondary-hover);
}



/* 
 *  # Page
 */

.page {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
}


/*
 *  # Page Layout
 */

.sub-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: var(--color-bg-white);
}

.sub-bar a {
    text-decoration: none;
    color: inherit;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.toolbar .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 28px;
    padding: 0 8px;
    font-size: 0.9em;
}

.toolbar .button .material-icons {
    font-size: 16px;
    font-weight: 400;
}

.input.toolbar-search {
    width: 220px;
    flex-grow: 0;
    height: 28px;
    padding: 0 8px;
}

.page-content {
    padding: 20px;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}


/*
 *  # States
 */

.loading {
    padding: 40px;
    text-align: center;
    color: var(--color-text-muted);
}

.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--color-text-muted);
}


/*
 *  # Status Badge
 */

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    white-space: nowrap;
    color: var(--color-text-white);
}

.status-badge-teal   { background: var(--color-teal); }
/* Бледный teal — промежуточное состояние «частично» (между серым и зелёным). */
.status-badge-teal-pale { background: #d9e7e4; color: var(--color-teal); }
.status-badge-stone  { background: var(--color-bg-secondary); color: var(--color-text-muted); }
.status-badge-gold   { background: #d4a056; }
.status-badge-terra  { background: var(--color-terra); }
.status-badge-slate  { background: #5a6d7a; }
.status-badge-plum   { background: #7b5e7b; }
.status-badge-umber  { background: #7a5c42; }
.status-badge-indigo { background: #4e5d8c; }
.status-badge-graphite { background: #4a4a4a; }
.status-badge-rose  { background: #b25670; }

/* Остаток к оплате: долг — красным, ноль — полутоном */
.balance-due  { color: var(--color-error); }
.balance-zero { color: var(--color-text-muted2); }

/* Зелёный чип-источник Google Sheets — отличается от тёплых 1С-чипов.
   Глобальный, чтобы цвет был один на все чипы GSheets (счета, договоры). */
.gsheets-source-chip {
    background-color: #e6f4ea;
    color: #137333;
    cursor: pointer;
    white-space: nowrap;
}

.gsheets-source-chip:hover {
    background-color: #ceead6;
}

@media (max-width: 768px) {
    .sub-bar {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .toolbar {
        flex-wrap: wrap;
    }

    .input.toolbar-search {
        width: auto;
        min-width: 100px;
        flex: 1;
    }

    .page-content {
        padding: 10px;
    }

    /* Класс дублируется в селекторе намеренно: .button ниже по файлу задаёт
       display: inline-flex с той же специфичностью и иначе побеждает. */
    .hide-mobile.hide-mobile {
        display: none;
    }
}


/*
 *  # Button
 */

button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

.button {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 14px;
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
}

.button:hover {
    background-color: var(--color-bg-secondary);
}

.button:disabled {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: default;
}

.button:disabled:hover {
    background: none;
    color: var(--color-text-muted);
}

/* black */
.button-black {
    border: none;
    background-color: var(--color-bg-dark);
    color: var(--color-text-white);
}

.button-black:hover {
    background-color: var(--color-bg-dark-secondary);
}

/* white */
.button-white {
    border: none;
}

/* danger-button */
.danger-button:hover {
    background-color: #dc3545;
    color: white;
}

.button-small {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 22px;
}

.button-small.active {
    background: var(--color-bg-dark);
    color: var(--color-text-white);
    border-color: var(--color-bg-dark);
}

.button-small2 {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 22px;
}

/* Extra small button (24x24) - for table rows, compact UI */
.button-xs {
    padding: 4px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-white);
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.button-xs:hover:not(:disabled) {
    background: var(--color-bg-secondary);
}

.button-xs:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Безрамочный вариант .button-xs — те же 24px, но без рамки и фона.
   Для плотных таблиц/строк, где рамка кнопки лишняя. Ховер остаётся от .button-xs. */
.button-xs-plain {
    border-color: transparent;
    background: none;
}

/* Responsive button - icon + text on desktop, icon only on mobile.
   Высота наследуется от .button (32px). */
.button-responsive {
    gap: 6px;
}

.button-responsive .material-icons {
    font-size: 20px;
}

.button-text {
    display: inline;
}

@media (max-width: 768px) {
    .button-text {
        display: none;
    }

    .button-responsive {
        padding: 0;
        width: 32px;
    }
}

/* Toolbar badge — count indicator inside toolbar buttons (e.g. active filter count) */
.toolbar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--color-text);
    color: var(--color-bg-white);
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
}

/* Active responsive button — indicates active filter/grouping */
.button-responsive.active {
    background-color: var(--color-bg-dark);
    color: var(--color-text-white);
    border-color: var(--color-bg-dark);
}

.button-responsive.active:hover {
    background-color: var(--color-bg-dark-secondary);
}

.button-responsive.active .toolbar-badge {
    background: rgba(255, 255, 255, 0.2);
}

/* On mobile, badge hidden — dark button alone signals active state */
@media (max-width: 768px) {
    .button-responsive .toolbar-badge {
        display: none;
    }
}

/* Unread badge — тёмная круглая плашка со счётчиком непрочитанных сообщений.
   Используется в мессенджере (ConversationList), в ячейке «Комментарии» (EntityChatCell)
   и в ленте чатов (InvoiceChatFeedPanel). */
.unread-badge {
    margin-left: auto;
    flex-shrink: 0;
    background-color: var(--color-bg-dark);
    color: var(--color-text-white);
    font-size: 0.75em;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* На активной (тёмной) строке списка плашка инвертируется */
.list-item.active .unread-badge {
    background-color: var(--color-bg-white);
    color: var(--color-bg-dark);
}





.tabs-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

/*  # Tabs */
.tabs {
    display: flex;
    width: fit-content;
    background-color: var(--color-bg-secondary);
    padding: 5px;
}

.tab-button {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 12px;
    border: none;
    background-color: var(--color-bg-transparent);
    cursor: pointer;
    font-size: 0.9em;
    margin-right: 5px;
    white-space: nowrap;
}

.tab-button-small {
    height: 28px;
    font-size: 20px;
    justify-content: center;
    padding: 0 10px;
}

.tab-button:last-child {
    margin-right: 0;
}

.tab-button:hover {
    background-color: var(--color-bg-secondary);
}

.tab-button.active {
    background-color: var(--color-bg-white);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}


/*  # Segmented Control */
.segmented-control {
    display: inline-flex;
    gap: 2px;
}

.segmented-control-item {
    padding: 6px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--color-text-secondary);
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
    user-select: none;
}

.segmented-control-item:hover {
    color: var(--color-text);
}

.segmented-control-item.active {
    background-color: var(--color-bg-dark);
    color: var(--color-text-white);
}

.segmented-control.disabled {
    opacity: 0.5;
    pointer-events: none;
}



/* 
 *  # Input
 */

/* deprecated: use .form-field instead */
.input-area {
    display: flex;
}

/*
 *  # Input with action button
 *  Поле (input / SearchSelect / SelectInput) + квадратная кнопка справа.
 *  Локально снижаем высоту поля до высоты стандартной .button — ~32px,
 *  чтобы пара «поле + иконка» читалась как компактный действующий элемент.
 */
.input-with-action {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input-with-action > :first-child {
    flex: 1;
    min-width: 0;
}

.input-with-action .input {
    height: 32px;
    padding: 0 10px;
}

.input-with-action > .button {
    width: 32px;
    height: 32px;
    padding: 0;
    flex-shrink: 0;
}

.input-with-action > .button .material-icons {
    font-size: 20px;
}

/* Joined variant — поле и кнопка как одно целое (без зазора, общий бордер) */
.input-with-action.joined {
    gap: 0;
}

.input-with-action.joined > .button {
    border-left: none;
}

/* Labeled variant — кнопка шире с текстом (например «+ Создать») */
.input-with-action.labeled > .button {
    width: auto;
    padding: 0 12px;
    white-space: nowrap;
}

/* Inset variant — кнопка внутри поля справа (как в чате — input + send) */
.input-with-action.inset {
    position: relative;
    gap: 0;
}

.input-with-action.inset .input {
    padding-right: 40px;
}

.input-with-action.inset > .button {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
}

.input-with-action.inset > .button .material-icons,
.input-with-action.inset > .button.material-icons {
    font-size: 16px;
}

.input {
    flex-grow: 1;
    width: 100%;
    box-sizing: border-box;
    height: 32px;
    padding: 0 10px;
    font-size: 14px;
    border: 1px solid var(--color-border);
}

/* Placeholder бледнее обычного текста — чтобы не путался со значением. */
.input::placeholder {
    color: var(--color-text-muted2);
}

/* Поле «заподлицо»: без рамки и фона в покое, рамка на hover и фокусе.
   Для полей в ячейках таблиц и реквизитах — NumberInput (BorderOnHover="true")
   и обычные .input с этим классом. У DateInput/MonthYearInput свой аналог
   на div-триггере в scoped CSS. */
.input.border-on-hover {
    border-color: transparent;
    background: transparent;
}

.input.border-on-hover:hover,
.input.border-on-hover:focus {
    border-color: var(--color-border);
    background: var(--color-bg-white);
}

.input:disabled {
    background: repeating-linear-gradient(
        -45deg,
        transparent 0 6px,
        rgba(117, 113, 107, 0.1) 6px 7px
    );
    border-color: var(--color-bg-secondary);
    color: var(--color-text-secondary);
}

/* input date / month */

input[type="date"].input,
input[type="month"].input {
    font-family: inherit; /* или укажите конкретный шрифт */
}

input[type="date"].input::-webkit-datetime-edit,
input[type="date"].input::-webkit-datetime-edit-fields-wrapper,
input[type="date"].input::-webkit-datetime-edit-text,
input[type="date"].input::-webkit-datetime-edit-month-field,
input[type="date"].input::-webkit-datetime-edit-day-field,
input[type="date"].input::-webkit-datetime-edit-year-field,
input[type="month"].input::-webkit-datetime-edit,
input[type="month"].input::-webkit-datetime-edit-fields-wrapper,
input[type="month"].input::-webkit-datetime-edit-text,
input[type="month"].input::-webkit-datetime-edit-month-field,
input[type="month"].input::-webkit-datetime-edit-year-field {
    font-family: inherit;
}


/* input number */
input[type="number"].input {
    font-family: inherit;
}

/* textarea — высота по строкам, не по шкале контролов */
textarea.input {
    font-family: inherit;
    height: auto;
    min-height: 32px;
    padding: 6px 10px;
}



/* 
 * select
 */

.setting-section .input {
    width: calc(100% - 22px);
    margin-right: 0;
}

.select-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

.select-container::after {
    content: '▼';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--color-text-muted);
    font-size: 0.7em;
    font-family: inherit;
}

.select {
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    color: inherit;
    appearance: none;
}

.select:hover {
    background-color: var(--color-bg-white-hover);
}

.select:focus {
    outline: none;
}


/*
 *  # Checkbox
 */
input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--color-border);
    /* border-radius: 3px; */
    background: var(--color-bg-white);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}

input[type="checkbox"]:checked {
    background: var(--color-bg-dark-hover);
    border-color: var(--color-bg-dark-hover);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4.5px;
    top: 2px;
    width: 4px;
    height: 7px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

input[type="checkbox"]:hover {
    border-color: var(--color-text-muted);
}


/*
 *  # ModalView
 */
.form-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 20px;
}

.form-container p {
    margin-top: 0;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Две колонки полей в форме диалога; на узких экранах — одна. */
.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 360px) {
    .form-row-2col {
        grid-template-columns: 1fr;
    }
}

.input-label {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Подсказка под полем формы (серый текст); вариант -error — красный для ошибок. */
.form-hint {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.form-hint-error {
    color: var(--color-error);
}

/* Строки реквизитов внутри note-box (счёт поставщика из PDF).
   Общие для SupplierInvoiceFromPdfDialog и SupplierInvoiceCreateDialog. */
.pdf-requisites-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.pdf-requisites-row {
    display: flex;
    gap: 8px;
}

.pdf-requisites-label {
    color: var(--color-text-muted);
    min-width: 60px;
}

.pdf-requisites-value {
    word-break: break-word;
}

.input {
    margin-right: 0px;
}

/* Поле со «откуда пришло» подсказкой справа внутри заблокированного инпута.
   Серый текст рядом с правым краем, не перекрываемый значением (padding-right у .input). */
.field-with-disabled-hint {
    position: relative;
}

.field-with-disabled-hint > .input {
    padding-right: 52px;
}

.field-disabled-hint {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    color: var(--color-text-muted);
    pointer-events: none;
    white-space: nowrap;
}

.button-group {
    display: flex;
    gap: 8px;
}



/*
 *  # Dashboard grid
 *  Сетка секций/виджетов дашборда. Карточки держат фиксированную ширину (~400px),
 *  при сужении окна переносятся под соседнюю, а не растягиваются. Прямые потомки —
 *  это карточки (свою рамку/отступы задаёт каждая карточка сама).
 */

.dashboard-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
}

.dashboard-grid > * {
    flex: 0 1 400px;
}

/* Рамка карточки дашборда — единая для всех виджетов сетки. */
.dashboard-card {
    border: 1px solid var(--color-border);
    padding: 16px;
    background: var(--color-bg-white);
}


/*
 *  # List
 */

.list {
    display: flex;
    flex-direction: column;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
}

.list-item-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.list-item-name {
    font-size: 1em;
    margin-bottom: 2px;
}

.list-item-detail {
    font-size: 0.85em;
    color: var(--color-text-secondary);
}

.list-item:hover {
    background-color: var(--color-bg-white-hover);
}

.list-item.active {
    background-color: var(--color-bg-dark);
}

.list-item.active .list-item-name {
    color: var(--color-text-white);
}

.list-item.active .list-item-detail {
    color: var(--color-text-muted);
}

.list-item.active .avatar {
    background-color: var(--color-bg-dark-secondary);
}

/* Перетаскивание строк списка (drag-and-drop): /statuses, /drag-drop-demo */
.list-item.dragging {
    opacity: 0.5;
}

.list-item.drop-target {
    background: var(--color-bg-white-hover);
    box-shadow: inset 0 2px 0 var(--color-text-muted);
}

.drag-handle {
    color: var(--color-text-muted);
    font-size: 20px;
    cursor: grab;
}

.list-item.active:hover {
    background-color: var(--color-bg-dark-hover);
}



/* 
 *  # Avatar
 */

.avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 50%;
    background-color: var(--color-bg-secondary);
    margin-right: 7px;
}


 .avatar-average {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    background-color: var(--color-bg-secondary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted2);
    margin-right: 7px;
}

img.avatar-average {
    object-fit: cover;
    display: block;
}

.avatar-element {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 5px;
    background-color: var(--color-bg-secondary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted2);
    margin-right: 7px;
}

.avatar-upload-container {
    display: block;
    width: 100px;
    height: 100px;
    margin: 0 auto 16px;
    position: relative;
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
}

.avatar-upload {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-upload-placeholder {
    width: 100%;
    height: 100%;
    background-color: var(--color-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--color-text-muted2);
}

.avatar-upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: white;
    font-size: 24px;
}

.avatar-upload-container:hover .avatar-upload-overlay {
    opacity: 1;
}


/*
 *  # Chat
 */


/* Контейнер для сообщений чата */
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    /* padding: 10px; */
    display: flex;
    flex-direction: column-reverse;
}

/* Основной стиль пузыря сообщения */
.message-bubble {
    padding: 8px 12px;
    margin-bottom: 6px;
    max-width: 80%;
    min-width: 50px;
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
}

/* Исходящие сообщения (от пользователя) */
.outgoing {
    background-color: var(--color-bg-dark);
    align-self: flex-end;
    margin-left: auto;
    color: var(--color-text-white);
}

/* Входящие сообщения (от бота) */
.incoming {
    background-color: var(--color-bg-secondary);
    align-self: flex-start;
    margin-right: auto;
    text-align: left;
}



/* Имя отправителя */
.message-bubble .message-from {
    font-size: 0.8em;
    color: var(--color-text-muted);
}

/* Текст сообщения */
.message-bubble .message-text {
    font-size: 1em;
    max-width: 470px;
    display: block;
    /* margin-top: 2.5px; */
    /* margin-bottom: 2.5px; */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

/* Время сообщения */
.message-bubble .message-time {
    font-size: 0.8em;
    color: var(--color-text-muted);
    /* margin-top: 4px; */
    align-self: flex-end;
}

/* Удалённое сообщение — курсивом. Глобальный: используется и облачком (MessageBubble),
   и цитатой-ответом на удалённое сообщение (слот Quote в MessageArea). */
.deleted-text {
    font-style: italic;
    color: var(--color-text-muted);
}

/* Картинки-вложения сообщений рисует компонент ChatAttachments (Components/Shared/Chat). */

.json-editor {
    margin: 0;
    padding: 10px;
    min-height: 150px;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre;
    overflow-wrap: break-word;
    word-break: break-all;
}


/* 
 * Dropdown
 */

.dropdown {
    position: relative;
    display: inline-block;
    margin-left: auto;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--color-bg-white);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-dropdown);
    min-width: 140px;
    z-index: 1000;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}

    .dropdown-item .material-icons {
        font-size: 18px;
        margin-right: 8px;
    }

.dropdown-item:hover {
    background-color: var(--color-bg-secondary);
}

/* Выбранный пункт меню (фильтр, группировка). Именно is-selected, не active:
   active занят состоянием кнопки-триггера в тулбаре. См. DESIGN.md. */
.dropdown-item.is-selected {
    font-weight: 600;
}

.dropdown-divider {
    height: 1px;
    margin: 4px 0;
    border: none;
    background-color: var(--color-border);
}

.dropdown-item.danger-button:hover {
    background-color: #dc3545;
    color: white;
}

/* Чекбокс-пункт выпадающего меню (фильтры, переключение столбцов) */
.dropdown-item.column-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.dropdown-item.column-toggle input[type="checkbox"],
.dropdown-item.column-toggle input[type="radio"] {
    width: auto;
    cursor: pointer;
}

/* Пункт фильтра с индикатором-полоской вместо галочки.
   Выбранное значение — тёмная полоска, скруглений нет. */
.dropdown-item.filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.dropdown-item.filter-toggle input[type="checkbox"],
.dropdown-item.filter-toggle input[type="radio"] {
    appearance: none;
    width: 6px;
    height: 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
}

.dropdown-item.filter-toggle input:checked {
    background: var(--color-bg-dark);
}

/* Несколько значений (checkbox) — невыбранные светло-серые, видно весь набор.
   Один из N (radio) — серых полосок нет, тёмная переезжает на выбранный пункт. */
.dropdown-item.filter-toggle input[type="checkbox"]:not(:checked) {
    background: var(--color-border);
}

.dropdown-item.filter-toggle:hover input[type="checkbox"]:not(:checked) {
    background: var(--color-text-muted);
}

/* Галочка внутри полоски не нужна — состояние читается цветом */
.dropdown-item.filter-toggle input[type="checkbox"]:checked::after {
    content: none;
}

/* Строка «чекбокс + подпись» вне выпадающих меню (формы, поповеры) —
   общий класс вместо локальных копий в .razor.css */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* Заголовок секции внутри выпадающего меню фильтра */
.dropdown-section-title {
    padding: 8px 12px 4px;
    font-size: 0.75em;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-section-divider {
    border-top: 1px solid var(--color-border);
    margin: 4px 0;
}

/* Пункт «Сбросить всё» внизу меню фильтра */
.dropdown-reset {
    color: var(--color-text-muted);
    font-size: 0.85em;
}

/*
 * Пара представлений «desktop-таблица / mobile-список» (GroupTable + GroupedList).
 * См. DESIGN.md, раздел Mobile.
 */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: block;
    }
}

/* Компактная плотность строк справочника — обёртка вокруг GroupTable */
/* Класс продублирован намеренно: scoped-бандл (web.styles.css) подключён после app.css,
   и правило GroupTable .group-table-cell[b-...] { padding: 6px 8px } при равной
   специфичности победило бы. Удвоение класса даёт (0,3,0) и возвращает компактность. */
.table-compact .group-table-cell.group-table-cell {
    padding: 2px 8px;
}

/* Кнопка ⋮ (.button-xs) в компактной строке: дефолтные 24px растят строку —
   ужимаем под высоту текстовой строки. */
.table-compact .group-table-cell .button-xs {
    height: 20px;
    width: 24px;
    padding: 0;
    border: none;
    font-size: 18px;
}

/* Ячейка действий строки (⋮ / кнопки) — прижата вправо. Общий класс для всех
   справочников и таблиц; страничные .razor.css переопределяют только отличия
   (например justify-content: center в редакторах позиций). */
.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
    flex-shrink: 0;
}



/* 
 * Прочее
 */

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--color-success);
}

.invalid {
    outline: 1px solid var(--color-error);
}

.validation-message {
    color: var(--color-error);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--color-warning);
    padding: 1rem 1rem 1rem 3.7rem;
    color: var(--color-text-white);
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.darker-border-checkbox.form-check-input {
    border-color: var(--color-border);
}

.form-floating>.form-control-plaintext::placeholder,
.form-floating>.form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating>.form-control-plaintext:focus::placeholder,
.form-floating>.form-control:focus::placeholder {
    text-align: start;
}


/*
 * Clickable Cards
 */

.card-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-link {
    display: block;
    padding: 15px;
    background: transparent;
    border: 1px solid var(--color-border);
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s;

    max-width: 320px;
}

.card-link:hover {
    background: var(--color-bg-white-hover);
}

.card-link-title {
    font-size: 1.0em;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--color-text);
}

.card-link-description {
    /* font-size: 0.9em; */
    color: var(--color-text-muted);
    font-weight: 300;
}

.card-link-placeholder {
    max-width: 320px;
    padding: 15px;
    background: var(--color-bg-white-hover);
    font-style: italic;
    text-align: center;
}


/*
 *  # Chip hover popover props (ChipHover-компоненты)
 *
 *  Вертикальная пара «метка над значением» для узких hover-поповеров чипов.
 *  Не путать с props-table карточек (метка слева, значение справа).
 */

.chip-hover-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chip-hover-label {
    font-size: 0.8em;
    color: var(--color-text-secondary);
}

.chip-hover-value {
    font-size: 1em;
}


/*
 *  # Card sections template (pattern D from /ui-template-card-panel)
 */

.tpl-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

/* Внутри карточки .edit-card родительский gap (14px) + собственный margin
   заголовка = двойной отступ. Гасим margin — раньше правило дублировалось
   в scoped css каждой карточки. */
.edit-card .tpl-section-header {
    margin: 0;
}

.tpl-section-header::before,
.tpl-section-header::after {
    content: "";
    flex: 1;
    border-top: 1px dashed var(--color-border);
}

.tpl-section-title {
    font-size: 0.8em;
    color: var(--color-text-secondary);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tpl-tiles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tpl-tile {
    position: relative;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
}

/* Место справа под крестик, чтобы текст не заезжал под абсолютную кнопку. */
.tpl-tile.has-delete {
    padding-right: 30px;
}

.tpl-tile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tpl-tile-name {
    font-weight: 500;
    font-size: 0.9em;
}

.tpl-tile-detail {
    font-size: 0.8em;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Двойная плитка: две связанные ItemTile сливаются в одну — общая рамка снаружи,
   пунктирный разделитель внутри. Каждая половина кликабельна отдельно
   (свои OnClick/крестик), hover-фон подсвечивает только свою половину. */
.tpl-tile-pair {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
}

.tpl-tile-pair > .tpl-tile {
    border: none;
}

.tpl-tile-pair > .tpl-tile + .tpl-tile {
    border-top: 1px dashed var(--color-border);
}

.tpl-tile-add {
    padding: 8px;
    border: 1px dashed var(--color-border);
    cursor: pointer;
    background: none;
    font: inherit;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.tpl-tile-add:hover {
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

.tpl-tile-add .material-icons {
    font-size: 16px;
}

.tpl-tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tpl-tag-chip {
    display: inline-block;
    padding: 2px 8px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    font-size: 0.8em;
    white-space: nowrap;
}

.tpl-tag-chip-brand {
    background: #f0f4ff;
    border-color: #c7d2fe;
    color: #3730a3;
}

/*
 *  # Card content modifiers (shared between cards inside CardPanel:
 *    ProcurementExpenseCard, ClientInvoiceCard, ...)
 *
 *  Used for finance grids, locked values, link tiles, history timeline.
 *  Card-specific styles (status flow, reject notice, ...) stay in *.razor.css.
 */

.card-bold {
    font-weight: 600;
}

.card-payment-amount {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.card-income {
    color: var(--color-success);
}

.card-expense {
    color: var(--color-error);
}

/* Цвет денежной суммы по знаку: зелёный плюс / красный минус.
   Единый источник для всех финансовых страниц (CSS-класс выдаёт хелпер Web.CRM.AmountCssClass). */
.amount-income {
    color: var(--color-success);
}

.amount-expense {
    color: var(--color-error);
}

.card-nowrap {
    white-space: nowrap;
}

/* Карточка-эталон (DemoEditCard): «тихие» поля — в покое выглядят как текст,
   рамка проявляется по hover/фокусу. Раскладка: подпись слева, поле справа.
   Используется карточками КП и счёта поставщика. */
.edit-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.edit-card-rows {
    display: flex;
    flex-direction: column;
}

/* Разделительная линия между блоками карточки. Сидит в общем gap родителя (14px сверху и снизу). */
.edit-card-divider {
    border-top: 1px solid var(--color-border);
}

/* Строка свойства: подпись слева, значение справа. */
.edit-card-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    min-height: 36px;
    min-width: 0;
}

/* Строка-список: подпись прижата к верху, значение — вертикальная колонка */
.edit-card-row-list {
    align-items: start;
    min-height: 0;
    padding: 8px 0;
}

.edit-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/* Поле добавления невидимо в покое, но занимает место — раскладка ниже не прыгает.
   Проявляется при наведении на строку или фокусе внутри. */
.edit-card-add {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.edit-card-row-list:hover .edit-card-add,
.edit-card-row-list:focus-within .edit-card-add {
    visibility: visible;
    opacity: 1;
}

.edit-card-label {
    font-size: 0.8em;
    color: var(--color-text-secondary);
}

/* Read-only значение (вычисляемые суммы): выравниваем по тексту инпута. */
.edit-card-static {
    padding: 0 10px;
    font-size: 14px;
    min-width: 0;
}

/* В покое поля без рамок — значение читается как текст. */
.edit-card-row .input,
.edit-card-row .select-input-trigger {
    border-color: transparent;
    background: transparent;
}

/* Наведение на строку подсказывает, что поле редактируемое. */
.edit-card-row:hover .input,
.edit-card-row:hover .select-input-trigger {
    border-color: var(--color-border);
    background: var(--color-bg-white);
}

.edit-card-row .input:focus {
    border-color: var(--color-text-muted);
}

/* Стрелка выпадающего списка почти не видна, пока строка не под курсором. */
.edit-card-row .select-input-arrow {
    color: var(--color-text-muted2);
}

.edit-card-row:hover .select-input-arrow {
    color: var(--color-text-muted);
}

/*
 *  # Props table — реквизиты в рамке с редакторами
 *  Таблица «подпись | значение» в рамке (как позиции счёта в ExpensePackageViewDialog),
 *  но значения — живые редакторы (SearchSelect, DateInput, input, SelectInput).
 *  Редакторы идут заподлицо с ячейкой (общий контракт с .edit-cell ниже): в покое без
 *  своей рамки и фона, рамка возвращается при редактировании. Строки — те же .edit-card-row.
 *  Без overflow: hidden — иначе рамка режет выпадающие списки редакторов.
 */
.props-table {
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

/* Строка: подпись | значение, разделители между строками.
   align-items: stretch — ячейки на всю высоту строки, вертикальная граница подписи сплошная. */
.props-table .edit-card-row {
    grid-template-columns: 130px 1fr;
    align-items: stretch;
    min-height: 36px;
    border-top: 1px solid var(--color-border);
}

.props-table .edit-card-row:first-child {
    border-top: none;
}

/* Подпись слева + вертикальная граница до значения; текст по центру по высоте. */
.props-table .edit-card-label {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-right: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.85em;
}

/* Текстовые значения (edit-card-static) — по центру по высоте
   ячейки (строка растянута через align-items: stretch). */
.props-table .edit-card-static {
    display: flex;
    align-items: center;
}

/*
 *  # Общий контракт «редактор заподлицо» (.props-table и .edit-cell)
 *  .props-table — рамку ячейки рисует сама props-table (карточки);
 *  .edit-cell — рамку рисует сетка таблицы (GroupTable / SimpleTable), обёртка
 *  каждой редактируемой ячейки — <div class="edit-cell"> (в GroupTable ещё и
 *  @onclick:stopPropagation, чтобы клик по полю не всплыл как клик строки).
 *  Редакторы — без своей рамки и фона в покое и на hover: границы ячеек и так
 *  видны, а рамка у каждого поля превращает таблицу в решето. Поэтому
 *  BorderOnHover внутри этих обёрток не ставим. Рамка возвращается только
 *  в момент редактирования — фокус у input, открытый список у select/даты.
 *  !important бьёт и hover-правило .edit-card-row:hover .input выше в этом файле
 *  (его специфичность 0,3,0 выше нашей 0,2,0), и BorderOnHover самих DateInput/MonthYearInput.
 *  ВАЖНО — список редакторов это скрытый контракт: новый тип редактора внутри
 *  обёртки покажет свою рамку, пока его trigger-класс не добавлен сюда.
 *  Демо: /ui-template-editable-table (edit-cell), /ui-inputs (props-table).
 */
.props-table .input,
.props-table .select-input-trigger,
.props-table .date-input-trigger,
.props-table .month-input-trigger,
.edit-cell .input,
.edit-cell .select-input-trigger,
.edit-cell .date-input-trigger,
.edit-cell .month-input-trigger {
    border-color: transparent !important;
    background: transparent !important;
}

/* Исключение: редактор с фокусом возвращает рамку — affordance «сейчас редактирую»,
   как активная ячейка Excel. Для input это :focus, для SelectInput-триггера — открытый
   список (.open; сам триггер — div, фокус держит контейнер). У DateInput/MonthYearInput
   открытое состояние берём с .dropdown-container.open, а НЕ через :has() по содержимому
   поповера: с Portal="true" (а он тут предписан — карточки и прокручиваемые таблицы)
   поповер уезжает в <body>, и :has() не совпадает — рамка не возвращалась вообще. */
.props-table .input:focus,
.props-table .select-input-trigger.open,
.props-table .dropdown-container.open .date-input-trigger,
.props-table .dropdown-container.open .month-input-trigger,
.edit-cell .input:focus,
.edit-cell .select-input-trigger.open,
.edit-cell .dropdown-container.open .date-input-trigger,
.edit-cell .dropdown-container.open .month-input-trigger {
    border-color: var(--color-border) !important;
    background: var(--color-bg-white) !important;
}

/* Разделённая ячейка (паттерн /ui-template-split-row): вертикальный стек частей —
   по одной на этап. Части выравниваются между столбцами за счёт одинаковой
   фиксированной высоты .split-part: во всех разделённых столбцах одной строки
   одинаковое число частей, стеки получаются одной высоты, грид строки центрирует
   их — границы частей совпадают по всем столбцам. Глобально (не в scoped CSS),
   потому что части рисуют разные компоненты одной строки (PhaseCurrentPicker,
   ячейки страницы) и все должны делить одну высоту части. */
.split-cell {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
}

.split-part {
    height: 26px;
    display: flex;
    align-items: center;
    min-width: 0;
}

/* Разделитель между частями — пунктир, чтобы отличался от границ строк */
.split-part + .split-part {
    border-top: 1px dashed var(--color-border);
}

.split-phase-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Список элементов внутри ячейки props-table (связь M:N, например заказы 1С у КП).
   Тонкие строки с разделителями — читаются как продолжение таблицы; строка кликабельна
   целиком (открытие карточки), крестик удаления проявляется по hover. Внизу — постоянное
   поле добавления (SearchSelect ClearOnSelect, при необходимости в .input-with-action).
   Демо: /ui-inputs, секция «Список элементов в строке props-table». */
.multi-rows {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

/* Строка элемента — полноценной высоты, как обычная строка props-table (36px). */
.multi-row {
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    min-height: 36px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9em;
    cursor: pointer;
}

.multi-row:hover {
    background: var(--color-bg-white-hover);
}

/* Последний элемент без поля добавления (read-only или связь 1:1 уже заполнена):
   нижний бордер строки задваивается с бордером следующей строки props-table — гасим. */
.multi-row:last-child {
    border-bottom: none;
}

/* Название — главное: серая деталь справа (flex-basis: 0) обрезается первой,
   и только когда само название шире ячейки — оно тоже уходит в многоточие. */
.multi-row-name {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.multi-row-detail {
    flex: 1;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

/* margin-left: auto — крестик у правой границы и в строках без серой детали
   (иначе вправо его толкает только flex: 1 у .multi-row-detail). */
.multi-row-remove {
    border: none;
    background: transparent;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
    font-size: 16px;
    color: var(--color-text-muted);
    cursor: pointer;
    opacity: 0;
}

.multi-row:hover .multi-row-remove {
    opacity: 1;
}

.multi-row-remove:hover {
    color: var(--color-text);
}

/* Строка добавления — второстепенная: ниже строки элемента, мелче шрифт и кнопка. */
.multi-rows .input,
.multi-rows .input-with-action .input {
    height: 26px;
    font-size: 0.85em;
}

.multi-rows .input-with-action > .button {
    width: 26px;
    height: 26px;
}

.multi-rows .input-with-action > .button .material-icons {
    font-size: 16px;
}

/* Единичная 1:1-связь (модификатор .single-link): пока элемента нет, SearchSelect —
   не второстепенное поле добавления, а основной редактор ячейки — возвращаем ему
   обычные размеры (как у голого редактора props-table). Разметку ячейки рисует
   компонент SingleLinkRow. Демо: /ui-inputs,
   секция «Привязка сущности с переходом (SingleLinkRow)». */
.multi-rows.single-link .input {
    height: 32px;
    font-size: inherit;
}

/* В .single-link кнопка «создать новый» рядом с полем — тоже основной элемент ячейки:
   возвращаем ей обычные размеры .input-with-action (в списках она уменьшена до 26px). */
.multi-rows.single-link .input-with-action > .button {
    width: 32px;
    height: 32px;
}

.multi-rows.single-link .input-with-action > .button .material-icons {
    font-size: 20px;
}

/* Список файлов в строке props-table: строка файла целиком — ссылка на скачивание
   (как ItemTile Href), поле добавления — компактная дропзона FileUpload вместо
   SearchSelect. Демо: /ui-inputs, секция «Файлы в строке props-table». */
a.multi-row {
    color: inherit;
    text-decoration: none;
}

/* Строка «идёт загрузка» — тот же ряд списка, но не кликается и приглушена:
   загрузка файла на сервер занимает секунды, и список обязан это показывать. */
.multi-row.uploading {
    cursor: default;
    color: var(--color-text-muted);
}

.multi-row.uploading:hover {
    background: transparent;
}

.multi-row-icon {
    flex-shrink: 0;
    font-size: 16px;
    color: var(--color-text-muted);
}

/* Дропзона — второстепенное поле добавления, наравне с SearchSelect в списке:
   рамка тоньше, текст мельче. Селектор длиннее scoped-стиля FileUpload
   (web.styles.css подключается после app.css), иначе перебить не выйдет. */
.props-table .multi-rows .file-upload-area.compact {
    border-width: 1px;
    padding: 3px 8px;
}

.props-table .multi-rows .file-upload-area.compact .file-upload-text {
    font-size: 0.85em;
}

/* Two-column finance grid */
.card-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    row-gap: 12px;
}

.card-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.card-col:nth-child(odd) {
    padding-right: 16px;
    border-right: 1px dashed var(--color-border);
}

.card-col-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    padding: 0 10px;
}

.card-col-value {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    column-gap: 4px;
    min-height: 32px;
    padding: 0 10px;
    font-size: 14px;
    word-break: break-word;
    box-sizing: border-box;
}

.card-col-value.card-col-readonly {
    font-weight: 600;
}

.card-col.card-col-full {
    grid-column: 1 / -1;
    padding-right: 0;
    border-right: none;
}

/* Locked 1C-derived value: diagonal hatch + right-side hint "из 1С" */
.card-locked-value {
    position: relative;
    min-height: 32px;
    padding: 0 56px 0 10px;
    background: repeating-linear-gradient(
        -45deg,
        transparent 0 6px,
        rgba(117, 113, 107, 0.05) 6px 7px
    );
    border: 1px solid transparent;
    box-sizing: border-box;
    font-weight: 600;
    display: flex;
    align-items: center;
    cursor: default;
    word-break: break-word;
}

.card-lock-hint {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    font-weight: 400;
    color: var(--color-text-muted);
    pointer-events: none;
    white-space: nowrap;
}

/* Clickable surface (tile, data row) */
.card-clickable {
    cursor: pointer;
}

/* Плитка-ссылка (ItemTile с Href): корень — <a>, но выглядит как обычная плитка,
   а не как синяя ссылка. Наследуем цвет текста, без подчёркивания. */
a.tpl-tile,
a.tpl-tile:hover {
    color: inherit;
    text-decoration: none;
}

.card-clickable:hover {
    background: var(--color-bg-secondary);
}

/* Archived state banner (top of card) */
.card-archived-banner {
    padding: 8px 12px;
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
    font-size: 0.85em;
    text-align: center;
}

/* Link tiles: full-width tile with name (ellipsis) + delete crossbutton */
.card-link-tile .tpl-tile-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-link-tile .tpl-tile-detail {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-link-delete {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-secondary);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 120ms;
}

.card-link-tile:hover .card-link-delete {
    opacity: 1;
}

.card-link-delete:hover {
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

.card-link-delete:focus-visible {
    outline: none;
    opacity: 1;
    border-color: var(--color-text-muted);
}

.card-link-delete .material-icons {
    font-size: 12px;
}

/* Крестик удаления в плитке ItemTile — плоская квадратная кнопка 24px без рамки
   (button-xs button-xs-plain), проявляется при наведении на плитку. Только для плитки:
   остальные крестики в приложении остаются круглыми (.card-link-delete). */
.tpl-tile-delete {
    /* По центру плитки по высоте, у правого края — не влияет на высоту строки. */
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    opacity: 0.5;
    transition: opacity 120ms;
}

.card-link-tile:hover .tpl-tile-delete {
    opacity: 1;
}

.tpl-tile-delete:hover {
    color: var(--color-text);
}

.tpl-tile-delete:focus-visible {
    outline: none;
    opacity: 1;
}

/* Плитка файла: иконка слева на всю высоту, справа две строки (имя + размер), крестик.
   Общий вид для FileUpload и «Пакета документов» — как в блоке «Договоры». */
.file-tile {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Иконка файла, приглушённая, не сжимается. */
.file-tile .file-tile-icon {
    flex-shrink: 0;
    font-size: 24px;
    color: var(--color-text-muted);
}

/* Колонка с именем и размером — занимает всё свободное место. */
.file-tile .file-tile-info {
    flex: 1;
    min-width: 0;
}

/* Имя файла: обрезка длинного, размер наследуется от плитки (как у остальных). */
.file-tile .tpl-tile-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Имя уже загруженного файла — ссылка на скачивание. */
/* Держим приглушённый вид плитки, подчёркиваем только при наведении. */
.file-tile a.tpl-tile-name {
    color: inherit;
    text-decoration: none;
}

.file-tile a.tpl-tile-name:hover {
    text-decoration: underline;
}

/* Inline form to add link (replaces tpl-tile-add when expanded) */
.card-add-link-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
}

.card-add-link-error {
    font-size: 0.85em;
    color: var(--color-error);
}

.card-add-link-actions {
    display: flex;
    justify-content: flex-end;
}

/* History timeline (changelog + comments as messenger bubbles) */
/* Полоска тумблеров над лентой: приглушённые иконочные кнопки, активная — тёмная */
.card-history-filter {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    padding: 2px 0;
}

.card-history-filter .button-xs {
    color: var(--color-text-muted);
}

.card-history-filter .button-xs.active {
    color: var(--color-text);
}

.card-history-box {
    max-height: 220px;
    overflow-y: auto;
    padding: 8px 0;
    box-sizing: border-box;
}

/* .message-text теперь внутри дочернего MessageBubble; app.css глобальный, поэтому без ::deep */
.card-history-box .message-text {
    max-width: 100%;
    word-break: break-word;
}

.card-history-load-more {
    width: 100%;
    padding: 6px 0;
    background: transparent;
    border: none;
    font-size: 12px;
    color: var(--color-text-secondary);
    cursor: pointer;
    text-align: center;
}

.card-history-load-more:hover {
    color: var(--color-text);
    text-decoration: underline;
}

.card-history-hint {
    padding: 8px 4px;
    font-size: 0.85em;
    color: var(--color-text-muted);
    text-align: center;
}

.card-timeline-messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-tl-icon-flag {
    color: var(--color-error);
    font-size: inherit;
    vertical-align: text-bottom;
    margin-right: 4px;
}

/* System message (ChangeLog event) — small grey centered text without bubble */
.card-timeline-system {
    align-self: center;
    max-width: 100%;
    margin: 0;
    padding: 2px 8px;
    background: none;
    border: none;
    box-shadow: none;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.4;
    color: var(--color-text-muted);
    text-align: center;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.card-timeline-system-time {
    color: inherit;
    font-size: inherit;
    white-space: nowrap;
}

/* Автор изменения в ленте — контекст, а не суть: приглушён так же,
   как автор правки в ExpenseEditAlertBanner. Читают ленту ради «что поменялось». */
.card-timeline-system-actor {
    /* Глобальное `div, span, p, a, label { font-size: 14px }` бьёт по span'у сильнее,
       чем наследование от строки, — без inherit имя автора вырастает до 14px. */
    font-size: inherit;
    opacity: 0.7;
}

/* Позиционирование облачка (position: relative) задаёт сам MessageBubble.
   Кнопки правки/удаления переехали в компонент и используют button-xs вместо круглых кнопок. */

/* Mobile (CardPanel ~ 320px → content ~ 280px): collapse two-column grid */
@media (max-width: 360px) {
    .card-grid-2 {
        grid-template-columns: 1fr;
    }

    .card-col:nth-child(odd) {
        padding-right: 0;
        border-right: none;
    }
}

/* Uploaded files list — shared between FileUpload (modal) and cards */
.uploaded-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.uploaded-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background-color: var(--color-bg-white-hover);
    border: 1px solid var(--color-border);
}

.uploaded-file-item .file-icon {
    color: var(--color-text-muted);
    font-size: 24px;
}

.uploaded-file-item .file-info {
    flex-grow: 1;
}

.uploaded-file-item .file-name {
    font-weight: 400;
}

.uploaded-file-item .file-size {
    font-size: 0.85em;
    color: var(--color-text-muted);
}

.uploaded-file-item-existing .uploaded-file-link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.uploaded-file-item-existing .uploaded-file-link:hover .file-name {
    text-decoration: underline;
}

.uploaded-file-item.uploaded-file-link {
    color: inherit;
    text-decoration: none;
}

.uploaded-file-item.uploaded-file-link:hover .file-name {
    text-decoration: underline;
}

/* Print: hide navigation, show only content */
@media print {
    .sidebar,
    .sidebar-overlay,
    .top-bar {
        display: none !important;
    }

    .top-bar-content {
        margin-top: 0 !important;
    }
}
/* ── Финансовые сверки: детальная панель со вложенными таблицами ──
   Общая раскладка /object-finance-monthly и /monthly-finance: две колонки
   секций-карточек, внутри каждой вложенный GroupTable. */
.fin-detail-columns {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

@media (max-width: 1100px) {
    .fin-detail-columns {
        flex-direction: column;
    }
}

.fin-detail-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
}

/* Секция — карточка на тонированной панели, чтобы вложенная таблица читалась.
   Колонки и секции по ширине содержимого — ресайз столбца во вложенной таблице
   расширяет только свою секцию, соседнюю не двигает. */
.fin-detail-section {
    background: var(--color-bg-white);
    padding: 8px 12px;
    width: fit-content;
}

/* Отступ между секцией «Приход» (на всю ширину) и колонками под ней */
.fin-detail-section + .fin-detail-columns {
    margin-top: 16px;
}

.fin-detail-section-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-bottom: 4px;
}

.fin-detail-section-title {
    font-weight: 600;
    font-size: 13px;
}

.fin-detail-section-meta {
    color: var(--color-text-muted);
    font-size: 12px;
}

/* ===== Общие примитивы SVG-графиков =====
   Тултип и зоны наведения одинаковы у всех графиков (AreaChart, LineChart, RadarChart,
   StackedBarChart, PlanFactChart). Держим их здесь глобально — scoped-CSS нельзя переиспользовать
   между компонентами. Позиционирование тултипа (transform/top) и цвета маркеров серий остаются
   в .razor.css каждого графика — они различаются. */
.chart-tooltip {
    position: absolute;
    background: white;
    border: 1px solid #e8e8e8;
    box-shadow: var(--shadow-dropdown);
    padding: 12px 16px;
    min-width: 120px;
    z-index: 100;
    pointer-events: none;
    transform: translate(-50%, -100%);
}

.tooltip-title {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--color-bg-secondary);
    padding-bottom: 6px;
}

.tooltip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.tooltip-marker {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.tooltip-label {
    font-size: 13px;
    color: #666;
    flex-grow: 1;
}

.tooltip-value {
    font-size: 13px;
    font-weight: 500;
    color: #1a1a1a;
}

.chart-hover-zone {
    fill: transparent;
    cursor: pointer;
}

.chart-hover-line {
    stroke: #e0e0e0;
    stroke-width: 1;
}
