:root {
    --color-primary: #1f5eff;
    --color-primary-hover: #1848c9;

    --color-success: #1b7f3a;
    --color-warning: #9a6500;
    --color-danger: #b00020;

    --color-text: #222222;
    --color-text-secondary: #334155;
    --color-text-muted: #64748b;

    --color-background: #f6f7f9;
    --color-surface: #ffffff;
    --color-surface-hover: #eef2ff;
    --color-border: #dfe4ea;
    --color-border-light: #eef1f4;

    --shadow-default: 0 1px 4px rgba(0, 0, 0, 0.08);
    --shadow-small: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-overlay: 0 5px 25px rgba(0, 0, 0, 0.20);

    --radius-small: 6px;
    --radius-medium: 10px;
    --radius-large: 12px;
}


/* =====================================================
   Base
   ===================================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 24px;
    background: var(--color-background);
    color: var(--color-text);
    font-family: Arial, sans-serif;
}

h1 {
    margin-bottom: 18px;
}

a {
    color: var(--color-primary);
}

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    padding: 8px 10px;
    border: 1px solid #cccccc;
    border-radius: var(--radius-small);
    background: var(--color-surface);
    color: var(--color-text);
}


/* =====================================================
   Application Layout
   ===================================================== */

.app-shell {
    max-width: 1400px;
    margin: 0 auto;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 16px;
    padding: 18px 24px;

    border-radius: var(--radius-large);
    background: #101827;
    color: #ffffff;
}

.app-title {
    font-size: 22px;
    font-weight: 700;
}

.app-subtitle {
    margin-top: 4px;
    color: #cbd5e1;
    font-size: 13px;
}

.app-status {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--color-primary);
    font-size: 12px;
    font-weight: 600;
}

.app-body {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.app-sidebar {
    width: 250px;
    flex-shrink: 0;
    padding: 8px 0;
}

.app-content {
    min-width: 0;
    flex: 1;
}
.app-status a {
    color: inherit;
    text-decoration: none;
}

.app-status a:hover {
    text-decoration: underline;
}

/* =====================================================
   Page Structure
   ===================================================== */

.page-container {
    margin-top: 16px;
}

.page-header {
    margin-bottom: 16px;
    padding: 20px 24px;

    border-radius: var(--radius-large);
    background: var(--color-surface);
    box-shadow: var(--shadow-default);
}

.page-title {
    margin-bottom: 6px;
    font-size: 26px;
    font-weight: 700;
}

.page-description {
    color: var(--color-text-muted);
    font-size: 14px;
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.section {
    margin-bottom: 16px;
    padding: 18px 20px;

    border-radius: var(--radius-large);
    background: var(--color-surface);
    box-shadow: var(--shadow-default);
}

.section-title {
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 700;
}

.result-divider {
    margin: 20px 0;
}


/* =====================================================
   Action Bars
   ===================================================== */

.action-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;

    margin-bottom: 16px;
    padding: 14px 18px;

    border-radius: var(--radius-large);
    background: var(--color-surface);
    box-shadow: var(--shadow-default);
}

.action-bar-primary,
.action-bar-secondary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.action-bar-secondary {
    margin-left: auto;
}

.action-bar form {
    display: inline-flex;
    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.form-actions {
    margin-top: 16px;
}


/* =====================================================
   Buttons
   ===================================================== */

button,
.action-link,
.table-actions .table-action-button {
    min-width: 0;
    min-height: 30px;
    padding: 6px 9px;
    font-size: 13px;
}

button:hover,
.action-link:hover,
.table-action:hover,
.table-action-button:hover {
    border-color: var(--color-primary-hover);
    background: var(--color-primary-hover);
    color: #ffffff;
    text-decoration: none;
}

.button-secondary,
.table-action,
.table-action-button {
    background: var(--color-surface);
    color: var(--color-primary);
}

.button-secondary:hover,
.table-action:hover,
.table-action-button:hover {
    background: var(--color-primary);
    color: #ffffff;
}

.button-danger {
    border-color: var(--color-danger);
    background: var(--color-danger);
    color: #ffffff;
}

.button-danger:hover {
    border-color: #8f001a;
    background: #8f001a;
}
.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.table-actions .table-action-form {
    margin: 0;
}
.table-action,
.table-action-button {
    min-width: 72px;
    padding: 6px 12px;
}

.table-action-form {
    display: inline-flex;
    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.table-action + .table-action,
.table-action + .table-action-form,
.table-action-form + .table-action,
.table-action-form + .table-action-form {
    margin-left: 8px;
}

.table-action-muted {
    color: var(--color-text-muted);
    font-size: 14px;
}


/* =====================================================
   Forms
   ===================================================== */

.standard-form {
    margin: 0;
    padding: 0;

    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.form-field {
    margin-bottom: 18px;
}

.form-field:last-child {
    margin-bottom: 0;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.form-field input:not([type="checkbox"]),
.form-field select,
.form-field textarea {
    width: 100%;
    margin: 0;
}

.form-field textarea {
    min-height: 100px;
    resize: vertical;
}

.form-field input[type="checkbox"] {
    width: auto;
    margin: 0 8px 0 0;
    padding: 0;
}

.form-field .errorlist {
    margin: 6px 0 0;
    padding-left: 20px;
    color: var(--color-danger);
}

.required-marker {
    color: var(--color-danger);
}

#id_notes {
    min-height: 120px;
    height: 120px;
    resize: vertical;
}

.standard-form .form-field textarea[name="source_folder"],
.standard-form .form-field textarea[name="destination_folder"] {
    min-height: 48px;
    height: 48px;
    resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 3px solid rgba(31, 94, 255, 0.16);
    border-color: var(--color-primary);
}

.form-field input:disabled,
.form-field select:disabled,
.form-field textarea:disabled {
    background: #eef1f4;
    color: #8a94a3;
    cursor: not-allowed;
}

.form-field input[readonly],
.form-field textarea[readonly] {
    background: #f3f4f6;
    color: var(--color-text-secondary);
}

.form-field input::placeholder,
.form-field textarea::placeholder {
    color: #9aa3af;
}

.form-field input[type="checkbox"]:focus-visible {
    outline: 3px solid rgba(31, 94, 255, 0.16);
    outline-offset: 2px;
}
/* =====================================================
   Tables
   ===================================================== */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

table,
.data-table,
.validation-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
}

table,
.data-table {
    box-shadow: var(--shadow-default);
}

.table-section table,
.table-section .data-table {
    box-shadow: none;
}

th {
    padding: 10px;
    background: #263238;
    color: #ffffff;
    text-align: left;
}

td {
    padding: 9px 10px;
    border-bottom: 1px solid #eeeeee;
}

tbody tr:hover {
    background: #f1f5ff;
}

.table-actions-column {
    width: 180px;
    white-space: nowrap;
}

.table-cell-truncate {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}


/* =====================================================
   Validation Tables
   ===================================================== */

.validation-table {
    margin-top: 16px;
}

.validation-table th,
.validation-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #dddddd;
    text-align: left;
}

.validation-table th {
    background: #eef2f7;
    color: var(--color-text);
    font-weight: 600;
}


/* =====================================================
   Status Badges
   ===================================================== */

.status-badge {
    display: inline-block;
    padding: 5px 9px;

    border-radius: 999px;

    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.ok,
.status-badge.completed,
.status-badge.success,
.status-badge.parsed,
.status-badge.active {
    background: #e7f6ec;
    color: var(--color-success);
}

.status-badge.pending,
.status-badge.running,
.status-badge.processing,
.status-badge.ready_to_close,
.status-badge.ready_for_review {
    background: #fff4d6;
    color: var(--color-warning);
}

.status-badge.failed,
.status-badge.error,
.status-badge.has_issues,
.status-badge.inactive {
    background: #fde7e9;
    color: var(--color-danger);
}

.status-badge.info,
.status-badge.new {
    background: #e8efff;
    color: var(--color-primary);
}

.status-ok {
    color: #2e7d32;
}

.status-has_issues {
    color: #c62828;
}


/* =====================================================
   Messages
   ===================================================== */

.messages {
    margin-bottom: 20px;
}

.message {
    margin-bottom: 10px;
    padding: 12px 16px;

    border-radius: 8px;

    font-weight: 500;
}

.message.success {
    border: 1px solid #b8dfc2;
    background: #eaf8ed;
    color: #1e6b30;
}

.message.error {
    border: 1px solid #efb5b5;
    background: #fdeaea;
    color: #a12626;
}

.message.warning {
    border: 1px solid #f0d48a;
    background: #fff8e5;
    color: #8b6200;
}

.message.info {
    border: 1px solid #b8d3f5;
    background: #e8f2ff;
    color: #205ea8;
}


/* =====================================================
   Empty State
   ===================================================== */

.empty-state {
    padding: 24px;

    border-radius: var(--radius-large);
    background: var(--color-surface);
    color: var(--color-text-muted);
    box-shadow: var(--shadow-default);

    text-align: center;
}

.table-section .empty-state {
    box-shadow: none;
}

.empty-state-title {
    margin-bottom: 8px;
    color: var(--color-text);
    font-size: 18px;
    font-weight: 700;
}

.empty-state-description {
    margin-bottom: 16px;
}


/* =====================================================
   Sidebar
   ===================================================== */

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    margin-top: 16px;
}

.sidebar-section-title {
    padding: 8px 16px;

    color: #8b8b8b;

    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar-item {
    display: flex;
    align-items: center;

    min-height: 40px;
    padding: 0 16px;

    border-radius: 8px;

    color: #1f2937;
    text-decoration: none;
}

.sidebar-item:hover,
.sidebar-item:focus-visible {
    background: var(--color-surface-hover);
    color: #1f2937;
    text-decoration: none;
}

.sidebar-placeholder {
    color: var(--color-text-muted);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}


/* =====================================================
   Dashboard
   ===================================================== */

.dashboard-header {
    margin-bottom: 24px;
}

.dashboard-title {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
}

.dashboard-section {
    margin-bottom: 24px;
}

.dashboard-section-title {
    margin-bottom: 10px;

    color: var(--color-text-muted);

    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.dashboard-grid-single {
    grid-template-columns: 1fr;
}

.dashboard-card {
    display: block;

    min-height: 88px;
    padding: 16px 18px;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);

    background: var(--color-surface);
    color: #1f2937;
    box-shadow: var(--shadow-small);

    text-decoration: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.dashboard-card:hover,
.dashboard-card:focus-visible {
    border-color: #8daafa;
    box-shadow: 0 4px 12px rgba(31, 94, 255, 0.10);
    color: #1f2937;
    text-decoration: none;
    transform: translateY(-1px);
}

.dashboard-card:focus-visible {
    outline: 3px solid rgba(31, 94, 255, 0.20);
    outline-offset: 2px;
}

.dashboard-card-title {
    margin-bottom: 5px;
    font-size: 17px;
    font-weight: 700;
}

.dashboard-card-description {
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.4;
}


/* =====================================================
   Summary Cards
   ===================================================== */

.summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
}

.summary-card {
    min-width: 170px;
    padding: 16px;

    border: 1px solid #dddddd;
    border-radius: 8px;

    background: var(--color-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.summary-label {
    margin-bottom: 8px;
    color: var(--color-text-muted);
    font-size: 12px;
    text-transform: uppercase;
}

.summary-value {
    font-size: 22px;
    font-weight: 600;
}


/* =====================================================
   Processing Workspace
   ===================================================== */

.workspace-header-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.workspace-folders {
    padding-top: 14px;
    padding-bottom: 14px;
}

.workspace-folder-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 14px;

    padding: 8px 0;

    border-bottom: 1px solid var(--color-border-light);
}

.workspace-folder-row:last-child {
    border-bottom: none;
}

.workspace-folder-label {
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 700;
}

.workspace-folder-value {
    overflow: hidden;

    color: var(--color-text-secondary);
    font-size: 13px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-summary {
    display: grid;
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    gap: 10px;
    margin: 0;
}

.workspace-summary .summary-card {
    min-width: 0;
    padding: 13px 14px;
}

.workspace-summary .summary-value {
    font-size: 20px;
}

.workspace-files-table th:first-child,
.workspace-files-table td:first-child {
    width: 42px;
    text-align: center;
}

.workspace-files-table th:nth-child(2),
.workspace-files-table td:nth-child(2) {
    width: 220px;
}

.workspace-files-table th:nth-child(3),
.workspace-files-table td:nth-child(3) {
    width: 180px;
}

.workspace-files-table th:nth-child(4),
.workspace-files-table td:nth-child(4) {
    width: 190px;
}

.workspace-files-table th:last-child,
.workspace-files-table td:last-child {
    width: 320px;
    white-space: normal;
}


/* =====================================================
   Technical Panels
   ===================================================== */

.technical-panel {
    margin-top: 16px;
}

.technical-panel details {
    margin-bottom: 10px;
    padding: 12px 14px;

    border-radius: var(--radius-medium);

    background: var(--color-surface);
    box-shadow: var(--shadow-default);
}

.technical-panel summary {
    cursor: pointer;
    font-weight: 700;
}

.technical-panel pre {
    margin-top: 10px;
    padding: 12px;

    border-radius: 8px;

    background: #f5f5f5;

    white-space: pre-wrap;
}


/* =====================================================
   Validation Indicators
   ===================================================== */

.severity-dot {
    display: inline-block;

    width: 12px;
    height: 12px;
    margin-right: 8px;

    border-radius: 50%;
}

.severity-high {
    background: #d93025;
}

.severity-medium {
    background: #fbbc04;
}

.severity-low {
    background: #34a853;
}

.risk-HIGH {
    color: var(--color-danger);
    font-weight: 700;
}

.risk-MEDIUM {
    color: #b36b00;
    font-weight: 700;
}

.risk-OK {
    color: var(--color-success);
    font-weight: 700;
}

.risk-OVERSTOCK,
.risk-NO-SALES {
    color: #555555;
    font-weight: 700;
}


/* =====================================================
   Breadcrumb
   ===================================================== */

.breadcrumb {
    margin-bottom: 12px;
    padding: 10px 14px;

    border-radius: 8px;

    background: var(--color-surface);
}


/* =====================================================
   Loading Overlay
   ===================================================== */

.loading-overlay {
    display: none;
    position: fixed;
    z-index: 9999;

    inset: 0;

    align-items: center;
    justify-content: center;

    background: rgba(255, 255, 255, 0.75);
}

.loading-box {
    padding: 30px;

    border-radius: var(--radius-large);

    background: var(--color-surface);
    box-shadow: var(--shadow-overlay);

    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: auto;

    border: 4px solid #dddddd;
    border-top-color: var(--color-primary);
    border-radius: 50%;

    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}
/* =====================================================
   Generic Modal
   ===================================================== */

.app-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    inset: 0;

    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.35);
}

.app-modal.open {
    display: flex;
}

.app-modal-dialog {
    width: min(1000px, 90vw);
    max-height: 90vh;

    display: flex;
    flex-direction: column;

    border-radius: var(--radius-large);

    background: var(--color-surface);
    box-shadow: var(--shadow-overlay);

    overflow: hidden;
}

.app-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 16px 20px;

    border-bottom: 1px solid var(--color-border);
}

.app-modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.app-modal-close {
    min-width: 36px;
    min-height: 36px;
    padding: 0;

    border: none;
    background: transparent;

    color: var(--color-text-muted);
    font-size: 24px;
    cursor: pointer;
}

.app-modal-close:hover {
    background: var(--color-border-light);
    color: var(--color-text);
}

.app-modal-body {
    padding: 20px;
    overflow: auto;
}
.xml-preview {

    margin: 0;
    padding: 16px;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);

    background: #f8fafc;

    font-family:
        Consolas,
        "Courier New",
        monospace;

    font-size: 13px;
    line-height: 1.45;

    overflow: auto;
    white-space: pre;
    max-height: 65vh;

}
.json-preview {

    margin: 0;
    padding: 16px;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);

    background: #f8fafc;

    font-family:
        Consolas,
        "Courier New",
        monospace;

    font-size: 13px;
    line-height: 1.45;

    overflow: auto;
    white-space: pre;
    max-height: 65vh;

}
.result-file-name {

    margin-bottom: 10px;

    color: var(--color-text-secondary);

    font-size: 14px;
    font-weight: 600;

}
/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 1200px) {
    .workspace-summary {
        grid-template-columns: repeat(4, minmax(120px, 1fr));
    }
}

@media (max-width: 900px) {
    body {
        margin: 12px;
    }

    .app-body {
        display: block;
    }

    .app-sidebar {
        width: 100%;
        margin-bottom: 16px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .workspace-summary {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .action-bar-secondary {
        margin-left: 0;
    }
}
