:root {
    --color-primary: #0d9488;
    --color-primary-dark: #0f766e;
    --color-primary-soft: #f0fdfa;
    --color-ring: rgb(13 148 136 / 0.28);
    --color-success: #15803d;
    --color-danger: #b91c1c;
    --color-danger-soft: #fef2f2;
    --color-warning: #b45309;
    --color-text: #1e293b;
    --color-text-muted: #5b6574;
    --color-border: #dfe7e4;
    --color-bg: #f5f7f6;
    --color-card: #ffffff;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.05);
    --shadow-md: 0 6px 20px rgb(0 0 0 / 0.08);
    --nav-height: 64px;
    --header-height: 56px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p {
    margin: 0;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* Ошибки Blazor: НЕ прятать! Иначе убитый circuit выглядит как живая страница,
   где «ничего не происходит при нажатии». Blazor сам показывает блок через inline-style. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    padding: 10px 16px;
    background: #fff7ed;
    border-top: 2px solid #ea580c;
    color: #7c2d12;
    font-size: 14px;
}

#blazor-error-ui a {
    font-weight: 700;
}

/* ====== Каркас приложения ====== */
.app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: 720px;
    margin: 0 auto;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text);
}

.app-brand__logo {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 18px;
}

.app-brand__name {
    font-weight: 600;
    font-size: 18px;
}

.app-header__user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header__user-name {
    font-size: 13px;
    font-weight: 600;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-header__role {
    font-size: 13px;
    color: var(--color-text-muted);
}

.app-header__logout {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-card);
    color: var(--color-text-muted);
    font-size: 13px;
}

.app-header__logout:hover {
    background: var(--color-bg);
}

.app-header__logout:active {
    background: var(--color-bg);
}

.app-content {
    flex: 1;
    width: 100%;
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0px));
}

/* ====== Нижняя навигация (mobile-first) ====== */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 720px;
    height: var(--nav-height);
    display: flex;
    align-items: stretch;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 10px rgb(0 0 0 / 0.04);
    z-index: 20;
}

.app-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 500;
    border: none;
    background: none;
}

.app-nav__item:active {
    color: var(--color-primary);
}

.app-nav__item--active {
    color: var(--color-primary);
    font-weight: 700;
}

/* На десктопе навигация — горизонтальная полоса сразу под шапкой */
@media (min-width: 768px) {
    .app-shell {
        max-width: 100%;
    }

    .app-content {
        order: 3;
        max-width: 752px;
        margin: 0 auto;
        padding-bottom: 48px;
    }

    .app-nav {
        order: 2;
        position: sticky;
        top: var(--header-height);
        left: auto;
        right: auto;
        transform: none;
        width: 100%;
        margin: 12px auto;
        max-width: 720px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        z-index: 19;
    }
}

/* ====== Карточки и списки ====== */
.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.card + .card {
    margin-top: 12px;
}

.card--link {
    display: block;
    color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card--link:hover {
    border-color: #c3d2cd;
    box-shadow: var(--shadow-md);
}

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

.card__title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.card__text {
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ====== Бейджи статусов ====== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge--new { background: #fef3c7; color: #92400e; }
.badge--assigned { background: #dbeafe; color: #1e40af; }
.badge--processing { background: #ede9fe; color: #5b21b6; }
.badge--completed { background: #dcfce7; color: #166534; }
.badge--cancelled { background: #fee2e2; color: #991b1b; }

/* ====== Пустое состояние ====== */
.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-muted);
}

.empty__icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.empty__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

/* ====== Кнопки ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn--primary {
    background: var(--color-primary);
    color: #fff;
}
.btn--primary:hover { background: var(--color-primary-dark); }
.btn--primary:active { background: var(--color-primary-dark); }

.btn--danger {
    background: var(--color-danger-soft);
    color: var(--color-danger);
    border-color: #f1c7c7;
}
.btn--danger:hover {
    background: #fde4e4;
    color: #991b1b;
}
.btn--danger:active {
    background: #fde4e4;
    color: #991b1b;
}

.btn--ghost {
    background: var(--color-card);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn--ghost:hover {
    background: var(--color-bg);
    border-color: var(--color-border);
}

.btn--danger-ghost {
    background: var(--color-card);
    color: var(--color-danger);
    border-color: #f3c9c9;
}
.btn--danger-ghost:hover {
    background: var(--color-danger-soft);
}

.btn--block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn--sm {
    padding: 7px 12px;
    font-size: 13px;
    border-radius: 8px;
}

/* ====== Формы ====== */
.field {
    margin-bottom: 16px;
}

.field__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.field__hint {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 6px;
}

.input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-card);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-ring);
}

textarea.input {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

select.input {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%), linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

/* ====== Ошибки / сообщения ====== */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 12px;
}

.alert--error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert--success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.validation-message {
    color: var(--color-danger);
    font-size: 13px;
    margin-top: 4px;
    display: block;
}

.valid.modified:not([type=checkbox]) { border-color: var(--color-border); }
.invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgb(185 28 28 / 0.15);
}

/* ====== Списки файлов ====== */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-card);
    font-size: 14px;
}

.file-item__icon {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.file-item__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ====== Детали заявки ====== */
.detail-section {
    margin-top: 16px;
}

.detail-section__title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

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

.meta {
    min-width: 0;
    padding: 10px 12px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.meta__label {
    font-size: 12px;
    color: var(--color-text-muted);
    display: block;
    margin-bottom: 2px;
}

.meta__value {
    font-size: 14px;
    font-weight: 600;
}

/* ====== Экран загрузки ====== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--color-text-muted);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ====== Аватар ====== */
.avatar {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 26px;
    font-weight: 700;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.profile-header__name {
    font-size: 18px;
    font-weight: 700;
}

.profile-header__role {
    color: var(--color-text-muted);
    font-size: 14px;
}

/* ====== Админ-карточки ====== */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 640px) {
    .admin-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ====== Аутентификация ====== */
.auth {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(160deg, var(--color-primary-soft) 0%, var(--color-bg) 62%);
}

.auth__card {
    width: 100%;
    max-width: 400px;
    padding: 28px 24px;
    background: var(--color-card);
    border-radius: 16px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
}

.auth__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.auth__title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
}

.auth__subtitle {
    font-size: 14px;
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 20px;
}

.auth__footer {
    text-align: center;
    font-size: 14px;
    color: var(--color-text-muted);
    margin-top: 16px;
}

.auth__footer a {
    font-weight: 600;
}

/* ====== Заголовки страниц ====== */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
}

/* ====== Поиск ====== */
.search-field {
    margin-bottom: 12px;
}

.search-field .input {
    padding-left: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6574' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 16px 16px;
}

/* ====== Фильтры-чипы ====== */
.filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.chip {
    flex-shrink: 0;
    padding: 7px 14px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-card);
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

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

.chip--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.chip--active:hover {
    background: var(--color-primary);
}

/* ====== Список заявок ====== */
.order-list .card--link {
    display: flex;
    flex-direction: column;
}

.order-card {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.order-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.order-card__id {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
}

.order-list .card__text {
    flex: 1;
    min-height: 61px;
}

.order-card__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.order-card__files {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ====== Кастомный дропдаун (в стиле .input) ====== */
.dropdown {
    position: relative;
}

.dropdown__button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown__button:disabled {
    background: var(--color-bg);
    color: var(--color-text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.dropdown__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown__chevron {
    flex-shrink: 0;
    color: var(--color-text-muted);
    transition: transform 0.15s ease;
}

.dropdown__button[aria-expanded="true"] .dropdown__chevron {
    transform: rotate(180deg);
}

.dropdown__backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    cursor: default;
}

.dropdown__list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 31;
    max-height: 260px;
    overflow-y: auto;
    padding: 6px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    animation: modal-in 0.12s ease-out;
}

.dropdown__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 8px;
    background: none;
    text-align: left;
    color: var(--color-text);
}

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

.dropdown__option--selected {
    background: var(--color-primary-soft);
}

.dropdown__option-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.dropdown__option-name {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown__option svg {
    flex-shrink: 0;
    color: var(--color-primary);
}

.dropdown__empty {
    padding: 12px;
    font-size: 14px;
    color: var(--color-text-muted);
    text-align: center;
}

/* ====== Таймлайн истории заявки ====== */
.timeline {
    display: flex;
    flex-direction: column;
}

.timeline__item {
    position: relative;
    display: flex;
    gap: 12px;
    padding-bottom: 16px;
}

.timeline__item:last-child {
    padding-bottom: 2px;
}

/* Вертикальная соединительная линия */
.timeline__item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 20px;
    bottom: 0;
    width: 2px;
    border-radius: 2px;
    background: var(--color-border);
}

.timeline__dot {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    border-radius: 50%;
    background: var(--color-text-muted);
    border: 3px solid var(--color-card);
    box-shadow: 0 0 0 2px var(--color-border);
}

.timeline__item--new .timeline__dot { background: #d97706; box-shadow: 0 0 0 2px #fde68a; }
.timeline__item--assigned .timeline__dot { background: #2563eb; box-shadow: 0 0 0 2px #bfdbfe; }
.timeline__item--processing .timeline__dot { background: #7c3aed; box-shadow: 0 0 0 2px #ddd6fe; }
.timeline__item--completed .timeline__dot { background: #16a34a; box-shadow: 0 0 0 2px #bbf7d0; }
.timeline__item--cancelled .timeline__dot { background: #dc2626; box-shadow: 0 0 0 2px #fecaca; }
.timeline__item--neutral .timeline__dot { background: var(--color-primary); box-shadow: 0 0 0 2px #ccfbf1; }

.timeline__body {
    flex: 1;
    min-width: 0;
}

.timeline__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.timeline__action {
    font-size: 14px;
    font-weight: 700;
}

.timeline__time {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.timeline__actor {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline__detail {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--color-bg);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
}

/* ====== Детали заявки ====== */
.order-detail__id {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
    margin-bottom: 12px;
}

.order-detail__text {
    font-size: 15px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.order-actions {
    margin-top: 16px;
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.actions > .btn {
    flex: 1;
}

.actions > .card {
    flex: 1 1 100%;
    min-width: 0;
}

/* Вертикальная стопка кнопок внутри карточек */
.btn-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

/* Текущий назначенный врач */
.assignee {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    min-width: 0;
}

.assignee__dot {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary);
}

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

.assignee__name {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Карточка опасных действий */
.card--danger {
    border-color: #f3c9c9;
}

.card--danger .card__title {
    color: var(--color-danger);
}

/* ====== Действия над карточками (админ) ====== */
.entity-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.entity-actions .btn {
    flex: 1 1 auto;
    min-width: 110px;
}

/* ====== Список ссылок заявки ====== */
.link-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-list a {
    overflow-wrap: anywhere;
    word-break: break-all;
}

/* ====== Модальное окно ====== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgb(15 23 42 / 0.45);
}

.modal__card {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    animation: modal-in 0.16s ease-out;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .modal__card {
        animation: none;
    }
}

.modal__text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-muted);
    margin: 8px 0 4px;
    white-space: pre-line;
}

/* ====== Зона загрузки файлов ====== */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 24px 16px;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.dropzone--dragging {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    box-shadow: 0 0 0 3px var(--color-ring);
}

.dropzone__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone__icon {
    font-size: 22px;
    line-height: 1;
    margin-bottom: 4px;
}

.dropzone__text {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.dropzone__hint {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ====== Карточка приглашения ====== */
.invite {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    text-align: center;
}

.invite__title {
    font-size: 15px;
    font-weight: 600;
}

.invite__text {
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.45;
    margin-bottom: 4px;
}

.invite .btn {
    margin-top: 4px;
}

/* ====== Опасные действия (внизу, отдельно) ====== */
.danger-zone {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.danger-zone .btn {
    align-self: flex-start;
}

/* ====== Сетка карточек сущностей (десктоп) ====== */
@media (min-width: 640px) {
    .entity-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

.order-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
    align-content: start;
}

@media (min-width: 640px) {
    .order-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Карточки одинаковой высоты в сетке (врачи, сотрудники, клиники).
   Высоту выравнивает align-items: stretch у .order-list — явный height:100%
   здесь вреден: проценты от auto-высоты ряда схлопываются в auto и ломают stretch */
.card--equal {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.card--equal .entity-actions {
    margin-top: auto;
    padding-top: 12px;
}

.card__title--truncate {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-card__top .badge {
    flex-shrink: 0;
}

/* В сетках отступы задаёт gap — сбрасываем соседский margin от .card + .card,
   иначе вторая карточка (верхняя правая на десктопе) съезжает вниз */
.order-list > .card,
.order-list > .card--link,
.entity-grid > .card {
    margin-top: 0;
}



/* ====== Защита от горизонтального скролла (mobile-first) ====== */
html,
body {
    overflow-x: hidden;
}

/* Резервируем место под вертикальный скроллбар на десктопе,
   чтобы появление/исчезновение скролла не дёргало контент влево.
   На мобильных скроллбары оверлейные — там не нужно. */
@media (min-width: 768px) {
    html {
        scrollbar-gutter: stable;
    }
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

pre,
code,
.order-detail__text,
.order-card__id,
.order-detail__id {
    overflow-wrap: anywhere;
}

.app-header__user,
.order-card__top,
.file-item__name {
    min-width: 0;
}

/* ====== Узкие экраны (смартфоны) ====== */
@media (max-width: 420px) {
    .app-header {
        padding: 0 12px;
    }

    .app-header__role {
        display: none;
    }

    .app-header__user-name {
        display: none;
    }

    .app-brand__name {
        font-size: 16px;
    }

    .app-content {
        padding: 12px;
        /* Нижний отступ под фикс-меню нельзя сбрасывать, иначе оно перекроет конец страницы */
        padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0px));
    }

    .page-title {
        font-size: 19px;
    }

    .profile-header {
        gap: 12px;
    }

    .actions > .btn,
    .order-actions > .btn,
    .entity-actions .btn {
        flex: 1 1 100%;
    }
}