@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-400.ttf") format("truetype");
}
@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-500.ttf") format("truetype");
}
@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-600.ttf") format("truetype");
}
@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/IBMPlexSans-700.ttf") format("truetype");
}
@font-face {
    font-family: "Golos Text";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/GolosText-400.ttf") format("truetype");
}
@font-face {
    font-family: "Golos Text";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/GolosText-500.ttf") format("truetype");
}
@font-face {
    font-family: "Golos Text";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/GolosText-600.ttf") format("truetype");
}
@font-face {
    font-family: "Golos Text";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/GolosText-700.ttf") format("truetype");
}

/* Спільна тема інтерфейсу (ТЗ.md, Оновлення 22.07_3/22.07_4): навбар + hero + 3 колірні гами.
   Палітра застосовується через [data-theme] на <html>; за замовчуванням "a".
   --brand-teal/--brand-navy — ті самі кольори, що й навбар (Оновлення 22.07_4: навбар того
   ж кольору, що й усі кнопки по проекту), щоб старі .btn/.btn-save по всіх сторінках теж
   перефарбовувались темою без переписування кожної кнопки. */
:root {
    --app-btn-green: #14968F;  /* зелений «золотих» кнопок (Додати…/Надіслати/дії на В5), не залежить від теми */
    --font-ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --app-nav-ink: #FFFFFF;
    --app-nav-ink-dim: rgba(255, 255, 255, 0.78);
    --app-nav-ink-dim2: rgba(255, 255, 255, 0.85);
    --app-nav-mark-ink: #FFFFFF;
    --app-nav-hover-bg: rgba(255, 255, 255, 0.08);
    --app-nav-avatar-bg: rgba(255, 255, 255, 0.18);
}

:root,
[data-theme="a"] {
    --app-shell: #16232B;
    --app-shell-2: #1C3B37;
    --app-shell-light: #234B6E;
    --app-bg: #E7E3D8;
    --app-surface: #FFFFFF;
    --app-surface-2: #FBFAF6;
    --app-ink: #000000;
    --app-sub: #262624;
    --app-line: #DCD6C6;
    --app-accent: #3F6FE0;
    --app-accent-2: #A87C34;
    --app-accent-light: #6C93EA;
    --app-status-pending-bg: #F2E6CC;
    --app-status-pending-ink: #8A6416;
    --app-status-done-bg: #DCEEEC;
    --app-status-done-ink: #14685F;
}

/* "Вугілля класичне" (2026-07-28) — заміна попередньої чорно-золотої гами ("чогось бракувало"):
   справді темна тема — фон сторінки сіро-коричневий (не білий/світлий), навбар вугільно-чорний
   з теплим підтоном, класичне золото + іржавий другий акцент. Картки лишаються світлими (кольору
   топленого молока) для контрасту й читабельності. Обрано з 5 показаних варіацій "Вугілля". */
[data-theme="d"] {
    --app-shell: #15130F;
    --app-shell-2: #0C0A08;
    --app-shell-light: #3A342A;
    --app-bg: #38352F;
    --app-surface: #F5F1E9;
    --app-surface-2: #EAE5D9;
    --app-ink: #000000;
    --app-sub: #262624;
    --app-line: #DFD8C6;
    --app-accent: #D9A536;
    --app-accent-2: #9C4A2E;
    --app-accent-light: #E8C066;
    --app-status-pending-bg: #F1E7C9;
    --app-status-pending-ink: #7A611A;
    --app-status-done-bg: #E9E8E3;
    --app-status-done-ink: #5B5A53;
}

html[data-theme] {
    --brand-teal: var(--app-accent);
    --brand-navy: var(--app-shell);
    --brand-teal-light: var(--app-accent-light);
    --brand-navy-light: var(--app-shell-light);
    --text-navy: var(--app-ink);
    --ink: var(--app-ink);
    --sub: var(--app-sub);
}

html[data-theme] body {
    background: var(--app-bg);
    font-family: var(--font-ui);
}

.app-navbar {
    position: relative;
    background: linear-gradient(120deg, var(--app-shell), var(--app-shell-2));
    padding: 0.85rem 1.9rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
    align-items: center;
    gap: 1.2rem;
    box-shadow: 0 8px 30px -10px rgba(0, 0, 0, 0.55);
    position: sticky;
    top: 0;
    z-index: 40;
}

.app-navbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -26px;
    height: 26px;
    pointer-events: none;
    background: radial-gradient(60% 100% at 50% 0%, color-mix(in srgb, var(--app-accent) 28%, transparent), transparent 75%);
}

.app-navbar-brand {
    display: flex;
    align-items: center;
    justify-self: start;
    gap: 0.7rem;
    color: var(--app-nav-ink);
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
}

.app-navbar-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.app-navbar-brand-mark img {
    width: 19px;
    height: auto;
}

.app-navbar-brand-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.app-navbar-brand-name { font-weight: 500; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; }
.app-navbar-brand-address { font-size: 0.74rem; color: var(--app-nav-ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-navbar-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.6rem;
    flex-wrap: nowrap;
    grid-column: 2;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.app-nav-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--app-nav-ink-dim);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 500;
    padding: 0.6rem 1rem;
    background: none;
    border-radius: 9px;
    border: none;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
}

/* Глянцевий круглий значок (стиль TourMate): градієнт, біла обвідка, тінь, біла іконка. Колір — за предметом */
.app-nav-icon {
    --c: #7b8494;
    box-sizing: border-box;
    width: 24.7px;
    height: 24.7px;
    padding: 3.8px;
    flex-shrink: 0;
    color: #fff;
    border-radius: 50%;
    border: 2px solid #fff;
    background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--c) 45%, white) 0%, var(--c) 55%, color-mix(in srgb, var(--c) 72%, black) 100%);
    box-shadow: 0 2px 5px -1px rgba(15, 23, 42, 0.32), inset 0 -2px 3px rgba(0, 0, 0, 0.18);
}

.app-nav-icon.ic-home { --c: #2f9e8f; }
.app-nav-icon.ic-reception { --c: #2f9e8f; }
.app-nav-icon.ic-reports { --c: #8b5cf6; }
.app-nav-icon.ic-documents { --c: #d6a019; }
.app-nav-icon.ic-settings { --c: #7b8494; }
.app-nav-icon.ic-appointments { --c: #3b82f6; }
.app-nav-icon.ic-accounting { --c: #2f9e6b; }
.app-nav-icon.ic-patients { --c: #0ea5a4; }
.app-nav-icon.ic-support { --c: #e08a2c; }
.app-nav-icon.ic-clinics { --c: #6366f1; }
.app-nav-icon.ic-statistics { --c: #ec6a4c; }
.app-nav-icon.ic-logout { --c: #d25555; }

.app-nav-btn:hover {
    color: var(--app-nav-ink);
    background: var(--app-nav-hover-bg);
}

.app-nav-btn.active {
    color: var(--app-nav-ink);
}

.app-nav-btn.active::after {
    content: "";
    position: absolute;
    left: 0.9rem;
    right: 0.9rem;
    bottom: 0.15rem;
    height: 2px;
    border-radius: 2px;
    background: var(--app-accent);
    box-shadow: 0 0 10px 2px color-mix(in srgb, var(--app-accent) 90%, transparent);
}

.app-navbar-right {
    display: flex;
    align-items: center;
    justify-self: end;
    gap: 1rem;
    flex-wrap: nowrap;
    min-width: 0;
}

.app-navbar-user {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--app-nav-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.app-navbar-user-role {
    font-size: 0.72rem;
    color: var(--app-nav-ink-dim);
}

.app-btn-end-shift {
    padding: 0.55rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(196, 74, 74, 0.35);
    background: rgba(196, 74, 74, 0.18);
    color: var(--app-nav-ink);
}

.app-btn-end-shift:hover {
    background: rgba(196, 74, 74, 0.32);
}

@media (max-width: 1440px) {
    .app-navbar {
        padding: 0.75rem 1.4rem;
        gap: 0.9rem;
    }

    .app-navbar-nav {
        gap: 1rem;
    }

    .app-nav-btn {
        font-size: 0.95rem;
        padding: 0.55rem 0.8rem;
        gap: 0.4rem;
    }
}

@media (max-width: 1180px) {
    .app-navbar {
        padding: 0.7rem 1.1rem;
        gap: 0.7rem;
    }

    .app-navbar-brand-address {
        display: none;
    }

    .app-navbar-nav {
        gap: 0.5rem;
    }

    .app-nav-btn {
        font-size: 0.87rem;
        padding: 0.5rem 0.6rem;
    }

    .app-navbar-user-role {
        display: none;
    }
}

/* Бічний варіант навбару (navbar(..., side=True)) */
.app-navbar--side {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 1.6rem;
    width: 240px;
    padding: 1.4rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    box-shadow: 8px 0 30px -10px rgba(0, 0, 0, 0.55);
    overflow-y: auto;
}

.app-navbar--side::after { display: none; }

/* Сайдбар: глибокий синій (варіант 3), яскравий текст без прозорості, активний пункт — заливка акценту */
.app-navbar--side {
    background: #111C36;
    --app-nav-ink: #F2F5FF;
    --app-nav-ink-dim: #F2F5FF;
    --app-nav-ink-dim2: #F2F5FF;
    --app-nav-hover-bg: rgba(108, 147, 234, 0.18);
}

.app-navbar--side .app-navbar-brand { justify-self: auto; flex-shrink: 0; }
.app-navbar--side .app-navbar-brand-address { display: block; white-space: normal; }

.app-navbar--side .app-navbar-nav {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.15rem;
    grid-column: auto;
    overflow: visible;
    flex: 1;
}

.app-navbar--side .app-nav-btn {
    font-size: 1rem;
    padding: 0.5rem 0.9rem;
    gap: 0.7rem;
}

.app-navbar--side .app-nav-btn.active { background: #3F6FE0; color: #FFFFFF; font-weight: 500; }

/* Темна тема: сайдбар «Вугілля тепле» (варіант 2 з мокапів) */
[data-theme="d"] .app-navbar--side {
    background: #1B1A17;
    --app-nav-ink: #F6F3EA;
    --app-nav-ink-dim: #F6F3EA;
    --app-nav-ink-dim2: #F6F3EA;
    --app-nav-hover-bg: rgba(217, 165, 54, 0.16);
}
[data-theme="d"] .app-navbar--side .app-nav-btn.active { background: #D9A536; color: #1B1A17; }

.app-navbar--side .app-nav-btn.active::after {
    display: none;
    left: 0;
    right: auto;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 3px;
    height: auto;
}

.app-navbar--side .app-navbar-right {
    flex-direction: column;
    align-items: stretch;
    justify-self: auto;
    gap: 0.8rem;
}

.app-navbar--side .app-navbar-user { white-space: normal; }
.app-navbar--side .app-navbar-user-role { display: block; }
.app-navbar--side .app-btn-end-shift { justify-content: center; }

/* Лічильник пацієнтів і черга в сайдбарі */
.app-navbar--side .app-navbar-nav { flex: 0 0 auto; }
.app-sb-stats {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    color: var(--app-nav-ink);
}
.app-navbar--side .app-navbar-right { margin-top: auto; }
.app-sb-stats-main { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.1rem; }
.app-sb-stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.app-sb-stat-label { font-size: 0.85rem; opacity: 0.85; margin-bottom: 0.4rem; }
.app-sb-stat-label:last-child { margin-bottom: 0; }
.app-sb-chips { display: flex; flex-direction: column; }
.app-sb-chip {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.35rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}
.app-sb-chip span { opacity: 0.85; }
.app-sb-chip b { font-weight: 500; font-variant-numeric: tabular-nums; }
.app-sb-queue {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.7rem;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    font-weight: 500;
}
.app-sb-queue b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.app-sb-queue-dot {
    display: inline-block;
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: currentColor;
    margin-right: 0.4rem;
    vertical-align: middle;
    animation: app-sb-pulse 1.8s ease-in-out infinite;
}
@keyframes app-sb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .app-sb-queue-dot { animation: none; } }

body:has(.app-navbar--side) { padding-left: 240px; }

@media (max-width: 800px) {
    body:has(.app-navbar--side) { padding-left: 0; }
    .app-navbar--side { width: 100%; position: relative; bottom: auto; }
    .app-navbar--side .app-navbar-nav { flex-direction: row; flex-wrap: wrap; }
}

.search-eyebrow {
    text-align: center;
    font-size: 0.84rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--app-accent);
    margin-bottom: 0.3rem;
}

.app-hero {
    background: linear-gradient(180deg, var(--app-shell-2), var(--app-bg) 140%);
    color: var(--app-nav-ink);
    padding: 0.6rem 1.5rem;
    text-align: center;
    min-height: 3.7rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.app-hero-title { font-size: 1.25rem; font-weight: 500; }
.app-hero-sub { font-size: 0.92rem; color: var(--app-nav-ink-dim); margin-top: 0.2rem; }

/* ===== Модалка перемикача теми (В4/В7) ===== */
.theme-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 35, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 60;
}
.theme-modal-overlay.visible { display: flex; }
.theme-modal-box {
    background: var(--app-surface);
    color: var(--app-ink);
    border-radius: 14px;
    padding: 1.8rem;
    max-width: 560px;
    width: 92%;
    box-shadow: 0 20px 40px -16px rgba(4, 20, 26, 0.4);
}
.theme-modal-box p { font-size: 0.9rem; font-weight: 500; color: var(--app-sub); text-align: center; margin: 0 0 1.2rem; }
.theme-swatches { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.theme-swatch { flex: 1; min-width: 140px; }
.theme-swatch-bar { height: 30px; border-radius: 8px; margin-bottom: 0.5rem; }
.theme-swatch label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; font-weight: 500; cursor: pointer; }
.theme-modal-actions { display: flex; justify-content: flex-end; gap: 0.7rem; }
.theme-btn-apply {
    border: none; border-radius: 8px; padding: 0.65rem 1.5rem; font-size: 0.88rem; font-weight: 500;
    color: #fff; background: var(--app-accent); cursor: pointer;
}
.theme-btn-cancel {
    border: none; border-radius: 8px; padding: 0.65rem 1.5rem; font-size: 0.88rem; font-weight: 500;
    color: var(--app-ink); background: var(--app-surface-2); border: 1.5px solid var(--app-line); cursor: pointer;
}

/* Спільні елементи, раніше продубльовані по кожному шаблону (visit_new/reports/patient_new/settings):
   олівець-кнопка редагування поля і фото пацієнта з посиланням на друк. */
.pencil-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1.5px solid var(--app-line);
    background: var(--app-surface-2);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pencil-btn.confirm {
    border: none;
    background: var(--brand-teal);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 500;
}

.pencil-btn.confirm:hover {
    filter: brightness(1.08);
}

.pencil-btn.text {
    width: auto;
    height: auto;
    padding: 0.4rem 0.8rem;
    font-size: 0.78rem;
    white-space: nowrap;
}

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

/* Кнопки-значки (олівець, ✓, ✕, смітник, оновити) — глянцеві круглі, розмір 30×30 як раніше */
button.pencil-btn:not(.text) {
    --c: #e08a2c;
    width: 28.5px;
    height: 28.5px;
    border-radius: 50%;
    border: 2px solid #fff;
    color: #fff;
    background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--c) 45%, white) 0%, var(--c) 55%, color-mix(in srgb, var(--c) 72%, black) 100%);
    box-shadow: 0 2px 5px -1px rgba(15, 23, 42, 0.32), inset 0 -2px 3px rgba(0, 0, 0, 0.18);
}

button.pencil-btn.confirm:not(.text) { --c: #2f9e6b; }
button.pencil-btn.cancel:not(.text), button.pencil-btn.note-delete:not(.text) { --c: #d25555; }
button.pencil-btn.active-toggle:not(.confirm):not(.text) { --c: #9aa3ad; }
.pencil-btn .pencil-ic {
    width: 14px;
    height: 14px;
    display: block;
    fill: currentColor;
}

button.pencil-btn:not(.text):hover { filter: brightness(1.07); }

.photo-block {
    flex-shrink: 0;
    width: 108px;
    text-align: center;
}

.patient-photo {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 8px 20px -10px rgba(4, 20, 26, 0.4);
    display: block;
}

.photo-print-link {
    display: block;
    position: relative;
}

.photo-print-link .patient-photo {
    transition: filter 0.15s;
}

.photo-print-link:hover .patient-photo {
    filter: brightness(0.75);
}

/* Легке припіднімання кнопок і значків при наведенні (низька специфічність — локальні стилі мають пріоритет) */
:where(button, .btn, [class*="-btn"], .pick-btn, .app-nav-icon) {
    transition: transform 0.15s ease, filter 0.15s ease;
}
:where(button, .btn, [class*="-btn"], .pick-btn):where(:not(:disabled, .tick, .rail-cat)):hover {
    transform: translateY(-1.5px);
    filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.2));
}
.app-nav-btn:hover .app-nav-icon {
    transform: translateY(-1.5px);
    filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.25));
}
