/* ============================================================
   Штаб — основной стиль приложения (синий, офисный).
   Подключается ПОСЛЕ темы, чтобы перекрывать её цвета.
   ============================================================ */

:root {
    --shtab:        #1F2733;
    --shtab-dark:   #121821;
    --shtab-soft:   #EDEFF2;
    --shtab-ink:    #1F2733;
    --ink:          #161A20;
    --muted:        #6B7280;
    --line:         #ECEDEF;
    --bg:           #F4F5F7;
    --card:         #FFFFFF;
    --radius:       16px;
    --tabbar-h:     64px;
}

body.bg-secondary,
body {
    background: var(--bg) !important;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    display: block !important;
}

/* --- акцентный цвет поверх темы --- */
.btn-primary {
    background: var(--shtab) !important;
    border-color: var(--shtab) !important;
    box-shadow: none !important;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background: var(--shtab-dark) !important;
    border-color: var(--shtab-dark) !important;
}
.btn-outline-primary {
    color: var(--shtab) !important;
    border-color: var(--shtab) !important;
}
.btn-outline-primary:hover {
    background: var(--shtab) !important;
    color: #fff !important;
}
.text-primary { color: var(--shtab) !important; }
.bg-primary   { background: var(--shtab) !important; }
a { color: var(--shtab); }
a:hover { color: var(--shtab-dark); }
.form-control:focus, .form-select:focus {
    border-color: var(--shtab) !important;
    box-shadow: 0 0 0 3px rgba(31,39,51,.16) !important;
}
.btn-check:checked + .btn-outline-secondary {
    background: var(--shtab-soft) !important;
    border-color: var(--shtab) !important;
    color: var(--shtab-ink) !important;
}

/* --- верхняя панель (чистая белая) --- */
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    height: 56px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center;
    padding: 0 16px;
}
.app-topbar .brand {
    font-weight: 700; font-size: 18px; color: var(--ink);
    text-decoration: none; display: flex; align-items: center;
}
.app-topbar .brand-word { letter-spacing: -.3px; }
.app-topbar .brand-dim { color: var(--muted); font-weight: 500; }
.app-topbar .brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 9px;
    background: var(--shtab); color: #fff;
    font-weight: 700; font-size: 17px; line-height: 1;
    margin-right: 9px; letter-spacing: -.5px;
}
.app-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--shtab-soft); color: var(--shtab);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; border: none; flex: 0 0 auto;
}
/* кнопка пользователя в шапке (на ПК — с именем и ролью) */
.app-userbtn {
    display: flex; align-items: center; gap: 9px;
    background: none; border: none; cursor: pointer;
    padding: 4px; border-radius: 24px; transition: background .12s;
}
.app-userbtn:hover { background: var(--bg); }
.app-userbtn-meta { flex-direction: column; align-items: flex-start; line-height: 1.15; }
.app-userbtn-name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.app-userbtn-role { font-size: 11px; color: var(--muted); }
.app-userbtn-caret { font-size: 11px; color: var(--muted); margin-right: 4px; }
@media (min-width: 992px) { .app-userbtn { padding-right: 8px; } }
/* название текущего раздела по центру шапки (телефон) — «где я» */
.topbar-title {
    position: absolute; left: 50%; transform: translateX(-50%);
    max-width: 50%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-weight: 600; font-size: 16px; color: var(--ink); pointer-events: none;
}

/* --- основная область --- */
.app-main {
    max-width: 640px; margin: 0 auto;
    padding: 16px 16px calc(var(--tabbar-h) + 24px);
}
.page-title { font-size: 22px; font-weight: 700; margin: 4px 0 14px; }

/* --- карточки --- */
.s-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.s-card.pad { padding: 16px; }

/* --- сводка / hero --- */
.hero {
    background: var(--shtab);
    color: #fff;
    border-radius: var(--radius);
    padding: 18px 18px 20px;
}
.hero .label { font-size: 13px; opacity: .85; }
.hero .big   { font-size: 32px; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.hero .sub   { font-size: 13px; opacity: .9; margin-top: 4px; }

/* --- строка списка (трата, человек, сотрудник) --- */
.row-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 8px;
    text-decoration: none; color: inherit;
}
.row-item:hover { color: inherit; }
.row-tile {
    width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; flex-shrink: 0;
}
.row-main { flex: 1; min-width: 0; }
.row-main .t1 { font-size: 15px; font-weight: 600; }
.row-main .t2 { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amount { font-weight: 700; font-size: 15px; white-space: nowrap; }
.day-label { font-size: 12px; color: var(--muted); margin: 14px 2px 8px; font-weight: 600; }

/* --- цвета категорий (плитки) --- */
.cat-products  { background:#E1F5EE; color:#0F6E56; }
.cat-fuel      { background:#FAEEDA; color:#854F0B; }
.cat-transport { background:#E6F1FB; color:#0C447C; }
.cat-cafe      { background:#FBEAF0; color:#993556; }
.cat-gifts     { background:#EEEDFE; color:#3C3489; }
.cat-household { background:#E1F5EE; color:#0F6E56; }
.cat-pharmacy  { background:#FCEBEB; color:#A32D2D; }
.cat-office    { background:#E6F1FB; color:#185FA5; }
.cat-other     { background:#F1EFE8; color:#444441; }
.cat-wash      { background:#E6F1FB; color:#185FA5; }
.cat-service   { background:#FAEEDA; color:#633806; }
.cat-parking   { background:#EEEDFE; color:#3C3489; }
.cat-repair    { background:#F1EFE8; color:#444441; }
.cat-fine      { background:#FCEBEB; color:#A32D2D; }

/* --- чипы (фильтры, теги) --- */
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 13px; padding: 6px 14px; border-radius: 18px;
    background: var(--card); border: 1px solid var(--line);
    color: var(--muted); text-decoration: none; white-space: nowrap;
}
.chip.active { background: var(--shtab); border-color: var(--shtab); color: #fff; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.chip-row::-webkit-scrollbar { display: none; }

/* --- бейджи-теги --- */
.tag { display:inline-block; font-size:12px; padding:3px 10px; border-radius:12px; background:var(--shtab-soft); color:var(--shtab-ink); margin:0 4px 4px 0; }

/* --- плашки-уведомления --- */
.note { border-radius: 12px; padding: 10px 14px; font-size: 13px; display:flex; align-items:center; gap:8px; margin-bottom: 10px; }
.note-warn   { background:#FAEEDA; color:#633806; }
.note-danger { background:#FCEBEB; color:#791F1F; }
.note-info   { background: var(--shtab-soft); color: var(--shtab-ink); }

/* --- нижнее меню-табы --- */
.app-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    height: var(--tabbar-h);
    background: var(--card);
    border-top: 1px solid var(--line);
    display: flex; align-items: stretch; justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.app-tabbar .tab {
    flex: 1; min-width: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: 10px;
}
.app-tabbar .tab span {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-tabbar .tab .tab-ic { position: relative; display: inline-flex; line-height: 1; }
.app-tabbar .tab i { font-size: 21px; }
.app-tabbar .tab.active { color: var(--shtab); }
/* бейдж-счётчик «требует внимания» */
.tab-badge {
    position: absolute; top: -6px; left: 12px;
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px;
    background: #E5484D; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px;
    text-align: center; box-shadow: 0 0 0 2px var(--card);
}
.app-tabbar .tab-add-wrap {
    flex: 0 0 auto; align-self: center; position: relative;
    margin-top: -16px;
}
.app-tabbar .tab-add {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--shtab); color: #fff; border: none; padding: 0;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(31,39,51,.38);
    text-decoration: none; cursor: pointer;
    transition: transform .12s ease, background .12s;
}
.app-tabbar .tab-add i { font-size: 28px; transition: transform .18s ease; }
.app-tabbar .tab-add:active { transform: scale(.94); }
.app-tabbar .tab-add[aria-expanded="true"] { background: var(--shtab-dark); }
.app-tabbar .tab-add[aria-expanded="true"] i { transform: rotate(45deg); } /* «+» → «×» */

/* --- меню создания (всплывает над «＋» на телефоне, под кнопкой на ПК) --- */
.create-menu {
    border: 1px solid var(--line); border-radius: 16px; padding: 6px;
    box-shadow: 0 12px 32px rgba(16,24,40,.18); min-width: 230px;
    z-index: 1045;
}
.create-menu-title {
    font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
    color: var(--muted); padding: 6px 12px 4px;
}
.create-menu .dropdown-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 10px; font-size: 15px; font-weight: 500;
}
.create-menu .dropdown-item i { font-size: 19px; color: var(--shtab); width: 22px; text-align: center; }
.create-menu .dropdown-item:hover, .create-menu .dropdown-item:focus { background: var(--shtab-soft); color: var(--shtab-ink); }
.create-menu .dropdown-item:active { background: var(--shtab-soft); color: var(--shtab-ink); }

/* мобильный FAB: меню строго НАД «＋» по центру (статичное позиционирование) */
.app-tabbar .tab-add-wrap .create-menu {
    position: absolute; inset: auto auto 100% 50%;
    transform: translateX(-50%) translateY(-12px);
    margin: 0; animation: createPop .14s ease-out;
}
@keyframes createPop {
    from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(-12px); }
}
/* затемнение фона при открытом меню «＋» (нативный фокус) */
.tab-scrim {
    position: fixed; inset: 0; z-index: 1029;
    background: rgba(15,20,30,.4);
    opacity: 0; visibility: hidden; transition: opacity .15s ease;
}
.tab-scrim.show { opacity: 1; visibility: visible; }

/* --- быстрые кнопки на главной --- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.quick-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
    padding: 16px 8px; background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; text-decoration: none; color: var(--ink); text-align: center;
}
.quick-btn i { font-size: 22px; color: var(--shtab); }
.quick-btn span { font-size: 13px; font-weight: 500; }
.quick-btn:hover { background: var(--bg); color: var(--ink); }
.quick-btn.accent { background: var(--shtab); border-color: var(--shtab); color: #fff; }
.quick-btn.accent i { color: #fff; }
.quick-btn.accent:hover { background: var(--shtab-dark); color: #fff; }

/* --- хаб «Управление» (страница /site/manage, таб «Ещё») --- */
.hub-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { .hub-grid { grid-template-columns: 1fr 1fr; } }
.hub-card {
    display: flex; align-items: center; gap: 14px;
    padding: 16px; background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; text-decoration: none; color: var(--ink);
    transition: border-color .15s, box-shadow .15s, transform .05s;
}
.hub-card:hover { color: var(--ink); border-color: #D9DCE1; box-shadow: 0 2px 10px rgba(16,24,40,.06); }
.hub-card:active { transform: translateY(1px); }
.hub-ic {
    flex: 0 0 auto; width: 46px; height: 46px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    background: var(--shtab-soft); color: var(--shtab); font-size: 22px;
}
.hub-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hub-title { font-size: 16px; font-weight: 600; }
.hub-sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.hub-go { color: var(--muted); font-size: 15px; flex: 0 0 auto; }

/* --- дашборд: на широком экране виджеты в две колонки (мобила — одна) --- */
/* auto-fit: один виджет растягивается на всю ширину, два — делятся пополам */
.dash-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.dash-pair .s-card { height: 100%; }
.dash-recent { display: grid; grid-template-columns: 1fr; gap: 8px; }
.dash-recent .row-item { margin-bottom: 0; }
@media (min-width: 992px) {
    .dash-recent { grid-template-columns: 1fr 1fr; column-gap: 16px; }
}

/* --- боковое меню (ПК) --- */
.app-sidebar { display: none; }
.side-link {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 12px;
    color: var(--ink); text-decoration: none; font-size: 15px;
    margin-bottom: 2px; transition: background .12s, color .12s;
}
.side-link i { font-size: 19px; color: var(--muted); width: 22px; text-align: center; transition: color .12s; }
.side-link:hover { background: var(--bg); color: var(--ink); }
.side-link.active { background: var(--shtab-soft); color: var(--shtab-ink); font-weight: 600; }
.side-link.active i { color: var(--shtab); }
/* акцентная полоска слева у активного пункта (нативный «app»-вид) */
.side-link.active::before {
    content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 3px; background: var(--shtab);
}
.side-link > span { flex: 1; min-width: 0; }
.side-badge {
    flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: #E5484D; color: #fff; font-size: 11px; font-weight: 700; line-height: 20px;
    text-align: center;
}
/* подпись группы «Управление» в сайдбаре */
.side-group {
    font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
    color: var(--muted); padding: 6px 14px 4px; margin-top: 14px;
    border-top: 1px solid var(--line); padding-top: 14px;
}
/* кнопка-меню «Добавить» в сайдбаре (ПК) */
.side-create { display: inline-flex; align-items: center; justify-content: center; }
.side-create-caret { font-size: 12px; opacity: .8; transition: transform .18s ease; }
.side-create[aria-expanded="true"] .side-create-caret { transform: rotate(180deg); }

/* ПК: сайдбар слева, нижние табы прячем, контент шире и со сдвигом */
@media (min-width: 992px) {
    .app-sidebar {
        display: block;
        position: fixed; top: 56px; left: 0; bottom: 0; width: 256px;
        background: var(--card); border-right: 1px solid var(--line);
        padding: 20px 16px; overflow-y: auto;
    }
    /* на ПК пункты чуть крупнее и просторнее */
    .side-link { padding: 11px 14px; font-size: 15.5px; border-radius: 12px; }
    .side-link i { font-size: 20px; }
    .app-tabbar { display: none; }
    .app-main.has-sidebar {
        margin-left: 256px;
        max-width: none;
        padding: 32px 40px 56px;
    }
    .app-main.has-sidebar .app-content {
        max-width: 960px;
        margin: 0 auto;
    }
    .page-title { font-size: 26px; }
    .app-topbar { padding-left: 20px; }
}

/* --- права (раздел «Доступы») — КОМПАКТНАЯ сетка чипов --- */
.perm-card { padding: 2px 13px; }
.perm-row { padding: 10px 0; border-top: 1px solid var(--line); }
.perm-row:first-child { border-top: none; }
.perm-sec { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.perm-ico {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--shtab-soft); color: var(--shtab); font-size: 14px;
}
.perm-sec-text { display: flex; align-items: baseline; gap: 7px; min-width: 0; flex-wrap: wrap; }
.perm-label { font-size: 14px; font-weight: 600; line-height: 1.15; }
.perm-state { font-size: 11.5px; color: var(--muted); }
.perm-state.is-on { color: var(--shtab); font-weight: 600; }
.perm-state.is-off { color: #9aa1ad; }

.perm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 130px)); gap: 6px; }
.perm-chk {
    display: flex; align-items: center; justify-content: center; line-height: 1;
    font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap;
    padding: 7px 4px; border: 1px solid var(--line); border-radius: 9px;
    cursor: pointer; user-select: none; background: var(--card);
    transition: background .14s, border-color .14s, color .14s;
}
.perm-chk input { display: none; }
.perm-chk span { overflow: hidden; text-overflow: ellipsis; }
.perm-chk:hover { border-color: var(--shtab); }
.perm-chk:has(input:checked) {
    background: var(--shtab); border-color: var(--shtab); color: #fff; font-weight: 600;
}
.perm-cell-empty { border-radius: 9px; }
@media (min-width: 560px) { .perm-chk { font-size: 12px; padding: 8px 6px; } }

/* подсказка над сеткой — компактно, в одну строку */
.perm-legend { font-size: 11.5px; color: var(--muted); margin: 0 2px 8px; display: flex; gap: 5px; align-items: baseline; line-height: 1.3; }
.perm-legend i { color: var(--shtab); }

/* категории — компактный список (как люди) */
.cat-row { display: flex; align-items: center; gap: 11px; padding: 9px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 7px; text-decoration: none; color: inherit; }
.cat-row:hover { color: inherit; border-color: var(--shtab); }
.cat-ico {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--shtab-soft); color: var(--shtab); font-size: 16px;
}
.cat-main { flex: 1; min-width: 0; }
.cat-name { font-size: 14.5px; font-weight: 600; line-height: 1.2; }
.cat-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-sub.is-none { font-style: italic; opacity: .8; }
.cat-create {
    display: inline-flex; align-items: center; gap: 7px; margin-top: 2px;
    padding: 9px 16px; border: 1px dashed var(--line); border-radius: 999px;
    color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 500; background: var(--card);
}
.cat-create:hover { border-color: var(--shtab); color: var(--shtab-ink); }

/* выбор иконки — мельче */
.icon-pick { display: flex; flex-wrap: wrap; gap: 5px; }
.icon-pick label {
    width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 14px;
}
.icon-pick input { display: none; }
.icon-pick input:checked + label { background: var(--shtab); border-color: var(--shtab); color: #fff; }

/* чипы «за основу» — мельче */
.base-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.base-chips input { display: none; }
.base-chips label {
    display: inline-flex; align-items: center;
    font-size: 12px; padding: 6px 12px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--bg); color: var(--ink);
    cursor: pointer; user-select: none;
}
.base-chips input:checked + label { background: var(--shtab); border-color: var(--shtab); color: #fff; font-weight: 600; }
.base-chips label.base-chip-blank { color: var(--muted); }
.base-chips input:checked + label.base-chip-blank { color: #fff; }

/* --- мелочи --- */
.btn { box-shadow: none !important; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty i { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }
.empty-title { font-size: 17px; font-weight: 600; color: var(--ink); }
.empty-sub { font-size: 13.5px; color: var(--muted); margin: 6px 0 16px; }
.empty .btn { margin-top: 2px; }
.back-btn {
    width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--card);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--ink); text-decoration: none; flex-shrink: 0;
}
