.clinics-add-toggle-wrap {
    margin-top: 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: flex-end;
}

.clinics-add-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    border-width: 1px;
    background: rgba(15, 23, 42, 0.8);
}

.clinics-add-toggle-btn .icon {
    width: 14px;
    height: 14px;
}

.clinics-add-section {
    display: none;
    padding: 20px 20px 18px;
    border-radius: 18px;
    background: radial-gradient(circle at top left, rgba(37,99,235,0.15), transparent 55%),
                radial-gradient(circle at bottom right, rgba(147,197,253,0.12), transparent 55%),
                var(--glass-bg);
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(18px) saturate(190%);
    -webkit-backdrop-filter: blur(18px) saturate(190%);
}

.clinics-add-section.clinics-add-open {
    display: block;
}

/* Временно убираем форму добавления клиники из каталога */
.clinics-add-toggle-wrap,
.clinics-add-section {
    display: none !important;
}

.clinic-add-modal {
    max-width: 520px;
}

.clinic-add-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.clinics-add-title {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #e5e7eb;
}

.clinics-add-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px 14px;
}

@media (min-width: 640px) {
    .clinics-add-form {
        grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    }
    .clinics-add-field:nth-child(1),
    .clinics-add-field:nth-child(2) {
        grid-column: 1 / -1;
    }
    .clinics-add-field:nth-child(6) {
        grid-column: 1 / -1;
    }
    .clinics-add-submit {
        grid-column: 1 / -1;
        justify-self: flex-end;
    }
}

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

.clinics-add-field span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.clinics-add-field input,
.clinics-add-field select {
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: rgba(15, 23, 42, 0.9);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.08s ease;
}

.clinics-add-field input::placeholder,
.clinics-add-field select::placeholder {
    color: var(--text-light);
}

.clinics-add-field input:focus,
.clinics-add-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
    background: rgba(15, 23, 42, 0.96);
}

.clinics-add-field input[type="number"] {
    -moz-appearance: textfield;
}
.clinics-add-field input[type="number"]::-webkit-outer-spin-button,
.clinics-add-field input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.clinics-add-field.clinics-add-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.clinics-add-field.clinics-add-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

.clinics-add-submit {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-inline: 16px;
    font-size: 14px;
    border-radius: 999px;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.55);
}

.clinics-add-submit .icon {
    width: 16px;
    height: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --primary-lighter: #eff6ff;
    --secondary: #0f172a;
    --secondary-light: #e0e7ff;
    --bg: #ffffff;
    --card-bg: #ffffff;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --text-lighter: #d1d5db;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --error: #dc2626;
    --error-light: #fee2e2;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --risk-medium: #ea580c;
    --risk-medium-light: #ffedd5;
    --accent: #6366f1;
    /* Дополнительная палитра для красочного оформления */
    --color-violet: #7c3aed;
    --color-violet-bg: #ede9fe;
    --color-teal: #0d9488;
    --color-teal-bg: #ccfbf1;
    --color-amber: #d97706;
    --color-amber-bg: #fef3c7;
    --color-rose: #e11d48;
    --color-rose-bg: #ffe4e6;
    --color-emerald: #059669;
    --color-emerald-bg: #d1fae5;
    --color-indigo: #4f46e5;
    --color-indigo-bg: #e0e7ff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 3px 12px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.35);
    --bg-grad-1: #f0f4ff;
    --bg-grad-2: #ffffff;
    --bg-grad-3: #f0fdf9;
    color-scheme: light;
}

html {
    height: 100%;
}

html, body {
    min-height: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
    background-color: var(--bg);
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

/* Скрыть полосу прокрутки везде */
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.app-shell::-webkit-scrollbar,
.container::-webkit-scrollbar,
main::-webkit-scrollbar,
*::-webkit-scrollbar {
    display: none;
}

html, body, .app-shell, .container, main,
.admin-chat-messages {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body {
    height: 100%;
}

/* Убираем синюю подсветку при нажатии/фокусе по всему приложению */
button,
a,
[role="button"],
input[type="submit"],
input[type="button"] {
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}
button:focus,
button:focus-visible,
a:focus,
a:focus-visible,
[role="button"]:focus,
[role="button"]:focus-visible {
    outline: none;
}

/* Выравнивание иконок по всему приложению */
svg.icon,
.icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    fill: currentColor;
    color: inherit;
}
svg.icon {
    object-fit: contain;
    object-position: center;
}

.app-shell {
    min-height: 100vh;
    min-height: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.4s ease;
}

.app-shell.app-shell-visible {
    opacity: 1;
    visibility: visible;
}

.app-shell.app-shell-fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Background particles layer — above body bg, below content */
.particles-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.particles-bg .particle {
    position: absolute;
    left: 0;
    bottom: 0;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.55);
    animation: particleFloat linear infinite;
    will-change: transform;
}

@keyframes particleFloat {
    from {
        transform: translateY(0);
        opacity: 0.5;
    }
    to {
        transform: translateY(-120vh);
        opacity: 0;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', Oxygen, Ubuntu, Cantarell, sans-serif;
    background:
        radial-gradient(1400px 700px at 15% -5%, rgba(37, 99, 235, 0.18) 0%, rgba(124, 58, 237, 0.06) 45%, transparent 60%),
        radial-gradient(1000px 550px at 88% 15%, rgba(13, 148, 136, 0.1) 0%, rgba(124, 58, 237, 0.06) 50%, transparent 55%),
        linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 40%, var(--bg-grad-3) 100%);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    letter-spacing: 0;
    overscroll-behavior-y: none;
    font-weight: 600;
}

.container {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    min-width: 0;
    max-width: min(980px, 100vw);
    margin: 0 auto;
    width: 100%;
    padding: 24px;
    /* Компенсируем фиксированную шапку: базово без отступа */
    padding-top: 0;
    animation: fadeIn 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    /* Отступ снизу, чтобы контент был виден до конца над нижним баром */
    padding-bottom: 140px;
}

.more-section-logout {
    margin-top: 8px;
}
.more-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Экран загрузки при старте (4 сек) */
.app-loading {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Мягкий градиентный фон для экрана загрузки */
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.26), transparent 55%),
        radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.26), transparent 55%),
        linear-gradient(135deg, #eef2ff 0%, #eff6ff 40%, #f5f3ff 100%);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

/* Вариант градиента для тёмного режима */
body.dark-mode .app-loading {
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.24), transparent 55%),
        radial-gradient(circle at bottom right, rgba(129, 140, 248, 0.28), transparent 55%),
        radial-gradient(circle at center, rgba(15, 23, 42, 0.8), #020617 70%);
}

.app-loading[aria-hidden="true"] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-loading-inner {
    text-align: center;
    padding: 32px;
}

.app-loading-icon {
    width: 72px;
    height: 72px;
    color: var(--primary);
    animation: scan-pulse 2.4s ease-in-out infinite;
}

.app-loading-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.app-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: loadingDot 1.2s ease-in-out infinite both;
}

.app-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.app-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes loadingDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* OralAI — моноширинный, жирный, синий как кнопка */
.brand-name {
    font-family: "JetBrains Mono", "SF Mono", Monaco, Consolas, monospace;
    font-weight: 800;
    color: #2563eb;
    letter-spacing: -0.02em;
}

body.dark-mode .brand-name {
    color: #60a5fa;
}

/* Auth page: login / register */
.auth-page {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    transition: opacity 0.4s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.4s ease;
}

.auth-page.auth-fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

html.no-scroll,
body.no-scroll {
    overflow-y: hidden;
}

/* Главный экран: полностью заблокировать скролл и сдвиг (нельзя двигать) */
html.home-no-scroll,
body.home-no-scroll {
    overflow: hidden !important;
    touch-action: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
}

body.home-no-scroll .app-shell {
    overflow: hidden;
    touch-action: none;
}

/* Страница «Ближайшие клиники»: не растягивается при скролле — высота по экрану, скролл только у списка */
html.tools-page-active,
body.tools-page-active {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
}
/* Страница «Клиники»: ведём себя так же, как дневник — фиксированная высота приложения и скролл внутри окна */
body.tools-page-active .app-shell {
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.tools-page-active .app-shell .container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
body.tools-page-active .app-shell main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
body.tools-page-active #tools-page.page.active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Страница «Дневник»: заголовок фиксирован, записи в отдельном окне со своим скроллом */
html.diary-page-active,
body.diary-page-active {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
}
body.diary-page-active .app-shell {
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.diary-page-active .app-shell .container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
body.diary-page-active .app-shell main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
body.diary-page-active #diary-page.page.active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.diary-page-active #diary-page .page-back-header {
    flex-shrink: 0;
}
.diary-window {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: 80px;
}
body.diary-page-active .diary-window {
    margin-top: 0;
}
.diary-window .diary-grid,
.diary-window .empty-state {
    margin-bottom: 16px;
}
.diary-window .diary-bottom-actions {
    margin-top: 8px;
    margin-bottom: 0;
    padding-bottom: 8px;
}

.auth-page[aria-hidden="true"] {
    display: none;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    box-shadow: none;
    border: 1px solid var(--glass-border);
}

body.dark-mode .auth-card {
    background: var(--glass-bg);
    border-color: var(--glass-border);
}

/* Terms of use page (after first registration) */
.terms-page {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

body.dark-mode .terms-page {
    background: rgba(0, 0, 0, 0.55);
}

.terms-page[aria-hidden="true"] {
    display: none;
}

.terms-card {
    width: 100%;
    max-width: 400px;
    max-height: min(440px, calc(100vh - 32px));
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: 16px;
    padding: 0;
    border: 1px solid var(--border);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.03),
        0 2px 4px rgba(0, 0, 0, 0.04),
        0 12px 24px rgba(0, 0, 0, 0.08),
        0 24px 48px rgba(0, 0, 0, 0.06);
}

body.dark-mode .terms-card {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 12px 24px rgba(0, 0, 0, 0.3),
        0 24px 48px rgba(0, 0, 0, 0.2);
}

.terms-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 14px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to bottom, rgba(37, 99, 235, 0.04), transparent 100%);
}

body.dark-mode .terms-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
    background: linear-gradient(to bottom, rgba(59, 130, 246, 0.08), transparent 100%);
}

.terms-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--text);
}

body.dark-mode .terms-title {
    color: #f1f5f9;
}

.terms-close-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.terms-close-btn:hover {
    background: var(--border-light);
    color: var(--text);
}

body.dark-mode .terms-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

.terms-close-icon {
    width: 20px;
    height: 20px;
}

.terms-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 18px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
    -webkit-overflow-scrolling: touch;
}

.terms-body::-webkit-scrollbar {
    width: 6px;
    display: block;
}

.terms-body::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 3px;
}

.terms-body::-webkit-scrollbar-thumb {
    background: var(--text-lighter);
    border-radius: 3px;
}

.terms-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

body.dark-mode .terms-body {
    color: #e2e8f0;
}

body.dark-mode .terms-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
}

body.dark-mode .terms-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

body.dark-mode .terms-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.terms-body p {
    margin: 0 0 10px;
}

.terms-body p:last-child {
    margin-bottom: 0;
}

.terms-doc-section {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.terms-doc-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

body.dark-mode .terms-doc-section {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.terms-doc-heading {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0 0 10px;
    color: var(--primary);
}

body.dark-mode .terms-doc-heading {
    color: #93c5fd;
}

.terms-doc-content {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
}

body.dark-mode .terms-doc-content {
    color: #e2e8f0;
}

.terms-doc-content p {
    margin: 0 0 8px;
}

.terms-doc-content p:last-child {
    margin-bottom: 0;
}

.terms-actions {
    flex-shrink: 0;
    padding: 14px 18px 18px;
    border-top: 1px solid var(--border);
}

body.dark-mode .terms-actions {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.terms-accept-btn {
    width: 100%;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.terms-accept-btn:hover {
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.auth-brand {
    text-align: center;
    margin-bottom: 24px;
}

.auth-brand-icon {
    width: 48px;
    height: 48px;
    color: var(--primary);
    margin-bottom: 12px;
}

.auth-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-radius: var(--radius);
    background: var(--primary-lighter);
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab:hover {
    color: var(--text);
}

.auth-tab.active {
    background: var(--bg);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.auth-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-input::placeholder {
    color: var(--text-light);
}

.auth-submit {
    width: 100%;
    margin-top: 8px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-error {
    font-size: 13px;
    color: var(--error);
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--error-light);
    border-radius: var(--radius);
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 0;
}

.auth-link {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    padding: 0;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-forgot-wrap {
    margin-top: 10px;
    margin-bottom: 0;
    text-align: center;
}

.auth-link-forgot {
    font-size: 13px;
}

.auth-reset-block {
    margin-top: 0;
}

.auth-reset-title {
    font-size: 15px;
    margin-bottom: 14px;
    color: var(--text);
}

.auth-reset-hint {
    font-size: 13px;
    color: var(--text-muted, #9ca3af);
    margin-bottom: 12px;
}

main {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    min-width: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: none;
    margin: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    /* Glass effect */
    background: var(--glass-bg);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    height: 80px;
    padding: 12px 16px 25px;
    border-top: 1px solid var(--glass-border);
    border-radius: 0;
    z-index: 1000;
    gap: 4px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    overflow: visible;
}

.bottom-nav .nav-btn {
    cursor: pointer;
    pointer-events: auto;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    flex: 0 0 auto;
    width: 52px;
    min-height: 56px;
    max-width: none;
    position: relative;
    overflow: visible;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto;
    color: var(--text-secondary);
    user-select: none;
    -webkit-user-select: none;
}

/* All bar buttons на одной высоте по центру */
.bottom-nav .nav-btn {
    transform: none;
}


.nav-btn:not(.initialized) {
    animation: buttonFadeIn 0.25s cubic-bezier(0.25, 0.1, 0.25, 1) backwards;
}

.nav-btn:nth-child(1) { animation-delay: 0.05s; }
.nav-btn:nth-child(2) { animation-delay: 0.1s; }
.nav-btn:nth-child(3) { animation-delay: 0.15s; }
.nav-btn:nth-child(4) { animation-delay: 0.2s; }
.nav-btn:nth-child(5) { animation-delay: 0.25s; }

@keyframes buttonFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* Высокие иконки в баре (растянуты по высоте) */
.nav-btn .icon {
    width: 32px;
    height: 48px;
    margin-bottom: 0;
    margin-right: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.nav-btn span {
    display: none !important;
}

.nav-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.15);
    transform: scale(0);
    animation: rippleEffect 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.nav-btn {
    overflow: hidden;
}

.nav-btn.active .ripple {
    background: rgba(255, 255, 255, 0.2);
}

@keyframes rippleEffect {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

.nav-btn:hover:not(.active) {
    /* Без голубого подсвечивания при hover */
    background: transparent;
    color: var(--text-secondary);
}

.nav-btn:hover:not(.active) .icon {
    transform: scale(1.1);
}

.nav-btn:hover:not(.active) span,
.nav-btn:active span,
.nav-btn:focus span,
.nav-btn:focus-visible span {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.nav-btn.deactivating {
    /* Плавный переход через transition */
    opacity: 1 !important;
    visibility: visible !important;
}

/* Убираем голубой фон/outline при наведении, фокусе и нажатии для кнопок нижнего бара */
.bottom-nav .nav-btn,
.bottom-nav .nav-btn:hover,
.bottom-nav .nav-btn:active,
.bottom-nav .nav-btn:focus,
.bottom-nav .nav-btn:focus-visible {
    outline: none;
    background: transparent;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn.activating {
    /* Плавный переход через transition */
    opacity: 1 !important;
    visibility: visible !important;
}

.nav-btn.active {
    background: transparent;
    color: var(--text-secondary) !important;
    box-shadow: none;
    transform: none;
    pointer-events: auto;
    opacity: 1 !important;
    visibility: visible !important;
}

.nav-btn.active span {
    display: none !important;
}

.nav-btn.active::before {
    display: none;
}



.nav-btn .icon {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1 !important;
    visibility: visible !important;
    color: var(--text-secondary);
}

.nav-btn.active .icon {
    transform: none;
    filter: none;
    opacity: 1 !important;
    visibility: visible !important;
    color: var(--primary) !important;
}

/* Center (home) button — без кружка, как остальные иконки */
.bottom-nav .nav-btn[data-page="home"] {
    transform: translateY(0px);
    width: 60px;
    min-height: 60px;
}

.bottom-nav .nav-btn[data-page="home"] .icon {
    width: 32px;
    height: 48px;
    background: none;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

.bottom-nav .nav-btn[data-page="home"].active .icon {
    color: var(--primary) !important;
    filter: none;
}

.bottom-nav .nav-btn[data-page="home"] span {
    color: var(--text) !important;
}

.bottom-nav .nav-btn[data-page="home"] span {
    font-size: 12px;
    font-weight: 700;
}

body.dark-mode .bottom-nav .nav-btn[data-page="home"] span {
    color: var(--text) !important;
}



.page {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.2s cubic-bezier(0.25, 0.1, 0.25, 1), 
                transform 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    /* Скролл теперь общий для всей страницы, а не вложенный */
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* Отступ сверху для страниц (шапка убрана) */
.page:not(#home-page) {
    padding-top: 56px;
}

.page.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
    min-height: auto;
}

/* Страница клиник: верх статичный, скроллится только список */
#tools-page.page.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Верх страницы клиник не скроллится — только список карточек */
#tools-page .page-back-header {
    flex-shrink: 0;
}

#tools-page .clinics-filters-container {
    flex-shrink: 0;
}

#tools-page #clinics-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: 92px; /* отступ под бар (80px бар + 12px) — край списка над баром */
    overscroll-behavior-y: contain;
}

/* Профиль — контент задаёт высоту, страница листается до конца (body scroll) */
body.profile-page-active .app-shell .container {
    flex: none;
}
body.profile-page-active .app-shell main {
    flex: none;
}
#profile-page.page.active {
    align-self: flex-start;
    width: 100%;
}

/* Единый отступ под заголовком страницы */
.page > .hero,
.page > .result-header,
.page > .diary-header,
.page > .page-back-header,
.page > h2:first-child {
    margin-top: 0;
    margin-bottom: 24px;
}
.page > .hero,
.page > .result-header,
.page > .diary-header,
.page > h2:first-child {
    text-align: center;
}

.page.fade-in {
    animation: fadeInSlide 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

.page.fade-out {
    animation: fadeOutSlide 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutSlide {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-16px);
    }
}

h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
    letter-spacing: -0.3px;
    line-height: 1.3;
}

h3 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.2px;
    line-height: 1.4;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.3px;
}

.hero h2 {
    margin-bottom: 4px;
}

.hero h2 .icon {
    color: var(--primary);
}

.hero .subtitle {
    margin-bottom: 0;
    max-width: 52ch;
}

/* ——— Сканирование (главная страница) ——— */

.scan-page {
    position: relative;
    flex-direction: column;
}

/* Главная (scan-page) должна быть видима только когда активна страница */
.page.active.scan-page {
    display: flex;
}

#home-page {
    padding-top: 385px;
    max-width: 100%;
    overflow-x: hidden;
    min-width: 0; /* не даём flex-элементу растягивать контейнер */
}

.scan-page::before {
    content: '';
    position: absolute;
    inset: -24px -24px auto;
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 55%),
                radial-gradient(circle at top right, rgba(56, 189, 248, 0.16), transparent 55%);
    pointer-events: none;
    z-index: -1;
}

/* Текст «AI-сканирование ротовой полости» на главной */
.home-title-circle {
    --circle-size: 200px;
    width: var(--circle-size);
    height: var(--circle-size);
    border-radius: 50%;
    background: linear-gradient(165deg,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(255, 255, 255, 0.88) 45%,
        rgba(219, 234, 254, 0.5) 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(37, 99, 235, 0.18);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.6) inset,
        0 4px 20px rgba(37, 99, 235, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 28px;
    padding: 24px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.home-title-circle::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(
        circle 70% at 50% 25%,
        rgba(255, 255, 255, 0.5) 0%,
        transparent 55%
    );
    pointer-events: none;
}

.home-title-circle-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    line-height: 1.4;
    letter-spacing: 0.02em;
    position: relative;
    z-index: 1;
    max-width: 100%;
}

body.dark-mode .home-title-circle {
    background: linear-gradient(165deg,
        rgba(30, 41, 59, 0.9) 0%,
        rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.2) inset,
        0 4px 24px rgba(37, 99, 235, 0.2),
        0 2px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .home-title-circle::before {
    background: radial-gradient(
        circle 65% at 50% 30%,
        rgba(59, 130, 246, 0.08) 0%,
        transparent 55%
    );
}

.scan-hero {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    text-align: center;
    position: relative;
    min-height: 260px;
}

/* Заголовок в верхней части главной страницы — как у названий страниц */
.hero-masthead-title {
    position: fixed;
    top: 28px;
    left: 0;
    right: 0;
    z-index: 2;
    margin: 0;
    padding: 20px 20px 24px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    color: var(--text);
    pointer-events: none;
}

.scan-bottom {
    position: relative;
    margin-top: auto;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scan-bottom-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scan-chat-layer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 120px;
    max-height: 55vh;
    gap: 6px;
    pointer-events: none;
    overflow-x: hidden;
    overflow-y: auto;
}

.scan-chat-layer .scan-chat-bubble:not(:first-child),
.scan-chat-layer .scan-chat-bubble-secondary {
    pointer-events: auto;
    animation: chat-bubble-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

/* При возврате на главную не показывать пузыри заново (без повторной анимации) */
.scan-page.no-chat-animation .scan-chat-layer .scan-chat-bubble:not(:first-child),
.scan-page.no-chat-animation .scan-chat-layer .scan-chat-bubble-secondary {
    animation: none;
    opacity: 1;
    transform: translateY(0);
}

.scan-chat-layer .scan-chat-bubble:nth-child(2),
.scan-chat-layer .scan-chat-bubble-secondary:nth-child(2) { animation-delay: 0.5s; }
.scan-chat-layer .scan-chat-bubble:not(#analyzing-bubble):nth-child(3) { animation-delay: 0.85s; }

/* Плавное появление нового сообщения (например «Принял! Анализирую...») */
.scan-chat-bubble-enter {
    opacity: 0;
    transform: translateY(20px) translateX(-16px);
    animation: chat-bubble-rise-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes chat-bubble-rise {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes chat-bubble-rise-in {
    from {
        opacity: 0;
        transform: translateY(20px) translateX(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateX(0);
    }
}

/* Сообщения вытесняются вверх за счёт flex (justify-content: flex-end), без провала вниз */

/* Новое сообщение — в потоке, вытесняет предыдущие вверх */

#analyzing-bubble.scan-chat-bubble-new-enter {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#analyzing-bubble.scan-chat-bubble-new-visible {
    opacity: 1;
    transform: translateY(0);
}

#error-chat-bubble.scan-chat-bubble-new-enter {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#error-chat-bubble.scan-chat-bubble-new-visible {
    opacity: 1;
    transform: translateY(0);
}

.scan-chat-bubble-error {
    background: var(--error-light);
    border-color: var(--error);
    color: var(--error);
    white-space: pre-line;
    font-weight: 500;
}
.scan-chat-bubble-error,
.scan-chat-bubble-error * {
    color: var(--error) !important;
}

.scan-chat-bubble {
    align-self: flex-start;
    max-width: 78%;
    background: var(--glass-bg);
    border-radius: 18px 18px 18px 6px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 14px;
    color: var(--text);
    box-shadow: none;
    border: 1px solid var(--glass-border);
    position: relative;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), padding 0.35s ease, min-height 0.35s ease, max-width 0.35s ease, border-radius 0.35s ease, background 0.35s ease, border-color 0.35s ease;
}

.scan-chat-bubble::before {
    content: none;
}

/* Курсор при эффекте печати в левых пузырях */
.scan-chat-bubble .typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 1px;
    background: currentColor;
    vertical-align: text-bottom;
    animation: typing-cursor-blink 0.7s step-end infinite;
}

@keyframes typing-cursor-blink {
    50% { opacity: 0; }
}

.scan-chat-bubble-secondary {
    background: #ffffff;
    border-radius: 14px 14px 4px 14px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    color: #000000;
    align-self: flex-end;
    text-align: left;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 18px;
    min-height: 44px;
    min-width: 56px;
    box-shadow: none;
    justify-content: center;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), padding 0.22s ease, min-height 0.22s ease, min-width 0.22s ease, max-width 0.22s ease, border-radius 0.22s ease, background 0.22s ease, border-color 0.22s ease, flex-direction 0.22s ease;
}
/* Сначала пузырь растягивается до этого размера (без контента) */
.scan-chat-bubble-secondary.has-photo-expanding {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 50%, #1e3a8a 100%);
    border: none;
    color: #fff;
    padding: 10px 12px;
    min-height: 76px;
    min-width: 200px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    text-align: left;
    max-width: 85%;
    box-shadow: none;
    margin-right: 0;
    margin-left: auto;
}

.scan-chat-bubble-secondary.has-photo-expanding .typing-dots {
    display: none !important;
}

.scan-chat-bubble-secondary.has-photo {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 50%, #1e3a8a 100%);
    border: none;
    color: #fff;
    padding: 10px 12px;
    min-height: 0;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    text-align: left;
    max-width: 85%;
    box-shadow: none;
    margin-right: 0;
    margin-left: auto;
}

.chat-photo-content {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: chatBubbleContentIn 0.18s ease 0.02s forwards;
    opacity: 0;
}

@keyframes chatBubbleContentIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chat-photo-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
}

.chat-photo-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-photo-filename {
    font-size: 14px;
    font-weight: 500;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-photo-size {
    font-size: 12px;
    color: rgba(0, 0, 0, 0.65);
}

/* В синем состоянии пузыря текст становится белым */
.scan-chat-bubble-secondary.has-photo .chat-photo-filename {
    color: #ffffff;
}

.scan-chat-bubble-secondary.has-photo .chat-photo-size {
    color: rgba(255, 255, 255, 0.85);
}

/* Результат анализа в чате — как файл: прямоугольник с закруглёнными углами (не пузырь) */
.scan-chat-result-file {
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    margin-bottom: 14px;
    max-width: 85%;
    min-width: 200px;
    padding: 10px 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 50%, #1e3a8a 100%);
    border: none;
    color: #fff;
    box-shadow: none;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: auto;
}
.scan-chat-result-file:hover {
    opacity: 0.95;
    transform: scale(1.01);
}
.scan-chat-result-file:focus {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}
.chat-result-file-content {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    animation: chatBubbleContentIn 0.18s ease 0.02s forwards;
}
.scan-chat-result-file .chat-result-file-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
}
.chat-result-file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.chat-result-file-title {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-result-file-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
}
.scan-chat-result-file.scan-chat-bubble-new-enter {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.scan-chat-result-file.scan-chat-bubble-new-visible {
    opacity: 1;
    transform: translateY(0);
}

.chat-result-file-content[data-action="result"] {
    cursor: pointer;
}

.chat-result-file-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
}

.chat-result-file-view-photo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.chat-result-file-view-photo-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Окно просмотра фото по центру с зумом */
.photo-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.photo-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.photo-viewer-box {
    position: relative;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 1;
}

.photo-viewer-close {
    align-self: flex-end;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 28px;
    line-height: 1;
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.photo-viewer-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Окно — только фото, размер под пропорции изображения (без чёрных областей) */
.photo-viewer-zoom-wrap {
    overflow: hidden;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    display: block;
    user-select: none;
}

.photo-viewer-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    vertical-align: middle;
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: flex-end;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.9);
    animation: typingDots 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.chat-preview-thumb {
    margin-top: 4px;
    border-radius: 10px;
    max-width: 200px;
    max-height: 150px;
    object-fit: cover;
    box-shadow: var(--shadow);
}

@keyframes typingDots {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    40% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

.scan-hero-icon-wrapper {
    margin-top: 0;
    margin-bottom: 0;
    position: fixed;
    top: 200px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 0;
}

.scan-hero-icon-wrapper::before,
.scan-hero-icon-wrapper::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 160px;
    height: 160px;
    transform: translate(-50%, -50%) scale(0.6);
    border-radius: 999px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.32), transparent 60%);
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    animation: scan-wave 3.2s ease-out infinite;
}

.scan-hero-icon-wrapper::after {
    animation-delay: 1.4s;
}

.scan-hero-icon {
    width: 96px;
    height: 96px;
    color: var(--primary);
    filter: drop-shadow(0 8px 18px rgba(37, 99, 235, 0.45));
    animation: scan-pulse 2.4s ease-in-out infinite;
}

@keyframes scan-pulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 8px 18px rgba(37, 99, 235, 0.45));
    }
    50% {
        transform: scale(1.06);
        filter: drop-shadow(0 14px 26px rgba(59, 130, 246, 0.75));
    }
}

@keyframes scan-wave {
    0% {
        transform: translate(-50%, -50%) scale(0.6);
        opacity: 0.0;
    }
    25% {
        opacity: 0.45;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.25);
        opacity: 0;
    }
}

.scan-hero-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-dark);
    width: fit-content;
}

.scan-hero h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--color-violet) 50%, var(--color-teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.scan-hero h2 .icon {
    color: inherit;
}

.scan-steps {
    position: relative;
    display: inline-flex;
    align-items: flex-start;
    justify-content: center;
    gap: 40px;
    padding: 10px 4px 2px;
    margin-top: 6px;
}

.scan-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 24px;
    right: 24px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.6), rgba(148, 163, 184, 0.2));
    z-index: 0;
}

.scan-step {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    z-index: 1;
}

.scan-step-circle {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    background: #ffffff;
    color: var(--text-secondary);
    border: 2px solid rgba(148, 163, 184, 0.8);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.scan-step-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.scan-step.active .scan-step-circle {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
}

.scan-step.active .scan-step-label {
    color: var(--primary-dark);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0;
}

.scan-subtitle-below {
    margin-top: 10px;
    margin-bottom: 4px;
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    padding: 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: none;
    border: 1px solid var(--glass-border);
    transition: all 0.2s ease;
    animation: cardFadeIn 0.2s cubic-bezier(0.25, 0.1, 0.25, 1) backwards;
}

.card:hover {
    box-shadow: none;
    border-color: rgba(37, 99, 235, 0.25);
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }
.card:nth-child(5) { animation-delay: 0.5s; }

/* На главной: убираем карточку у блока «Сделать фото или загрузить» (карточка — второй ребёнок после .hero) */
#home-page > .card:nth-child(2) {
    display: contents;
}

#home-page > .card:nth-child(2) > .upload-area,
#home-page > .card:nth-child(2) > .preview-area,
#home-page > .card:nth-child(2) > .error-message {
    margin-bottom: 16px;
}

/* ——— Страница «Ещё» ——— */
.more-page {
    padding-bottom: 80px;
}

.more-header {
    margin-bottom: 24px;
}

.more-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--color-violet) 50%, var(--color-teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.more-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.more-section {
    margin-bottom: 20px;
}

.more-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 10px 6px;
}

.more-section:first-of-type .more-section-title { color: var(--primary); }
.more-section:nth-of-type(2) .more-section-title { color: var(--color-teal); }
.more-section:nth-of-type(3) .more-section-title { color: var(--color-violet); }

.more-list {
    background: var(--glass-bg);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.06);
}

.more-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.more-row:focus,
.more-row:focus-visible {
    outline: none;
    box-shadow: none;
}

.more-row svg.icon {
    vertical-align: middle;
    object-fit: contain;
}

.more-row {
    position: relative;
}

.more-row::after {
    content: '';
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    height: 1px;
    background: var(--border);
}

.more-row:last-child::after {
    display: none;
}

.more-row:hover {
    background: rgba(37, 99, 235, 0.06);
}

.more-row:active {
    background: rgba(37, 99, 235, 0.1);
}

.more-row-theme {
    cursor: default;
}
.more-row-theme:hover {
    background: transparent;
}
.more-row-theme:active {
    background: transparent;
}
.more-row-theme .theme-toggle {
    flex-shrink: 0;
}

.more-row-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border-radius: 12px;
    flex-shrink: 0;
    padding: 0;
    box-sizing: border-box;
}

.more-row-icon .icon {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    display: block;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    vertical-align: middle;
}

/* Иконка ровно по центру квадратика: SVG внутри .more-row-icon */
.more-row-icon svg.icon {
    position: relative;
    top: 0;
    left: 0;
    object-fit: contain;
}

/* Цветные иконки по строкам — Основное */
.more-section:nth-of-type(1) .more-row:nth-child(1) .more-row-icon { background: var(--primary-light); color: var(--primary); }
.more-section:nth-of-type(1) .more-row:nth-child(2) .more-row-icon { background: var(--color-amber-bg); color: var(--color-amber); }
.more-section:nth-of-type(1) .more-row:nth-child(3) .more-row-icon { background: var(--color-emerald-bg); color: var(--color-emerald); }
.more-section:nth-of-type(1) .more-row:nth-child(4) .more-row-icon { background: var(--color-rose-bg); color: var(--color-rose); }
.more-section:nth-of-type(1) .more-row:nth-child(5) .more-row-icon { background: var(--color-violet-bg); color: var(--color-violet); }

/* Цветные иконки — Дополнительно */
.more-section:nth-of-type(2) .more-row:nth-child(1) .more-row-icon { background: var(--color-teal-bg); color: var(--color-teal); }
.more-section:nth-of-type(2) .more-row:nth-child(2) .more-row-icon { background: var(--primary-light); color: var(--primary); }
.more-section:nth-of-type(2) .more-row:nth-child(3) .more-row-icon { background: var(--color-indigo-bg); color: var(--color-indigo); }
.more-section:nth-of-type(2) .more-row:nth-child(4) .more-row-icon { background: var(--color-rose-bg); color: var(--color-rose); }
.more-section:nth-of-type(2) .more-row:nth-child(5) .more-row-icon { background: var(--color-emerald-bg); color: var(--color-emerald); }

/* Тема */
.more-section-theme .more-row .more-row-icon { background: linear-gradient(135deg, var(--primary-light) 0%, var(--color-indigo-bg) 100%); color: var(--primary); }

/* Настройки */
.more-section:nth-of-type(4) .more-row .more-row-icon { background: linear-gradient(135deg, var(--primary-light) 0%, var(--color-indigo-bg) 100%); color: var(--primary); }

.more-row-label {
    flex: 1;
}

.more-row-arrow {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    color: var(--text-light);
    flex-shrink: 0;
    display: block;
}

body.dark-mode .more-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

body.dark-mode .more-row:active {
    background: rgba(255, 255, 255, 0.1);
}

/* Тёмная тема: цветные иконки сохраняем, но с тёмным фоном */
body.dark-mode .more-section:nth-of-type(1) .more-row:nth-child(1) .more-row-icon { background: rgba(37, 99, 235, 0.35); color: #93c5fd; }
body.dark-mode .more-section:nth-of-type(1) .more-row:nth-child(2) .more-row-icon { background: rgba(217, 119, 6, 0.3); color: #fcd34d; }
body.dark-mode .more-section:nth-of-type(1) .more-row:nth-child(3) .more-row-icon { background: rgba(5, 150, 105, 0.35); color: #6ee7b7; }
body.dark-mode .more-section:nth-of-type(1) .more-row:nth-child(4) .more-row-icon { background: rgba(225, 29, 72, 0.3); color: #fda4af; }
body.dark-mode .more-section:nth-of-type(1) .more-row:nth-child(5) .more-row-icon { background: rgba(124, 58, 237, 0.35); color: #c4b5fd; }
body.dark-mode .more-section:nth-of-type(2) .more-row:nth-child(1) .more-row-icon { background: rgba(13, 148, 136, 0.35); color: #5eead4; }
body.dark-mode .more-section:nth-of-type(2) .more-row:nth-child(2) .more-row-icon { background: rgba(37, 99, 235, 0.35); color: #93c5fd; }
body.dark-mode .more-section:nth-of-type(2) .more-row:nth-child(3) .more-row-icon { background: rgba(79, 70, 229, 0.35); color: #a5b4fc; }
body.dark-mode .more-section:nth-of-type(2) .more-row:nth-child(4) .more-row-icon { background: rgba(5, 150, 105, 0.35); color: #6ee7b7; }
body.dark-mode .more-section:nth-of-type(2) .more-row:nth-child(4) .more-row-icon { background: rgba(225, 29, 72, 0.3); color: #fda4af; }
body.dark-mode .more-section:nth-of-type(2) .more-row:nth-child(5) .more-row-icon { background: rgba(5, 150, 105, 0.35); color: #6ee7b7; }
body.dark-mode .more-section-theme .more-row .more-row-icon,
body.dark-mode .more-section:nth-of-type(4) .more-row .more-row-icon { background: rgba(37, 99, 235, 0.3); color: #93c5fd; }

body.dark-mode .more-title {
    background: linear-gradient(135deg, #93c5fd 0%, #c4b5fd 50%, #5eead4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Модальные окна на странице «Ещё» */
.more-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.3s ease;
}

.more-dialog-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.more-dialog-overlay .more-dialog {
    opacity: 0;
    transform: scale(0.96) translateY(-12px);
    transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1), transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.more-dialog-overlay.is-open .more-dialog {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.more-dialog {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-xl);
    padding: 24px;
    max-width: 400px;
    width: 100%;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.more-dialog h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.more-dialog h3 .icon {
    color: var(--primary);
}

.more-dialog p {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    margin: 0 0 12px 0;
}

.more-dialog p:last-of-type {
    margin-bottom: 0;
}

.more-dialog-tips {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.more-dialog-tips li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
}

.more-dialog-tips li:last-child {
    margin-bottom: 0;
}

.more-dialog-tips li .icon {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--primary);
}

input, textarea, select {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.ai-training-textarea {
    min-height: 320px;
    width: 100%;
    resize: vertical;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.tips-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tips-card {
    display: flex;
    flex-direction: column;
    row-gap: 0;
}

.tips-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 0 4px;
    background: transparent;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
}

.tips-toggle-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.tips-content {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.tips-card.is-open .tips-content {
    max-height: 300px;
    opacity: 1;
    margin-top: 8px;
}

.tips-card.is-open .tips-toggle-icon {
    transform: rotate(180deg);
}

.tips-card li {
    padding: 12px 16px 12px 8px;
    color: var(--text);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 15px;
    margin: 0;
    cursor: default;
    background: transparent;
    border-bottom: 1px solid var(--border);
    transition: none;
    line-height: 1.5;
}

.tips-card li .icon {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
    color: var(--primary);
}

.tips-card li:last-child {
    border-bottom: none;
}

.tips-card li:hover {
    background: transparent;
}

.tips-link-wrap {
    margin: 16px 0 0;
    text-align: center;
}
.tips-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 15px;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}
.tips-link:hover {
    text-decoration: none;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 50%, #1e3a8a 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.5s ease, box-shadow 0.2s ease, filter 0.2s ease, transform 0.2s ease;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.1px;
    min-height: 48px;
}


.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    filter: brightness(0.98);
    box-shadow: none;
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:focus,
.btn-primary:focus-visible {
    outline: none;
    box-shadow: none;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text);
    border: 1.5px solid var(--border);
    padding: 14px 28px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.1px;
    min-height: 48px;
}


.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary:focus,
.btn-secondary:focus-visible,
.btn-secondary:active {
    outline: none;
    box-shadow: none;
}

.btn-view-result {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #ffffff;
    color: #000000;
    border: 1.5px solid rgba(0, 0, 0, 0.15);
    padding: 14px 28px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    min-height: 48px;
    width: 100%;
    max-width: 420px;
}

.btn-view-result:hover {
    background: #f3f4f6;
    color: #000000;
    border-color: rgba(0, 0, 0, 0.2);
}

.btn-view-result .icon {
    color: #000000;
}

.upload-area {
    text-align: center;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: none;
    position: static;
    overflow: visible;
}

.upload-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.scan-help-link-wrap {
    text-align: center;
    margin-top: 14px;
}

.scan-help-link {
    display: inline-block;
    margin-top: 0;
    padding: 0;
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

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

.upload-area .btn-primary {
    width: 100%;
    max-width: 420px;
    box-shadow: none;
}

#upload-file-btn .icon {
    width: 1.25em;
    height: 1.25em;
}

#take-photo-btn {
    background: #ffffff;
    color: #111827;
    border: 1px solid var(--border);
}

#upload-file-btn {
    background: #111827;
    border: 1px solid var(--border);
}

#upload-file-btn {
    background: #111827;
    border: 1px solid var(--border);
}

@media (hover: hover) and (pointer: fine) {
    .upload-area:hover {
        background: transparent;
    }
}

/* Removed ::before pseudo-element - using inline SVG icon instead */

.preview-area {
    text-align: center;
}

/* Плавная смена цвета кнопки «Начать анализ» — тот же синий, что у сообщения с файлом */
#home-page.photo-loaded .preview-area .btn-primary,
#home-page.photo-loaded .preview-area #analyze-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 50%, #1e3a8a 100%);
}

#preview-image {
    display: none;
}

.preview-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.error-message {
    background: var(--error-light);
    color: var(--error);
    padding: 16px;
    border-radius: 12px;
    margin-top: 20px;
    border-left: 4px solid var(--error);
    font-weight: 500;
}

.result-header, .diary-header {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    text-align: center;
}

/* Шапка второстепенных страниц: стрелка назад слева + название страницы по центру */
.page-back-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 4px;
    padding-right: 16px;
    margin-bottom: 24px;
}
.page-back-header::after {
    content: '';
    width: 44px;
    flex-shrink: 0;
}
.page-back-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    flex: 1;
    min-width: 0;
    text-align: center;
}
.page-back-header .back-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.page-back-header .back-btn:hover {
    background: var(--border-light);
    color: var(--primary);
}
.page-back-header .back-btn .icon {
    width: 24px;
    height: 24px;
}
body.dark-mode .page-back-header .back-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary);
}

/* Admin chat page */
.admin-chat-header {
    flex-direction: column;
    align-items: flex-start;
}
.admin-chat-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 220px);
    min-height: 320px;
    margin-top: 8px;
}
.admin-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}
.admin-chat-msg {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.admin-chat-msg--user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.admin-chat-msg--assistant {
    align-self: flex-start;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}
.admin-chat-msg--loading .admin-chat-msg-text {
    color: var(--text-light);
    font-style: italic;
}
.admin-chat-msg-text {
    font-size: 15px;
}
.admin-chat-input-wrap {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.admin-chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    background: var(--bg);
    color: var(--text);
    -webkit-user-select: text;
    user-select: text;
}
.admin-chat-input:focus {
    outline: none;
    border-color: var(--primary);
}
.admin-chat-send {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}
.admin-chat-send .icon {
    transform: rotate(-90deg);
}
.admin-chat-error {
    font-size: 13px;
    color: var(--error);
    margin-top: 6px;
}

body.dark-mode .admin-chat-msg--assistant {
    background: var(--glass-bg);
    border-color: var(--glass-border);
}
body.dark-mode .admin-chat-input {
    background: var(--bg);
    border-color: var(--glass-border);
    color: var(--text);
}

.diary-bottom-actions {
    padding: 16px;
    margin-top: 24px;
    margin-bottom: 16px; /* Отступ перед нижним баром */
}

.diary-bottom-actions button {
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.diary-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.diary-entry {
    background: var(--glass-bg);
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    position: relative;
}

.diary-entry::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 16px 0 0 16px;
    transition: width 0.2s ease;
}

.diary-entry.diary-urgency-low::before   { background: var(--success); }
.diary-entry.diary-urgency-medium::before { background: var(--warning); }
.diary-entry.diary-urgency-high::before   { background: var(--error); }

.diary-entry:hover {
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.diary-entry:hover::before {
    width: 5px;
}

.diary-entry-inner {
    padding: 18px 20px 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.diary-entry-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.diary-entry-date {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}

.diary-entry-relative {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

.diary-entry-header .delete-entry-btn {
    margin-left: auto;
}

.diary-entry-body {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.diary-entry-gauge-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.diary-entry-gauge {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.diary-entry-gauge-bg {
    stroke: var(--border-light);
}

.diary-entry-gauge-fill {
    stroke: var(--risk-color, var(--primary));
    transition: stroke-dashoffset 0.5s ease;
}

.diary-entry-risk {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
}

.diary-entry-risk-unit {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.7;
    margin-left: 1px;
}

.diary-entry-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.diary-entry-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
}

.diary-entry-badge.urgency-low {
    background: var(--success-light);
    color: #065f46;
}

.diary-entry-badge.urgency-medium {
    background: var(--warning-light);
    color: #92400e;
}

.diary-entry-badge.urgency-high {
    background: var(--error-light);
    color: #991b1b;
}

body.dark-mode .diary-entry-badge.urgency-low   { color: #6ee7b7; }
body.dark-mode .diary-entry-badge.urgency-medium { color: #fcd34d; }
body.dark-mode .diary-entry-badge.urgency-high  { color: #fca5a5; }

.diary-entry-findings {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

body.dark-mode .diary-entry {
    background: var(--glass-bg);
    border-color: var(--glass-border);
    box-shadow: var(--shadow);
}

body.dark-mode .diary-entry:hover {
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: var(--shadow-md);
}

.delete-entry-btn {
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    padding: 4px 6px;
    color: #ef4444;
    opacity: 0.7;
    transition: all 0.2s ease;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative !important;
    z-index: 100 !important;
    pointer-events: auto !important;
}

.delete-entry-btn:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.1) !important;
    transform: scale(1.1);
}

.delete-entry-btn:active {
    transform: scale(0.95);
}

.delete-entry-btn .icon {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.urgency-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 8px;
    transition: transform 0.2s ease;
}

.urgency-badge:hover {
    transform: scale(1.05);
}

.urgency-high {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.urgency-medium {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #fcd34d;
}

.urgency-low {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

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

.filters input, .filters select {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: var(--card-bg);
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.filters input:focus, .filters select:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-color: var(--primary);
}

/* Кастомный выпадающий список — варианты всегда под кнопкой */
.filter-select-wrap {
    position: relative;
}

.filter-select-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.filter-select-btn:focus,
.filter-select-btn:focus-visible {
    outline: none;
    border-color: var(--primary);
}

.filter-select-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.filter-select-wrap.open .filter-select-chevron {
    transform: rotate(180deg);
}

.filter-select-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    padding: 4px 0;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}

.filter-select-wrap.open .filter-select-menu {
    display: block;
}

.filter-select-option {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.filter-select-option:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.filter-select-option.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.filter-checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.filter-checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.clinics-filters-container {
    margin-top: 16px;
}

.clinics-filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.clinics-filters-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    gap: 8px;
    font-size: 13px;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}
.clinics-filters-header:focus,
.clinics-filters-header:focus-visible,
.clinics-filters-header:active {
    outline: none;
    box-shadow: none;
}

.clinics-filters-header-main {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 13px;
}

.clinics-filters-header-main .icon {
    color: var(--primary);
}

.clinics-filters-chevron {
    transition: transform 0.2s ease;
}

.clinics-filters-chevron-open {
    transform: rotate(180deg);
}

.clinics-filters-body {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
    transform-origin: top;
}

.clinics-filters-body-collapsed {
    max-height: 0;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
}

.clinics-filters-body-expanded {
    max-height: 260px; /* достаточно для пары полей и кнопок */
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.clinics-search-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 12px;
    border: 2px solid var(--border);
    font-size: 14px;
    background: var(--card-bg);
}

.clinics-search-input::placeholder {
    color: var(--text-light);
}

.clinics-search-input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-color: var(--primary);
}

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

.tools-search-input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239ca3af'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5A6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5S14 7.01 14 9.5S11.99 14 9.5 14z'/%3E%3C/svg%3E") no-repeat 14px center;
    background-size: 20px 20px;
    -webkit-user-select: text;
    user-select: text;
}

.tools-search-input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-color: var(--primary);
}

.tools-search-input::placeholder {
    color: var(--text-light);
}

.clinics-load-more-sentinel {
    height: 1px;
    width: 100%;
    pointer-events: none;
    visibility: hidden;
}

.clinics-list {
    display: grid;
    gap: 12px;
    align-content: start;
    grid-auto-rows: minmax(min-content, auto);
}

/* ——— Карточка клиники: премиальный вид, не сжимается ——— */
.clinic-card {
    --clinic-card-radius: 16px;
    --clinic-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --clinic-card-shadow-hover: 0 12px 28px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(37, 99, 235, 0.06);
    background: var(--card-bg);
    border-radius: var(--clinic-card-radius);
    box-shadow: var(--clinic-card-shadow);
    border: 1px solid var(--border-light);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-height: min-content;
    flex-shrink: 0;
}

.clinic-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.clinic-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--clinic-card-shadow-hover);
    border-color: rgba(37, 99, 235, 0.15);
}

.clinic-card:hover::before {
    opacity: 1;
}

.clinic-card-inner {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: min-content;
    flex-shrink: 0;
}

.clinic-card-enter {
    animation: clinicCardEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
}

@keyframes clinicCardEnter {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.clinic-card-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clinic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 28px;
}

.clinic-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.clinic-rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
    color: #854d0e;
    font-size: 12px;
    font-weight: 700;
    border-radius: 20px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.clinic-rating-badge .icon {
    width: 12px;
    height: 12px;
    opacity: 0.9;
}

.clinic-address-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 4px;
}
.clinic-address-row .clinic-address {
    flex: 1;
    min-width: 0;
}
.clinic-address-row .specialization-tag-children {
    flex-shrink: 0;
}
.clinic-address {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
}

.clinic-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.clinic-meta-item {
    color: var(--text-light);
    font-weight: 500;
}

.clinic-phone {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    margin-top: 2px;
    transition: color 0.2s ease;
}

.clinic-phone:hover {
    color: var(--primary-dark);
}

.clinic-card-actions {
    padding-top: 8px;
}

.clinic-details-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 6px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    background: transparent;
    border: 1px solid var(--primary);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.clinic-details-btn:hover {
    background: var(--primary-lighter);
    color: var(--primary-dark);
    transform: translateX(2px);
}

.specialization-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Модальное окно подробностей клиники */
.clinic-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: clinicDetailFadeIn 0.2s ease;
}
@keyframes clinicDetailFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.clinic-detail-modal {
    background: var(--card-bg);
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    position: relative;
    padding: 24px;
    padding-top: 48px;
}
.clinic-detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--border-light);
    color: var(--text);
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.clinic-detail-close:hover {
    background: var(--border);
}
.clinic-detail-title {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.clinic-detail-body {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.clinic-detail-body p {
    margin: 0 0 12px 0;
}
.clinic-detail-body a[href^="tel:"] {
    color: var(--primary);
}
.clinic-detail-footer {
    margin-top: 20px;
    padding-top: 0;
}
.clinic-detail-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #dc2626;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.clinic-detail-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.5);
    color: #b91c1c;
}

/* Окно подтверждения удаления клиники */
.clinic-delete-confirm-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: 16px;
}
.clinic-delete-confirm-card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 20px 24px;
    max-width: 320px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
}
.clinic-delete-confirm-text {
    margin: 0 0 20px 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
}
.clinic-delete-confirm-text strong {
    color: var(--text);
}
.clinic-delete-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.clinic-delete-confirm-cancel {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--border-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.clinic-delete-confirm-cancel:hover {
    background: var(--border);
    color: var(--text);
}
.clinic-delete-confirm-ok {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: #dc2626;
    border: 1px solid #b91c1c;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.clinic-delete-confirm-ok:hover {
    background: #b91c1c;
    border-color: #991b1b;
}

.specialization-tag {
    background: var(--primary-lighter);
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: default;
    display: inline-block;
    transition: background 0.2s ease, color 0.2s ease;
}
.specialization-tag-children {
    background: rgba(34, 197, 94, 0.2);
    color: #15803d;
}
\.clinic-name-children {
    margin-left: 8px;
}
body.dark-mode .specialization-tag-children {
    background: rgba(34, 197, 94, 0.25);
    color: #86efac;
}

.clinic-card:hover .specialization-tag {
    background: rgba(37, 99, 235, 0.12);
}

/* Тёмная тема: карточка клиники */
body.dark-mode .clinic-card {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(71, 85, 105, 0.5);
    --clinic-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    --clinic-card-shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(59, 130, 246, 0.15);
}
body.dark-mode .clinic-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
}
body.dark-mode .clinic-rating-badge {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.35) 0%, rgba(245, 158, 11, 0.25) 100%);
    color: #fcd34d;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
body.dark-mode .clinic-details-btn {
    border-color: rgba(96, 165, 250, 0.5);
    color: #93c5fd;
}
body.dark-mode .clinic-details-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #bfdbfe;
}
body.dark-mode .clinic-detail-delete-btn {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}
body.dark-mode .clinic-detail-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fecaca;
}
body.dark-mode .specialization-tag {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}
body.dark-mode .clinic-card:hover .specialization-tag {
    background: rgba(59, 130, 246, 0.28);
}

.empty-state {
    text-align: center;
    padding: 64px 48px;
}

.empty-state p {
    font-size: 18px;
    color: var(--text-light);
    margin-bottom: 24px;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    opacity: 0.5;
}

.disclaimer {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    padding: 16px;
    border-radius: 12px;
    margin-top: 20px;
    font-size: 14px;
    border-left: 4px solid var(--primary);
    line-height: 1.6;
}

/* List item hover effects */
ul li, ol li {
    padding: 8px 12px 8px 4px;
    margin: 0;
    background: transparent;
    border-bottom: 1px solid var(--border);
}

ul li:last-child, ol li:last-child {
    border-bottom: none;
}

ul li:hover, ol li:hover {
    background: transparent;
}

/* Special styling for recommendation lists */
.card ul li, .card ol li {
    padding: 10px 14px 10px 6px;
    margin: 0;
    background: transparent;
    border-bottom: 1px solid var(--border);
    transition: none;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.card ul li .icon, .card ol li .icon {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
}

.card ul li:last-child, .card ol li:last-child {
    border-bottom: none;
}

.card ul li:hover, .card ol li:hover {
    background: transparent;
}

/* ——— Страница результата анализа (новый дизайн) ——— */
#result-page #result-content {
    padding-bottom: 80px;
}

.result-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-detail .card {
    margin-bottom: 0;
}

/* Hero-блок с оценкой риска */
.result-hero {
    border-radius: var(--radius-xl);
    padding: 28px 24px 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.result-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.06;
    pointer-events: none;
}

.result-hero--low {
    background: linear-gradient(160deg, #ecfdf5 0%, #d1fae5 50%, #a7f3d0 100%);
    border: 1px solid rgba(5, 150, 105, 0.25);
}

.result-hero--medium {
    background: linear-gradient(160deg, #fffbeb 0%, #fef3c7 50%, #fde68a 100%);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.result-hero--high {
    background: linear-gradient(160deg, #fef2f2 0%, #fee2e2 50%, #fecaca 100%);
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.result-hero-gauge {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.result-hero .gauge-circle {
    width: 160px;
    height: 160px;
    margin: 0;
    position: relative;
    flex-shrink: 0;
}

.result-hero .gauge-circle .gauge-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.result-hero .gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1;
    pointer-events: none;
    color: var(--text);
}

.result-hero--low .gauge-value { color: #047857; }
.result-hero--medium .gauge-value { color: #b45309; }
.result-hero--high .gauge-value { color: #b91c1c; }

.gauge-value-unit {
    font-size: 0.45em;
    font-weight: 600;
    opacity: 0.85;
}

.result-hero-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.result-hero--low .result-hero-badge {
    background: rgba(5, 150, 105, 0.25);
    color: #065f46;
}

.result-hero--medium .result-hero-badge {
    background: rgba(245, 158, 11, 0.35);
    color: #92400e;
}

.result-hero--high .result-hero-badge {
    background: rgba(220, 38, 38, 0.25);
    color: #991b1b;
}

.result-hero-desc {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.gauge-circle-bg {
    stroke: rgba(0, 0, 0, 0.08);
}

.result-hero--low .gauge-circle-bg { stroke: rgba(5, 150, 105, 0.2); }
.result-hero--medium .gauge-circle-bg { stroke: rgba(245, 158, 11, 0.25); }
.result-hero--high .gauge-circle-bg { stroke: rgba(220, 38, 38, 0.2); }

.gauge-circle-fill {
    stroke: var(--gauge-color, var(--primary));
    transition: stroke-dashoffset 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Сетка: находки + рекомендации в два столбца на широких экранах */
.result-grid {
    display: grid;
    gap: 20px;
}

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

/* Заголовки карточек результата */
.result-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.result-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-lighter);
    color: var(--primary);
}

.result-card-icon .icon {
    width: 18px;
    height: 18px;
}

.result-card-count {
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    background: var(--border-light);
    color: var(--text-secondary);
}

/* Находки */
.findings-list {
    margin-top: 0;
}

.findings-empty {
    margin: 0;
    padding: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    background: var(--border-light);
    border-radius: var(--radius);
}

.findings-list .finding-item:last-child {
    margin-bottom: 0;
}

.finding-item {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.finding-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.finding-item--high { border-left: 4px solid var(--error); }
.finding-item--medium { border-left: 4px solid var(--warning); }
.finding-item--low { border-left: 4px solid var(--success); }

.finding-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
}

.finding-title {
    font-size: 14px;
    color: var(--text);
}

.finding-severity {
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.finding-severity.severity-low {
    background: var(--success-light);
    color: #065f46;
}

.finding-severity.severity-medium {
    background: var(--warning-light);
    color: #92400e;
}

.finding-severity.severity-high {
    background: var(--error-light);
    color: #991b1b;
}

.finding-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.finding-meta .icon {
    width: 14px;
    height: 14px;
}

.finding-note {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.image-overlay-container {
    position: relative;
    display: inline-block;
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--border-light);
}

.overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.result-image {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    vertical-align: top;
}

/* На странице результатов: карточка «файл» и кнопка «Посмотреть фото» */
.result-page-file-card {
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 50%, #1e3a8a 100%);
    padding: 12px 14px;
    color: #fff;
}

.result-page-file-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.result-page-file-thumb {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.15);
}

.result-page-file-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.result-page-file-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.result-page-file-meta {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
}

.result-page-view-photo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.result-page-view-photo-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.6);
}

.card-recommendations {
    background: linear-gradient(180deg, #f0fdfa 0%, #ccfbf1 100%);
    border: 1px solid rgba(13, 148, 136, 0.2);
}

.card-recommendations .result-card-title {
    color: var(--text);
}

.result-rec-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-rec-block {
    margin: 0;
}

.result-rec-title {
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.result-rec-title .icon {
    width: 16px;
    height: 16px;
    color: var(--color-teal);
}

.result-rec-list {
    margin: 0 0 0 24px;
    padding: 0;
    list-style: disc;
}

.result-rec-list li {
    padding: 4px 0;
    color: var(--text);
    line-height: 1.5;
}

.result-rec-list li:last-child {
    padding-bottom: 0;
}

.result-rec-empty {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.result-alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid transparent;
}

.result-alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border-color: rgba(245, 158, 11, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-alert-warning .icon {
    width: 18px;
    height: 18px;
    color: var(--warning);
    flex-shrink: 0;
}

.result-alert-danger {
    background: var(--error-light);
    color: #991b1b;
    border-color: rgba(220, 38, 38, 0.4);
}

.result-alert-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #b91c1c;
}

.result-alert-heading .icon {
    width: 16px;
    height: 16px;
    color: var(--error);
    flex-shrink: 0;
}

.result-alert-list {
    margin: 4px 0 0 20px;
    padding: 0;
    list-style: disc;
    font-size: 13px;
    color: #991b1b;
}

.result-alert-list li {
    padding: 2px 0;
    line-height: 1.45;
}

.result-disclaimer {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
    padding: 12px 16px;
    background: var(--border-light);
    border-radius: var(--radius);
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

@media (min-width: 480px) {
    .result-actions {
        grid-template-columns: repeat(4, 1fr);
    }
}

.result-action-btn {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.result-action-btn--primary {
    grid-column: 1 / -1;
}

@media (min-width: 480px) {
    .result-action-btn--primary {
        grid-column: span 1;
    }
}

.result-delete-wrap {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.btn-delete-entry {
    width: 100%;
    color: var(--error) !important;
    border-color: var(--error) !important;
}

.btn-delete-entry:hover {
    background: var(--error-light) !important;
    color: var(--error) !important;
}

.loading {
    text-align: center;
    padding: 64px;
    color: var(--text-light);
    font-size: 16px;
}

.spinner {
    border: 4px solid var(--border-light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dark mode */
:root.dark-mode,
body.dark-mode {
    --bg: #111827;
    --card-bg: #1f2937;
    --text: #f9fafb;
    --text-secondary: #d1d5db;
    --text-light: #9ca3af;
    --text-lighter: #6b7280;
    --border: #374151;
    --border-light: #4b5563;
    --primary-light: rgba(37, 99, 235, 0.2);
    --secondary-light: rgba(15, 23, 42, 0.5);
    --error-light: rgba(220, 38, 38, 0.2);
    --success-light: rgba(16, 185, 129, 0.2);
    --warning-light: rgba(245, 158, 11, 0.2);
    --primary-lighter: rgba(37, 99, 235, 0.12);
    --glass-bg: rgba(17, 24, 39, 0.72);
    --glass-border: rgba(255, 255, 255, 0.10);
    --bg-grad-1: #0b1220;
    --bg-grad-2: #111827;
    --bg-grad-3: #0b1220;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 3px 14px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 4px 20px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
}

body.dark-mode .card {
    background: var(--glass-bg);
    border-color: var(--glass-border);
    box-shadow: none;
}

body.dark-mode .card-recommendations {
    background: rgba(13, 148, 136, 0.18);
    border-color: rgba(13, 148, 136, 0.3);
}

body.dark-mode .card-disclaimer {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.25);
}

body.dark-mode .result-alert-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.35);
}

body.dark-mode .result-alert-warning .icon {
    color: #fcd34d;
}

body.dark-mode .result-alert-danger,
body.dark-mode .result-alert-danger .result-alert-heading,
body.dark-mode .result-alert-list {
    color: #fca5a5;
}

body.dark-mode .result-alert-heading .icon,
body.dark-mode .result-alert-list li .icon {
    color: #fca5a5;
}

body.dark-mode .result-alert-danger {
    background: rgba(220, 38, 38, 0.2);
    border-color: rgba(220, 38, 38, 0.35);
}

body.dark-mode .result-hero--low {
    background: linear-gradient(160deg, rgba(5, 150, 105, 0.25) 0%, rgba(16, 185, 129, 0.2) 100%);
    border-color: rgba(16, 185, 129, 0.35);
}

body.dark-mode .result-hero--medium {
    background: linear-gradient(160deg, rgba(245, 158, 11, 0.2) 0%, rgba(251, 191, 36, 0.15) 100%);
    border-color: rgba(245, 158, 11, 0.35);
}

body.dark-mode .result-hero--high {
    background: linear-gradient(160deg, rgba(220, 38, 38, 0.2) 0%, rgba(248, 113, 113, 0.15) 100%);
    border-color: rgba(220, 38, 38, 0.35);
}

body.dark-mode .result-hero .gauge-value,
body.dark-mode .result-hero-desc {
    color: var(--text);
}

body.dark-mode .result-hero--low .gauge-value { color: #6ee7b7; }
body.dark-mode .result-hero--medium .gauge-value { color: #fcd34d; }
body.dark-mode .result-hero--high .gauge-value { color: #fca5a5; }

body.dark-mode .result-hero--low .result-hero-badge {
    background: rgba(5, 150, 105, 0.4);
    color: #a7f3d0;
}

body.dark-mode .result-hero--medium .result-hero-badge {
    background: rgba(245, 158, 11, 0.4);
    color: #fde68a;
}

body.dark-mode .result-hero--high .result-hero-badge {
    background: rgba(220, 38, 38, 0.4);
    color: #fecaca;
}

body.dark-mode .result-disclaimer {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

body.dark-mode .result-card-icon {
    background: rgba(37, 99, 235, 0.3);
    color: #93c5fd;
}

body.dark-mode .urgency-badge.urgency-low {
    background: rgba(5, 150, 105, 0.5);
    color: #a7f3d0;
    border-color: rgba(16, 185, 129, 0.5);
}

body.dark-mode .urgency-badge.urgency-medium {
    background: rgba(180, 83, 9, 0.5);
    color: #fde68a;
    border-color: rgba(245, 158, 11, 0.5);
}

body.dark-mode .urgency-badge.urgency-high {
    background: rgba(185, 28, 28, 0.5);
    color: #fecaca;
    border-color: rgba(220, 38, 38, 0.5);
}

body.dark-mode #profile-page .profile-stat-card:first-child {
    background: rgba(37, 99, 235, 0.25);
}

body.dark-mode #profile-page .profile-stat-card.profile-stat-card--medium-risk {
    background: rgba(234, 88, 12, 0.25);
}

body.dark-mode #profile-page .profile-stat-card.profile-stat-card--medium-risk .profile-stat-value {
    color: #fb923c;
}

body.dark-mode #profile-page .profile-stat-card:last-child {
    background: rgba(16, 185, 129, 0.2);
}

body.dark-mode .btn-secondary {
    background: rgba(17, 24, 39, 0.65);
}

/* If a touch browser still triggers hover, keep it dark */
body.dark-mode .upload-area:hover,
:root.dark-mode .upload-area:hover {
    background: transparent;
}

body.dark-mode .bottom-nav {
    background: var(--glass-bg);
    border-top-color: var(--glass-border);
}

/* Theme toggle */
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .theme-slider {
    background-color: var(--primary);
}

input:checked + .theme-slider:before {
    transform: translateX(26px);
}

/* Statistics styles */
.stats-overview {
    margin-top: 16px;
}

.stats-chart {
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.period-dropdown {
    position: relative;
}

.period-dropdown-btn {
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    color: var(--text) !important;
}

.period-dropdown-btn:hover {
    background: var(--primary-light) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    box-shadow: var(--shadow-md) !important;
}

.period-dropdown-btn span {
    color: var(--text) !important;
}

.period-dropdown-btn:hover span {
    color: var(--primary) !important;
}

.period-dropdown-btn .icon {
    color: var(--text) !important;
}

.period-dropdown-btn:hover .icon {
    color: var(--primary) !important;
}

.period-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    z-index: 50;
    animation: fadeInSlide 0.15s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.period-option {
    border-bottom: 1px solid var(--border) !important;
    color: var(--text) !important;
}

.period-option:last-child {
    border-bottom: none !important;
}

.period-option:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

.period-option.active {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    font-weight: 600;
}

.period-option.active:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

/* Comparison styles */
.comparison-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Страница профиля: карточки статистики */
#profile-page .profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 12px;
}

@media (max-width: 480px) {
    #profile-page .profile-stats {
        grid-template-columns: 1fr;
    }
}

#profile-page .profile-stat-card {
    padding: 20px 16px;
    border-radius: var(--radius-lg);
    text-align: center;
    border: 1px solid var(--border);
    transition: box-shadow 0.2s ease;
}

#profile-page .profile-stat-card:first-child {
    background: var(--primary-light);
    border-color: transparent;
}

#profile-page .profile-stat-card:first-child .profile-stat-value {
    color: var(--primary);
}

#profile-page .profile-stat-card.profile-stat-card--medium-risk {
    background: var(--risk-medium-light);
    border-color: transparent;
}

#profile-page .profile-stat-card.profile-stat-card--medium-risk .profile-stat-value {
    color: var(--risk-medium);
}

#profile-page .profile-stat-card:last-child {
    background: var(--success-light);
    border-color: transparent;
}

#profile-page .profile-stat-card:last-child .profile-stat-value {
    color: var(--success);
}

#profile-page .profile-stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    display: block;
}

#profile-page .profile-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}

#profile-page .profile-last-date {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-light);
}

#profile-page .profile-header {
    margin-bottom: 8px;
}

#profile-page .profile-chart-tip {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-light);
}

#profile-page .profile-actions {
    margin-top: 8px;
    margin-bottom: 24px;
}

#profile-page .profile-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 24px;
    font-size: 16px;
    min-height: 52px;
}

#profile-page .card {
    margin-bottom: 16px;
}

#profile-page .card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Мини‑график в профиле */
.profile-chart {
    margin-top: 8px;
}

.profile-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.profile-chart-svg {
    width: 100%;
    height: 320px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-lighter) 0%, var(--secondary-light) 100%);
    overflow: hidden;
}

.profile-chart-svg--bars {
    display: block;
}

.profile-chart-grid {
    stroke: rgba(255, 255, 255, 0.4);
    stroke-width: 0.3;
}

.profile-chart-bar {
    transition: opacity 0.2s ease;
}

.profile-chart-bar:hover {
    opacity: 0.9;
}

.profile-chart-risk-label {
    font-size: 4px;
    font-weight: 600;
    fill: var(--text-primary, #111827);
    font-family: inherit;
}

.profile-chart-risk-label--inside {
    fill: #fff;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.35);
    stroke-width: 0.4px;
}

.profile-chart-label {
    font-size: 4px;
    fill: var(--text-secondary);
    font-family: inherit;
}

@media (min-width: 769px) {
    .profile-chart-risk-label {
        font-size: 5px;
    }
    .profile-chart-label {
        font-size: 5px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
        padding-top: 0;
        padding-bottom: 0; /* Контент может доходить до бара на мобилках, отступ задаём локально */
    }
    /* Профиль: отступ снизу, чтобы кнопка «Выйти» не уходила под нижний бар */
    body.profile-page-active #profile-page {
        padding-bottom: 100px;
    }

    .bottom-nav {
        bottom: 0;
        left: 0;
        right: 0;
        height: 80px;
        padding: 12px 8px 25px;
        gap: 4px;
        border-radius: 0;
    }
    
    .nav-btn {
        width: 48px;
        min-height: 52px;
        padding: 8px;
    }
    
    .nav-btn .icon {
        width: 28px;
        height: 42px;
    }
    
    .nav-btn span {
        display: none !important;
    }

    .bottom-nav .nav-btn[data-page="home"] {
        transform: translateY(0px);
        width: 56px;
        min-height: 56px;
    }

    .bottom-nav .nav-btn[data-page="home"] .icon {
        width: 28px;
        height: 42px;
        padding: 0;
        border-radius: 0;
    }
    
    .card {
        padding: 20px;
        border-radius: 16px;
    }
    
    .diary-grid {
        gap: 12px;
    }
    
    .diary-entry-inner {
        padding: 14px 16px 14px 18px;
    }
    
    .diary-bottom-actions {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .filters {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .preview-actions {
        flex-direction: column;
    }
    
    .preview-actions button {
        width: 100%;
    }
    
    h2 {
        font-size: 24px;
    }
    
    h3 {
        font-size: 18px;
    }
    
    .comparison-container {
        grid-template-columns: 1fr;
    }
}
