:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-button-color: #3390ec;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #f1f1f1;
    --tg-theme-separator-color: #e5e5e5;
    --success: #4CAF50;
    --warning: #ff9800;
    --danger: #ff3b30;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.3;
}
.hidden { display: none !important; }
.screen { min-height: 100vh; padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.tg-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; background: var(--tg-theme-bg-color);
    border-bottom: 1px solid var(--tg-theme-separator-color);
    border-radius: 12px; margin-bottom: 8px;
    position: sticky; top: 0; z-index: 100;
}
.header-left h1 { font-size: 17px; font-weight: 600; }
.mode-switch { display: flex; background: var(--tg-theme-secondary-bg-color); border-radius: 10px; padding: 3px; gap: 2px; }
.mode-btn {
    padding: 7px 12px; border: none; border-radius: 8px; background: transparent;
    color: var(--tg-theme-hint-color); font-size: 12px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all 0.2s;
    display: inline-flex; align-items: center; gap: 5px;
}
.mode-btn.active { background: var(--tg-theme-button-color); color: white; }
.admin-section { padding: 10px 12px; background: var(--tg-theme-bg-color); border-radius: 12px; margin-bottom: 8px; }
.tg-section-title { font-size: 11px; color: #6d6d6d; text-transform: uppercase; font-weight: 600; margin-bottom: 8px; }
.tg-buttons-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 14px; border: none; border-radius: 10px;
    font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; min-height: 44px;
}
.tg-btn:active { opacity: 0.8; }
.tg-btn-primary { background: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); }
.tg-btn-secondary { background: var(--tg-theme-secondary-bg-color); color: var(--tg-theme-text-color); }
.tg-btn-success { background: var(--success); color: white; }
.tg-btn-warning { background: var(--warning); color: white; }
.filters-section { padding: 8px 10px; background: var(--tg-theme-bg-color); border-radius: 12px; margin-bottom: 8px; }
.tg-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tg-chips::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0; padding: 8px 16px; background: var(--tg-theme-secondary-bg-color);
    border: none; border-radius: 16px; font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: inherit; min-height: 36px;
}
.chip.active { background: var(--tg-theme-button-color); color: white; }
.tg-list { padding: 0 0 16px; }
.card {
    background: var(--tg-theme-bg-color); border-radius: 12px; padding: 12px;
    margin-bottom: 8px; position: relative; display: flex; gap: 8px;
}
.card-body { flex: 1; min-width: 0; }
.drag-handle {
    display: flex; align-items: center; justify-content: center;
    padding: 6px 4px; cursor: grab; color: var(--tg-theme-hint-color);
    opacity: 0.6; touch-action: none; user-select: none; -webkit-user-select: none; flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; opacity: 1; color: var(--tg-theme-button-color); }
.drag-handle .ic { width: 20px; height: 20px; }
.card-ghost { opacity: 0.4; background: rgba(51,144,236,0.15); border: 2px dashed var(--tg-theme-button-color); }
.card-chosen { box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.card-head { display: flex; align-items: center; margin-bottom: 8px; gap: 8px; }
.card-type { padding: 3px 8px; background: rgba(51,144,236,0.1); color: var(--tg-theme-button-color); border-radius: 6px; font-size: 11px; font-weight: 700; }
.card-code { font-weight: 700; font-size: 14px; flex: 1; }
.card-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.icon-action {
    width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 10px; cursor: pointer; transition: transform 0.15s; flex-shrink: 0;
}
.icon-action .ic { width: 16px; height: 16px; }
.icon-action:active { transform: scale(0.9); }
.icon-action.map { background: rgba(120,120,128,0.12); color: #ff3b30; }
.icon-action.note { background: rgba(120,120,128,0.12); color: var(--tg-theme-text-color); }
.icon-action.note.active { background: #ff3b30; color: white; }
.icon-action.reset { background: rgba(120,120,128,0.12); color: var(--tg-theme-text-color); }
.icon-action.edit { background: #ff9800; color: white; }
.icon-action.del { background: #ff3b30; color: white; }
.card-title { font-size: 14px; font-weight: 500; margin-bottom: 10px; }
.checks { display: flex; gap: 8px; flex-wrap: wrap; }
.check-item { display: block; position: relative; cursor: pointer; }
.check-item input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.check-box {
    display: flex; align-items: center; justify-content: center;
    min-width: 42px; min-height: 42px; padding: 6px 10px;
    border: 2px solid var(--tg-theme-separator-color); border-radius: 10px;
    background: var(--tg-theme-bg-color); font-size: 13px; font-weight: 600;
    color: var(--tg-theme-hint-color); text-align: center; transition: all 0.2s;
}
.check-item input[type="checkbox"]:checked + .check-box { background: var(--success); border-color: var(--success); color: white; }
.check-item:active .check-box { transform: scale(0.95); }
.card-info { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--tg-theme-separator-color); }
.info-item { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--tg-theme-hint-color); font-weight: 500; }
.info-item .ic { width: 13px; height: 13px; }
.user-select-wrap { gap: 6px; }
.user-select {
    border: 1px solid var(--tg-theme-separator-color); background: var(--tg-theme-bg-color);
    border-radius: 8px; padding: 4px 8px; font-size: 12px; font-weight: 600;
    color: var(--tg-theme-button-color); font-family: inherit; outline: none; max-width: 140px;
}
.tg-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: flex; align-items: flex-end;
    justify-content: center; z-index: 1000; animation: fadeIn 0.25s ease;
}
.tg-modal-content {
    background: var(--tg-theme-bg-color); width: 100%; max-width: 500px;
    border-radius: 20px 20px 0 0; padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    max-height: 90vh; overflow-y: auto;
    animation: slideUp 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.tg-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.tg-modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px; background: var(--tg-theme-secondary-bg-color);
    border: none; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.modal-close .ic { width: 14px; height: 14px; }
.tg-input-group { margin-bottom: 10px; text-align: left; }
.tg-input-group label { display: block; font-size: 12px; color: var(--tg-theme-hint-color); margin-bottom: 4px; font-weight: 500; }
.tg-input-group input, .tg-input-group select {
    width: 100%; padding: 12px; background: var(--tg-theme-bg-color);
    border: 1px solid var(--tg-theme-separator-color); border-radius: 10px;
    font-size: 16px; font-family: inherit; outline: none;
}
.tg-input-group input:focus, .tg-input-group select:focus { border-color: var(--tg-theme-button-color); }
.time-row { display: flex; gap: 8px; }
.time-row select { flex: 1; }
.tg-modal-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.settings-block { background: var(--tg-theme-secondary-bg-color); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.settings-title { font-size: 11px; color: #6d6d6d; text-transform: uppercase; font-weight: 700; margin-bottom: 10px; }
.settings-row { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.settings-row input {
    flex: 1; padding: 10px 12px; background: var(--tg-theme-bg-color);
    border: 1px solid var(--tg-theme-separator-color); border-radius: 10px;
    font-size: 15px; font-family: inherit; outline: none; min-width: 0;
}
.settings-row .tg-btn { white-space: nowrap; padding: 10px 14px; min-height: 40px; font-size: 13px; flex-shrink: 0; }
.type-selector-row { display: flex; gap: 8px; margin-bottom: 10px; align-items: stretch; }
.type-selector-row select {
    flex: 1; padding: 10px 12px; background: var(--tg-theme-bg-color);
    border: 1px solid var(--tg-theme-separator-color); border-radius: 10px;
    font-size: 15px; font-family: inherit; outline: none; min-width: 0;
}
.btn-delete-type {
    display: inline-flex; align-items: center; gap: 6px;
    background: linear-gradient(135deg, #ff3b30 0%, #ff6b6b 100%);
    color: white; border: none; cursor: pointer; font-weight: 600;
    white-space: nowrap; padding: 10px 14px; border-radius: 10px;
    font-size: 13px; font-family: inherit; min-height: 40px;
}
.btn-delete-type:active { opacity: 0.8; transform: scale(0.97); }
.btn-delete-type .ic { width: 15px; height: 15px; }
.fields-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.field-item {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
    background: var(--tg-theme-bg-color); border: 1px solid var(--tg-theme-separator-color);
    border-radius: 10px; font-size: 14px; font-weight: 500;
}
.field-delete-btn {
    width: 24px; height: 24px; background: rgba(255,59,48,0.1); color: var(--danger);
    border: none; border-radius: 50%; font-size: 12px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.field-delete-btn:active { background: var(--danger); color: white; }
.note-textarea {
    width: 100%; min-height: 110px; padding: 12px;
    border: 1px solid var(--tg-theme-separator-color); border-radius: 10px;
    font-size: 15px; font-family: inherit; outline: none; resize: vertical;
    margin-bottom: 12px; background: var(--tg-theme-bg-color);
}
.note-textarea:focus { border-color: var(--tg-theme-button-color); }
.note-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.note-buttons .tg-btn { font-size: 12px; padding: 10px 6px; min-height: 40px; }
.ic { width: 16px; height: 16px; flex-shrink: 0; vertical-align: middle; }
.mode-btn .ic { width: 13px; height: 13px; }
@media (max-width: 380px) {
    .mode-btn { padding: 6px 8px; font-size: 11px; }
    .check-box { min-width: 38px; min-height: 38px; font-size: 12px; }
}

/* === КНОПКИ РЕЖИМОВ: ТОЛЬКО ИКОНКИ === */
.mode-btn { padding: 8px 12px; }
.mode-btn .ic { width: 17px; height: 17px; }

/* === ПАНЕЛЬ ПОИСКА И ВИДА === */
.toolbar { display: flex; gap: 8px; margin-bottom: 8px; }
.search-wrap { flex: 1; position: relative; }
.search-wrap input {
    width: 100%;
    padding: 11px 12px 11px 38px;
    border: 1px solid var(--tg-theme-separator-color);
    border-radius: 10px;
    background: var(--tg-theme-bg-color);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}
.search-wrap input:focus { border-color: var(--tg-theme-button-color); }
.search-ic {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--tg-theme-hint-color);
}
.view-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--tg-theme-separator-color);
    border-radius: 10px;
    background: var(--tg-theme-bg-color);
    cursor: pointer;
    color: var(--tg-theme-text-color);
    flex-shrink: 0;
}
.view-toggle:active { opacity: 0.7; }
.view-toggle .ic { width: 18px; height: 18px; }

/* === СЕТКА === */
#board.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#board.grid .card { margin-bottom: 0; }
#board.grid .card-title { font-size: 12px; }
#board.grid .card-code { font-size: 12px; }
#board.grid .card-type { font-size: 9px; }
#board.grid .check-box { min-width: 32px; min-height: 32px; font-size: 11px; padding: 4px 6px; }
#board.grid .icon-action { width: 28px; height: 28px; }
#board.grid .icon-action .ic { width: 13px; height: 13px; }
#board.grid .card-info { gap: 6px; }
#board.grid .info-item { font-size: 10px; }
@media (max-width: 380px) {
    #board.grid { grid-template-columns: 1fr 1fr; }
}

/* === ПРАВИЛЬНАЯ СЕТКА === */
.head-main { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.card-code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#board.grid .card {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}
#board.grid .drag-handle {
    align-self: center;
    padding: 2px 6px;
}
#board.grid .card-body {
    display: flex;
    flex-direction: column;
}
#board.grid .card-head { display: contents; }
#board.grid .head-main { order: 1; }
#board.grid .card-title { order: 2; }
#board.grid .card-actions {
    order: 3;
    margin-left: 0;
    justify-content: flex-start;
}
#board.grid .checks { order: 4; }
#board.grid .card-info { order: 5; }

/* === СЕТКА: ФИНАЛЬНЫЕ ПРАВКИ === */
#board.grid .head-main { width: 100%; }
#board.grid .card-type { flex-shrink: 0; }
#board.grid .card-actions { margin-bottom: 10px; }
#board.grid .card-title { margin-bottom: 6px; }
.drag-handle .ic { width: 22px; height: 22px; }

/* === ТОЧКИ ПЕРЕТАСКИВАНИЯ === */
/* Список: вертикально */
.drag-handle .ic { transform: rotate(90deg); }
/* Сетка: горизонтально */
#board.grid .drag-handle .ic { transform: rotate(0deg); }

/* === КНОПКА ФИЛЬТРА ПО ОТМЕТКАМ === */
.view-toggle.active {
    background: var(--tg-theme-button-color);
    border-color: var(--tg-theme-button-color);
    color: white;
}

/* === КНОПКА ФИЛЬТРА СПРАВА === */
.search-wrap { order: 1; }
#viewToggle { order: 2; }
#checkedToggle { order: 3; }

/* === ДИЗАЙН ЖУРНАЛА КАК НА САЙТЕ === */
.header-right { display: flex; align-items: center; gap: 6px; }
.journal-btn {
    width: 40px;
    height: 40px;
    border: none;
    outline: none;
    border-radius: 10px;
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-button-color);
    margin-right: 0;
}
.journal-btn .ic { width: 18px; height: 18px; }

/* Крестик шторки справа */
.journal-header .modal-close { order: 3; }
.journal-header h3 { order: 1; flex: 1; text-align: left; margin-right: 0; }
.journal-header .header-spacer { display: none; }

/* === ПОРЯДОК КНОПОК ПАНЕЛИ === */
.search-wrap { order: 1; }
#viewToggle { order: 2; }
#hasNoteToggle { order: 3; }
#checkedToggle { order: 4; }

/* === КНОПКА "С ЗАМЕТКАМИ" КАК В КАРТОЧКЕ === */
#hasNoteToggle.active {
    background: #ff3b30;
    border-color: #ff3b30;
    color: white;
}

/* === ВКЛАДКИ ЖУРНАЛА КАК КНОПКИ В КАРТОЧКАХ === */
.journal-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}
.journal-tabs::-webkit-scrollbar { display: none; }
.jtab {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    cursor: pointer;
    transition: all 0.2s;
}
.jtab:active { transform: scale(0.92); }
.jtab.active {
    background: var(--tg-theme-button-color);
    color: white;
}
.jtab .ic { width: 18px; height: 18px; }
.journal-body { min-height: 160px; margin-top: 8px; }
.journal-body .note-textarea { margin-bottom: 0; }
.cash-total {
    margin-top: 8px;
    padding: 10px;
    background: rgba(76,175,80,0.12);
    color: var(--success);
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    text-align: center;
}
.contact-form { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.contact-form input {
    flex: 1 1 45%;
    padding: 9px 10px;
    border: 1px solid var(--tg-theme-separator-color);
    border-radius: 9px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    min-width: 0;
    background: var(--tg-theme-bg-color);
}
.contact-form .tg-btn { flex: 0 0 44px; min-height: 38px; padding: 8px; }
.contacts-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.contact-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 10px;
}
.contact-info { flex: 1; min-width: 0; }
.contact-fio { font-weight: 700; font-size: 14px; }
.contact-line { font-size: 12px; color: var(--tg-theme-hint-color); }
.journal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

/* === ТЕКСТОВОЕ ПОЛЕ ЖУРНАЛА === */
.journal-body { min-height: 120px; margin-top: 8px; }
.jeditor {
    width: 100%;
    min-height: 140px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--tg-theme-separator-color);
    border-radius: 10px;
    background: var(--tg-theme-bg-color);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
}
.jeditor:focus { border-color: var(--tg-theme-button-color); }
.jeditor:empty:before { content: attr(data-placeholder); color: var(--tg-theme-hint-color); }
.jeditor ol, .jeditor ul { list-style-position: inside; padding-left: 4px; margin: 4px 0; }
.jeditor li { margin: 2px 0; }

/* === КНОПКИ ФОРМАТИРОВАНИЯ В СТИЛЕ САЙТА === */
.fmt-toolbar { display: flex; gap: 6px; margin-top: 6px; }
.fmt-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    cursor: pointer;
    transition: all 0.2s;
}
.fmt-btn:active { opacity: 0.7; transform: scale(0.92); }
.fmt-btn.active { background: var(--tg-theme-button-color); color: white; }
.fmt-btn .ic { width: 18px; height: 18px; }

/* === ЧЕКБОКСЫ В РЕДАКТОРЕ === */
.jeditor input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: -2px;
    accent-color: var(--success);
}

/* === КНОПКИ В КАРТОЧКЕ КОНТАКТА === */
.contact-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.contact-copy {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: rgba(51,144,236,0.12);
    color: var(--tg-theme-button-color);
    cursor: pointer;
}
.contact-copy:active { opacity: 0.7; transform: scale(0.9); }
.contact-copy .ic { width: 15px; height: 15px; }

/* === ЛИПКАЯ ШАПКА === */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--tg-theme-secondary-bg-color);
    padding-bottom: 4px;
}
.tg-header { position: static; }

/* === ВРЕМЯ В ОДНУ СТРОКУ С НАЗВАНИЕМ === */
.title-time {
    color: var(--tg-theme-hint-color);
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
}
.title-time .ic { width: 12px; height: 12px; vertical-align: -1px; }

/* === ПЛАВНОЕ ПОЯВЛЕНИЕ ШТОРОК === */
.tg-modal { animation: fadeIn 0.25s ease; }
.tg-modal-content {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

/* === НЕТ ПЕРЕЗАГРУЗКИ ПРИ СВАЙПЕ === */
html, body { overscroll-behavior-y: contain; }
.tg-modal-content { overscroll-behavior: contain; }

/* === ПОЛЕ ИМЕНИ СОТРУДНИКА === */
.emp-name {
    flex: 1;
    border: 1px solid var(--tg-theme-separator-color);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: var(--tg-theme-bg-color);
    min-width: 0;
}
.emp-name:focus { border-color: var(--tg-theme-button-color); }

/* === ИТОГО КАССЫ === */
.cash-total-line {
    margin-top: 10px;
    padding: 12px;
    background: rgba(76,175,80,0.12);
    color: var(--success);
    border-radius: 10px;
    font-weight: 700;
    font-size: 16px;
    text-align: center;
}

/* === КНОПКА КАССЫ В КАРТОЧКЕ === */
.icon-action.cash { background: rgba(120,120,128,0.12); color: var(--success); }

/* === СЧЁТЧИКИ НА ЧИПАХ === */
.chip-count {
    font-size: 10px;
    margin-left: 5px;
    opacity: 0.65;
    font-weight: 700;
    vertical-align: 1px;
}
.chip.active .chip-count { color: white; opacity: 0.85; }

/* === ФОРМА ТОВАРА === */
.pz-select-all {
    width: 100%; padding: 10px; border: none; border-radius: 10px;
    background: rgba(51,144,236,0.15); color: var(--tg-theme-button-color);
    font-weight: 600; font-family: inherit; font-size: 14px; margin-bottom: 8px;
}
.pz-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.pz-cat {
    padding: 8px 14px; border: 1px solid var(--tg-theme-separator-color); border-radius: 10px;
    background: var(--tg-theme-bg-color); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.pz-cat.active { border-color: var(--tg-theme-button-color); color: var(--tg-theme-button-color); box-shadow: 0 0 0 1px var(--tg-theme-button-color); }
.pz-line { border: 1px solid var(--tg-theme-separator-color); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.pz-line-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 8px; }
.pz-all-fields { border: none; background: none; color: var(--tg-theme-button-color); font-weight: 600; font-family: inherit; font-size: 13px; }
.pz-line-fields { display: flex; flex-wrap: wrap; gap: 6px; }
.pz-field {
    padding: 7px 10px; border: 1px solid var(--tg-theme-separator-color); border-radius: 9px;
    background: var(--tg-theme-bg-color); font-family: inherit; font-size: 13px; cursor: pointer;
}
.pz-field.active { background: var(--success); border-color: var(--success); color: white; }

/* === ФОТО ТОВАРА === */
.pz-photo-row { display: flex; gap: 8px; align-items: center; }
.pz-photo-preview { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.prize-photo { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; margin-right: 8px; flex-shrink: 0; }

/* === ФОТО В КАРТОЧКЕ ПРИЗА === */
.prize-photo-big {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
    align-self: center;
}

/* === ИЗБРАННОЕ === */
#favToggle { order: 3; }
#hasNoteToggle { order: 4; }
#checkedToggle { order: 5; }
#prizesToggle { order: 6; }
.icon-action.fav { background: rgba(120,120,128,0.12); color: var(--warning); }
.icon-action.fav.active { background: var(--warning); color: white; }
#favToggle.active { background: var(--warning); border-color: var(--warning); color: white; }
#favToggle.active .ic { fill: currentColor; }

/* === ЗАКАЗ === */
#cartBtn { order: 4; position: relative; }
#hasNoteToggle { order: 5; }
#checkedToggle { order: 6; }
#prizesToggle { order: 7; }
.cart-badge {
    position: absolute; top: -5px; right: -5px;
    background: var(--danger); color: white;
    font-size: 10px; font-weight: 700;
    border-radius: 10px; padding: 2px 5px; min-width: 17px; text-align: center;
}
.order-row { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.order-add { min-height: 36px; padding: 8px 16px; font-size: 13px; border-radius: 10px; }
.order-qty { display: flex; align-items: center; gap: 10px; }
.qty-btn {
    width: 34px; height: 34px;
    border: 1px solid var(--tg-theme-separator-color); border-radius: 9px;
    background: var(--tg-theme-bg-color); color: var(--tg-theme-text-color);
    font-size: 18px; font-weight: 700; cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
}
.qty-btn:active { opacity: 0.7; }
.qty-num { font-weight: 700; font-size: 16px; min-width: 20px; text-align: center; }

/* === ПОЛЕ ДАННЫХ ЗАКАЗА === */
.order-preview {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--tg-theme-separator-color);
    border-radius: 10px;
    background: var(--tg-theme-bg-color);
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.5;
    max-height: 220px;
    overflow-y: auto;
}

/* === КНОПКА ЗАКАЗА В ПРАВОМ НИЖНЕМ УГЛУ === */
.card-body { display: flex; flex-direction: column; }
.order-row {
    margin-top: auto;
    padding-top: 10px;
    justify-content: flex-end;
}

/* === КНОПКА ЗАКАЗА СВЕРХУ СПРАВА === */
.order-row {
    margin-top: 0;
    padding-top: 0;
    margin-bottom: 6px;
    justify-content: flex-end;
}

/* === КОМПАКТНАЯ КАРТОЧКА ПРИЗА === */
.icon-action.order-add-sq { background: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); }
.line-chip { background: rgba(255,193,7,0.15); color: #b28704; }
.prize-card { padding: 10px; }
.prize-card .prize-photo-big { width: 64px; height: 64px; align-self: flex-start; }

/* === КНОПКА РЕЖИМА ПЕРВАЯ === */
#prizesToggle { order: 2; }
#viewToggle { order: 3; }
#favToggle { order: 4; }
#cartBtn { order: 5; }
#hasNoteToggle { order: 6; }
#checkedToggle { order: 7; }

/* === КНОПКА РЕЖИМА В ШАПКЕ === */
.tg-header #prizesToggle {
    order: 0;
    margin-right: 8px;
    flex-shrink: 0;
    align-self: center;
}

/* === ФОТО НА ВСЮ ШИРИНУ (СЕТКА) === */
#board.grid .prize-card { flex-direction: column; }
#board.grid .prize-photo-big {
    width: 100%;
    height: 160px;
    align-self: stretch;
    border-radius: 10px;
}

/* === СПИСОК: БЕЗ ОПИСАНИЯ === */
#board:not(.grid) .prize-card .contact-line { display: none; }

/* === СЕТКА: КНОПКИ В САМОМ НИЗУ СПРАВА === */
#board.grid .prize-card .card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}
#board.grid .prize-card .order-row {
    margin-top: auto !important;
    padding-top: 10px;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    display: flex;
}

/* === СПИСОК: КРУПНЕЕ ФОТО, КОМПАКТНАЯ КАРТОЧКА === */
#board:not(.grid) .prize-card { padding: 6px; }
#board:not(.grid) .prize-photo-big {
    width: 100px;
    height: 100px;
    border-radius: 10px;
}
#board:not(.grid) .prize-card .card-body { gap: 2px; }
#board:not(.grid) .prize-card .order-row { padding-top: 4px; }

/* === КОМПАКТНЫЕ ТРИ ТОЧКИ === */
.drag-handle {
    padding: 2px !important;
    margin: 0 !important;
    align-self: center;
}

/* === ЭКРАН ВХОДА === */
.login-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--tg-theme-bg-color, #f4f5f8);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-screen.hidden { display: none; }
.login-card {
    width: 100%; max-width: 340px;
    background: var(--tg-theme-secondary-bg-color, #fff);
    border-radius: 16px; padding: 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 16px; }
.login-error { color: var(--danger, #e53935); font-size: 13px; margin-bottom: 10px; text-align: center; }

/* === СКРОЛЛ ВНУТРИ ПОЛЕЙ НЕ ЗАКРЫВАЕТ ШТОРКУ === */
textarea, .order-preview, .contacts-list, .fields-list {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* === СКРОЛЛБАР СПРАВА В ПОЛЕ ДАННЫХ === */
.note-textarea, .order-preview {
    overflow-y: scroll;
    max-height: 50vh;
    scrollbar-width: thin;
    scrollbar-color: rgba(120,120,128,0.5) transparent;
}
.note-textarea::-webkit-scrollbar, .order-preview::-webkit-scrollbar {
    width: 6px;
}
.note-textarea::-webkit-scrollbar-track, .order-preview::-webkit-scrollbar-track {
    background: transparent;
}
.note-textarea::-webkit-scrollbar-thumb, .order-preview::-webkit-scrollbar-thumb {
    background: rgba(120,120,128,0.5);
    border-radius: 3px;
}

/* === ВЫПАДАЮЩЕЕ МЕНЮ ЧЕКОВ === */
.toolbar { position: relative; }
.checks-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 8px;
    z-index: 60;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,.18);
    padding: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
#checksToggle.active { background: var(--tg-theme-button-color, #2481cc); color: #fff; }

/* === КНОПКА ЧЕК СПРАВА === */
#checksToggle { order: 10; }

/* === МЕНЮ ЧЕКОВ В ОДНУ СТРОКУ === */
.checks-menu {
    flex-wrap: nowrap !important;
    left: 8px !important;
    right: 8px !important;
    gap: 4px !important;
    padding: 6px !important;
    justify-content: space-between;
}
.checks-menu .chip {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 0 !important;
    font-size: 15px !important;
    text-align: center;
    justify-content: center;
}




/* === КОМПАКТНЫЙ РЕЖИМ v2 === */
#board.compact .card { padding: 5px 6px; display: flex; align-items: center; gap: 4px; }
#board.compact .card .drag-handle { padding: 0; margin: 0; }
#board.compact .card .card-body { display: flex; flex-direction: row; align-items: center; gap: 5px; flex: 1; min-width: 0; padding: 0; }
/* название: маленький шрифт, одна строка */
#board.compact .card .card-title { font-size: 11px; line-height: 1.1; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; font-weight: 500; }
#board.compact .card .card-title [class*="time"] { display: none !important; }
/* чеки: маленькие */
#board.compact .card .checks { display: flex; gap: 2px; margin: 0; flex: 0 0 auto; }
#board.compact .card .checks button { width: 19px; height: 19px; min-width: 19px; font-size: 10px; border-radius: 5px; padding: 0; line-height: 19px; }
#board.compact .card .checks button[onclick*="erve"] { width: auto; padding: 0 8px; font-size: 10px; height: 19px; }
/* шапка: скрыть тип/код и лишние кнопки, оставить ТОЛЬКО сбос (последняя) */
#board.compact .card .card-head { display: flex; align-items: center; margin: 0; flex: 0 0 auto; }
#board.compact .card .head-main { display: none !important; }
#board.compact .card .card-head button { display: none !important; }
#board.compact .card .card-head button:last-child { display: flex !important; width: 20px; height: 20px; min-width: 20px; padding: 0; align-items: center; justify-content: center; }
#board.compact .card .card-head button:last-child svg { width: 11px; height: 11px; }
#board.compact .card .order-row, #board.compact .card .contact-line, #board.compact .card .info-line { display: none !important; }
#compactToggle.active { background: var(--tg-theme-button-color, #2481cc); color: #fff; }
/* === ЧЕКИ В КОМПАКТЕ: шрифт как у названия === */
#board.compact .card .checks button {
    width: 19px !important;
    height: 19px !important;
    min-width: 19px !important;
    font-size: 11px !important;
    line-height: 19px !important;
    border-radius: 5px !important;
    padding: 0 !important;
}

/* === ЧЕКИ В КОМПАКТЕ: ко всем элементам === */
#board.compact .card .checks,
#board.compact .card .checks > * {
    width: 19px !important;
    height: 19px !important;
    min-width: 19px !important;
    max-width: 19px !important;
    font-size: 11px !important;
    line-height: 17px !important;
    border-radius: 5px !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}
#board.compact .card .checks > * svg { width: 10px !important; height: 10px !important; }

/* === КОМПАКТ v3: точные селекторы чеков === */
#board.compact .card .checks {
    display: flex !important;
    flex-direction: row !important;
    gap: 2px !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    align-items: center !important;
}
#board.compact .card .checks .check-item {
    width: 19px !important;
    height: 19px !important;
    min-width: 19px !important;
    margin: 0 !important;
    padding: 0 !important;
}
#board.compact .card .checks .check-box {
    width: 19px !important;
    height: 19px !important;
    min-width: 19px !important;
    font-size: 11px !important;
    line-height: 1 !important;
    border-radius: 5px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
#board.compact .card .checks button {
    width: auto !important;
    height: 19px !important;
    font-size: 10px !important;
    padding: 0 6px !important;
    border-radius: 5px !important;
}

/* === КОМПАКТ v4: квадратные чеки === */
#board.compact .card .checks .check-item {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    max-height: 19px !important;
    overflow: hidden !important;
}
#board.compact .card .checks .check-item input {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
}
#board.compact .card .checks .check-box {
    max-height: 19px !important;
    min-height: 19px !important;
    aspect-ratio: 1 / 1 !important;
    box-sizing: border-box !important;
}

/* === КОМПАКТ v5: кнопка заметки перед чеками === */
#board.compact .card .card-body > .card-title { order: 1; }
#board.compact .card .card-body > .card-head { order: 2; margin: 0; }
#board.compact .card .card-body > .checks { order: 3; }
#board.compact .card .card-head button.note {
    display: flex !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    padding: 0 !important;
    align-items: center;
    justify-content: center;
}
#board.compact .card .card-head button.note svg { width: 11px !important; height: 11px !important; }
#board.compact .card .card-head button.note.active { background: rgba(229,57,53,.15) !important; color: #e53935 !important; }

/* === КОМПАКТ v6: нормальная мини-карточка в админке === */
#board.compact .card .card-body > * { display: none !important; }
#board.compact .card .card-body > .card-title {
    display: block !important;
    order: 1;
    flex: 1;
    min-width: 0;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}
#board.compact .card .card-body > .card-head {
    display: flex !important;
    order: 2;
    align-items: center;
    gap: 3px;
    flex: 0 0 auto;
    margin: 0;
}
#board.compact .card .card-head .head-main {
    display: block !important;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
}
#board.compact .card .card-head .card-type { display: none !important; }
#board.compact .card .card-head button { display: none !important; }
#board.compact .card .card-head button.note,
#board.compact .card .card-head button.reset {
    display: flex !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    padding: 0 !important;
    align-items: center;
    justify-content: center;
}
#board.compact .card .card-head button svg { width: 11px !important; height: 11px !important; }
#board.compact .card .card-body > .checks { display: flex !important; order: 3; }

/* === КОМПАКТ v7: без номера аппарата === */
#board.compact .card .card-head .head-main { display: none !important; }

/* === КОМПАКТ v8: мини-карточка приза === */
#board.compact .prize-card .prize-photo-big { display: none !important; }
#board.compact .prize-card .card-body > * { display: none !important; }
#board.compact .prize-card .card-head { display: contents !important; }
#board.compact .prize-card .head-main {
    display: block !important;
    order: 1;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
}
#board.compact .prize-card .card-body > .card-title:nth-child(2) {
    display: flex !important;
    order: 2;
    flex: 0 0 auto;
    gap: 3px;
    margin: 0 !important;
}
#board.compact .prize-card .card-title .card-type[style*="76,175,80"] { display: none !important; }
#board.compact .prize-card .card-actions {
    display: flex !important;
    order: 3;
    gap: 4px;
    flex: 0 0 auto;
}
#board.compact .prize-card .card-head button,
#board.compact .prize-card .card-actions button {
    display: flex !important;
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    padding: 0 !important;
    align-items: center;
    justify-content: center;
}
#board.compact .prize-card .card-actions button svg { width: 14px !important; height: 14px !important; }

/* === КОМПАКТ v9: приз — кнопки слева, название видно === */
#board.compact .card.prize-card .prize-photo-big { display: none !important; }
#board.compact .card.prize-card .card-body > * { display: none !important; }
#board.compact .card.prize-card .card-head { display: contents !important; }
#board.compact .card.prize-card .card-actions {
    display: flex !important;
    order: 1 !important;
    gap: 4px;
    flex: 0 0 auto;
    margin: 0;
}
#board.compact .card.prize-card .head-main {
    display: block !important;
    order: 2 !important;
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#board.compact .card.prize-card .card-body > div:nth-child(2) {
    display: flex !important;
    order: 3 !important;
    flex: 0 0 auto;
    gap: 3px;
    margin: 0 !important;
}
#board.compact .card.prize-card .card-title .card-type[style*="76,175,80"] { display: none !important; }
#board.compact .card.prize-card .card-actions button {
    display: flex !important;
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    padding: 0 !important;
    align-items: center;
    justify-content: center;
}
#board.compact .card.prize-card .card-actions button svg { width: 14px !important; height: 14px !important; }

/* === КОМПАКТ v10: приз — кнопки справа, шрифт 11px === */
#board.compact .card.prize-card .head-main { order: 1 !important; font-size: 11px !important; }
#board.compact .card.prize-card .card-body > div:nth-child(2) { order: 2 !important; }
#board.compact .card.prize-card .card-actions { order: 4 !important; }
#board.compact.cat-filter .card.prize-card .card-body > .card-title[style*="4px 0 0"] {
    display: flex !important;
    order: 3 !important;
    margin: 0 !important;
    gap: 3px;
}

/* === КОМПАКТ v11: приз — кнопки слева, шрифт обычный === */
#board.compact .card.prize-card .card-actions { order: 1 !important; }
#board.compact .card.prize-card .head-main { order: 2 !important; font-weight: 500 !important; }
#board.compact .card.prize-card .card-body > div:nth-child(2) { order: 3 !important; }
#board.compact .card.prize-card .card-body > .card-title[style*="4px 0 0"] { order: 3 !important; }
/* при включённом фильтре категории — категорию скрыть, оставить линию */
#board.compact.cat-filter .card.prize-card .card-body > div:nth-child(2) { display: none !important; }

/* === КОМПАКТ v12: приз — кнопки справа, шрифт как в аппаратах === */
#board.compact .card.prize-card .head-main {
    order: 1 !important;
    font-weight: 500 !important;
    font-size: 11px !important;
}
#board.compact .card.prize-card .card-body > div:nth-child(2) { order: 2 !important; }
#board.compact .card.prize-card .card-body > .card-title[style*="4px 0 0"] { order: 3 !important; }
#board.compact .card.prize-card .card-actions { order: 4 !important; }

/* === КОМПАКТ v13: приз — шрифт названия и кнопки вправо === */
#board.compact .card.prize-card .head-main .card-code,
#board.compact .card.prize-card .card-code {
    font-size: 11px !important;
    font-weight: 500 !important;
}
#board.compact .card.prize-card .card-actions {
    order: 4 !important;
    margin-left: auto !important;
    flex: 0 0 auto !important;
}
#alphaToggle.active { background: var(--tg-theme-button-color, #2481cc); color: #fff; }

/* === А-Я после кнопки списка === */
#alphaToggle { order: 4; }
#favToggle { order: 5; }
#cartBtn { order: 6; }

/* === СКРОЛЛИНГ В ЗАМЕТКАХ === */
#noteText, #noteEditor, .note-editor,
#noteModal textarea, #noteModal [contenteditable="true"],
.modal textarea, .modal [contenteditable="true"] {
    max-height: 45vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* === СКРОЛЛИНГ: jeditor + note-textarea === */
.jeditor, .note-textarea {
    max-height: 45vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* === СКРОЛЛИНГ v2: фиксированная высота === */
#j_dice, #j_notes, #j_cash, #j_misc, #j_parts, #j_archive, .jeditor {
    height: 40vh !important;
    max-height: 40vh !important;
    overflow-y: scroll !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* === СОВРЕМЕННАЯ КНОПКА ФОТО === */
.photo-upload-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(36,129,204,.08) !important;
    border: 1.5px dashed var(--tg-theme-button-color, #2481cc) !important;
    color: var(--tg-theme-button-color, #2481cc) !important;
    border-radius: 14px !important;
    padding: 12px 18px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    min-height: 44px !important;
    cursor: pointer;
}
.photo-upload-btn svg { width: 20px; height: 20px; flex: 0 0 auto; }

/* === ОПИСАНИЕ: 4 СТРОКИ === */
textarea[placeholder="Описание"] {
    height: auto !important;
    min-height: 0 !important;
    max-height: 140px !important;
    resize: vertical;
}

/* === ПРЕВЬЮ ФОТО В ФОРМЕ === */
.pz-photo-preview {
    max-width: 120px !important;
    max-height: 120px !important;
    border-radius: 12px !important;
    object-fit: cover !important;
    border: 1px solid rgba(0,0,0,.1);
}

/* === КВАДРАТНАЯ КНОПКА ФОТО === */
.photo-upload-btn {
    width: 96px !important;
    height: 96px !important;
    min-height: 0 !important;
    padding: 0 !important;
    border-radius: 16px !important;
    position: relative;
    overflow: hidden;
    flex-direction: column;
    gap: 4px;
}
.photo-upload-btn svg { width: 24px !important; height: 24px !important; }
.photo-upload-btn.has-photo {
    border-color: transparent !important;
    background: transparent !important;
    font-size: 0 !important;
}
.photo-upload-btn.has-photo svg { display: none !important; }
.photo-upload-btn.has-photo .pz-photo-preview {
    max-width: none !important;
    max-height: none !important;
    width: 96px !important;
    height: 96px !important;
    border-radius: 16px !important;
    object-fit: cover !important;
    border: none !important;
    display: block !important;
}

/* === ЧЕКБОКС "ОТДЕЛЬНЫЙ СПИСОК" === */
.pz-separate-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    margin: 12px 0 !important;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.pz-separate-label input { width: 20px; height: 20px; accent-color: var(--tg-theme-button-color, #2481cc); }

/* === КОЛИЧЕСТВО: видимое текстовое поле === */
.qty-input {
    width: 48px !important;
    height: 38px !important;
    border: 1.5px solid rgba(0,0,0,.2) !important;
    background: var(--tg-theme-bg-color, #fff) !important;
    border-radius: 10px !important;
    text-align: center !important;
    font-weight: 700 !important;
    font-size: 16px !important;
    color: inherit !important;
    padding: 0 !important;
}
.qty-input:focus {
    outline: none !important;
    border-color: var(--tg-theme-button-color, #2481cc) !important;
    box-shadow: 0 0 0 2px rgba(36,129,204,.25);
}

/* === КОРЗИНА-ФИЛЬТР === */
#cartFilterBtn { flex: 0 0 auto; }
#cartFilterBtn.active {
    background: var(--tg-theme-button-color, #2481cc) !important;
    color: #fff !important;
}

/* === КАЛЬКУЛЯТОР ИГРУШЕК === */
.calc-fab {
    position: fixed; right: 16px; bottom: 16px;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--tg-theme-button-color, #2481cc); color: #fff;
    display: flex; align-items: center; justify-content: center;
    border: none; z-index: 95;
    box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
.calc-fab svg { width: 26px; height: 26px; }
.calc-sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--tg-theme-bg-color, #fff);
    border-radius: 20px 20px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    z-index: 96; box-shadow: 0 -4px 20px rgba(0,0,0,.25);
    transform: translateY(105%); transition: transform .25s;
}
.calc-sheet.open { transform: translateY(0); }
.calc-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.calc-sheet label { display: block; font-size: 13px; color: var(--tg-theme-hint-color, #888); margin: 8px 0 4px; }
.calc-sheet input {
    width: 100%; padding: 10px 12px; border-radius: 12px;
    border: 1.5px solid rgba(0,0,0,.15); background: var(--tg-theme-secondary-bg-color, #f5f5f5);
    font-size: 16px; color: var(--tg-theme-text-color, #000);
}
.calc-total { margin: 12px 0; font-size: 16px; }
.calc-total b { font-size: 20px; color: var(--tg-theme-button-color, #2481cc); }
.calc-actions { display: flex; gap: 10px; align-items: center; }

/* === ШТОРКА ПОВЕРХ ВСЕГО === */
.calc-sheet { z-index: 9999 !important; }
.calc-fab { z-index: 9998 !important; }

/* === ЖУРНАЛ: ШТОРКА НА ВЕСЬ ЭКРАН === */
#journalModal .tg-modal-content {
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}
#journalModal .journal-body { flex: 1; min-height: 0; overflow-y: auto; }
#journalModal .jeditor { height: 100%; min-height: 0; }

/* === ЖУРНАЛ: РЕДАКТОР НА ВСЮ ВЫСОТУ === */
#journalModal .journal-body { display: flex; flex-direction: column; overflow: hidden; }
#journalModal .jpane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#journalModal .jpane.hidden { display: none; }
#journalModal .jeditor { flex: 1; height: auto; min-height: 0; overflow-y: auto; }

/* === ЖУРНАЛ: ПОЛЕ НА ВСЮ ВЫСОТУ (принудительно) === */
#journalModal .tg-modal-content { overflow: hidden !important; }
#journalModal .journal-body { height: auto !important; flex: 1 1 auto !important; display: flex !important; flex-direction: column !important; min-height: 0 !important; }
#journalModal .jpane { height: auto !important; }
#journalModal .jpane:not(.hidden) { flex: 1 1 auto !important; display: flex !important; flex-direction: column !important; min-height: 0 !important; }
#journalModal .jeditor { flex: 1 1 auto !important; height: auto !important; min-height: 0 !important; overflow-y: auto !important; }

/* === ЖУРНАЛ: СНЯТЬ ЛИМИТ 40vh === */
#journalModal .jeditor { max-height: none !important; height: auto !important; flex: 1 1 auto !important; }

/* === ЖУРНАЛ: ПОЛЕ НЕ НАЕЗЖАЕТ НА КНОПКИ === */
#journalModal .jpane { overflow: hidden; }
#journalModal .jeditor { margin-bottom: 10px; }
#journalModal .fmt-toolbar { position: relative; z-index: 10; background: var(--tg-theme-bg-color); padding-top: 8px; }
#journalModal .journal-footer { position: relative; z-index: 10; background: var(--tg-theme-bg-color); padding-top: 8px; }

/* === ЖУРНАЛ: КНОПКИ В ПОТОКЕ, ПОЛЕ НЕ НАЕЗЖАЕТ === */
#journalModal .journal-header,
#journalModal .journal-tabs,
#journalModal .fmt-toolbar,
#journalModal .journal-footer {
    position: static !important;
    flex: 0 0 auto !important;
    background: var(--tg-theme-bg-color);
    z-index: 11;
}

/* === ЖУРНАЛ: КОНТАКТЫ НА ВСЮ ВЫСОТУ === */
#journalModal .contact-form { flex: 0 0 auto; }
#journalModal .contacts-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* === ЖУРНАЛ: КОНТАКТЫ НА ВСЮ ВЫСОТУ (принудительно) === */
#journalModal .jpane[data-pane="contacts"]:not(.hidden) { display: flex !important; flex-direction: column !important; flex: 1 1 auto !important; min-height: 0 !important; }
#journalModal .contact-form { flex: 0 0 auto !important; }
#journalModal .contacts-list { flex: 1 1 auto !important; min-height: 0 !important; height: auto !important; max-height: none !important; overflow-y: auto !important; }

/* === ЖУРНАЛ: НАЗВАНИЕ РАЗДЕЛА СВЕРХУ === */
.journal-section-name { font-size: 13px; color: var(--tg-theme-hint-color); font-weight: 700; margin: -6px 0 8px; text-align: left; text-transform: uppercase; letter-spacing: 0.4px; }

/* ========== ПАКЕТ 2026-09-02 ========== */
/* Журнал: весь экран */
#journalModal .tg-modal-content { max-width:100%; height:100vh; height:100dvh; max-height:100vh; max-height:100dvh; border-radius:0; display:flex; flex-direction:column; position:relative; overflow:hidden !important; }
#journalModal .journal-body { flex:1 1 auto !important; min-height:0 !important; display:flex !important; flex-direction:column !important; overflow:hidden; }
#journalModal .jpane { flex:1 1 auto !important; min-height:0 !important; display:flex; flex-direction:column; overflow:hidden; height:auto !important; }
#journalModal .jpane.hidden { display:none !important; }
#journalModal .jeditor { flex:1 1 auto !important; height:auto !important; min-height:0 !important; max-height:none !important; overflow-y:auto !important; margin-bottom:10px; }
#journalModal .journal-header, #journalModal .journal-tabs, #journalModal .fmt-toolbar, #journalModal .journal-footer { position:static !important; flex:0 0 auto !important; background:var(--tg-theme-bg-color); z-index:11; }
#journalModal .fmt-toolbar { position:relative; z-index:10; padding-top:8px; }
#journalModal .journal-footer { position:relative; z-index:10; padding-top:8px; padding-bottom:calc(8px + env(safe-area-inset-bottom)); grid-template-columns:repeat(auto-fit,minmax(110px,1fr)); }
/* Контакты на всю высоту */
#journalModal .jpane[data-pane="contacts"]:not(.hidden) { display:flex !important; flex-direction:column !important; }
#journalModal .contact-form { flex:0 0 auto !important; }
#journalModal .contacts-list { flex:1 1 auto !important; min-height:0 !important; max-height:none !important; overflow-y:auto !important; }
/* Название раздела */
.journal-section-name { font-size:13px; color:var(--tg-theme-hint-color); font-weight:700; margin:-6px 0 8px; text-align:left; text-transform:uppercase; letter-spacing:.4px; }
/* Mini-Excel */
#journalModal #j_cash { padding:0 !important; overflow:auto !important; white-space:normal !important; }
#journalModal #j_cash.cash-sheet { border:1px solid var(--tg-theme-separator-color); border-radius:10px; }
.cash-grid { width:max-content; min-width:100%; border-collapse:collapse; table-layout:fixed; font-size:14px; }
.cash-grid th, .cash-grid td { border:1px solid var(--tg-theme-separator-color); min-width:82px; height:34px; padding:6px; vertical-align:middle; background:var(--tg-theme-bg-color); }
.cash-grid th { position:sticky; top:0; z-index:2; background:var(--tg-theme-secondary-bg-color); color:var(--tg-theme-hint-color); font-weight:700; text-align:center; font-size:12px; }
.cash-grid tbody th { left:0; z-index:1; min-width:34px; width:34px; }
.cash-grid thead th:first-child { left:0; z-index:3; min-width:34px; width:34px; }
.cash-grid td { outline:none; }
.cash-grid td:focus { box-shadow:inset 0 0 0 2px var(--tg-theme-button-color); background:rgba(0,136,204,.08); }
.cash-grid td[data-error="1"] { color:#d93025; background:rgba(217,48,37,.08); }
.cash-ref-pick { box-shadow:inset 0 0 0 2px #34c759 !important; }
#cashClearBtn.hidden { display:none; }
.sec-icons { display:grid; grid-template-columns:repeat(8,1fr); gap:4px; margin-top:6px; }
.sec-icon { padding:6px; border:none; border-radius:6px; font-size:20px; cursor:pointer; background:var(--tg-theme-secondary-bg-color); }
.sec-icon.active { background:var(--tg-theme-button-color); }

/* === КЭШ: СТРОКА ФОРМУЛ fx === */
.cash-fxbar { display: flex; gap: 6px; margin: 0 0 6px; align-items: center; }
.cash-fxbar.hidden { display: none; }
.cash-fx-btn { flex: 0 0 auto; width: 40px; height: 40px; border: none; border-radius: 10px; background: var(--tg-theme-secondary-bg-color); color: var(--tg-theme-button-color); font-style: italic; font-weight: 700; font-size: 17px; font-family: Georgia, serif; }
.cash-fxbar input { flex: 1; height: 40px; border: 1px solid var(--tg-theme-separator-color); border-radius: 10px; padding: 0 10px; font-size: 14px; background: var(--tg-theme-bg-color); outline: none; color: var(--tg-theme-text-color); }
.cash-fx-apply { flex: 0 0 auto; width: 40px; height: 40px; border: none; border-radius: 10px; background: var(--tg-theme-button-color); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cash-fx-apply .ic { width: 18px; height: 18px; }

/* === EXCEL ОТКЛЮЧЕН === */
.cash-grid, .cash-fxbar, .cash-sheet table { display: none !important; }
#j_cash.cash-sheet { padding: 12px !important; }
#cashClearBtn { display: none !important; }

/* === СВАЙПЫ КАРТОЧЕК === */
.swipe-card-wrap { position: relative; overflow: hidden; border-radius: 12px; margin-bottom: 10px; }
.swipe-card-actions { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding: 0 20px; font-weight: 700; color: #fff; font-size: 14px; }
.swipe-card-actions.left { left: 0; background: #e53935; justify-content: flex-start; }
.swipe-card-actions.right { right: 0; background: #34c759; justify-content: flex-end; }
.swipe-card-inner { position: relative; z-index: 2; background: var(--tg-theme-bg-color); transition: transform 0.2s ease; }

/* === СВАЙПЫ: ФИНАЛ === */
.swipe-card-wrap { position: relative; overflow: hidden; border-radius: 12px; margin-bottom: 10px; }
.swipe-card-wrap .card { margin-bottom: 0 !important; }
.swipe-card-actions { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding: 0 18px; font-weight: 700; color: #fff; font-size: 13px; z-index: 1; border-radius: 12px; }
.swipe-card-actions.sw-right { right: 0; background: #e53935; }
.swipe-card-actions.sw-left { left: 0; background: #ff9500; }
.swipe-card-inner { position: relative; z-index: 2; background: transparent !important; transition: transform 0.2s ease; }
/* === СВАЙП: ПЛАШКИ ТОЛЬКО ВО ВРЕМЯ СВАЙПА + ОБЫЧНЫЙ ЗАЗОР === */
.swipe-card-actions { opacity: 0; transition: opacity .15s; }
.swipe-card-wrap.swiping .swipe-card-actions { opacity: 1; }
.swipe-card-wrap { margin-bottom: 12px !important; }

/* === ЦВЕТА СВАЙПОВ: ЧЕКИ ЗЕЛЁНЫЕ, ЗАМЕТКИ КРАСНЫЕ === */
.swipe-card-actions.sw-right { background: #34c759 !important; }
.swipe-card-actions.sw-left { background: #e53935 !important; }








/* === Σ: ПЛОСКАЯ КНОПКА ПОД ПОЛЕМ === */
.cash-sigma-row { display: flex; justify-content: flex-end; padding: 6px 4px 0; }
.cash-sigma-row.hidden { display: none !important; }
.cash-sigma-btn { width: 36px !important; height: 34px !important; min-width: 36px !important; padding: 0 !important; border-radius: 8px !important; font-size: 18px !important; font-weight: 700 !important; }
.cash-sigma-btn .ic { width: 0 !important; height: 0 !important; }

/* === ДАТА: ИКОНКА ВИДНА + ОТСТУП МЕЖДУ КНОПКАМИ === */
.cash-sigma-row { gap: 8px !important; }
.cash-sigma-btn .ic { width: 16px !important; height: 16px !important; }

.sigma-danger { margin-right: auto !important; color: #e53935 !important; }

/* === ОДИНАКОВЫЕ КНОПКИ ОБА РЯДА === */
.cash-sigma-row .fmt-btn,
#journalModal .fmt-toolbar button {
    width: 38px !important;
    height: 36px !important;
    min-width: 38px !important;
    padding: 0 !important;
    border-radius: 9px !important;
    font-size: 17px !important;
}
.cash-sigma-row .fmt-btn .ic,
#journalModal .fmt-toolbar button .ic {
    width: 16px !important;
    height: 16px !important;
}

/* === ПЕРВЫЙ РЯД НА ВСЮ ШИРИНУ ПОЛЯ === */
.cash-sigma-row { width: 100%; }
.cash-sigma-row .fmt-btn { flex: 1 1 0 !important; width: auto !important; min-width: 0 !important; }
.sigma-danger { margin-right: 0 !important; }

/* === НИЖНИЙ РЯД КАК ПЕРВЫЙ: РАВНЫЕ НА ВСЮ ШИРИНУ === */
#journalModal .fmt-toolbar { width: 100%; }
#journalModal .fmt-toolbar button { flex: 1 1 0 !important; width: auto !important; min-width: 0 !important; }

/* === ПОЛНАЯ УНИФИКАЦИЯ РЯДОВ === */
#journalModal .fmt-toolbar,
.cash-sigma-row {
    display: flex !important;
    gap: 8px !important;
    padding: 4px 0 !important;
    width: 100% !important;
    align-items: stretch !important;
}
#journalModal .fmt-toolbar button,
.cash-sigma-row .fmt-btn {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    font-size: 17px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* === КНОПКА СОХРАНИТЬ: ГОЛУБАЯ КАК АКТИВНАЯ === */
.fmt-save-active { background: var(--tg-theme-button-color, #2481cc) !important; color: #fff !important; }

/* === ФИЛЬТР ЧЕКОВ: СКРЫТЫЕ КАРТОЧКИ НЕ ЗАНИМАЮТ МЕСТО === */
#board .card.hidden { display: none !important; }
#board .swipe-card-wrap:has(.card.hidden) { display: none !important; }
#board .swipe-card-wrap { margin: 0 0 5px 0 !important; }

/* === ФИНАЛЬНЫЙ ФИКС ИНТЕРВАЛОВ: 5PX ВЕЗДЕ === */
#board { display: flex !important; flex-direction: column !important; gap: 5px !important; }
#board.grid { display: grid !important; gap: 5px !important; }
#board > .swipe-card-wrap { margin: 0 !important; width: 100% !important; }
.swipe-card-wrap { position: relative !important; overflow: hidden !important; }
.swipe-card-actions { position: absolute !important; top: 0 !important; bottom: 0 !important; margin: 0 !important; }
.swipe-card-inner { margin: 0 !important; }
#board .card { margin: 0 !important; }
