/* --- Design Tokens --- */
:root {
    /* Palette: Slate (Neutral) */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* Palette: Blue (Primary) */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;

    /* Palette: Semantic */
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    /* Variables */
    --bg-app: var(--slate-50);
    --bg-card: #ffffff;
    --text-main: var(--slate-800);
    --text-muted: var(--slate-500);
    --border-light: var(--slate-200);
    --border-focus: var(--blue-500);

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* --- Reset & Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

button,
input,
select {
    font-family: inherit;
    font-size: inherit;
}

/* --- Layout --- */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 0 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding-top: 20px;
    padding-bottom: 40px;
    overflow-y: auto;
    /* Allow scrolling within main if needed */
}

/* --- Header --- */
.app-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-app);
    flex-shrink: 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    color: var(--blue-600);
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--slate-900);
    letter-spacing: -0.02em;
}

.version {
    font-size: 11px;
    background: var(--slate-200);
    color: var(--slate-600);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
    margin-left: 4px;
}

/* --- Admin Menu --- */
.admin-menu {
    position: relative;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--slate-500);
    padding: 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--slate-200);
    color: var(--slate-700);
}

.admin-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    width: 200px;
    z-index: 50;
    padding: 4px;
}

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: none;
    border: none;
    font-size: 13px;
    color: var(--slate-700);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.dropdown-item:hover {
    background: var(--slate-100);
}

.dropdown-item.danger {
    color: var(--error);
}

.dropdown-item.danger:hover {
    background: #fef2f2;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

/* --- Workflow Grid --- */
.workflow-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    height: 100%;
    align-items: start;
}

@media (max-width: 1024px) {
    .workflow-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--slate-50);
}

.card-header h2 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--slate-500);
    letter-spacing: 0.05em;
}

.card-body {
    padding: 20px;
}

/* --- File Upload --- */
.upload-grid {
    display: grid;
    gap: 16px;
}

.file-drop-zone {
    display: block;
    border: 1px dashed var(--slate-300);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--slate-50);
}

.file-drop-zone:hover {
    border-color: var(--blue-500);
    background: var(--blue-50);
}

.file-drop-zone.active {
    border-color: var(--blue-600);
    background: var(--blue-100);
}

.file-drop-zone.filled {
    border-style: solid;
    border-color: var(--success);
    background: #dcfce7;
    /* Brighter green (Green-100) */
}

.drop-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-box {
    color: var(--slate-400);
}

.file-drop-zone.filled .icon-box {
    color: var(--success);
}

.text-content {
    display: flex;
    flex-direction: column;
}

.file-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--slate-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* --- Data Grid (Sections) --- */
.config-card {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px);
    /* Fit in viewport */
}

.flex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.global-settings {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.compact-input {
    width: 70px;
    padding: 4px 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    text-align: right;
}

.data-grid-header {
    display: grid;
    grid-template-columns: 60px 2fr 1fr 1fr 1fr;
    padding: 10px 20px;
    background: var(--slate-100);
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-500);
    gap: 12px;
}

.data-grid-body {
    overflow-y: auto;
    flex: 1;
}

.data-grid-row {
    display: grid;
    grid-template-columns: 60px 2fr 1fr 1fr 1fr;
    padding: 12px 20px;
    border-bottom: 1px solid var(--slate-100);
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.data-grid-row:hover {
    background: var(--slate-50);
}

/* Columns */
.col-img img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid var(--slate-200);
    background: white;
}

.no-img {
    width: 40px;
    height: 40px;
    background: var(--slate-100);
    border-radius: 4px;
}

.col-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    background: var(--slate-200);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-700);
}

.table-input,
.table-select {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.table-input:focus,
.table-select:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 2px var(--blue-100);
}

/* --- Custom Number Input --- */
.number-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.number-input-wrapper .table-input {
    padding-right: 28px; /* Space for buttons */
}

.number-input-buttons {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    display: flex;
    flex-direction: column;
    width: 26px;
}

.number-input-buttons button {
    flex: 1;
    background: var(--slate-100);
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 10px;
    color: var(--slate-600);
    transition: background 0.2s;
    border-left: 1px solid var(--border-light);
}

.number-input-buttons button:hover {
    background: var(--slate-200);
}

.number-input-buttons button:first-child {
    border-bottom: 1px solid var(--border-light);
    border-radius: 0 3px 0 0;
}

.number-input-buttons button:last-child {
    border-radius: 0 0 3px 0;
}

/* Hide default number input arrows */
/* Hide default number input arrows */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
  appearance: none;
  -webkit-appearance: none;
}


/* --- Footer & Buttons --- */
.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-card);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--blue-600);
    color: white;
}

.btn-primary:hover {
    background: var(--blue-700);
}

.btn-secondary {
    background: var(--slate-100);
    color: var(--slate-700);
}

.btn-secondary:hover {
    background: var(--slate-200);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--slate-600);
}

.btn-outline:hover {
    border-color: var(--slate-400);
    color: var(--slate-800);
}

/* --- Status & Progress --- */
.status-bar-container {
    height: 4px;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
}

.progress-line {
    height: 100%;
    background: var(--blue-600);
    width: 0%;
    transition: width 0.3s ease;
}

.status-message {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 90;
    animation: slideDown 0.3s ease;
}

.status-message.success {
    background: var(--slate-800);
    color: var(--success);
}

.status-message.error {
    background: var(--error);
    color: white;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -20px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.hidden {
    display: none !important;
}

/* --- Results State --- */
.success-state {
    text-align: center;
    padding: 20px 0;
}

.success-icon {
    color: var(--success);
    margin-bottom: 10px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- Preview Card --- */
.preview-card {
    margin-top: 16px;
    border-color: var(--blue-200);
    background: var(--blue-50);
}

.preview-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.preview-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-600);
}

.preview-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--blue-700);
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-status {
    font-size: 12px;
    color: var(--slate-500);
}

.preview-status.loading {
    color: var(--blue-600);
    font-style: italic;
}

.preview-status.success {
    color: var(--success);
}

.preview-status.error {
    color: var(--error);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
    height: 28px;
}

#force-refresh-btn {
    background-color: var(--blue-600);
    color: white;
    border: 1px solid var(--blue-600);
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    gap: 6px; /* Отступ между иконкой и текстом */
    width: auto; /* Убираем фиксированную ширину */
}

#force-refresh-btn:hover {
    background-color: var(--blue-700);
    border-color: var(--blue-700);
}