/* =====================================================================
   Вектор — прототип. Токены, «телефонная оболочка», компоненты.
   ===================================================================== */

:root {
    --brand-1: #FF8241;
    --brand-2: #940900;
    --brand-gradient: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    --ink: #1c1c1e;
    --ink-soft: #6b6b70;
    --surface: #ffffff;
    --surface-muted: #f4f5f7;
    --bg: #f0f1f4;
    --line: #e6e7eb;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-card: 0 1px 2px rgba(20, 20, 25, .04), 0 8px 24px -12px rgba(20, 20, 25, .12);
    --shadow-float: 0 10px 30px -10px rgba(148, 9, 0, .35);
    --tab-bar-h: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { text-decoration: none; }

/* ---------------------------------------------------------------------
   Телефонная оболочка: на десктопе — рамка «устройства», на мобиле —
   просто полноэкранная страница.
   --------------------------------------------------------------------- */
.device-frame {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: stretch;
    background: var(--bg);
}

.device-screen {
    position: relative;
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    background: var(--surface-muted);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

@media (min-width: 560px) {
    .device-frame { padding: 32px 16px; align-items: center; }
    .device-screen {
        min-height: 860px;
        max-height: 900px;
        border-radius: 40px;
        box-shadow: 0 30px 60px -20px rgba(20, 20, 25, .35), 0 0 0 10px #0b0b0d;
        overflow: hidden;
    }
    .device-screen::before {
        content: "";
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 120px;
        height: 22px;
        border-radius: 14px;
        background: #0b0b0d;
        z-index: 40;
    }
}

.device-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 12px);
}

.device-scroll.no-tabbar { padding-bottom: 24px; }

/* ---------------------------------------------------------------------
   Заголовок приложения
   --------------------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: calc(10px + var(--safe-top)) 16px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header .btn-back {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-muted);
    color: var(--ink);
    flex-shrink: 0;
}

.app-header .btn-back:hover { background: var(--line); }

.app-header .app-header-title {
    font-weight: 600;
    font-size: 17px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------
   Свитчер аккаунтов (dropdown в шапке)
   --------------------------------------------------------------------- */
.account-switcher .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-muted);
    border-radius: 999px;
    padding: 6px 12px 6px 6px;
    border: none;
    max-width: 220px;
}

.account-switcher .dropdown-toggle::after { display: none; }

.account-switcher .account-badge {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.account-switcher .account-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-switcher .dropdown-menu {
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-card);
    padding: 8px;
    min-width: 260px;
}

.account-switcher .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--radius-sm);
    padding: 8px;
}

.account-switcher .dropdown-item.active,
.account-switcher .dropdown-item:active { background: var(--surface-muted); color: var(--ink); }

/* ---------------------------------------------------------------------
   Нижний tab-bar
   --------------------------------------------------------------------- */
.tab-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + var(--safe-bottom));
    height: calc(var(--tab-bar-h) + var(--safe-bottom));
}

@media (max-width: 559.98px) {
    .tab-bar { position: fixed; }
}

.tab-bar .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--ink-soft);
    font-size: 11px;
    border-radius: var(--radius-sm);
}

.tab-bar .tab-item i { font-size: 20px; }

.tab-bar .tab-item.active { color: var(--brand-2); font-weight: 600; }

/* ---------------------------------------------------------------------
   Общие элементы
   --------------------------------------------------------------------- */
.page-pad { padding: 16px; }

.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    margin: 20px 4px 10px;
}

.card-ui {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 16px;
}

.list-ui { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }

.list-item-ui {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}

.list-item-ui:last-child { border-bottom: none; }

.list-item-ui .list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--surface-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    color: var(--brand-2);
}

.list-item-ui .list-item-body { flex: 1; min-width: 0; }
.list-item-ui .list-item-title { font-weight: 600; font-size: 14.5px; }
.list-item-ui .list-item-sub { font-size: 12.5px; color: var(--ink-soft); }
.list-item-ui .list-item-end { text-align: right; flex-shrink: 0; }
.list-item-ui.link:active { background: var(--surface-muted); }

/* Плитки сервисов на Главной */
.service-tile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    color: var(--ink);
    height: 100%;
}

.service-tile:active { transform: scale(.98); }

.service-tile .service-tile-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
}

.service-tile .service-tile-title { font-weight: 700; font-size: 14.5px; }
.service-tile .service-tile-sub { font-size: 12px; color: var(--ink-soft); }

.service-tile.locked { opacity: .55; }
.service-tile.locked .service-tile-icon { background: var(--ink-soft) !important; }

/* Карточки-статистики (баланс, задолженность) */
.stat-card {
    border-radius: var(--radius-lg);
    padding: 18px;
    color: #fff;
    background: var(--brand-gradient);
    box-shadow: var(--shadow-float);
    position: relative;
    overflow: hidden;
}

.stat-card.neutral { background: linear-gradient(135deg, #2b2a29 0%, #4a4946 100%); box-shadow: 0 10px 30px -10px rgba(20,20,20,.35); }
.stat-card .stat-label { font-size: 12.5px; opacity: .85; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 2px; }
.stat-card .stat-foot { font-size: 12px; opacity: .85; margin-top: 8px; }

/* Кнопки-бейджи */
.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-muted);
    color: var(--ink-soft);
}

.badge-soft.success { background: #e6f6ea; color: #1a7f37; }
.badge-soft.danger { background: #fdeceb; color: #b3261e; }
.badge-soft.warning { background: #fff4dd; color: #9a6400; }

/* Кнопки приложения */
.btn-brand {
    background: var(--brand-gradient);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.btn-brand:hover, .btn-brand:focus { color: #fff; filter: brightness(1.05); }
.btn-brand:active { filter: brightness(.95); }

.btn-outline-brand {
    border: 1.5px solid var(--brand-2);
    color: var(--brand-2);
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: transparent;
}

.btn-outline-brand:hover { background: rgba(148, 9, 0, .06); color: var(--brand-2); }

.btn-tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 14px 10px;
    text-align: center;
    color: var(--ink);
}

.btn-tile:active { background: var(--surface-muted); }
.btn-tile i { font-size: 22px; color: var(--brand-2); display: block; margin-bottom: 6px; }

.btn-tile.sm { font-size: 11px; padding: 12px 4px; line-height: 1.25; }
.btn-tile.sm i { font-size: 19px; margin-bottom: 5px; }

/* ---------------------------------------------------------------------
   Экраны авторизации
   --------------------------------------------------------------------- */
.auth-screen {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 28px 24px calc(28px + var(--safe-bottom));
}

.splash-screen {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--brand-gradient);
    color: #fff;
    text-align: center;
    padding: 32px;
}

.splash-screen img { width: 92px; height: auto; filter: drop-shadow(0 10px 24px rgba(0,0,0,.25)); }
.splash-screen .splash-title { font-size: 22px; font-weight: 700; }
.splash-screen .splash-sub { font-size: 13.5px; opacity: .9; max-width: 280px; }
.splash-screen .spinner-border { margin-top: 6px; }

.auth-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--brand-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.auth-logo img { width: 28px; }

.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 24px; }

.phone-input-group {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    background: var(--surface);
}

.phone-input-group span { color: var(--ink-soft); font-weight: 600; margin-right: 6px; }
.phone-input-group input { border: none; outline: none; font-size: 16px; flex: 1; background: transparent; }

.otp-row { display: flex; gap: 10px; justify-content: center; margin: 8px 0 4px; }

.otp-cell {
    width: 48px;
    height: 56px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--line);
    background: var(--surface);
    text-align: center;
    font-size: 22px;
    font-weight: 700;
}

.otp-cell:focus { border-color: var(--brand-2); outline: none; }

.demo-hint {
    background: var(--surface-muted);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.demo-hint b { color: var(--ink); }

.company-pick {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    margin-bottom: 10px;
    color: var(--ink);
}

.company-pick .company-logo-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-muted);
    flex-shrink: 0;
    padding: 8px;
}

.company-pick .company-logo-wrap img { max-width: 100%; max-height: 100%; }
.company-pick:active { border-color: var(--brand-2); }

.lookup-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    color: var(--ink-soft);
    font-size: 14px;
}

.lookup-step .step-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
}

.lookup-step.done { color: var(--ink); }
.lookup-step.done .step-dot { background: #1a7f37; border-color: #1a7f37; color: #fff; }
.lookup-step.active { color: var(--ink); font-weight: 600; }
.lookup-step.active .step-dot { border-color: var(--brand-2); }

/* ---------------------------------------------------------------------
   Заглушка видеокамеры
   --------------------------------------------------------------------- */
.camera-frame {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background:
        repeating-linear-gradient(135deg, #23262b 0 12px, #1a1c20 12px 24px);
    aspect-ratio: 16/10;
    display: flex;
    align-items: flex-end;
    color: #fff;
}

.camera-frame.large { aspect-ratio: 16/10; border-radius: var(--radius-lg); }

.camera-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.08), transparent 60%);
}

.camera-frame .camera-noise {
    position: absolute;
    inset: 0;
    opacity: .5;
    background-image: linear-gradient(0deg, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 100% 3px;
    animation: cameraScan 6s linear infinite;
}

@keyframes cameraScan { from { background-position: 0 0; } to { background-position: 0 400px; } }

.camera-frame .camera-live {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,.5);
    border-radius: 999px;
    padding: 4px 10px 4px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .03em;
    z-index: 2;
}

.camera-frame .camera-live .dot { width: 7px; height: 7px; border-radius: 50%; background: #ff3b30; animation: blink 1.4s infinite; }

@keyframes blink { 0%, 60% { opacity: 1; } 30% { opacity: .25; } }

.camera-frame .camera-offline-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,.55);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
}

.camera-frame .camera-timecode {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 11px;
    font-family: "Consolas", monospace;
    background: rgba(0,0,0,.5);
    border-radius: 6px;
    padding: 3px 7px;
    z-index: 2;
}

.camera-frame .camera-title {
    position: relative;
    z-index: 2;
    padding: 10px 12px;
    font-size: 12.5px;
    font-weight: 600;
    background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
    width: 100%;
}

.camera-frame .camera-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.camera-frame .camera-play i {
    font-size: 30px;
    background: rgba(255,255,255,.18);
    border-radius: 50%;
    padding: 12px;
}

.date-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; }

.date-strip .date-chip {
    flex-shrink: 0;
    min-width: 52px;
    text-align: center;
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--line);
    background: var(--surface);
    font-size: 12px;
    color: var(--ink-soft);
}

.date-strip .date-chip.active { border-color: var(--brand-2); color: var(--brand-2); background: #fff4f0; font-weight: 700; }
.date-strip .date-chip .d-num { font-size: 15px; font-weight: 700; display: block; color: inherit; }

/* Домофон */
.device-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 10px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    border: none;
    width: 100%;
    color: var(--ink);
    position: relative;
    overflow: hidden;
}

.device-btn i { font-size: 26px; color: var(--brand-2); }
.device-btn .device-btn-title { font-size: 13px; font-weight: 600; text-align: center; }
.device-btn .device-btn-progress {
    position: absolute;
    left: 0; bottom: 0; height: 3px;
    background: var(--brand-gradient);
    width: 0%;
    transition: width .9s linear;
}

.device-btn.opening i { color: #1a7f37; }

/* Тарифы */
.tariff-card {
    border: 1.5px solid var(--line);
    border-radius: var(--radius-md);
    padding: 14px;
    background: var(--surface);
    margin-bottom: 10px;
}

.tariff-card.current { border-color: var(--brand-2); background: linear-gradient(0deg, #fff, #fff8f5); }
.tariff-card .tariff-name { font-weight: 700; font-size: 15px; }
.tariff-card .tariff-price { font-weight: 700; font-size: 17px; color: var(--brand-2); }
.tariff-card ul { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-soft); }

/* Счётчики */
.meter-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px; margin-bottom: 10px; background: var(--surface); }
.meter-card .meter-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.meter-card .meter-prev { font-size: 12px; color: var(--ink-soft); }

/* Способы оплаты */
.pay-method {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    background: var(--surface);
    cursor: pointer;
}

.pay-method input { accent-color: var(--brand-2); width: 18px; height: 18px; }
.pay-method.checked { border-color: var(--brand-2); background: #fff8f5; }
.pay-method i { font-size: 20px; color: var(--brand-2); }

/* Пустое состояние */
.empty-ui { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-ui i { font-size: 40px; color: var(--line); margin-bottom: 10px; display: block; }
.empty-ui .empty-title { font-weight: 600; color: var(--ink); margin-bottom: 4px; }

/* ---------------------------------------------------------------------
   Баннер установки PWA
   --------------------------------------------------------------------- */
.install-banner {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 10px);
    z-index: 45;
    background: #1c1c1e;
    color: #fff;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
}

@media (max-width: 559.98px) { .install-banner { position: fixed; } }

.install-banner.show { display: flex; }
.install-banner img { width: 32px; height: 32px; border-radius: 8px; }
.install-banner .install-text { flex: 1; font-size: 12.5px; }
.install-banner .install-text b { display: block; font-size: 13.5px; }

/* ---------------------------------------------------------------------
   Демо-панель
   --------------------------------------------------------------------- */
.demo-fab {
    position: absolute;
    right: 14px;
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 16px);
    z-index: 50;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1c1c1e;
    color: #fff;
    border: none;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .02em;
    box-shadow: 0 10px 24px -6px rgba(0,0,0,.45);
}

@media (max-width: 559.98px) { .demo-fab { position: fixed; } }

.demo-fab.no-tabbar { bottom: 16px; }

.scenario-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--line);
    margin-bottom: 10px;
    background: var(--surface);
}

.scenario-card.active { border-color: var(--brand-2); background: #fff8f5; }
.scenario-card .form-check-input { margin-top: 3px; accent-color: var(--brand-2); }
.scenario-card .scenario-label { font-weight: 700; font-size: 14px; }
.scenario-card .scenario-desc { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

/* Toast-контейнер поверх экрана */
.toast-stack {
    position: absolute;
    top: calc(12px + var(--safe-top));
    left: 12px;
    right: 12px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

@media (max-width: 559.98px) { .toast-stack { position: fixed; } }

.toast-ui {
    background: #1c1c1e;
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    box-shadow: 0 10px 24px -8px rgba(0,0,0,.4);
    opacity: 0;
    transform: translateY(-8px);
    transition: all .25s ease;
}

.toast-ui.show { opacity: 1; transform: translateY(0); }
.toast-ui.success { background: #1a7f37; }
.toast-ui.danger { background: #b3261e; }

/* Разное */
.divider-label { display:flex; align-items:center; gap:10px; color: var(--ink-soft); font-size: 12px; margin: 16px 0; }
.divider-label::before, .divider-label::after { content:""; flex:1; height:1px; background: var(--line); }

.spec-check {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    background: var(--surface);
}

.spec-check input { width: 18px; height: 18px; accent-color: var(--brand-2); }

.progress-thin { height: 4px; border-radius: 4px; }
.progress-thin .progress-bar { background: var(--brand-gradient); }

::-webkit-scrollbar { width: 0; height: 0; }
