/* style.css - Минималистичный компактный стиль */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 13px;
    background: #f5f6f8;
    padding: 12px;
    color: #1e293b;
    line-height: 1.4;
}

.header {
    background: #fff;
    padding: 10px 16px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.header h1 {
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
}

.deal-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #475569;
}

.deal-info span {
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 4px;
}

.tabs {
    display: flex;
    gap: 4px;
    background: #fff;
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 12px;
}

.tabs button {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.15s;
}

.tabs button:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.tabs button.active {
    background: #0f172a;
    color: #fff;
}

.tab-content {
    background: #fff;
    padding: 14px 16px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-warning,
.btn-refresh,
.btn-delete,
.btn-create-deal,
.btn-delete-small {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: #0f172a;
    color: #fff;
}
.btn-primary:hover { background: #1e293b; }

.btn-secondary {
    background: #f1f5f9;
    color: #334155;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-success {
    background: #10b981;
    color: #fff;
}
.btn-success:hover { background: #059669; }

.btn-warning {
    background: #f59e0b;
    color: #fff;
}
.btn-warning:hover { background: #d97706; }

.btn-refresh {
    background: #f1f5f9;
    color: #334155;
}
.btn-refresh:hover { background: #e2e8f0; }

.btn-delete {
    background: #ef4444;
    color: #fff;
    padding: 3px 8px;
    font-size: 12px;
}
.btn-delete:hover { background: #dc2626; }

.btn-create-deal {
    background: #10b981;
    color: #fff;
    padding: 3px 10px;
    font-size: 12px;
}
.btn-create-deal:hover { background: #059669; }
.btn-create-deal.btn-disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.btn-delete-small {
    background: #ef4444;
    color: #fff;
    padding: 2px 6px;
    font-size: 11px;
}
.btn-delete-small:hover { background: #dc2626; }

.btn-large {
    padding: 8px 20px;
    font-size: 13px;
}

.toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* ===== ТАБЛИЦА ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: auto;
}

.data-table thead {
    background: #f8fafc;
}

.data-table th {
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: bottom;
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 5;
    min-width: 40px;
    max-width: 200px;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.3;
}

/* Числовые колонки */
.data-table th.number-column,
.data-table td.number-column {
    text-align: right;
    white-space: nowrap;
    min-width: 50px;
    padding: 6px 4px;
}

/* Колонка "Количество" */
.data-table th.quantity-column,
.data-table td.quantity-column {
    text-align: center;
    min-width: 40px;
    padding: 6px 4px;
}

/* Колонка "Действия" */
.data-table th.actions-column,
.data-table td.actions-column {
    text-align: center;
    min-width: 120px;
    padding: 6px 4px;
    white-space: nowrap;
}

/* Колонка "Дата" */
.data-table th.date-column,
.data-table td.date-column {
    text-align: center;
    min-width: 90px;
    white-space: nowrap;
}

.data-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    max-width: 200px;
}

.data-table tr:hover td {
    background: #fafbfc;
}

/* ===== ПОЛЯ ВВОДА ===== */
.editable-input,
.editable-select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 12px;
    background: transparent;
    transition: all 0.15s;
    font-family: inherit;
    color: #1e293b;
    min-height: 28px;
}

.editable-input:hover,
.editable-select:hover {
    background: #fff;
    border-color: #e2e8f0;
}

.editable-input:focus,
.editable-select:focus {
    outline: none;
    background: #fff;
    border-color: #0f172a;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

/* Числовые поля */
.editable-input[type="number"] {
    width: 100%;
    min-width: 40px;
    max-width: 100px;
    padding: 4px 4px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 12px;
    background: transparent;
    transition: all 0.15s;
    font-family: inherit;
    color: #1e293b;
    text-align: right;
}

/* Поля даты */
.editable-input[type="date"] {
    width: 100%;
    min-width: 80px;
    max-width: 120px;
    padding: 4px 4px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 12px;
    background: transparent;
    transition: all 0.15s;
    font-family: inherit;
    color: #1e293b;
    text-align: center;
}

/* Текстовая область */
.editable-textarea {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 12px;
    background: transparent;
    font-family: inherit;
    color: #1e293b;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    min-height: 28px;
    height: auto;
    resize: none;
    line-height: 1.4;
    transition: all 0.15s;
}

.editable-textarea:hover {
    background: #fff;
    border-color: #e2e8f0;
}

.editable-textarea:focus {
    outline: none;
    background: #fff;
    border-color: #0f172a;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.editable-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M0 0l4 6 4-6z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 18px;
}

.field-value {
    display: inline-block;
    padding: 2px 6px;
    background: #f1f5f9;
    border-radius: 3px;
    font-size: 12px;
}

.field-value.number-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    display: inline-block;
}

.field-value.quantity-value {
    text-align: center;
    min-width: 30px;
    display: inline-block;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.deal-link {
    color: #0f172a;
    text-decoration: none;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 3px;
    background: #f1f5f9;
    font-size: 11px;
    transition: all 0.15s;
}

.deal-link:hover {
    background: #e2e8f0;
}

.hint-text {
    font-size: 11px;
    color: #94a3b8;
}

.field-code-badge {
    font-size: 10px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 3px;
    font-family: monospace;
}

/* ===== НАСТРОЙКА КОЛОНОК ===== */
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.settings-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}

.columns-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.column-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 8px 12px;
    transition: all 0.15s;
}

.column-item.active {
    border-color: #0f172a;
    background: #fafbfc;
}

.column-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-label {
    flex: 1;
    font-weight: 500;
    font-size: 13px;
}

.column-actions {
    display: flex;
    gap: 2px;
}

.column-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
    transition: all 0.15s;
}

.column-actions button:hover {
    background: #e2e8f0;
}

.column-settings {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 3px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.15s;
    font-family: inherit;
    background: #fff;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #0f172a;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.option-item {
    display: flex;
    gap: 6px;
    align-items: center;
}

.option-item .form-input {
    flex: 1;
}

.template-save {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}

.template-form {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.template-form .form-input {
    max-width: 260px;
}

.templates-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.template-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.template-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.template-name {
    font-weight: 500;
    font-size: 13px;
}

.template-date {
    color: #94a3b8;
    font-size: 12px;
}

.template-actions {
    display: flex;
    gap: 4px;
}

.template-badge {
    background: #0f172a;
    color: #fff;
    padding: 1px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 30px 16px;
    color: #94a3b8;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 4px;
}

.empty-state .hint {
    font-size: 12px;
    color: #cbd5e1;
}

.loading-spinner {
    text-align: center;
    padding: 30px;
    font-size: 18px;
    color: #94a3b8;
}

.crm-select-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.loading-icon {
    font-size: 12px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.table-actions {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.status {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

@media (max-width: 768px) {
    body { padding: 8px; font-size: 12px; }
    
    .header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .header h1 { font-size: 15px; }
    
    .tabs { flex-wrap: wrap; }
    .tabs button { flex: 1; min-width: 80px; text-align: center; padding: 6px 10px; font-size: 12px; }
    
    .tab-content { padding: 10px 12px; }
    
    .data-table { font-size: 11px; }
    .data-table th,
    .data-table td { padding: 4px 6px; }
    
    .data-table th { font-size: 10px; }
    .data-table th.number-column,
    .data-table td.number-column { min-width: 35px; padding: 4px 3px; }
    .data-table th.quantity-column,
    .data-table td.quantity-column { min-width: 30px; padding: 4px 3px; }
    .data-table th.actions-column,
    .data-table td.actions-column { min-width: 80px; padding: 4px 3px; }
    
    .toolbar { gap: 4px; }
    .toolbar button { font-size: 11px; padding: 4px 10px; }
    
    .template-form { flex-direction: column; }
    .template-form .form-input { max-width: 100%; }
    
    .template-item { flex-direction: column; gap: 8px; align-items: flex-start; }
    .template-info { flex-wrap: wrap; gap: 6px; }
    
    .row-actions { gap: 3px; }
    .btn-create-deal { font-size: 11px; padding: 2px 8px; }
    .deal-link { font-size: 11px; padding: 2px 6px; }
}
.order-badge {
    font-size: 10px;
    color: #94a3b8;
    background: #e2e8f0;
    padding: 1px 8px;
    border-radius: 3px;
    font-family: monospace;
    margin-left: 4px;
}

/* Поле "Порядок" — компактное */
.form-group .form-input[type="number"] {
    max-width: 80px;
}

/* Заголовок колонки с кнопкой */
.th-content {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.th-label {
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-hide-doc {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 2px;
    font-size: 12px;
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.btn-hide-doc:hover {
    opacity: 1;
    transform: scale(1.1);
}

.data-table th:hover .btn-hide-doc {
    opacity: 1;
}

/* Индикатор скрытой колонки */
.data-table th.col-hidden-from-doc {
    opacity: 0.5;
    background: #f8fafc;
}

.data-table th.col-hidden-from-doc .th-label {
    text-decoration: line-through;
    color: #94a3b8;
}

/* В блоке .field-value.number-value уже есть, но добавим комментарий */
.field-value.number-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    display: inline-block;
}

/* Для полей с процентами */
.field-value.percent-value {
    text-align: center;
    min-width: 30px;
    display: inline-block;
}