/* =====================================================
   CSS V3 — ПОЛНЫЙ МИНИМАЛЬНЫЙ НАБОР КЛАССОВ
   ===================================================== */

:root {
    /* ========== МАСШТАБ ========== */
    --v3-scale: 1;

    /* ========== ОТСТУПЫ (масштабируемые) ========== */
    --v3-offset-mini: calc(2px * var(--v3-scale));
    --v3-offset-little: calc(4px * var(--v3-scale));
    --v3-offset-normal: calc(8px * var(--v3-scale));
    --v3-offset-max: calc(12px * var(--v3-scale));

    --v3-height-52px: calc(52px * var(--v3-scale));
    --v3-height-56px: calc(56px * var(--v3-scale));

    /* ========== РАЗМЕРЫ (НЕ масштабируемые для панелей) ========== */
    --v3-panel-header-height: calc(48px * var(--v3-scale));
    --v3-panel-footer-height: auto;
    --v3-btn-min-height: calc(48px * var(--v3-scale));
    --v3-btn-padding: calc(6px * var(--v3-scale));

    /* ========== РАЗМЕРЫ (масштабируемые для контента) ========== */
    --v3-icon-16px: calc(16px * var(--v3-scale));
    --v3-icon-18px: calc(18px * var(--v3-scale));
    --v3-icon-20px: calc(20px * var(--v3-scale));
    --v3-icon-24px: calc(24px * var(--v3-scale));
    --v3-icon-28px: calc(28px * var(--v3-scale));
    --v3-icon-32px: calc(32px * var(--v3-scale));
    --v3-icon-40px: calc(40px * var(--v3-scale));
    --v3-icon-48px: calc(48px * var(--v3-scale));
    --v3-icon-64px: calc(64px * var(--v3-scale));

    /* ========== ШРИФТЫ (масштабируемые) ========== */
    --v3-font-0_55rem: calc(0.55rem * var(--v3-scale));
    --v3-font-0_6rem: calc(0.6rem * var(--v3-scale));
    --v3-font-0_65rem: calc(0.65rem * var(--v3-scale));
    --v3-font-0_7rem: calc(0.7rem * var(--v3-scale));
    --v3-font-0_75rem: calc(0.75rem * var(--v3-scale));
    --v3-font-0_8rem: calc(0.8rem * var(--v3-scale));
    --v3-font-0_85rem: calc(0.85rem * var(--v3-scale));
    --v3-font-0_9rem: calc(0.9rem * var(--v3-scale));
    --v3-font-0_95rem: calc(0.95rem * var(--v3-scale));
    --v3-font-1rem: calc(1rem * var(--v3-scale));
    --v3-font-1_1rem: calc(1.1rem * var(--v3-scale));
    --v3-font-1_2rem: calc(1.2rem * var(--v3-scale));
    --v3-font-1_25rem: calc(1.25rem * var(--v3-scale));
    --v3-font-1_3rem: calc(1.3rem * var(--v3-scale));

    /* ========== ЦВЕТА ========== */
    --v3-primary-base: #1a143d;
    --v3-primary-dark: #38325c;
    --v3-primary-primary: #564f7a;
    --v3-primary-hover: #746d99;
    --v3-primary-secondary: #928ab7;
    --v3-primary-light: #b0a8d6;
    --v3-primary-bg: #cec5f4;

    --v3-success-base: #0d7d23;
    --v3-success-dark: #2b9b42;
    --v3-success-primary: #49b860;
    --v3-success-hover: #67d67f;
    --v3-success-secondary: #85f39d;
    --v3-success-light: #a3ffbc;
    --v3-success-bg: #c1ffda;

    --v3-info-base: #153579;
    --v3-info-dark: #335398;
    --v3-info-primary: #5170b6;
    --v3-info-hover: #6f8ed5;
    --v3-info-secondary: #8dabf3;
    --v3-info-light: #abc9ff;
    --v3-info-bg: #c9e6ff;

    --v3-error-base: #821717;
    --v3-error-dark: #a03536;
    --v3-error-primary: #be5254;
    --v3-error-hover: #dc7073;
    --v3-error-secondary: #fa8d91;
    --v3-error-light: #ffabb0;
    --v3-error-bg: #ffc8ce;

    --v3-text-primary: var(--v3-primary-base);
    --v3-text-secondary: var(--v3-primary-secondary);
    --v3-text-muted: var(--v3-primary-hover);
    --v3-text-disabled: color-mix(in srgb, var(--v3-primary-base) 50%, transparent);

    --v3-shadow: 0 2px 8px rgba(0,0,0,0.1);
    --v3-radius: calc(8px * var(--v3-scale));
    --v3-header-bg: linear-gradient(135deg, var(--v3-primary-dark) 0%, var(--v3-primary-base) 100%);
    --v3-white: #ffffff;
}

/* ========== БАЗОВЫЕ СБРОСЫ ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--v3-primary-bg);
    color: var(--v3-primary-base);
    height: 100vh;
    overflow: hidden;
}

.v3-app { display: flex; flex-direction: column; height: 100vh; }

/* ========== ШАПКА (НЕ масштабируется) ========== */
.v3-header {
    background:  var(--v3-primary-hover);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    height: auto;
}

.v3-header-top {
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.08);
    font-size: 0.7rem;
    font-weight: 500;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;

}

.v3-header-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px;
    gap: 4px;
    min-height: 48px;
}

.v3-header-left,
.v3-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    min-width: 30px;
}

.v3-header-center {
    flex: 1;
    text-align: center;
    color: #ffffff;
    font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    padding: 0 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ========== ОСНОВНАЯ ОБЛАСТЬ ========== */
.v3-main {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    height: 100%;
}

/* ========== ПАНЕЛИ (НЕ масштабируются) ========== */
.v3-left-panel,
.v3-center-panel,
.v3-right-panel,
.v3-log-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.v3-left-panel {
    width: 25vw;
    min-width: 50px;
    max-width: 300px;
    background: var(--v3-primary-bg);
    border-right: 1px solid var(--v3-primary-base);
    flex-shrink: 0;
}

.v3-center-panel {
    width: 25vw;
    min-width: 200px;
    max-width: 400px;
    background: var(--v3-primary-bg);
    border-right: 1px solid var(--v3-primary-base);
    flex-shrink: 0;
    position: relative;
}

.v3-right-panel {
    flex: 1;
    background: var(--v3-primary-bg);
    min-width: 0;
}

.v3-log-panel {
    width: 25vw;
    min-width: 200px;
    background: var(--v3-primary-bg);
    border-left: 1px solid var(--v3-primary-base);
    display: none;
    flex-shrink: 0;
}

.v3-center-panel:not(.v3-visible) {
    display: none !important;
}

/* ========== КОНТЕЙНЕРЫ КОНТЕНТА (масштабируются через transform) ========== */
#leftPanelContent,
#centerPanelContent,
#rightPanelDefault,
#rightPanelEditor,
#rightPanelEditPath,
#logPanelContent {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Масштабирование применяется через JS transform */
}

/* ========== СТРУКТУРА ПАНЕЛИ V3 (внутри контента) ========== */
.v3-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--v3-primary-bg);
    overflow: hidden;
    min-height: 0;
    padding: 6px;
}

.v3-panel-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0 4px 0;
    flex-shrink: 0;
    border-bottom: 1px solid var(--v3-primary-base);
    background: var(--v3-primary-bg);
    min-height: 40px;
}

.v3-panel-header h2,
.v3-panel-header h3 {
    margin: 0;
    color: var(--v3-primary-base);
    font-size: clamp(var(--v3-font-0_7rem), 3vw, var(--v3-font-1rem));
}

.v3-panel-header img {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.v3-panel-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    background: var(--v3-primary-bg);
    font-size: 0.95rem;
    scrollbar-width: thin;
    scrollbar-color: var(--v3-primary-secondary) var(--v3-primary-light);
    padding-right: 10px;
    padding-top: 8px;
    padding-bottom: 8px;

    /* Внутри body используется масштабирование через CSS-переменные */;
}

.v3-panel-body::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.v3-panel-body::-webkit-scrollbar-track {
    background: var(--v3-primary-light);
    border-radius: 3px;
}

.v3-panel-body::-webkit-scrollbar-thumb {
    background: var(--v3-primary-secondary);
    border-radius: 3px;
}

.v3-panel-body::-webkit-scrollbar-thumb:hover {
    background: var(--v3-primary-base);
}

.v3-panel-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 8px 0 0 0;
    border-top: 1px solid var(--v3-primary-base);
    background: var(--v3-primary-bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ========== КНОПКИ (масштабируются через calc) ========== */
.v3-btn {
    display: flex;
    align-items: center;
    gap: var(--v3-offset-normal);
    width: 100%;
    min-height: var(--v3-btn-min-height);
    padding: var(--v3-btn-padding);
    border-radius: var(--v3-radius);
    font-family: inherit;
    font-weight: 500;
    font-size: clamp(var(--v3-font-0_7rem), 1.8vw, var(--v3-font-0_9rem));
    cursor: pointer;
    border: 1px solid;
    background: none;
    justify-content: flex-start;
    transition: all 0.2s ease;
    text-wrap: wrap;
    word-break: break-word;
    line-height: 1.2;
}

.v3-btn.width-auto {
    width: auto !important;
    min-width: 33%;
}

.v3-btn:not(:has(span)) {
    gap: 0;
    justify-content: center;
}

.v3-btn img {
    width: var(--v3-icon-32px);
    height: var(--v3-icon-32px);
    flex-shrink: 0;
}

.v3-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.v3-btn:disabled img {
    filter: invert(1) saturate(0) brightness(2);
    opacity: 0.6;
}

/* ========== ЦВЕТОВЫЕ ВАРИАНТЫ КНОПОК ========== */
.v3-btn-primary {
    background: var(--v3-primary-primary);
    border-color: var(--v3-primary-base);
    color: var(--v3-primary-base);
}
.v3-btn-primary:hover:not(:disabled) {
    background: var(--v3-primary-hover);
}

.v3-btn-secondary {
    background: var(--v3-primary-secondary);
    border-color: var(--v3-primary-base);
    color: var(--v3-primary-base);
}
.v3-btn-secondary:hover:not(:disabled) {
    background: var(--v3-primary-hover);
}

.v3-btn-success {
    background: var(--v3-success-secondary);
    border-color: var(--v3-success-base);
    color: var(--v3-success-base);
}
.v3-btn-success:hover:not(:disabled) {
    background: var(--v3-success-hover);
}

.v3-btn-error {
    background: var(--v3-error-secondary);
    border-color: var(--v3-error-base);
    color: var(--v3-error-base);
}
.v3-btn-error:hover:not(:disabled) {
    background: var(--v3-error-hover);
}

.v3-btn-info {
    background: var(--v3-info-secondary);
    border-color: var(--v3-info-base);
    color: var(--v3-info-base);
}
.v3-btn-info:hover:not(:disabled) {
    background: var(--v3-info-hover);
}

/* ========== КВАДРАТНЫЕ КНОПКИ ========== */
.v3-btn-square-32px {
    width: calc(32px * var(--v3-scale));
    height: calc(32px * var(--v3-scale));
    padding: calc(4px * var(--v3-scale));
    justify-content: center;
    align-items: center;
    border: 1px solid var(--v3-primary-base);
    border-radius: var(--v3-radius);
    cursor: pointer;
    background: none;
    display: inline-flex;
    flex-shrink: 0;
}
.v3-btn-square-32px img {
    max-width: calc(24px * var(--v3-scale));
    max-height: calc(24px * var(--v3-scale));
}

.v3-btn-square-40px {
    width: calc(40px * var(--v3-scale));
    height: calc(40px * var(--v3-scale));
    padding: calc(4px * var(--v3-scale));
    justify-content: center;
    align-items: center;
    border: 1px solid var(--v3-primary-base);
    border-radius: var(--v3-radius);
    cursor: pointer;
    background: none;
    display: inline-flex;
    flex-shrink: 0;
}
.v3-btn-square-40px img {
    max-width: calc(32px * var(--v3-scale));
    max-height: calc(32px * var(--v3-scale));
}

.v3-btn-square-52px {
    width: calc(48px * var(--v3-scale));
    height: calc(48px * var(--v3-scale));
    padding: calc(4px * var(--v3-scale));
    justify-content: center;
    align-items: center;
    border: 1px solid var(--v3-primary-base);
    border-radius: var(--v3-radius);
    cursor: pointer;
    background: none;
    display: inline-flex;
    flex-shrink: 0;
}
.v3-btn-square-52px img {
    max-width: calc(48px * var(--v3-scale));
    max-height: calc(48px * var(--v3-scale));
}

/* ========== КАРТОЧКИ ========== */
.v3-card {
    width: 100%;
    height: auto;
    padding: var(--v3-offset-normal);
    border: 1px solid var(--v3-primary-base);
    border-radius: var(--v3-radius);
    background: transparent;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: var(--v3-offset-normal);
}

.v3-card.v3-selected {
    background: color-mix(in srgb, var(--v3-primary-base) 15%, transparent);
    border-width: var(--v3-offset-mini);
}

.v3-card-success {
    background: var(--v3-success-bg);
    border-color: var(--v3-success-base);
    color: var(--v3-success-base);
}
.v3-card-info {
    background: var(--v3-info-bg);
    border-color: var(--v3-info-base);
    color: var(--v3-info-base);
}
.v3-card-primary {
    background: var(--v3-primary-light);
    border-color: var(--v3-primary-base);
    color: var(--v3-primary-base);
}
.v3-card-secondary {
    background: var(--v3-primary-bg);
    border-color: var(--v3-primary-base);
    color: var(--v3-primary-base);
}
.v3-card-error {
    background: var(--v3-error-bg);
    border-color: var(--v3-error-base);
    color: var(--v3-error-base);
}

.v3-card-title {
    font-size: var(--v3-font-1_1rem);
    font-weight: 600;
}
.v3-card-subtitle {
    font-size: var(--v3-font-0_9rem);
    color: var(--v3-text-secondary);
}

/* ========== ПАНЕЛИ ДЛЯ КАРТОЧЕК ========== */
.v3-panel-for-card {
    display: flex;
    flex-direction: column;
    gap: var(--v3-offset-little);
    border-radius: var(--v3-offset-max);
    overflow: hidden;
    height: auto;
    background: var(--v3-primary-light);
    border: 1px solid var(--v3-primary-base);
}
.v3-panel-for-card-primary {
    background: var(--v3-primary-light);
    border: 1px solid var(--v3-primary-base);
}
.v3-panel-for-card-success {
    background: var(--v3-success-light);
    border: 1px solid var(--v3-success-base);
}
.v3-panel-for-card-error {
    background: var(--v3-error-light);
    border: 1px solid var(--v3-error-base);
}
.v3-panel-for-card-info {
    background: var(--v3-info-light);
    border: 1px solid var(--v3-info-base);
}

/* ========== СЕКЦИИ ========== */
.v3-section {
    background: var(--v3-primary-bg);
    border-radius: var(--v3-radius);
    border: 1px solid var(--v3-primary-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.v3-section-header {
    display: flex;
    align-items: center;
    gap: var(--v3-offset-normal);
    padding: 0 var(--v3-offset-normal);
    height: calc(40px * var(--v3-scale));
    background: var(--v3-primary-light);
    border-bottom: 1px solid var(--v3-primary-base);
    flex-shrink: 0;
}

.v3-section-header h3,
.v3-section-header h4 {
    font-size: var(--v3-font-0_9rem);
    font-weight: 600;
    margin: 0;
}

.v3-section-content {
    padding: var(--v3-offset-normal);
    display: flex;
    flex-direction: column;
    gap: var(--v3-offset-normal);
    flex: 1;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding-right: calc(var(--v3-offset-normal) + 2px);
}

.v3-section-primary {
    border-color: var(--v3-primary-base);
}
.v3-section-primary .v3-section-header {
    background: var(--v3-primary-light);
    border-bottom-color: var(--v3-primary-base);
    color: var(--v3-primary-base);
}
.v3-section-primary .v3-section-content {
    background: var(--v3-primary-bg);
}

.v3-section-success {
    border-color: var(--v3-success-base);
}
.v3-section-success .v3-section-header {
    background: var(--v3-success-light);
    border-bottom-color: var(--v3-success-base);
    color: var(--v3-success-base);
}
.v3-section-success .v3-section-content {
    background: var(--v3-success-bg);
}

.v3-section-info {
    border-color: var(--v3-info-base);
}
.v3-section-info .v3-section-header {
    background: var(--v3-info-light);
    border-bottom-color: var(--v3-info-base);
    color: var(--v3-info-base);
}
.v3-section-info .v3-section-content {
    background: var(--v3-info-bg);
}

/* ========== ФОРМЫ ========== */
.v3-field-group {
    display: flex;
    flex-direction: column;
    gap: var(--v3-offset-mini);
}

.v3-field-label {
    font-size: var(--v3-font-0_8rem);
    font-weight: 500;
    color: var(--v3-text-secondary);
}

.v3-field-input {
    width: 100%;
    height: var(--v3-btn-min-height);
    padding: var(--v3-offset-normal) var(--v3-offset-max);
    border: 1px solid var(--v3-primary-base);
    border-radius: var(--v3-radius);
    background: var(--v3-primary-light);
    color: var(--v3-primary-base);
    font-size: clamp(var(--v3-font-0_6rem), 4vw, var(--v3-font-0_9rem));
    font-family: inherit;
    transition: all 0.2s;
}

.v3-field-input:focus {
    outline: none;
    border-color: var(--v3-primary-base);
    box-shadow: 0 0 0 var(--v3-offset-mini) var(--v3-primary-light);
}

.v3-field-input:disabled {
    opacity: 0.5;
    background: var(--v3-primary-bg);
    cursor: not-allowed;
}

.v3-field-input.v3-error {
    border-color: var(--v3-error-base);
}
.v3-field-input:invalid {
    border-color: var(--v3-error-base);
}
.v3-field-input:user-valid {
    border-color: var(--v3-success-base);
}

select.v3-field-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b5b95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--v3-offset-max) center;
}

.v3-field-checkbox {
    display: flex;
    align-items: center;
    gap: var(--v3-offset-normal);
}
.v3-field-checkbox input {
    width: calc(18px * var(--v3-scale));
    height: calc(18px * var(--v3-scale));
    margin: 0;
}

/* ========== КЛИКАБЕЛЬНЫЕ ПОЛЯ ========== */
.v3-field-clickable {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--v3-offset-max);
    padding: var(--v3-offset-max);
    background: var(--v3-primary-light);
    border: 1px solid var(--v3-primary-base);
    border-radius: var(--v3-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: var(--v3-btn-min-height);
}

.v3-field-clickable:hover:not(.v3-disabled) {
    border-color: var(--v3-primary-base);
    background: var(--v3-primary-hover);
}
.v3-field-clickable.v3-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--v3-primary-bg);
}

.v3-field-clickable .v3-value {
    flex: 1;
    font-size: var(--v3-font-0_9rem);
    color: var(--v3-primary-base);
    word-break: break-word;
}
.v3-field-clickable .v3-value.v3-placeholder {
    color: var(--v3-text-muted);
    opacity: 0.6;
    font-style: italic;
}
.v3-field-clickable .v3-icon {
    flex-shrink: 0;
    width: var(--v3-icon-20px);
    height: var(--v3-icon-20px);
    color: var(--v3-text-secondary);
    font-size: var(--v3-font-0_8rem);
    transition: color 0.2s;
}
.v3-field-clickable:hover:not(.v3-disabled) .v3-icon {
    color: var(--v3-primary-base);
}

/* ========== ТАБЛИЦЫ ========== */
.v3-table-wrapper {
    overflow-x: auto;
    border-radius: var(--v3-radius);
    border: 1px solid var(--v3-primary-base);
}

.v3-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--v3-font-0_75rem);
    background: var(--v3-primary-light);
}

.v3-table th,
.v3-table td {
    border: 1px solid var(--v3-primary-base);
    padding: var(--v3-offset-normal) var(--v3-offset-max);
    vertical-align: middle;
}

.v3-table th {
    background: var(--v3-primary-bg);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.v3-table.v3-sticky-header th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--v3-primary-bg);
    box-shadow: inset 0 1px 0 var(--v3-primary-base);
}

.v3-table .v3-text-right { text-align: right; }
.v3-table .v3-text-center { text-align: center; }

/* ========== ДИАЛОГИ ========== */
.v3-dialog {
    border: none;
    padding: 0;
    background: transparent;
    width: auto;
    max-width: 90%;
    margin: auto;
    position: fixed;
    inset: 0;
}

.v3-dialog .v3-dialog-content {
    background: var(--v3-primary-light);
    border-radius: var(--v3-radius);
    padding: var(--v3-offset-max);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: var(--v3-shadow);
    animation: v3-dialog-in 0.2s ease;
    font-size: var(--v3-font-0_9rem);
    overscroll-behavior: contain;
}

.v3-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: v3-backdrop-in 0.2s ease;
}

.v3-dialog .v3-dialog-content h3 {
    margin: 0 0 var(--v3-offset-max) 0;
    font-size: var(--v3-font-0_85rem);
    font-weight: 600;
    color: var(--v3-primary-base);
    text-align: left;
}

.v3-dialog .v3-dialog-content input,
.v3-dialog .v3-dialog-content select {
    width: 100%;
    margin-bottom: var(--v3-offset-max);
}

.v3-dialog .v3-dialog-footer {
    display: flex;
    justify-content: center;
    gap: var(--v3-offset-normal);
    margin-top: var(--v3-offset-max);
}
.v3-dialog .v3-dialog-footer .v3-btn {
    width: auto;
    min-width: 100px;
    flex: 1;
    justify-content: center;
    font-size: var(--v3-font-0_9rem);
}

@keyframes v3-dialog-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes v3-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========== TOAST-УВЕДОМЛЕНИЯ ========== */
.v3-toast-area {
    position: fixed;
    top: var(--v3-offset-max);
    left: 50%;
    transform: translateX(-50%);
    z-index: 30000;
    display: flex;
    flex-direction: column;
    gap: var(--v3-offset-normal);
    pointer-events: none;
    width: max-content;
    max-width: 90vw;
}

.v3-toast {
    display: flex;
    align-items: center;
    gap: var(--v3-offset-normal);
    padding: var(--v3-offset-max) var(--v3-offset-max);
    border-radius: var(--v3-radius);
    border: 1px solid var(--v3-primary-base);
    font-size: var(--v3-font-0_9rem);
    font-weight: 500;
    min-width: 380px;
    max-width: 560px;
    box-shadow: var(--v3-shadow);
    pointer-events: auto;
    animation: v3-toast-in 0.3s ease forwards;
}
.v3-toast.v3-removing {
    animation: v3-toast-out 0.3s ease forwards;
}

.v3-toast-success {
    background: var(--v3-success-bg);
    border-color: var(--v3-success-base);
    color: var(--v3-success-base);
}
.v3-toast-error {
    background: var(--v3-error-bg);
    border-color: var(--v3-error-base);
    color: var(--v3-error-base);
}
.v3-toast-info {
    background: var(--v3-primary-light);
    border-color: var(--v3-primary-base);
    color: var(--v3-primary-base);
}

@keyframes v3-toast-in {
    from { opacity: 0; transform: translateY(-100%); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes v3-toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-100%); }
}

/* ========== ГЛОБАЛЬНЫЙ ЛОАДЕР (V3) ========== */
.v3-global-loader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.v3-global-loader-inner {
    background: var(--v3-primary-light);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.v3-loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--v3-primary-base);
    border-top-color: var(--v3-primary-base);
    border-radius: 50%;
    animation: v3-spin 1s linear infinite;
    margin-bottom: 4px;
}

.v3-loader-text {
    color: var(--v3-primary-base);
    font-size: 0.95rem;
    font-weight: 500;
}



@keyframes v3-spin {
    to { transform: rotate(360deg); }
}
@keyframes v3-fade-in {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* ========== ПУСТЫЕ СОСТОЯНИЯ ========== */
.v3-empty {
    text-align: center;
    padding: var(--v3-offset-max);
    color: var(--v3-text-secondary);
    font-size: var(--v3-font-0_9rem);
}

/* ========== БЭЙДЖИ ========== */
.v3-badge {
    padding: var(--v3-offset-little) var(--v3-offset-max);
    border-radius: var(--v3-offset-little);
    font-size: var(--v3-font-0_8rem);
    white-space: nowrap;
}
.v3-badge-primary {
    background: var(--v3-primary-base);
    color: var(--v3-white);
}
.v3-badge-success {
    background: var(--v3-success-base);
    color: var(--v3-white);
}
.v3-badge-info {
    background: var(--v3-info-base);
    color: var(--v3-white);
}
.v3-badge-error {
    background: var(--v3-error-base);
    color: var(--v3-white);
}

/* ========== FLEX ========== */
.v3-flex-row {
    display: flex;
    flex-direction: row;
    gap: var(--v3-offset-max);
}
.v3-flex-col {
    display: flex;
    flex-direction: column;
    gap: var(--v3-offset-max);
}
.v3-flex-wrap {
    flex-wrap: wrap;
}
.v3-flex-fill {
    flex: 1;
    min-width: 0;
    min-height: 0;
}
.v3-flex-center {
    align-items: center;
    justify-content: center;
}
.v3-flex-align-center {
    align-items: center;
}
.v3-flex-justify-center {
    justify-content: center;
}
.v3-flex-justify-between {
    justify-content: space-between;
}
.v3-push-right {
    margin-left: auto;
}

/* ========== GRID ========== */
.v3-grid {
    display: grid;
    gap: var(--v3-offset-max);
}
.v3-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.v3-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.v3-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.v3-grid-auto-fill { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.v3-grid-auto-fit { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.v3-grid-fill { height: 100%; min-height: 0; align-items: stretch; }

/* ========== ИКОНКИ ========== */
.v3-icon-16px { width: var(--v3-icon-16px); height: var(--v3-icon-16px); flex-shrink: 0; }
.v3-icon-18px { width: var(--v3-icon-18px); height: var(--v3-icon-18px); flex-shrink: 0; }
.v3-icon-20px { width: var(--v3-icon-20px); height: var(--v3-icon-20px); flex-shrink: 0; }
.v3-icon-24px { width: var(--v3-icon-24px); height: var(--v3-icon-24px); flex-shrink: 0; }
.v3-icon-28px { width: var(--v3-icon-28px); height: var(--v3-icon-28px); flex-shrink: 0; }
.v3-icon-32px { width: var(--v3-icon-32px); height: var(--v3-icon-32px); flex-shrink: 0; }
.v3-icon-40px { width: var(--v3-icon-40px); height: var(--v3-icon-40px); flex-shrink: 0; }
.v3-icon-48px { width: var(--v3-icon-48px); height: var(--v3-icon-48px); flex-shrink: 0; }
.v3-icon-64px { width: var(--v3-icon-64px); height: var(--v3-icon-64px); flex-shrink: 0; }

/* ========== УТИЛИТЫ ========== */
.v3-text-right { text-align: right; }
.v3-text-center { text-align: center; }
.v3-text-bold { font-weight: bold; }
.v3-text-small { font-size: var(--v3-font-0_9rem); }
.v3-text-muted { color: var(--v3-text-muted); }

.v3-text-status-verified {
    color: var(--v3-success-base);
    font-weight: bold;
}
.v3-text-status-unverified {
    color: var(--v3-error-base);
    font-weight: bold;
}

.v3-gap-6 { gap: calc(6px * var(--v3-scale)); }
.v3-gap-8 { gap: var(--v3-offset-normal); }
.v3-gap-20 { gap: calc(20px * var(--v3-scale)); }
.v3-margin-0 { margin: 0; }
.v3-margin-top-4 { margin-top: var(--v3-offset-little); }

.v3-place-center { display: grid; place-items: center; }
.v3-place-content-center { display: grid; place-content: center; }
.v3-text-wrap { overflow-wrap: anywhere; }
.v3-text-fluid {
    font-size: clamp(var(--v3-font-0_9rem), 4vw, var(--v3-font-1_1rem));
    line-height: 1.3;
}

/* ========== SCROLLBAR ========== */
.v3-scrollbar-thin { scrollbar-width: thin; }
.v3-scrollbar-gutter-stable { scrollbar-gutter: stable; }

/* ========== ПРОЗРАЧНОСТЬ ========== */
.v3-opacity-1 { opacity: 1; }
.v3-opacity-2 { opacity: 0.7; }
.v3-opacity-3 { opacity: 0.5; }

/* ========== HOVER-ЭФФЕКТЫ ========== */
@media (hover: hover) {
    .v3-btn:hover:not(:disabled) {
        transform: translateY(-1px);
    }
    .v3-card:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    .v3-field-clickable:hover:not(.v3-disabled) {
        transform: translateX(var(--v3-offset-mini));
    }
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 1024px) {
    .v3-left-panel,
    .v3-center-panel {
        width: 25vw;
    }
    .v3-log-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    .v3-left-panel,
    .v3-center-panel {
        width: 25vw;
    }
}

/* ========== ЗАПРЕТ ВЫДЕЛЕНИЯ ИКОНОК ========== */
.v3-btn img,
.v3-btn:disabled img {
    user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

.v3-info-text {
    flex: 1;
    color: #ffffff;

    font-size: clamp(var(--v3-font-0_7rem), 1,5vw, var(--v3-font-0_9rem));
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    text-align: center;
    line-height: 1.2;
    padding: 0 var(--v3-offset-normal);
}

/* ========== ASPECT-RATIO ДЛЯ КАРТОЧЕК ========== */
.v3-card-icon {
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

/* ========== КОМПАКТНЫЕ КНОПКИ В ШАПКЕ ========== */
.v3-header-btn {
    min-height: 40px !important;
    height: 40px !important;
    padding: 4px 4px !important;
    border-radius: 6px;
    font-size: 0.9rem !important;
    width: auto !important;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-width: 1px;
}

.v3-header-btn img {
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0;
}

/* Кнопки без текста — квадратные */
.v3-header-btn:not(:has(span)) {
    min-width: 32px !important;
    width: 40px !important;
    padding: 4px !important;
}

/* Кнопки с текстом */
.v3-header-btn:has(span) {
    gap: 4px;
    padding: 2px 10px !important;
    min-width: auto !important;
}

.v3-header-btn:has(span) img {
    width: 32px !important;
    height: 32px !important;
}

.v3-header-btn:has(span) span {
    font-size: var(--v3-font-0_9rem);
    line-height: 1;
}

/* ========== СВЕРТЫВАНИЕ ЛЕВОЙ ПАНЕЛИ ========== */
.v3-left-panel.v3-collapsed,
.v3-left-panel.collapsed {
    width: 70px !important;
    min-width: 70px !important;
    max-width: 70px !important;
    overflow: hidden;
}

.v3-left-panel.v3-collapsed .v3-btn,
.v3-left-panel.collapsed .v3-btn {
    place-content: center;
    padding: var(--v3-offset-little);
    gap: 0;
}

.v3-left-panel.v3-collapsed .v3-btn span,
.v3-left-panel.collapsed .v3-btn span {
    display: none;
}

.v3-left-panel.v3-collapsed .v3-btn img,
.v3-left-panel.collapsed .v3-btn img {
    margin: 0;
    flex-shrink: 0;
}

/* ========== МОБИЛЬНОЕ МЕНЮ ========== */
@media (max-width: 768px) {
    .v3-left-panel.v3-visible-mobile,
    .v3-left-panel.visible-mobile {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 280px !important;
        height: 100% !important;
        z-index: 1000 !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
        display: flex !important;
    }

    .v3-left-panel:not(.v3-visible-mobile):not(.visible-mobile) {
        display: none !important;
    }
}

/* ========== КНОПКА С ПЕРЕНОСОМ ТЕКСТА ========== */
.v3-btn-text-wrap {
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    text-wrap: wrap !important;
    min-height: var(--v3-btn-min-height);
    max-height: var(--v3-btn-min-height);
    height: var(--v3-btn-min-height);
    /* Сначала уменьшаем шрифт до очень маленького, потом уже перенос */
    font-size: clamp(var(--v3-font-0_7rem), 1.5vw, var(--v3-font-0_9rem));
    padding: calc(4px * var(--v3-scale)) var(--v3-btn-padding);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    justify-content: flex-start !important;
}

.v3-btn-text-wrap span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    min-width: 0;
    text-align: left;
}

/* =====================================================
   ТУТОРИАЛ (V3 — с масштабированием)
   ===================================================== */

.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 50000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--v3-offset-max);
}

.tutorial-container {
    max-width: 95%;
    max-height: 95%;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--v3-info-light);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.tutorial-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.tutorial-nav {
    width: calc(220px * var(--v3-scale));
    min-width: calc(180px * var(--v3-scale));
    max-width: calc(280px * var(--v3-scale));
    flex-shrink: 0;
    background: var(--v3-info-bg);
    border-right: 1px solid var(--v3-info-base);
    overflow-y: auto;
    padding: var(--v3-offset-normal);
}

.tutorial-chapter {
    padding: calc(10px * var(--v3-scale)) calc(16px * var(--v3-scale));
    cursor: pointer;
    border-radius: 6px;
    color: var(--v3-info-base);
    font-size: var(--v3-font-0_9rem);
    margin: calc(2px * var(--v3-scale)) calc(8px * var(--v3-scale));
    transition: background 0.2s;
}

.tutorial-chapter:hover {
    background: var(--v3-info-light);
}

.tutorial-chapter.active {
    background: var(--v3-info-hover);
    color: var(--v3-white);
}

.tutorial-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--v3-offset-max);
    line-height: 1.8;
    scroll-behavior: smooth;
}

.tutorial-section {
    padding: calc(6px * var(--v3-scale)) calc(16px * var(--v3-scale)) calc(6px * var(--v3-scale)) calc(32px * var(--v3-scale));
    cursor: pointer;
    border-radius: 6px;
    color: var(--v3-info-hover);
    font-size: var(--v3-font-0_85rem);
    margin: calc(1px * var(--v3-scale)) calc(8px * var(--v3-scale)) calc(1px * var(--v3-scale)) calc(4px * var(--v3-scale));
    transition: background 0.2s;
}

.tutorial-chapter.active + .tutorial-section,
.tutorial-section:has(~ .tutorial-chapter.active) {
    display: block;
}

.tutorial-section:hover {
    background: var(--v3-info-light);
}

.tutorial-section.active {
    background: var(--v3-info-light);
    color: var(--v3-info-base);
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); background: var(--v3-success-hover); }
}

/* ========== АДАПТАЦИЯ ДЛЯ МОБИЛЬНЫХ ========== */
@media (max-width: 768px) {
    .tutorial-overlay {
        padding: calc(10px * var(--v3-scale));
    }
    .tutorial-nav {
        width: calc(140px * var(--v3-scale));
        min-width: calc(120px * var(--v3-scale));
        max-width: calc(160px * var(--v3-scale));
    }
    .tutorial-chapter {
        font-size: var(--v3-font-0_8rem);
        padding: calc(6px * var(--v3-scale)) calc(12px * var(--v3-scale));
        margin: calc(2px * var(--v3-scale)) calc(4px * var(--v3-scale));
    }
    .tutorial-section {
        font-size: var(--v3-font-0_75rem);
        padding: calc(4px * var(--v3-scale)) calc(12px * var(--v3-scale)) calc(4px * var(--v3-scale)) calc(24px * var(--v3-scale));
    }
}