/* Каркас приложения: сайдбар + хедер + контент (стиль KotPlatform) */

.app {
    display: flex;
    min-height: 100vh;
}

/* ---------------------------------------------------------------- Сайдбар */
.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--card);
    border-right: 0.0625rem solid var(--border-soft);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    transition: transform var(--t-med);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1.125rem 1.25rem 0.875rem;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none !important;
}
.sidebar-brand .brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5625rem;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9375rem;
    flex: none;
}
.sidebar-brand .brand-badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.4375rem;
    border-radius: 0.375rem;
    background: var(--accent-soft);
    color: var(--accent);
    letter-spacing: .04em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.75rem 1rem;
}
.nav-section {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 1rem 0.625rem 0.375rem;
}

/* Переключатель рабочих пространств (систем) */
.space-switch { margin: 0 0.75rem 0.25rem; position: relative; }
.space-current {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 0.0625rem solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--gray-soft);
    color: var(--text);
    font-weight: 500;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: border-color var(--t-fast), background var(--t-fast);
}
.space-current:hover { border-color: var(--accent); }
.space-current .icon:first-child { color: var(--accent); }
.space-switch .dropdown-menu { top: calc(100% + 4px); }
.dropdown-label {
    padding: 0.4rem 0.75rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.dropdown-item.active { color: var(--accent); font-weight: 500; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6875rem;
    padding: 0.5625rem 0.75rem;
    margin-bottom: 0.125rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
    text-decoration: none !important;
    transition: background var(--t-fast), color var(--t-fast);
}
.nav-link:hover { background: var(--gray-soft); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link .icon { color: var(--text-faint); transition: color var(--t-fast); }
.nav-link:hover .icon { color: var(--text-muted); }
.nav-link.active .icon { color: var(--accent); }
.nav-link .counter { margin-left: auto; }

.sidebar-footer {
    padding: 0.75rem;
    border-top: 0.0625rem solid var(--border-soft);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--t-fast);
}
.sidebar-user:hover { background: var(--gray-soft); }
.sidebar-user .u-name { font-size: 0.8438rem; font-weight: 600; line-height: 1.25; }
.sidebar-user .u-role { font-size: 0.75rem; color: var(--text-muted); }

/* ---------------------------------------------------------------- Основная область */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header {
    height: var(--header-h);
    background: var(--card);
    border-bottom: 0.0625rem solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 40;
}
.header-titles { min-width: 0; flex: 1; }
.header-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-subtitle { font-size: 0.7813rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.625rem; flex: none; }

.burger {
    display: none;
    background: none;
    border: 0;
    padding: 0.5rem;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
}
.burger:hover { background: var(--gray-soft); }

.bell-btn {
    position: relative;
    background: none;
    border: 0;
    padding: 0.5625rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}
.bell-btn:hover { background: var(--gray-soft); color: var(--text); }
.bell-btn .counter { position: absolute; top: 0.125rem; right: 0.125rem; }

/* Часы в шапке */
.header-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
}
.header-date { font-size: 0.75rem; font-weight: 500; color: var(--text-faint); }
@media (max-width: 30rem) { .header-clock { display: none; } }

/* Справка по разделу */
.help-btn {
    width: 1.75rem;
    height: 1.75rem;
    flex: none;
    border-radius: 50%;
    border: 0.0625rem solid var(--border);
    background: var(--card);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: color var(--t-fast), border-color var(--t-fast);
}
.help-btn:hover { color: var(--accent); border-color: var(--accent); }
.help-panel { position: fixed; inset: 0; z-index: 70; }
.help-panel[hidden] { display: none !important; }
.help-back { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.35); animation: mig-fade 0.2s ease; }
.help-card {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: min(30rem, 100%);
    display: flex;
    flex-direction: column;
    background: var(--card);
    box-shadow: -1rem 0 3rem rgba(15, 23, 42, 0.18);
    animation: help-in 0.22s ease;
}
@keyframes help-in { from { transform: translateX(1.5rem); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mig-fade { from { opacity: 0; } to { opacity: 1; } }
.help-head,
.help-foot { flex: none; display: flex; align-items: center; gap: 0.6rem; padding: 0.9rem 1.1rem; }
.help-head { justify-content: space-between; border-bottom: 0.0625rem solid var(--border-soft); }
.help-foot { border-top: 0.0625rem solid var(--border-soft); background: var(--gray-soft); }
.help-foot .btn:last-child { margin-left: auto; }
/* min-height:0 — иначе длинная справка не скроллится, а выдавит футер */
.help-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1rem 1.1rem; line-height: 1.65; }
.help-body p { margin: 0 0 0.75rem; }
.help-body ul, .help-body ol { margin: 0 0 0.75rem; padding-left: 1.15rem; }
.help-body li { margin-bottom: 0.35rem; }
.help-body h4 { margin: 1rem 0 0.4rem; font-size: 0.9375rem; }
.help-toc { display: flex; flex-direction: column; gap: 0.35rem; }
.help-toc a { color: var(--text-muted); text-decoration: none; padding: 0.3rem 0; }
.help-toc a:hover { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .help-card, .help-back { animation: none; } }

/* Напоминание о ближайшем звонке — рядом с часами */
.header-remind {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    background: var(--warning-soft, #fff7ed);
    color: var(--warning, #b45309);
    border: 0.0625rem solid var(--warning, #b45309);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
}
.header-remind:hover { filter: brightness(0.97); }
.header-remind[hidden] { display: none; }
/* Просрочен — тревожно; оператор на звонке — спокойно, штрафа за это не будет */
.header-remind.is-late { background: var(--danger-soft, #fef2f2); color: var(--danger); border-color: var(--danger); }
.header-remind.is-busy { background: var(--gray-soft); color: var(--text-muted); border-color: var(--border); }
.header-remind.is-busy .dot { animation: none; }
.header-remind .dot {
    width: 0.45rem; height: 0.45rem; border-radius: 50%;
    background: currentColor; animation: remind-pulse 1.6s ease-in-out infinite;
}
@keyframes remind-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .header-remind .dot { animation: none; } }
@media (max-width: 48rem) { .header-remind .txt { display: none; } }

/* Чип зарплаты оператора в шапке */
.salary-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: var(--success-soft);
    color: var(--success);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    white-space: nowrap;
    transition: filter var(--t-fast);
}
.salary-chip:hover { filter: brightness(0.95); text-decoration: none; }
.salary-chip .icon { width: 1.1rem; height: 1.1rem; }
@media (max-width: 480px) {
    .salary-chip-sum { display: none; }
}

.content {
    flex: 1;
    padding: 1.5rem 1.75rem 3rem;
    width: 100%;
    max-width: var(--content-max);
}

/* Мобильная нижняя навигация */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card);
    border-top: 0.0625rem solid var(--border-soft);
    z-index: 70;
    padding: 0.375rem 0.5rem calc(0.375rem + env(safe-area-inset-bottom));
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1875rem;
    padding: 0.3125rem 0.125rem;
    color: var(--text-muted);
    font-size: 0.6563rem;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: var(--radius-xs);
}
.bottom-nav a.active { color: var(--accent); }

/* Затемнение при открытом мобильном сайдбаре */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .4);
    z-index: 55;
}

/* ---------------------------------------------------------------- Страница входа */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.auth-card {
    width: 100%;
    max-width: 25rem;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}
