:root {
    /* Палитра по ТЗ: тёмный SaaS, один уверенный акцент (оранжевый),
       без радуги вторичных ярких цветов и без стеклянных эффектов. */
    --bg: #0d0f14;
    --surface: #151820;
    --surface-2: #1b1e27;
    --surface-3: #232733;
    --border: rgba(255,255,255,0.06);
    --border-strong: rgba(255,255,255,0.12);

    --text: #f5f7fa;
    --text-dim: #8b919e;
    --text-faint: rgba(139,145,158,0.65);

    --accent: #ff6b35;
    --accent-2: #ff8b5c;
    --accent-grad: linear-gradient(135deg, var(--accent), var(--accent-2));
    --accent-soft: rgba(255,107,53,0.14);
    --accent-text: #ff8b5c;

    --info: #4c8dff;
    --info-soft: rgba(76,141,255,0.14);

    --success: #34c77b;
    --success-soft: rgba(52,199,123,0.14);
    --warning: #f2b84b;
    --warning-soft: rgba(242,184,75,0.14);
    --danger: #f0506e;
    --danger-soft: rgba(240,80,110,0.14);

    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --shadow-card: 0 1px 2px rgba(0,0,0,0.22), 0 6px 16px -8px rgba(0,0,0,0.45);
    --shadow-float: 0 12px 28px -8px rgba(0,0,0,0.55);

    /* Цветные тени под сплошными акцентными кнопками — та же логика, что
       уже была у .fab (свечение в цвет самой кнопки, не голая чёрная тень).
       "-sm" — для некрупных кнопок в потоке, обычная — для самых заметных
       (главный CTA-сабмит), "-active" — прижатое состояние при нажатии. */
    --shadow-accent: 0 8px 20px -8px rgba(255,107,53,0.5);
    --shadow-accent-sm: 0 4px 12px -5px rgba(255,107,53,0.45);
    --shadow-accent-active: 0 2px 8px -4px rgba(255,107,53,0.35);
    --shadow-danger-sm: 0 4px 12px -5px rgba(240,80,110,0.4);
    --shadow-danger-active: 0 2px 8px -4px rgba(240,80,110,0.3);

    --nav-height: 62px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Атрибут hidden должен побеждать всегда — иначе классы вроде .overlay
   и .fab со своим display:flex перебивают браузерное [hidden]{display:none},
   и элемент остаётся видимым (и "мёртвым" для JS-логики), даже когда
   скрипт правильно выставил hidden=true. */
[hidden] {
    display: none !important;
}

html {
    color-scheme: dark;
}

body {
    font-family: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;

    background: var(--bg);
    color: var(--text);

    min-height: 100vh;
    overflow-x: hidden;
}

button, input, select, textarea {
    font-family: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

svg { display: block; }

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 8px;
}

.app {
    min-height: 100vh;
    max-width: 700px;
    margin: 0 auto;

    display: flex;
    flex-direction: column;
}


/* HEADER */

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

    padding: 18px 20px;
    padding-top: calc(18px + env(safe-area-inset-top));

    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(13,15,20,0.82);
    /* Клип для header-glow ниже — чтобы блюр не вылезал за пределы шапки
       и не создавал горизонтальный скролл */
    overflow: hidden;
}

/* Едва заметное цветное свечение за шапкой — на грани заметности, не
   "неон" и не тяжёлый glass-эффект, просто лёгкая глубина у самого
   верха экрана. Рисуется ДО заголовка/аватара в разметке, поэтому лежит
   под ними по порядку отрисовки, хоть и без явного z-index. */
.header-glow {
    position: absolute;
    top: -70%;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    height: 200px;

    background: radial-gradient(ellipse, rgba(255,107,53,0.30), transparent 70%);
    filter: blur(36px);
    pointer-events: none;
}

.title {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.subtitle {
    margin-top: 3px;
    font-size: 13px;
    color: var(--text-dim);
}

.avatar {
    width: 42px;
    height: 42px;
    flex-shrink: 0;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--accent-grad);
    background-size: cover;
    background-position: center;
    color: #fff;
    box-shadow: var(--shadow-accent-sm);

    font-weight: 700;
    font-size: 15px;
}


/* CONTENT */

.content {
    flex: 1;
    padding: 18px 16px;
    padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom));

    animation: view-fade-in 0.2s ease;
}

@keyframes view-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome {
    margin-bottom: 18px;
}

.welcome-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.welcome-text {
    margin-top: 4px;
    font-size: 13.5px;
    color: var(--text-dim);
}


/* STATS ROW (главный экран — сводка "Сегодня") */

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 14px 12px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.1;

    /* Заливка градиентом текста — color остаётся фолбэком на случай,
       если background-clip:text почему-то не сработает */
    color: var(--text);
    background: var(--accent-grad);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--text-dim);
}


/* ГЛАВНАЯ: карточка "Заказы" + сетка 2×2 */

.primary-card {
    width: 100%;
    display: block;
    text-align: left;

    padding: 18px;
    border-radius: var(--radius-lg);
    margin-bottom: 10px;

    background: var(--surface);
    border: 1px solid var(--border);
    /* Обычная тень карточки + едва заметный тёплый отблеск снизу —
       главная карточка приложения должна читаться первой, даже без
       сплошной оранжевой заливки */
    box-shadow: var(--shadow-card), 0 14px 28px -18px rgba(255,107,53,0.4);

    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.primary-card:active {
    transform: scale(0.985);
    background: var(--surface-2);
}

.primary-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.primary-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--accent-soft);
    color: var(--accent);
}

.primary-card-title {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 17px;
    font-weight: 800;
}

.primary-card-desc {
    margin-top: 3px;
    font-size: 13px;
    color: var(--text-dim);
}

.primary-card-count {
    margin-top: 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-text);
}

/* "Бенто": сетка 2 колонки, но чат — широкая карточка на всю строку
   (у неё самое живое содержимое — счётчик непрочитанных), остальные —
   обычные квадратные ячейки друг под другом */
.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.quick-card {
    display: block;
    text-align: left;

    padding: 14px;
    border-radius: var(--radius-lg);

    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);

    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.quick-card:active {
    transform: scale(0.97);
    background: var(--surface-2);
}

.quick-card-wide {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 14px;
}

.quick-card-body {
    flex: 1;
    min-width: 0;
}

.quick-card-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--surface-3);
    color: var(--text-dim);
}

.quick-card-title {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 700;
}

/* В широкой карточке иконка стоит рядом с текстом, а не над ним —
   верхний отступ, унаследованный от обычной карточки, тут не нужен */
.quick-card-wide .quick-card-title {
    margin-top: 0;
}

.quick-card-desc {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--text-faint);
    line-height: 1.3;
}

/* Когда есть непрочитанные — описание чата подсвечивается акцентом
   (см. app.js: refreshUnreadBadges → #quick-chat-desc) */
.quick-card-desc.has-unread {
    color: var(--accent-text);
    font-weight: 700;
}


/* Иконки в фиксированных цветах бренда — используются экономно, только
   на главном экране, чтобы разделы отличались друг от друга на взгляд.
   Классы, а не :nth-of-type — порядок карточек в разметке теперь не
   привязан к тому, какой цвет у какой иконки. */
.quick-card-chat .quick-card-icon { background: var(--info-soft); color: var(--info); }
.quick-card-team .quick-card-icon { background: var(--success-soft); color: var(--success); }
.quick-card-analytics .quick-card-icon { background: var(--warning-soft); color: var(--warning); }
.quick-card-logs .quick-card-icon { background: var(--danger-soft); color: var(--danger); }
.quick-card-activity .quick-card-icon { background: var(--accent-soft); color: var(--accent); }


/* BOTTOM NAV */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;

    max-width: 700px;
    margin: 0 auto;

    display: flex;
    align-items: stretch;

    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);

    background: rgba(21,24,32,0.92);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
}

/* Плавающая "таблетка" за активной вкладкой — позиция и ширина
   выставляются в JS (updateNavPill, см. app.js: setActiveNav) под реальные
   размеры кнопки, а не жёстко на 1/4 ширины: пунктов навигации может
   быть разное количество. */
.nav-pill {
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 0;
    width: 0;

    border-radius: 16px;
    background: var(--accent-soft);

    pointer-events: none;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.15, 0.4, 1), width 0.3s ease, opacity 0.2s ease;
}

.nav-pill.visible {
    opacity: 1;
}

.nav-item {
    position: relative;
    z-index: 1;
    flex: 1;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;

    border: 0;
    background: transparent;
    color: var(--text-faint);

    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;

    min-height: 44px;
    transition: color 0.15s ease;
}

.nav-item svg {
    width: 22px;
    height: 22px;
}

.nav-item.active {
    color: var(--accent);
}

.nav-icon-wrap {
    position: relative;
    display: inline-flex;
}

/* Бейдж "непрочитано" на вкладке "Чат" — просто точка, без цифры (счёт
   чатов с непрочитанным не так важен, важен сам факт) */
.nav-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    border: 1.5px solid var(--bg);
}


/* SECTION HEADER (экраны кроме главной) */

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;

    margin-bottom: 18px;
}

.back-button {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 36px;
    height: 36px;
    flex-shrink: 0;

    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);

    cursor: pointer;
}

.back-button svg {
    width: 18px;
    height: 18px;
}

.section-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.farmer-mode-toggle {
    margin-left: auto;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    gap: 5px;

    padding: 7px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-strong);

    background: var(--surface);
    color: var(--text-dim);

    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;

    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.farmer-mode-toggle svg {
    width: 14px;
    height: 14px;
}

.farmer-mode-toggle.active {
    background: var(--accent-grad);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-accent-sm);
}


/* ORDERS LIST */

.status-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.status-tabs::-webkit-scrollbar {
    display: none;
}

.status-tab {
    flex-shrink: 0;

    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-strong);

    background: var(--surface);
    color: var(--text-dim);

    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;

    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.status-tab.active {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-accent-sm);
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-state {
    text-align: center;
    padding: 40px 0;
    color: var(--text-faint);
    font-size: 14px;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;

    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;

    background: var(--surface-2);
    color: var(--text-faint);
}

.empty-state-icon svg {
    width: 24px;
    height: 24px;
}

/* Для двух самых часто посещаемых пустых состояний (заказы, чат) —
   собственная мини-иллюстрация вместо иконки в кружке, см. app.js:
   ILLUSTRATIONS. Использует var(--...) прямо в SVG — работает, т.к. SVG
   встроен в разметку страницы, а не подключён отдельным файлом. */
.empty-state-illustration {
    margin: 0 auto 14px;
    width: 120px;
}


/* SKELETON (загрузка списка заказов при первом заходе) */

.skeleton-card {
    height: 78px;
    border-radius: var(--radius-lg);
    background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.3s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    0% { background-position: 120% 0; }
    100% { background-position: -20% 0; }
}

.order-card {
    display: block;
    padding: 13px;
    border-radius: var(--radius-lg);

    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    box-shadow: var(--shadow-card);

    transition: border-color 0.2s ease, transform 0.12s ease;
    animation: card-appear 0.22s ease;
}

@keyframes card-appear {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Цвет заказа сразу виден по полоске слева — меняется вместе со статусом */
.order-card.order-color-new { border-left-color: var(--info); }
.order-card.order-color-in_progress { border-left-color: var(--warning); }
.order-card.order-color-done { border-left-color: var(--success); }
.order-card.order-color-rejected { border-left-color: var(--danger); }

.order-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.order-photo {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.order-photo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--accent-grad);
    color: #fff;

    font-size: 17px;
    font-weight: 700;
}

.order-photos {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-top: 8px;
    padding-bottom: 2px;
}

.order-photo-item {
    position: relative;
    flex-shrink: 0;
}

.order-photo-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: block;
    cursor: pointer;
}

.order-photo-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--accent);
    color: #fff;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.order-photo-badge svg {
    width: 10px;
    height: 10px;
}

.order-info {
    flex: 1;
    min-width: 0;
}

.order-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.order-title {
    min-width: 0;
    font-size: 14.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Пометка "срочно" — ставит и снимает автор заказа (или админ) тапом
   прямо по бейджу, поэтому cursor:pointer и небольшой hit-area */
.badge-urgent {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 3px;

    padding: 3px 8px;
    border-radius: 20px;

    background: var(--danger-soft);
    color: var(--danger);

    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.badge-urgent svg {
    width: 10px;
    height: 10px;
}

/* Приглушённая версия — заказ ЕЩЁ не срочный, но тому, кто может, тут
   же предлагаем это исправить, не заходя отдельно в редактирование */
.badge-urgent-off {
    background: transparent;
    border: 1px dashed var(--border-strong);
    color: var(--text-faint);
}

.order-description {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--text-dim);
    line-height: 1.4;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.order-meta {
    margin-top: 3px;
    font-size: 11.5px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-meta.reject-reason {
    white-space: normal;
    color: var(--danger);
}

/* Имя профиля, на который выполнен заказ — раньше терялось среди обычных
   строк-метаданных ("Создан...", "Заказал...") одним и тем же тусклым
   цветом. Теперь отдельный акцентный бейдж, чтобы бросался в глаза сразу,
   особенно в списке готовых заказов. */
.order-profile-name {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;

    margin-top: 5px;
    padding: 3px 9px;
    border-radius: 999px;

    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 11.5px;
    font-weight: 700;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-profile-name svg {
    flex-shrink: 0;
    width: 11px;
    height: 11px;
}

.order-status {
    flex-shrink: 0;

    display: inline-flex;
    align-items: center;
    gap: 5px;

    padding: 5px 10px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
}

.order-status .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* "Живые" статусы (требуют действия) — сплошная заливка, заметнее;
   архивные (done/rejected, уже закрытый вопрос) — как раньше, приглушённо.
   Разница в весе сама ведёт взгляд к тому, что ещё не сделано. */
.status-new {
    background: var(--info);
    color: #fff;
    box-shadow: 0 3px 10px -5px rgba(76,141,255,0.6);
}

.status-in_progress {
    background: var(--warning);
    color: var(--bg);
    box-shadow: 0 3px 10px -5px rgba(242,184,75,0.6);
}

.status-done {
    background: var(--success-soft);
    color: var(--success);
}

.status-rejected {
    background: var(--danger-soft);
    color: var(--danger);
}

.status-select {
    flex-shrink: 0;

    padding: 5px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);

    background: var(--surface-2);
    color: var(--text);

    font-size: 11px;
}

.order-status-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.order-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.order-card-actions .small-button,
.order-card-actions .ghost-button {
    width: auto;
    margin-bottom: 0;
    padding: 9px 13px;
}

.order-card-actions .ghost-button {
    border-radius: var(--radius-sm);
}

.chat-open-button {
    position: relative;
}

/* Точка "есть непрочитанное" на кнопке чата заказа — считается только
   для участников переписки (создатель/фармер), см. GET /api/notifications/unread */
.chat-open-button.has-unread::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 7px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    border: 1.5px solid var(--surface);
}


/* TEAM SCREEN */

.role-badge {
    display: inline-block;

    padding: 5px 13px;
    border-radius: 20px;

    background: var(--accent-soft);
    color: var(--accent-text);

    font-size: 12.5px;
    font-weight: 700;

    margin-bottom: 16px;
}

.team-block {
    margin-bottom: 22px;
}

.team-block-title {
    font-size: 11.5px;
    color: var(--text-dim);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.team-card {
    padding: 14px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    margin-bottom: 10px;
}

.team-card-title {
    font-size: 14.5px;
    font-weight: 700;
}

.team-card-meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-dim);
}

.member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    margin-bottom: 8px;

    font-size: 13.5px;
}

.member-role {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
}

.ghost-button {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 12px;
    border-radius: var(--radius-md);
    border: 1.5px dashed var(--border-strong);

    background: transparent;
    color: var(--accent-text);

    font-size: 13.5px;
    font-weight: 700;

    cursor: pointer;
    margin-bottom: 10px;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.ghost-button svg {
    width: 16px;
    height: 16px;
}

.ghost-button:active {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: var(--shadow-accent-active);
    transform: scale(0.98);
}

.small-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 0;

    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-accent-sm);

    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.1s ease, box-shadow 0.1s ease;
}

.small-button svg {
    width: 14px;
    height: 14px;
}

.small-button:active {
    transform: scale(0.96);
    box-shadow: var(--shadow-accent-active);
}

.small-button:disabled {
    opacity: 0.5;
    box-shadow: none;
}

.danger-button {
    background: var(--danger);
    box-shadow: var(--shadow-danger-sm);
}

.danger-button:active {
    box-shadow: var(--shadow-danger-active);
}

.invite-panel {
    padding: 14px;
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
    border: 1px solid rgba(255,107,53,0.25);

    margin-bottom: 16px;
}

.invite-panel-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.invite-link-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.invite-link-box {
    display: block;
    flex: 1;
    min-width: 0;
    width: 100%;

    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);

    background: var(--surface);
    color: var(--text-dim);

    font-size: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    word-break: break-all;
}

.invite-copy-button {
    flex-shrink: 0;
    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-dim);

    cursor: pointer;
    transition: transform 0.1s ease, color 0.15s ease, border-color 0.15s ease;
}

.invite-copy-button svg {
    width: 16px;
    height: 16px;
}

.invite-copy-button:active {
    transform: scale(0.92);
}

.invite-copy-button.copied {
    color: var(--success);
    border-color: var(--success);
}

.rename-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.rename-row .field-input {
    flex: 1;
}


/* ADMIN: СТАТУС СЕРВЕРА + ЖУРНАЛ ОШИБОК */

.server-status {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 12px 14px;
    border-radius: var(--radius-md);

    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);

    font-size: 12.5px;
    font-weight: 600;

    margin-bottom: 14px;
}

.server-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.server-status.ok {
    background: var(--success-soft);
    color: var(--success);
}

.server-status.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.server-status.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.live-ping {
    display: flex;
    align-items: center;
    gap: 6px;

    padding: 6px 14px;
    margin-top: -8px;
    margin-bottom: 14px;

    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-faint);
}

.live-ping svg {
    width: 13px;
    height: 13px;
}

.live-ping.ok { color: var(--success); }
.live-ping.slow { color: var(--warning); }
.live-ping.error { color: var(--danger); }

.log-entry {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--danger);

    background: var(--surface);
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);

    margin-bottom: 8px;
}

.log-entry-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.log-entry-code {
    flex-shrink: 0;

    padding: 2px 7px;
    border-radius: 6px;

    background: var(--danger-soft);
    color: var(--danger);

    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 10.5px;
    font-weight: 700;
}

.log-entry-time {
    flex-shrink: 0;
    font-size: 10.5px;
    color: var(--text-faint);
}

.log-entry-message {
    font-size: 13px;
    line-height: 1.4;
}

.log-entry-detail {
    margin-top: 5px;

    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 11px;
    color: var(--text-faint);
    line-height: 1.4;
    word-break: break-all;
}


/* ЖУРНАЛ (бизнес-события по заказам — фармер/админ, routers/orders.py:
   list_activity). Не путать с .log-entry выше — те технические, про
   сервер/ошибки. */

.activity-item {
    display: flex;
    gap: 12px;

    padding: 12px 14px;
    border-radius: var(--radius-md);

    background: var(--surface);
    border: 1px solid var(--border);

    margin-bottom: 8px;
}

.activity-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;

    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-icon svg {
    width: 16px;
    height: 16px;
}

.activity-icon-info { background: var(--info-soft); color: var(--info); }
.activity-icon-warning { background: var(--warning-soft); color: var(--warning); }
.activity-icon-success { background: var(--success-soft); color: var(--success); }
.activity-icon-danger { background: var(--danger-soft); color: var(--danger); }
.activity-icon-muted { background: var(--surface-2); color: var(--text-faint); }

.activity-body {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 13.5px;
    line-height: 1.4;
}

.activity-text b {
    font-weight: 700;
}

.activity-time {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-faint);
}


/* ACCESS REQUESTS (заявки на доступ, экран команды у админа) */

.access-request-card {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 12px 14px;
    border-radius: var(--radius-md);

    background: var(--warning-soft);
    border: 1px solid rgba(242,184,75,0.25);

    margin-bottom: 8px;
}

.access-request-name {
    font-size: 13.5px;
    font-weight: 700;
}

.access-request-meta {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--text-dim);
}

.access-request-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.icon-button {
    width: 34px;
    height: 34px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: var(--radius-sm);
    border: 0;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.icon-button svg {
    width: 16px;
    height: 16px;
}

.icon-button:active {
    transform: scale(0.92);
}

.icon-button.approve {
    background: var(--success-soft);
    color: var(--success);
}

.icon-button.reject {
    background: var(--danger-soft);
    color: var(--danger);
}

.icon-button.neutral {
    background: var(--accent-soft);
    color: var(--accent-text);
}


/* PENDING / REJECTED ACCESS SCREEN */

.access-status-card {
    text-align: center;
    padding: 50px 20px;
}

.access-status-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;

    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;

    background: var(--surface-2);
    color: var(--text-dim);
}

.access-status-icon svg {
    width: 26px;
    height: 26px;
}

.access-status-title {
    font-size: 17px;
    font-weight: 800;
    margin-bottom: 8px;
}

.access-status-text {
    font-size: 13.5px;
    color: var(--text-dim);
    line-height: 1.55;
    max-width: 320px;
    margin: 0 auto;
}


/* CHAT */

.chat-sheet {
    display: flex;
    flex-direction: column;
    height: 82vh;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;

    display: flex;
    flex-direction: column;
    gap: 10px;

    padding: 4px 2px 12px;
}

/* Чат команды — отдельный экран, а не шторка, своего flex-родителя с
   заданной высотой нет, поэтому высоту задаём явно. */
.team-chat-messages {
    height: calc(100vh - 300px);
    min-height: 240px;
}

.chat-bubble {
    max-width: 78%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.45;
    word-wrap: break-word;
}

.chat-bubble.mine {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble.theirs {
    align-self: flex-start;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-bubble-author {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.75;
    margin-bottom: 3px;
}

.chat-bubble-time {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    margin-top: 4px;
}

.chat-bubble-time-text {
    font-size: 10px;
    opacity: 0.65;
}

/* Галочки "доставлено/прочитано" — только у своих сообщений (см. app.js:
   renderMessagesInto). Одна галочка тусклая (отправлено, ещё не увидели),
   двойная — яркая (прочитано хотя бы одним из адресатов чата). */
.chat-bubble-status {
    display: inline-flex;
    flex-shrink: 0;
    opacity: 0.55;
}

.chat-bubble-status.read {
    opacity: 1;
}

.chat-form {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.chat-form .field-input {
    flex: 1;
}

.chat-send-button {
    width: 44px;
    height: 44px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: var(--radius-md);

    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-accent-sm);

    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.chat-send-button svg {
    width: 18px;
    height: 18px;
}

.chat-send-button:active {
    transform: scale(0.94);
    box-shadow: var(--shadow-accent-active);
}


/* FAB (кнопка "добавить заказ") */

.fab {
    position: fixed;
    right: 18px;
    bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
    z-index: 21;

    width: 54px;
    height: 54px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 50%;

    background: var(--accent-grad);
    color: #fff;

    box-shadow: 0 8px 20px -6px rgba(255,107,53,0.55);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.fab svg {
    width: 24px;
    height: 24px;
}

.fab:active {
    transform: scale(0.93);
}


/* TOASTS */

.toast-container {
    position: fixed;
    left: 16px;
    right: 16px;
    /* Выше и панели навигации, и плавающей кнопки "+" (она видна на экране
       заказов) — чтобы тост никогда их не перекрывал */
    bottom: calc(var(--nav-height) + 78px + env(safe-area-inset-bottom));
    z-index: 200;

    max-width: 668px;
    margin: 0 auto;

    display: flex;
    flex-direction: column;
    gap: 8px;

    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 12px 14px;
    border-radius: var(--radius-md);

    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-float);
    color: var(--text);

    font-size: 13.5px;
    font-weight: 600;

    animation: toast-in 0.2s ease;
}

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

.toast.hide {
    animation: toast-out 0.18s ease forwards;
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(4px); }
}

.toast-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--info); }


/* БАННЕР "ДОСТУПНО ОБНОВЛЕНИЕ" */

.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 500; /* выше шапки и тостов — это важнее и появляется редко */

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;

    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: var(--accent-grad);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;

    box-shadow: var(--shadow-float);
}

.update-banner-button {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1.5px solid rgba(255,255,255,0.6);
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}


/* OVERLAY / BOTTOM SHEET (форма заказа, чат) */

.overlay {
    position: fixed;
    inset: 0;

    background: rgba(5,6,9,0.7);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);

    display: flex;
    align-items: flex-end;

    z-index: 100;

    animation: overlay-fade-in 0.18s ease;
}

@keyframes overlay-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes sheet-slide-up {
    from { transform: translateY(24px); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
}

.sheet {
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;

    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-bottom: none;

    box-shadow: var(--shadow-float);

    border-radius: 22px 22px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));

    animation: sheet-slide-up 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.sheet::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 4px;
    background: var(--border-strong);
    margin: -6px auto 14px;
}

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

    margin-bottom: 16px;
}

.sheet-title {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.close-button {
    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    background: var(--surface-3);
    color: var(--text);

    width: 34px;
    height: 34px;
    border-radius: 50%;

    cursor: pointer;
    transition: transform 0.1s ease;
}

.close-button svg {
    width: 16px;
    height: 16px;
}

.close-button:active {
    transform: scale(0.9);
}

.field-label {
    display: block;
    margin: 14px 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
}

.field-input {
    width: 100%;

    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);

    background: var(--surface-2);
    color: var(--text);

    font-size: 15px;

    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

textarea.field-input {
    resize: vertical;
    min-height: 90px;
    line-height: 1.4;
}

/* Кастомный чекбокс (нативный слишком выбивается из тёмного UI) — сам
   input остаётся в DOM и доступен (не display:none), просто визуально
   спрятан за собственным лейблом */
.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;

    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);

    font-size: 14px;
    font-weight: 600;

    cursor: pointer;
    /* Сама метка должна быть удобной для пальца целиком, не только квадратик */
    min-height: 44px;
}

.checkbox-field input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.checkbox-box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1.5px solid var(--border-strong);

    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;

    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.checkbox-field input:checked + .checkbox-box {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
}

.checkbox-field input:focus-visible + .checkbox-box {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.photo-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.photo-preview-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.submit-button {
    width: 100%;
    margin-top: 20px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 15px;
    border: 0;
    border-radius: var(--radius-md);

    background: var(--accent-grad);
    color: #fff;
    box-shadow: var(--shadow-accent);

    font-size: 15px;
    font-weight: 700;

    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.1s ease, box-shadow 0.1s ease;
}

.submit-button:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-accent-active);
}

.submit-button:disabled {
    opacity: 0.55;
    box-shadow: none;
}


/* LIGHTBOX (просмотр фото заказа крупно) */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;

    background: rgba(5,6,9,0.94);

    display: flex;
    align-items: center;
    justify-content: center;

    animation: overlay-fade-in 0.18s ease;
}

.lightbox-image {
    max-width: min(92vw, 640px);
    max-height: 72vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-close {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top));
    right: 16px;

    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text);

    cursor: pointer;
}

.lightbox-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);

    width: 40px;
    height: 40px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text);

    cursor: pointer;
}

.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

/* Стрелки нужны только когда фото несколько — прячем через JS (hidden),
   а не всегда рисуем неактивными: одна фотка — нечего листать */

.lightbox-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(20px + env(safe-area-inset-bottom));

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.lightbox-counter {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
}


/* АНАЛИТИКА: живые мини-графики (в отличие от PDF-отчётов ниже —
   считаются на лету из тех же данных, что и экран "Заказы") */

.chart-card {
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    margin-bottom: 12px;
}

.chart-card-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.chart-donut-row {
    display: flex;
    align-items: center;
    gap: 18px;
}

.chart-donut-row svg {
    flex-shrink: 0;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-legend-label {
    flex: 1;
    min-width: 0;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-legend-value {
    font-weight: 700;
    flex-shrink: 0;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 88px;
}

.chart-bar-col {
    flex: 1;
    height: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.chart-bar-track {
    width: 100%;
    max-width: 26px;
    flex: 1;

    display: flex;
    align-items: flex-end;
}

.chart-bar-fill {
    width: 100%;
    min-height: 3px;
    border-radius: 4px 4px 0 0;
    background: var(--accent-grad);
    transition: height 0.3s ease;
}

.chart-bar-label {
    font-size: 9.5px;
    color: var(--text-faint);
    white-space: nowrap;
}


/* Утилита — минимальный touch target там, где по вёрстке кнопка
   получилась бы меньше 44px (требование Telegram Mini App) */
.touch-target {
    min-width: 44px;
    min-height: 44px;
}


/* RESPONSIVE — узкие экраны (320–360px): сжимаем внутренние отступы и
   сетку статистики, чтобы ничего не резалось и не появлялся горизонтальный
   скролл */
@media (max-width: 360px) {
    .content { padding: 14px 12px; padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom)); }
    .stats-row { gap: 6px; }
    .stat-card { padding: 11px 8px; }
    .stat-value { font-size: 19px; }
    .quick-grid { gap: 8px; }
}
