@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-warning-text: #856404;
    --color-warning-border: #ffc107;

    /* Shadows */
    --shadow-dropdown: 0 0px 20px rgba(0, 0, 0, 0.05);
}

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);
}

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);
}

.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-loading { background-color: var(--color-info-bg); color: var(--color-info-text); border: 1px solid var(--color-info-border); padding: 8px 12px; border-radius: 4px; }
.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: #3d6b64; }
.status-badge-stone  { background: var(--color-bg-secondary); color: var(--color-text-muted); }
.status-badge-gold   { background: #d4a056; }
.status-badge-terra  { background: #b2552d; }
.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; }

/* Зелёный чип-источник 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;
    }

    .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;
}

/* 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;
    }
}





/*  # 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);
}



/* 
 *  # 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);
}

.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;
}

.input-label {
    font-size: 0.8rem;
    font-weight: 500;
}

.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;
}



/* 
 *  # 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);
}

.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;
}

/* image */
.message-image-container {
    margin: 5px 0;
}

.message-image {
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image:hover {
    transform: scale(1.05);
}

.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);
}

.dropdown-divider {
    height: 1px;
    margin: 4px 0;
    border: none;
    background-color: var(--color-border);
}

.dropdown-item.danger-button:hover {
    background-color: #dc3545;
    color: white;
}



/* 
 * Прочее
 */

.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;
}


/*
 *  # Object Card (SidePanel content)
 */

.object-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.object-card-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.object-card-label {
    font-size: 0.8em;
    color: var(--color-text-secondary);
}

.object-card-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;
}

.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 {
    padding: 6px 8px;
    border: 1px solid var(--color-border);
}

.tpl-tile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.9em;
}

.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;
}

.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-row-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    /* height: 32px; */
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: 4px;
    padding: 0;
    flex-shrink: 0;
}

.tpl-row-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.tpl-row-btn .material-icons {
    font-size: 20px;
}

.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;
}

/* 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;
}

.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;
}

/* 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;
    padding: 2px 0;
}

.card-history-filter ::deep .segmented-control {
    background: var(--color-bg-secondary);
    padding: 2px;
    display: inline-flex;
    gap: 2px;
}

.card-history-filter ::deep .segmented-control-item {
    padding: 4px 10px;
    font-size: 11px;
}

.card-history-box {
    max-height: 220px;
    overflow-y: auto;
    padding: 8px 0;
    box-sizing: border-box;
}

.card-history-box ::deep .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;
}

.card-timeline-messages .message-bubble {
    position: relative;
}

.card-bubble-delete,
.card-bubble-edit {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-bg-white);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.3;
    transition: opacity 120ms;
}

/* Кнопка правки стоит левее кнопки удаления */
.card-bubble-edit {
    right: 24px;
}

.card-timeline-messages .message-bubble:hover .card-bubble-delete,
.card-timeline-messages .message-bubble:hover .card-bubble-edit {
    opacity: 1;
}

.card-bubble-delete .material-icons,
.card-bubble-edit .material-icons {
    font-size: 12px;
}

/* 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;
}

/*
 *  # Inline edit (InlineEdit* components)
 *  Read-mode: clickable value → edit-mode. Blur/Enter saves, Esc reverts.
 *  Редактор — обычный .input проекта (32px, padding 0 10px, border 1px).
 *  Просмотр приведён к той же геометрии, чтобы строка не прыгала при переключении.
 */

.inline-edit-display {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 0 10px;
    border: 1px solid transparent;
    box-sizing: border-box;
    min-width: 16px;
    min-height: 32px;
}

.inline-edit-display:hover {
    background: var(--color-bg-secondary);
}

.inline-edit-disabled {
    cursor: default;
}

.inline-edit-disabled:hover {
    background: transparent;
}

.inline-edit-placeholder {
    color: var(--color-text-muted);
    font-style: italic;
}

.inline-edit-error {
    color: var(--color-error);
    font-size: 0.85em;
    margin-top: 2px;
}

.inline-edit-editor {
    display: block;
    width: 100%;
}

/* Print: hide navigation, show only content */
@media print {
    .sidebar,
    .sidebar-overlay,
    .top-bar {
        display: none !important;
    }

    .top-bar-content {
        margin-top: 0 !important;
    }
}