* {
    box-sizing: border-box;
}

:root {
    --app-primary: #2563eb;
    --app-primary-hover: #1d4ed8;
    --app-primary-active: #1e40af;
    --app-primary-shadow: rgba(37, 99, 235, 0.35);
    --app-primary-shadow-hover: rgba(37, 99, 235, 0.45);
    --app-surface-active: #eff6ff;
    --app-border-active: #60a5fa;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #111827;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Общие контейнеры */

.page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
}

.page--centered {
    align-items: center;
}

/* Вход (/login, /admin/login): Telegram — на мобильных и в PWA основная кнопка — полноэкранный OAuth; виджет скрыт, если OAuth-ссылка есть */
.login-tg-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (max-width: 768px), (display-mode: standalone) {
    .login-tg-stack:has(.login-tg-oauth-btn) .login-tg-widget-host {
        display: none !important;
        min-height: 0 !important;
        margin-bottom: 0 !important;
        overflow: hidden;
    }

    .login-tg-stack:has(.login-tg-oauth-btn) .login-tg-oauth-fallback {
        order: -1;
    }

    .login-tg-stack:has(.login-tg-oauth-btn) .login-tg-oauth-fallback-note {
        margin-bottom: 4px !important;
    }
}

.card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    padding: 24px 24px 28px;
}

/* Логин-карточка (макс. ширина) */

.card--narrow {
    max-width: 420px;
    width: 100%;
}

/* Админ-лейаут */

.layout {
    max-width: 1200px;
    width: 100%;
    min-width: 0;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* PWA: врач и поддержка — узкая колонка, плитки, удобные зоны нажатия */

.layout--app-narrow {
    max-width: 800px;
    margin: 0 auto;
    flex-direction: column;
}

.layout--app-detail {
    max-width: 920px;
    margin: 0 auto;
    flex-direction: row;
}

.main--app-fill {
    flex: 1;
    min-width: 0;
}

.main-header--app {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.app-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.app-toolbar--stack {
    flex-direction: column;
}

@media (min-width: 520px) {
    .app-toolbar--stack {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        width: auto;
    }
}

.app-toolbar .btn-primary,
.app-toolbar .btn-secondary {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    box-sizing: border-box;
}

.app-toolbar--stack .btn-primary {
    width: 100%;
}

.app-toolbar--stack .btn-secondary {
    width: 100%;
}

@media (min-width: 520px) {
    .app-toolbar--stack .btn-primary,
    .app-toolbar--stack .btn-secondary {
        width: auto;
        min-width: 140px;
    }
}

.app-toolbar a.btn-secondary,
.app-toolbar .btn-secondary {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
}

.app-page-lead {
    margin-top: 16px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f0f9ff 0%, #eff6ff 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #0c4a6e;
}

.app-page-lead strong {
    font-weight: 600;
    color: #075985;
}

.app-field {
    margin-top: 18px;
}

.app-field:first-child {
    margin-top: 0;
}

.app-field .text-input,
.app-field select.text-input,
.app-field textarea.text-input {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 10px;
    box-sizing: border-box;
}

.app-field-section {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #e5e7eb;
}

.app-field-section__title {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.app-field-section__hint {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.45;
}

.app-form-actions--split {
    flex-direction: column;
}

@media (min-width: 480px) {
    .app-form-actions--split {
        flex-direction: row;
        align-items: center;
    }

    .app-form-actions--split .btn-primary {
        flex: 1 1 auto;
    }

    .app-form-actions--split .btn-secondary {
        flex: 0 0 auto;
        min-width: 130px;
        width: auto;
    }
}

@media (min-width: 769px) {
    .app-mobile-cta-bar {
        display: none;
    }

    .app-consult-page--with-cta {
        padding-bottom: 0;
    }
}

.app-mobile-cta-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(8px);
}

.app-mobile-cta-bar .btn-primary {
    width: 100%;
    justify-content: center;
    min-height: 48px;
}

.app-consult-page--with-cta {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

.app-consult-card__doctor {
    display: block;
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 6px;
}

.app-consult-card__tap-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-left: auto;
}

.app-pay-list {
    list-style: none;
    margin: 12px 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.app-pay-item {
    padding: 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.app-pay-item__title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.app-pay-item__amount {
    font-size: 14px;
    color: #4b5563;
}

.app-link-btn {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 0;
    color: var(--app-primary);
    font-weight: 600;
    text-decoration: none;
}

.app-link-btn:hover {
    text-decoration: underline;
}

.app-link-btn:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.btn-primary.is-loading {
    opacity: 0.75;
    pointer-events: none;
}

.app-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
    gap: 12px;
    margin-top: 20px;
}

.app-tile-link {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 72px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease;
}

.app-tile-link:active {
    background: #f9fafb;
}

.app-list-item {
    border: 1px solid #e5e7eb;
    background: #fff;
}

.app-tile-emoji {
    font-size: 24px;
    line-height: 1.2;
    margin-bottom: 4px;
}

.app-tile-subtitle {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: #6b7280;
}

.app-tile-link--sos {
    border-color: #fecaca;
}

.app-tile-link--support-staff {
    border-color: #6ee7b7;
}

.app-tile-section {
    margin-top: 24px;
}

.app-tile-section:first-child {
    margin-top: 20px;
}

.app-tile-section__title {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-lk-role-strip {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.app-lk-card {
    padding: 16px;
    border-radius: 12px;
}

.app-lk-card--doctor {
    background: #eff6ff;
    border: 1px solid #93c5fd;
}

.app-lk-card--doctor p {
    margin: 8px 0 12px 0;
    font-size: 14px;
    color: #1e40af;
}

.app-lk-card--support {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
}

.app-lk-card--support p {
    margin: 8px 0 12px 0;
    font-size: 14px;
    color: #065f46;
}

.app-lk-card--admin {
    background: #fef3c7;
    border: 1px solid #fcd34d;
}

.app-lk-card--admin p {
    margin: 8px 0 12px 0;
    font-size: 14px;
    color: #92400e;
}

.app-lk-card__btn {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
}

.app-push-block {
    margin-top: 24px;
    padding: 16px;
    background: #f0f9ff;
    border-radius: 12px;
    border: 1px solid #bae6fd;
}

.app-push-block__title {
    margin: 0 0 8px 0;
    font-weight: 600;
}

.app-push-block__text {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #0c4a6e;
}

.app-push-block__status {
    margin: 8px 0 0 0;
    font-size: 13px;
    color: #6b7280;
}

.app-summary-card {
    margin-top: 24px;
    padding: 24px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.5;
}

.app-summary-warning {
    margin-top: 24px;
    padding: 20px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    color: #92400e;
}

.app-muted-text {
    color: #6b7280;
    font-size: 13px;
}

.app-consult-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0 16px;
    font-size: 15px;
    align-items: center;
}

.app-consult-filters__sep {
    color: #d1d5db;
}

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

.app-unpaid-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.app-tile-action {
    min-height: 72px;
}

.app-tile-action form {
    margin: 0;
    height: 100%;
}

.app-tile-btn {
    width: 100%;
    min-height: 72px;
    border-radius: 12px;
    cursor: pointer;
    border: none;
    padding: 16px;
    font: inherit;
}

.app-ticket-list {
    list-style: none;
    padding: 0;
    margin: 24px 0 0 0;
}

.app-ticket-list li {
    margin-bottom: 12px;
}

.app-ticket-list .app-tile-link {
    display: block;
}

.app-stat-panel {
    margin-top: 24px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.app-support-meta {
    margin-top: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 12px;
}

.app-support-meta p {
    margin: 0 0 6px 0;
}

.app-support-meta p:last-child {
    margin-bottom: 0;
}

.app-support-actions {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.app-support-actions form {
    display: inline;
}

.app-support-actions .btn-secondary,
.app-support-actions .btn {
    min-height: 44px;
}

.app-support-card {
    margin-top: 16px;
    padding: 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #111827;
    color: #e5e7eb;
    border-radius: 12px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    position: sticky;
    top: 16px;
    align-self: flex-start;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.sidebar-subtitle {
    font-size: 12px;
    color: #9ca3af;
}

.sidebar-nav {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 9999px;
    font-size: 14px;
    text-decoration: none;
    color: #e5e7eb;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.08);
}

.sidebar-link:hover {
    background: #1f2937;
}

.sidebar-link--active {
    background: var(--app-primary);
    color: #ffffff;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 11px;
    color: #6b7280;
}

/* Контент */

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

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.main-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: #6b7280;
}

.main-user {
    font-size: 13px;
    color: #6b7280;
}

.main-user strong {
    color: #111827;
}

/* Кнопки */

.btn-primary {
    border: none;
    border-radius: 9999px;
    background: var(--app-primary);
    color: #ffffff;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 8px 16px var(--app-primary-shadow);
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    text-decoration: none;
}

.btn-primary:hover {
    background: var(--app-primary-hover);
    box-shadow: 0 10px 22px var(--app-primary-shadow-hover);
    transform: translateY(-1px);
}

.btn-primary:active {
    background: var(--app-primary-active);
    box-shadow: 0 4px 10px rgba(30, 64, 175, 0.6);
    transform: translateY(0);
}

.app-link {
    color: var(--app-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.app-link:hover {
    color: var(--app-primary-hover);
}

.btn-primary-icon {
    font-size: 16px;
}

.btn-secondary {
    border-radius: 9999px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-secondary:hover {
    background: #f3f4f6;
}

/* Поля форм */

.field-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.text-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: #f9fafb;
}

.text-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
    background: #ffffff;
}

.textarea-input {
    width: 100%;
    min-height: 120px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    resize: vertical;
    outline: none;
    background: #f9fafb;
}

.textarea-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
    background: #ffffff;
}

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

/* Хинты и ошибки */

.hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

.callout-important,
.callout-note,
.callout-warn {
    border-radius: 0 8px 8px 0;
    padding: 12px 14px;
    margin: 0 0 12px;
    line-height: 1.5;
    font-size: 14px;
}
.callout-important {
    border-left: 4px solid #0ea5e9;
    background: #ecfeff;
    color: #155e75;
}
.callout-note {
    border-left: 4px solid #0284c7;
    background: #f0f9ff;
    color: #334155;
}
.callout-warn {
    border-left: 4px solid #d97706;
    background: #fffbeb;
    color: #78350f;
}

.error {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 13px;
    border: 1px solid #fecaca;
}

.alert {
    margin-top: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid;
}

.alert-success {
    background: #ecfdf3;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.footer-hint {
    margin-top: 16px;
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.4;
}

.footer-hint strong {
    color: #6b7280;
}

.btn-row {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

/* Таблицы */

.table-card {
    margin-top: 16px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    padding: 16px;
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    background: #f9fafb;
}

.table tr:hover td {
    background: #f3f4f6;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
}

.badge--green {
    background: #ecfdf3;
    color: #166534;
}

.badge--red {
    background: #fef2f2;
    color: #b91c1c;
}

.badge--yellow {
    background: #fffbeb;
    color: #92400e;
}

.badge--blue {
    background: #eff6ff;
    color: #1d4ed8;
}

/* Грид карточек */

.cards-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.metric-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.metric-title {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
}

/* Секции формы */

.form-section {
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.form-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #111827;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 16px;
}

/* Мелочи */

.mt-12 {
    margin-top: 12px;
}

.mt-16 {
    margin-top: 16px;
}

.mb-12 {
    margin-bottom: 12px;
}

.text-muted {
    color: #6b7280;
    font-size: 13px;
}

/* Кнопки для действий с врачами */

.btn {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.4;
}

.btn--small {
    padding: 4px 10px;
    font-size: 12px;
}

.btn--green {
    background: #10b981;
    color: #ffffff;
}

.btn--green:hover {
    background: #059669;
}

.btn--red {
    background: #ef4444;
    color: #ffffff;
}

.btn--red:hover {
    background: #dc2626;
}

.btn--warning {
    background: #f59e0b;
    color: #ffffff;
}

.btn--warning:hover {
    background: #d97706;
}

.btn--secondary {
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn--secondary:hover {
    background: #f3f4f6;
}

.btn--danger {
    background: #ef4444;
    color: #ffffff;
}

.btn--danger:hover {
    background: #dc2626;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar-search-form {
    margin-bottom: 8px;
}

.sidebar-search-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #374151;
    background: #1f2937;
    color: #e5e7eb;
    font-size: 13px;
}

.sidebar-search-input::placeholder {
    color: #9ca3af;
}

/* Админ: формы, заголовки, бейджи (шаблоны используют form-* / page-* / badge-*) */

.page-header {
    margin-bottom: 4px;
}

.page-title {
    margin: 0;
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    font-weight: 700;
    line-height: 1.25;
    word-break: break-word;
}

.form-group {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: inherit;
}

.form-input {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: #f9fafb;
    box-sizing: border-box;
}

.form-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
    background: #ffffff;
}

select.form-input,
textarea.form-input {
    font-size: 16px;
}

.badge-info {
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-success {
    background: #ecfdf3;
    color: #166534;
}

.badge-danger {
    background: #fef2f2;
    color: #b91c1c;
}

.btn--primary {
    border: none;
    border-radius: 9999px;
    background: var(--app-primary);
    color: #ffffff;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 8px 16px var(--app-primary-shadow);
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    text-decoration: none;
}

.btn--primary:hover {
    background: var(--app-primary-hover);
}

.table-card {
    -webkit-overflow-scrolling: touch;
}

.table-card > .table {
    min-width: 720px;
}

.table-card .table td .btn {
    margin-top: 4px;
}

.admin-sidebar-toggle {
    display: none;
    width: 100%;
    min-height: 44px;
    margin: 0 0 10px;
    padding: 10px 14px;
    border: 1px solid #374151;
    border-radius: 10px;
    background: #1f2937;
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.08);
}

.admin-sidebar-toggle::before {
    content: "☰";
    font-size: 16px;
}

.layout--sidebar-collapsed .admin-sidebar-toggle::before {
    content: "✕";
}

@media (max-width: 1024px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-width: none;
        max-height: min(70vh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px));
        position: relative;
        top: auto;
        align-self: stretch;
    }

    .page > .layout:not(.layout--app-narrow):not(.layout--app-detail) .admin-sidebar-toggle {
        display: inline-flex;
    }

    .page > .layout:not(.layout--app-narrow):not(.layout--app-detail).layout--sidebar-collapsed .sidebar-nav,
    .page > .layout:not(.layout--app-narrow):not(.layout--app-detail).layout--sidebar-collapsed .sidebar-footer,
    .page > .layout:not(.layout--app-narrow):not(.layout--app-detail).layout--sidebar-collapsed .sidebar-search-form {
        display: none;
    }

    .page > .layout:not(.layout--app-narrow):not(.layout--app-detail).layout--sidebar-collapsed .sidebar {
        max-height: none;
    }

    .page {
        padding: 8px;
        padding-left: max(8px, env(safe-area-inset-left, 0px));
        padding-right: max(8px, env(safe-area-inset-right, 0px));
    }

    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .main-title {
        font-size: clamp(1.05rem, 4vw, 1.25rem);
        line-height: 1.25;
        word-break: break-word;
    }

    .btn-primary,
    .btn-secondary {
        min-height: 44px;
        padding-top: 10px;
        padding-bottom: 10px;
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
    }

    .btn-row {
        justify-content: flex-start;
    }

    .table {
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 8px 6px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

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

    .card {
        padding: 16px 14px 18px;
    }
}

/* Компактные телефоны в PWA / узкий экран */
@media (max-width: 480px) {
    .sidebar {
        border-radius: 10px;
        padding: 14px 12px;
    }

    .sidebar-link {
        font-size: 13px;
        min-height: 46px;
    }
}

/* PWA standalone или типичный мобильный браузер: чуть плотнее сетки дашборда */
@media (max-width: 900px) {
    @supports (-webkit-touch-callout: none) {
        .page {
            padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
        }
    }
}

/* Тёмная тема (ручной переключатель: localStorage) */
html.admin-theme-light body {
    background: #f3f4f6;
    color: #111827;
}

html.admin-theme-light .card,
html.admin-theme-light .table-card,
html.admin-theme-light .metric-card {
    background: #ffffff;
    color: #111827;
    border-color: #e5e7eb;
}

html.admin-theme-dark body {
    background: #0f172a;
    color: #e2e8f0;
}

html.admin-theme-dark .card,
html.admin-theme-dark .table-card,
html.admin-theme-dark .metric-card {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

html.admin-theme-dark .main-title,
html.admin-theme-dark .text-input {
    color: #e2e8f0;
}

html.admin-theme-dark .text-input {
    background: #0f172a;
    border-color: #475569;
}

html.admin-theme-dark .form-input {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

html.admin-theme-dark .form-input:focus {
    background: #1e293b;
    border-color: #60a5fa;
}

html.admin-theme-dark .form-label {
    color: #e2e8f0;
}

html.admin-theme-dark .text-muted {
    color: #94a3b8;
}

html.admin-theme-dark .sidebar {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

html.admin-theme-dark .sidebar-title,
html.admin-theme-dark .sidebar-subtitle {
    color: #f1f5f9;
}

html.admin-theme-dark .sidebar-link {
    color: #cbd5e1;
}

html.admin-theme-dark .sidebar-link:hover {
    background: #334155;
}

html.admin-theme-dark .sidebar-link--active {
    background: #1d4ed8;
    color: #fff;
}

html.admin-theme-dark .main {
    color: #e2e8f0;
}

html.admin-theme-dark .table th,
html.admin-theme-dark .table td {
    border-color: #334155;
    color: #e2e8f0;
}

html.admin-theme-dark .table tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.5);
}

html.admin-theme-dark .select-input {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

html.admin-theme-dark .btn,
html.admin-theme-dark .btn-secondary {
    border-color: #475569;
}

html.admin-theme-dark .form-section {
    border-top-color: #334155;
}

html.admin-theme-dark .form-section-title {
    color: #f1f5f9;
}

html.admin-theme-dark .form-section label,
html.admin-theme-dark .form-section label span {
    color: #e2e8f0;
}

html.admin-theme-dark .hint {
    color: #94a3b8;
}

html.admin-theme-dark .field-label {
    color: #e2e8f0;
}

html.admin-theme-dark code {
    background: #0f172a;
    color: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
}

html.admin-theme-dark .main-subtitle a {
    color: #60a5fa;
}

html.admin-theme-dark .settings-card {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

html.admin-theme-dark .settings-card h3,
html.admin-theme-dark .settings-card strong {
    color: #f8fafc;
}

html.admin-theme-dark .settings-card p {
    color: #94a3b8 !important;
}

html.admin-theme-dark .alert-success {
    background: #064e3b;
    color: #a7f3d0;
    border-color: #059669;
}

html.admin-theme-dark .sidebar-theme-toggle {
    border-color: #475569;
    background: #0f172a;
    color: #e2e8f0;
}

html.app-theme-dark .form-section {
    border-top-color: #334155;
}

html.app-theme-dark .form-section-title {
    color: #f1f5f9;
}

html.app-theme-dark .settings-card {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

html.app-theme-dark .settings-card p {
    color: #94a3b8 !important;
}

@media (prefers-color-scheme: dark) {
    html:not(.admin-theme-light):not(.app-theme-light) body {
        background: #0f172a;
        color: #e2e8f0;
    }

    html:not(.admin-theme-light):not(.app-theme-light) .card,
    html:not(.admin-theme-light):not(.app-theme-light) .table-card,
    html:not(.admin-theme-light):not(.app-theme-light) .metric-card {
        background: #1e293b;
        color: #e2e8f0;
        border-color: #334155;
    }

    html:not(.admin-theme-light):not(.app-theme-light) .main-title,
    html:not(.admin-theme-light):not(.app-theme-light) .text-input {
        color: #e2e8f0;
    }

    html:not(.admin-theme-light):not(.app-theme-light) .text-input {
        background: #0f172a;
        border-color: #475569;
    }

    html:not(.admin-theme-light):not(.app-theme-light) .text-muted {
        color: #94a3b8;
    }

    html:not(.admin-theme-light):not(.app-theme-light) .form-section-title {
        color: #f1f5f9;
    }

    html:not(.admin-theme-light):not(.app-theme-light) .settings-card {
        background: #1e293b !important;
        border-color: #334155 !important;
        color: #e2e8f0 !important;
    }

    html:not(.admin-theme-light):not(.app-theme-light) .settings-card p {
        color: #94a3b8 !important;
    }
}

.select-input {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    background: #fff;
    color: #111827;
}

.dialogs-sidebar {
    width: 320px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.dialogs-sidebar__title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}

.dialogs-sidebar__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialogs-sidebar__item {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px;
    background: #fff;
}

.dialogs-sidebar__item:hover {
    background: #f9fafb;
}

.dialogs-sidebar__item--active {
    border-color: var(--app-border-active);
    background: var(--app-surface-active);
}

.dialogs-sidebar__item-title {
    font-size: 13px;
    font-weight: 600;
}

.dialogs-sidebar__item-meta,
.dialogs-sidebar__item-preview {
    margin-top: 4px;
    font-size: 12px;
    color: #6b7280;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 980px) {
    .layout--app-detail {
        flex-direction: column;
    }
    .dialogs-sidebar {
        width: 100%;
        max-height: 280px;
    }
}

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

    .main {
        padding: 0;
    }

    .table-card {
        padding: 12px;
    }

    .table-card > .table {
        min-width: 640px;
        font-size: 12px;
    }

    .table-card .table td form {
        display: block;
        margin-left: 0 !important;
    }

    .table-card .table td .btn {
        width: 100%;
        text-align: center;
        margin-top: 6px;
    }

    .page-title {
        font-size: 1.2rem;
    }
}

@media (prefers-color-scheme: dark) {
    html:not(.admin-theme-light) .dialogs-sidebar {
        background: #0f172a;
        border-color: #334155;
    }
    html:not(.admin-theme-light) .dialogs-sidebar__title {
        color: #e2e8f0;
    }
    html:not(.admin-theme-light) .dialogs-sidebar__item {
        background: #111827;
        border-color: #334155;
        color: #e2e8f0;
    }
    html:not(.admin-theme-light) .dialogs-sidebar__item:hover {
        background: #1f2937;
    }
    html:not(.admin-theme-light) .dialogs-sidebar__item--active {
        border-color: var(--app-border-active);
        background: #1e293b;
    }
    html:not(.admin-theme-light) .dialogs-sidebar__item-meta,
    html:not(.admin-theme-light) .dialogs-sidebar__item-preview {
        color: #94a3b8;
    }
    html:not(.admin-theme-light) .app-list-item {
        border-color: #334155;
        background: #111827;
    }
}

/* ------------------------------------------------------------------------- */
/* PWA /app: переключатель темы (классы app-theme-dark | app-theme-light)    */
/* ------------------------------------------------------------------------- */

.app-theme-toggle {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    z-index: 10050;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.app-theme-toggle__icon {
    font-size: 16px;
    line-height: 1;
}

html.app-theme-dark .app-theme-toggle {
    border-color: #475569;
    background: #1e293b;
    color: #e5e7eb;
}

html.app-theme-dark {
    --app-primary: #38bdf8;
    --app-primary-hover: #0ea5e9;
    --app-primary-active: #0284c7;
    --app-primary-shadow: rgba(14, 165, 233, 0.35);
    --app-primary-shadow-hover: rgba(14, 165, 233, 0.45);
    --app-surface-active: rgba(56, 189, 248, 0.12);
    --app-border-active: #38bdf8;
}

html.app-theme-dark body {
    background: #0f172a;
    color: #e5e7eb;
}

html.app-theme-dark .page {
    background: transparent;
}

html.app-theme-dark .card {
    background: #1e293b;
    color: #e5e7eb;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

html.app-theme-dark .main-title {
    color: #f9fafb;
}

html.app-theme-dark .main-subtitle,
html.app-theme-dark .text-muted {
    color: #94a3b8;
}

html.app-theme-dark .btn-secondary {
    background: #334155;
    color: #e5e7eb;
    border-color: #475569;
}

html.app-theme-dark .btn-secondary:hover {
    background: #475569;
}

html.app-theme-dark .btn-primary {
    background: var(--app-primary);
    color: #fff;
}

html.app-theme-dark .btn-primary:hover {
    background: var(--app-primary-hover);
}

html.app-theme-dark .app-tile-link {
    background: #1e293b;
    border-color: #334155;
    color: #e5e7eb;
}

html.app-theme-dark .app-tile-link p {
    color: #94a3b8 !important;
}

html.app-theme-dark .app-tile-link strong {
    color: #f9fafb;
}

html.app-theme-dark .app-ticket-list .app-tile-link {
    background: #1e293b;
}

html.app-theme-dark .table-card,
html.app-theme-dark .metric-card {
    background: #1e293b;
    border-color: #334155;
    color: #e5e7eb;
}

html.app-theme-dark .text-input,
html.app-theme-dark input[type="text"],
html.app-theme-dark input[type="email"],
html.app-theme-dark input[type="password"],
html.app-theme-dark input[type="number"],
html.app-theme-dark textarea,
html.app-theme-dark select {
    background: #0f172a;
    border-color: #475569;
    color: #e5e7eb;
}

html.app-theme-dark .app-lk-role-strip .app-lk-card {
    background: #1e3a5f;
    border-color: #3b82f6;
    color: #e5e7eb;
}

html.app-theme-dark .app-lk-role-strip .app-lk-card p {
    color: #93c5fd !important;
}

html.app-theme-dark .app-lk-role-strip .app-lk-card--support {
    background: #064e3b;
    border-color: #10b981;
}

html.app-theme-dark .app-lk-role-strip .app-lk-card--support p {
    color: #6ee7b7 !important;
}

html.app-theme-dark .app-lk-role-strip .app-lk-card--admin {
    background: #422006;
    border-color: #f59e0b;
}

html.app-theme-dark .app-lk-role-strip .app-lk-card--admin p {
    color: #fcd34d !important;
}

html.app-theme-dark .app-push-block {
    background: #0c4a6e;
    border-color: #0369a1;
    color: #e0f2fe;
}

html.app-theme-dark .app-push-block__text {
    color: #bae6fd;
}

html.app-theme-dark .app-push-block__status {
    color: #94a3b8;
}

html.app-theme-dark .app-summary-card {
    background: var(--app-surface);
    border-color: var(--app-border);
    color: #e5e7eb;
}

html.app-theme-dark .app-summary-warning {
    background: #422006;
    border-color: #f59e0b;
    color: #fcd34d;
}

html.app-theme-dark .app-stat-panel {
    background: var(--app-surface);
    border-color: var(--app-border);
    color: #e5e7eb;
}

html.app-theme-dark .app-tile-subtitle {
    color: #94a3b8;
}

html.app-theme-dark .error {
    background: #450a0a;
    color: #fecaca;
    border-color: #991b1b;
}

html.app-theme-dark .alert-success {
    background: #064e3b;
    color: #a7f3d0;
    border-color: #059669;
}

html.app-theme-dark {
    --app-surface: #1e293b;
    --app-border: #334155;
    --consult-bubble-user: #1c3d6b;
    --consult-bubble-doctor: #334155;
    --consult-bubble-system: #422006;
}

.msg-bubble-staff {
    background: #e0f2fe;
}
.msg-bubble-user {
    background: #f3f4f6;
}
html.admin-theme-dark .msg-bubble-staff,
html.app-theme-dark .msg-bubble-staff {
    background: #0c4a6e;
    color: #e2e8f0;
}
html.admin-theme-dark .msg-bubble-user,
html.app-theme-dark .msg-bubble-user {
    background: #334155;
    color: #e2e8f0;
}
html.admin-theme-dark .support-msg-meta,
html.app-theme-dark .support-msg-meta {
    color: #94a3b8 !important;
}
html.admin-theme-dark .support-ticket-attach-link,
html.app-theme-dark .support-ticket-attach-link {
    color: #38bdf8;
}

/* --- PWA /app/tariffs: группы, плитки, навигация --- */

.app-tariffs-page .app-tariffs-layout-inner {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.app-tariffs-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.app-tariffs-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.app-tariffs-alert {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    line-height: 1.45;
}

.app-tariffs-alert--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.app-tariffs-alert--warn {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.app-tariffs-alert--info {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.app-tariffs-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

@media (min-width: 900px) {
    .app-tariffs-body {
        flex-direction: row;
        align-items: flex-start;
        gap: 28px;
    }

    .app-tariffs-nav {
        flex: 0 0 200px;
        position: sticky;
        top: max(16px, env(safe-area-inset-top, 0px));
    }

    .app-tariffs-main {
        flex: 1;
        min-width: 0;
    }
}

.app-tariffs-nav {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
}

.app-tariffs-nav-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 10px;
}

.app-tariffs-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.app-tariffs-nav-list li {
    margin: 0 0 6px;
}

.app-tariffs-nav-list a {
    color: #2563eb;
    text-decoration: none;
    font-size: 0.9rem;
}

.app-tariffs-nav-list a:hover {
    text-decoration: underline;
}

.app-tariffs-main {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.app-tariffs-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px 22px;
}

.app-tariffs-card-title {
    margin: 0 0 12px;
    font-size: 1.05rem;
    font-weight: 600;
}

.app-tariffs-summary-line {
    margin: 0 0 8px;
}

.app-tariffs-summary-meta {
    margin: 0;
    color: #64748b;
    font-size: 0.95rem;
}

.app-tariffs-summary-actions {
    margin: 16px 0 0;
}

.app-tariffs-section-title {
    margin: 0 0 14px;
    font-size: 1.15rem;
    font-weight: 600;
    color: #0f172a;
}

.app-tariffs-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.app-tariffs-tile {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.app-tariffs-tile-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.app-tariffs-tile-name {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
}

.app-tariffs-badge {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 500;
}

.app-tariffs-tile-desc {
    margin: 0 0 10px;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.45;
}

.app-tariffs-tile-desc p {
    margin: 0 0 0.5em;
}

.app-tariffs-tile-desc p:last-child {
    margin-bottom: 0;
}

.app-tariffs-tile-desc ul,
.app-tariffs-tile-desc ol {
    margin: 0.35em 0 0.5em;
    padding-left: 1.25em;
}

.app-tariffs-tile-desc a {
    color: var(--app-primary, #2563eb);
}

.app-tariffs-tile-desc h1,
.app-tariffs-tile-desc h2,
.app-tariffs-tile-desc h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.5em 0 0.35em;
    color: #475569;
}

.app-tariffs-tile-prices {
    margin: 0 0 12px;
    font-size: 0.95rem;
    color: #334155;
}

.app-tariffs-price-main {
    font-weight: 700;
    font-size: 1.1rem;
}

.app-tariffs-price-unit {
    color: #64748b;
    margin-left: 2px;
}

.app-tariffs-price-year {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
    color: #64748b;
}

.app-tariffs-tile-link {
    margin: 0 0 12px;
}

.app-tariffs-tile-more {
    display: inline-block;
}

.app-tariffs-tile-form {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}

.app-tariffs-period {
    border: none;
    margin: 0 0 12px;
    padding: 0;
}

.app-tariffs-period-legend {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
    padding: 0;
}

.app-tariffs-radio {
    margin-right: 14px;
    font-size: 0.9rem;
    cursor: pointer;
}

.app-tariffs-pay-btn {
    width: 100%;
}

.app-tariffs-card--footer {
    padding: 16px 22px;
}

.app-tariffs-footer-promo {
    margin: 0;
}

@media (max-width: 899px) {
    .app-tariffs-section {
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 16px;
        background: #fafafa;
    }

    .app-tariffs-tiles {
        margin-top: 12px;
    }

    .app-tariffs-tile {
        background: #fff;
    }
}

html.app-theme-dark .app-tariffs-card,
html.app-theme-dark .app-tariffs-nav,
html.app-theme-dark .app-tariffs-tile {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

html.app-theme-dark .app-tariffs-section {
    background: #0f172a;
    border-color: #334155;
}

html.app-theme-dark .app-tariffs-section-title,
html.app-theme-dark .app-tariffs-tile-name {
    color: #f1f5f9;
}

html.app-theme-dark .app-tariffs-tile-desc,
html.app-theme-dark .app-tariffs-tile-desc p,
html.app-theme-dark .app-tariffs-tile-desc li,
html.app-theme-dark .app-tariffs-summary-meta,
html.app-theme-dark .app-tariffs-price-year,
html.app-theme-dark .app-tariffs-price-unit {
    color: #94a3b8;
}

html.app-theme-dark .app-tariffs-tile-desc a {
    color: #38bdf8;
}

html.app-theme-dark .app-tariffs-tile-desc h1,
html.app-theme-dark .app-tariffs-tile-desc h2,
html.app-theme-dark .app-tariffs-tile-desc h3 {
    color: #cbd5e1;
}

html.app-theme-dark .app-tariffs-nav-list a {
    color: #38bdf8;
}

html.app-theme-dark .app-tariffs-alert--info {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

/* ------------------------------------------------------------------------- */
/* PWA: консультации клиента — список, форма, чат                             */
/* ------------------------------------------------------------------------- */

.layout--app-narrow .btn-primary,
.layout--app-narrow .btn-secondary {
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.app-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.app-breadcrumb__link {
    color: var(--app-primary);
    text-decoration: none;
    padding: 4px 2px;
    border-radius: 4px;
}

.app-breadcrumb__link:hover {
    text-decoration: underline;
}

.app-breadcrumb__link:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

.app-breadcrumb__sep {
    color: #9ca3af;
    user-select: none;
}

.app-breadcrumb__current {
    color: #6b7280;
    font-weight: 500;
}

.app-consult-list {
    list-style: none;
    padding: 0;
    margin: 20px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-consult-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 18px;
    min-height: 76px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.app-consult-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.08);
}

.app-consult-card:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

.app-consult-card:active {
    background: #f9fafb;
}

.app-consult-card__body {
    flex: 1;
    min-width: 0;
}

.app-consult-card__title {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.app-consult-card__meta {
    display: block;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 8px;
}

.app-consult-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.app-consult-card__chevron {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 20px;
    line-height: 1;
    color: #6b7280;
    font-weight: 400;
    background: #f3f4f6;
    border-radius: 9999px;
}

.app-status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
}

.app-status-badge--new {
    background: #f3f4f6;
    color: #374151;
}

.app-status-badge--in_progress {
    background: #dbeafe;
    color: #1e40af;
}

.app-status-badge--waiting_doctor {
    background: #fef3c7;
    color: #92400e;
}

.app-status-badge--closed {
    background: #d1fae5;
    color: #065f46;
}

.app-status-badge--default {
    background: #f3f4f6;
    color: #374151;
}

.app-empty-state {
    margin-top: 28px;
    padding: 28px 20px;
    text-align: center;
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 12px;
}

.app-empty-state__icon {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 12px;
}

.app-empty-state__title {
    font-size: 17px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px 0;
}

.app-empty-state__text {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 20px 0;
    line-height: 1.5;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.app-empty-state .btn-primary {
    width: 100%;
    max-width: 280px;
    justify-content: center;
}

.app-form-card {
    margin-top: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.app-form-hint {
    margin: 8px 0 0 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.45;
}

.app-form-hint-box {
    margin-top: 12px;
    padding: 12px 14px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    font-size: 13px;
    color: #0c4a6e;
    line-height: 1.45;
}

.app-alert {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
}

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

.app-alert--info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
}

.app-alert--warn {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.app-choice-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.app-choice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s ease, background 0.15s ease;
    min-height: 48px;
}

.app-choice:has(input:checked) {
    border-color: var(--app-primary);
    background: #eff6ff;
}

.app-choice input {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.app-choice__text {
    font-size: 15px;
    line-height: 1.4;
    color: #111827;
}

.app-form-actions {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-form-actions .btn-primary {
    width: 100%;
    justify-content: center;
    font-size: 15px;
    padding: 12px 20px;
}

.app-chat-panel {
    margin-top: 20px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    min-height: 320px;
    overflow: hidden;
}

.app-chat-panel__head {
    margin: 0;
    padding: 14px 16px;
    font-size: 1.05rem;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
}

.app-chat-panel__msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: min(50vh, 420px);
    -webkit-overflow-scrolling: touch;
}

.app-chat-panel__compose {
    padding: 14px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}

.app-chat-panel__compose .btn-primary {
    width: 100%;
    justify-content: center;
}

.client-consult-msg {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.client-consult-msg--user {
    background: #e3f2fd;
}

.client-consult-msg--doctor {
    background: #f3f4f6;
}

.client-consult-msg--system {
    background: #fffbeb;
}

.client-consult-msg__head {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
}

.app-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 8px;
    font-size: 14px;
    color: #4b5563;
}

.app-meta-row strong {
    color: #111827;
}

.app-action-bar {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.app-action-bar .btn-primary,
.app-action-bar .btn-secondary {
    flex: 1 1 auto;
    min-width: min(100%, 160px);
    justify-content: center;
}

.app-rating-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.app-rating-choice {
    cursor: pointer;
    min-height: 48px;
    min-width: 56px;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 15px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.app-rating-choice:has(input:checked) {
    border-color: var(--app-primary);
    background: #eff6ff;
}

.app-rating-choice input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

html.app-theme-dark .app-breadcrumb__current {
    color: #94a3b8;
}

html.app-theme-dark .app-consult-card {
    background: #1e293b;
    border-color: #334155;
}

html.app-theme-dark .app-consult-card:hover {
    border-color: #38bdf8;
}

html.app-theme-dark .app-consult-card__title {
    color: #f9fafb;
}

html.app-theme-dark .app-consult-card__meta {
    color: #94a3b8;
}

html.app-theme-dark .app-empty-state {
    background: #111827;
    border-color: #475569;
}

html.app-theme-dark .app-form-card,
html.app-theme-dark .app-chat-panel {
    background: #1e293b;
    border-color: #334155;
}

html.app-theme-dark .app-chat-panel__compose {
    background: #0f172a;
}

html.app-theme-dark .app-choice {
    background: #1e293b;
    border-color: #475569;
}

html.app-theme-dark .app-choice:has(input:checked) {
    background: #1e3a5f;
}

html.app-theme-dark .client-consult-msg--user {
    background: #1e3a5f;
}

html.app-theme-dark .client-consult-msg--doctor {
    background: #334155;
}

html.app-theme-dark .client-consult-msg--system {
    background: #422006;
}

html.app-theme-dark .app-page-lead {
    background: linear-gradient(135deg, #0c4a6e 0%, #1e3a5f 100%);
    border-color: #334155;
    color: #bae6fd;
}

html.app-theme-dark .app-page-lead strong {
    color: #e0f2fe;
}

html.app-theme-dark .app-mobile-cta-bar {
    background: rgba(15, 23, 42, 0.96);
    border-color: #334155;
}

html.app-theme-dark .app-consult-card__chevron {
    background: #334155;
    color: #94a3b8;
}

html.app-theme-dark .app-pay-item {
    background: #0f172a;
    border-color: #334155;
}

html.app-theme-dark .app-pay-item__title {
    color: #f9fafb;
}

@media (max-width: 640px) {
    .app-chat-panel--live .app-chat-panel__compose {
        position: sticky;
        bottom: 0;
        z-index: 2;
        box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.06);
    }
}

/* Consultation detail: readable header + summary */
.app-consult-header {
    margin-bottom: 20px;
}

.app-consult-header__title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.app-consult-header__title {
    margin: 0;
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    line-height: 1.25;
    flex: 1 1 200px;
}

.app-consult-header__back {
    flex: 0 0 auto;
    min-width: 120px;
}

.app-consult-summary {
    margin: 0 0 14px 0;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    display: grid;
    gap: 12px;
}

.app-consult-summary__row {
    display: grid;
    grid-template-columns: minmax(88px, 110px) 1fr;
    gap: 8px 16px;
    align-items: center;
}

.app-consult-summary__label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.app-consult-summary__value {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: #111827;
    line-height: 1.4;
}

.app-consult-header__hint {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #4b5563;
}

.app-section-heading {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.app-form-hint--flush {
    margin-top: 0;
}

.app-action-bar--tight {
    margin-top: 10px;
    margin-bottom: 0;
}

.app-field--flush {
    margin-top: 0;
}

.app-field__file-input {
    display: block;
    width: 100%;
    margin-top: 8px;
    font-size: 15px;
}

.app-alert--in-panel {
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
}

.app-chat-empty {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

.client-consult-msg__role {
    font-weight: 600;
    color: #374151;
}

.client-consult-msg__time {
    color: #6b7280;
}

.client-consult-msg__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 10px;
}

.client-consult-msg-body {
    font-size: 15px;
    line-height: 1.5;
    color: #111827;
}

.client-consult-msg__attach {
    margin: 8px 0 0 0;
}

html.app-theme-dark .app-consult-summary {
    background: #0f172a;
    border-color: #334155;
}

html.app-theme-dark .app-consult-summary__label {
    color: #94a3b8;
}

html.app-theme-dark .app-consult-summary__value {
    color: #f9fafb;
}

html.app-theme-dark .app-consult-header__hint {
    color: #94a3b8;
}

html.app-theme-dark .client-consult-msg-body {
    color: #f3f4f6;
}

html.app-theme-dark .client-consult-msg__role {
    color: #e5e7eb;
}

/* Consultation attachment preview + lightbox (object-fit: contain) */
.consult-attach-thumb {
  display: inline-block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  max-width: 100%;
}
.consult-attach-thumb img {
  display: block;
  max-width: min(100%, 280px);
  max-height: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}
.consult-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.88);
  box-sizing: border-box;
}
.consult-lightbox[hidden] { display: none !important; }
.consult-lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
}
.consult-lightbox__close {
  position: absolute;
  top: 12px;
  right: 16px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}
