:root {
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d9e0ea;
    --line-strong: #c6d1de;
    --accent: #0f5aa8;
    --accent-soft: #e8f1fb;
    --success: #0f766e;
    --danger: #b42318;
    --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.06);
    --space-1: 6px;
    --space-2: 10px;
    --space-3: 14px;
    --space-4: 18px;
    --space-5: 24px;
    --space-6: 32px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar,
.footer {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 12px 20px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow-soft);
}

.brand {
    font-weight: 700;
    letter-spacing: 0.01em;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    font-size: 14px;
}

.top-actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-alt);
    color: var(--text);
    padding: 0 8px;
    text-decoration: none;
}

.top-actions a:hover {
    border-color: var(--line-strong);
    text-decoration: none;
}

.lang-label {
    color: var(--muted);
}

.footer {
    border-top: 1px solid var(--line);
    border-bottom: none;
    margin-top: auto;
    color: var(--muted);
    font-size: 13px;
}

.app-body {
    display: flex;
    min-height: calc(100vh - 118px);
}

.sidebar {
    width: 290px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: var(--space-4) var(--space-3);
    overflow-y: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    width: 100%;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: var(--space-2);
    background: var(--surface-alt);
}

.sidebar-group.is-active {
    border-color: #b5cae3;
    background: #f2f7fd;
}

.sidebar-group-title {
    display: block;
    margin: 0 0 var(--space-2);
    padding: 0 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
}

.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-item {
    display: block;
    margin: 0;
    padding: 0;
}

.sidebar-nav .sidebar-link,
.sidebar-nav .sidebar-sublink {
    display: block;
    width: 100%;
    float: none;
    clear: both;
    border-radius: 8px;
    color: var(--text);
    padding: 8px 10px;
    margin-bottom: 3px;
    text-decoration: none;
}

.sidebar-link:hover,
.sidebar-sublink:hover {
    background: #eef3f9;
    text-decoration: none;
}

.sidebar-sublink {
    padding-left: 18px;
    color: #384457;
    font-size: 14px;
}

.sidebar-link.is-active,
.sidebar-sublink.is-active {
    background: var(--accent-soft);
    color: #0b3f75;
    font-weight: 600;
}

.content-area {
    flex: 1;
    padding: var(--space-5);
}

.content-wrap {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
}

.layout-operations .content-wrap {
    max-width: none;
}

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: var(--space-3);
}

.page-breadcrumb a {
    color: var(--muted);
}

.page-breadcrumb .crumb-separator {
    color: #9aa5b5;
}

.page-stack {
    display: grid;
    gap: var(--space-4);
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: var(--space-5);
    box-shadow: var(--shadow-soft);
}

.page-card > h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.page-card > p:first-of-type {
    margin-top: 8px;
    margin-bottom: var(--space-4);
    color: var(--muted);
    max-width: 92ch;
}

.page-card h2 {
    margin: 0;
    font-size: 18px;
}

.page-card h3 {
    margin-top: var(--space-3);
    margin-bottom: var(--space-2);
    font-size: 16px;
}

.page-section {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-alt);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.page-section:last-child {
    margin-bottom: 0;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.section-note {
    margin: var(--space-2) 0 0;
    color: var(--muted);
    font-size: 14px;
}

.alert {
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 11px 12px;
    margin-bottom: 12px;
    font-size: 14px;
}

.alert.success {
    background: #ecfdf3;
    border-color: #b7e5c8;
    color: var(--success);
}

.alert.error {
    background: #fef3f2;
    border-color: #f3c3c0;
    color: var(--danger);
}

.form-grid {
    display: grid;
    gap: 8px;
}

input,
select,
textarea,
button {
    font: inherit;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: 2px solid rgba(15, 90, 168, 0.18);
    outline-offset: 0;
    border-color: #87acd3;
}

button {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
}

button:hover {
    background: #0d4f93;
    border-color: #0d4f93;
}

button[disabled] {
    cursor: not-allowed;
    opacity: 0.55;
}

.inline-form {
    display: inline;
}

.link-button {
    background: transparent;
    color: var(--accent);
    padding: 0;
    border: 0;
    border-radius: 0;
    text-decoration: underline;
    font-weight: 600;
}

.link-button:hover {
    background: transparent;
}

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.auth-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 16px;
}

.settings-toolbar,
.orders-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.settings-toolbar a,
.orders-toolbar a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    background: #fff;
    text-decoration: none;
}

.settings-toolbar a:hover,
.orders-toolbar a:hover {
    border-color: var(--line-strong);
    text-decoration: none;
}

.settings-toolbar input[type="search"] {
    margin-left: auto;
    max-width: 260px;
}

.settings-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1.6fr 1fr;
}

.settings-grid-table,
.settings-grid-form {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.settings-grid-form h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

.settings-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.settings-table th,
.settings-table td {
    border: 1px solid var(--line);
    padding: 8px;
    font-size: 14px;
    text-align: left;
    vertical-align: top;
}

.settings-table th {
    background: #f8fafc;
}

.settings-table td button {
    margin-right: 6px;
    margin-bottom: 4px;
    padding: 6px 9px;
    font-size: 12px;
}

.settings-form textarea,
.settings-form select,
.settings-form input {
    width: 100%;
}

.settings-form-actions {
    margin-top: 8px;
}

.settings-message {
    min-height: 20px;
    margin-bottom: 10px;
    font-size: 14px;
}

.settings-message.success,
.orders-sync-message.success {
    color: var(--success);
}

.settings-message.error,
.orders-sync-message.error {
    color: var(--danger);
}

.settings-form-general {
    max-width: 760px;
}

.orders-sync-form,
.orders-filter-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.orders-sync-form {
    margin-bottom: 12px;
}

.orders-sync-form button {
    align-self: end;
}

.orders-sync-message {
    min-height: 20px;
    font-size: 14px;
    grid-column: 1 / -1;
}

.orders-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 2px;
}

.order-summary-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
    padding: 12px;
}

.json-block {
    white-space: pre-wrap;
    word-break: break-word;
    background: #0b1220;
    color: #dbeafe;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid #1f304b;
}

@media (max-width: 1300px) {
    .content-area {
        padding: var(--space-4);
    }

    .sidebar {
        width: 260px;
    }
}

@media (max-width: 1100px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-toolbar {
        flex-wrap: wrap;
    }

    .settings-toolbar input[type="search"] {
        margin-left: 0;
        width: 100%;
        max-width: none;
    }

    .orders-sync-form,
    .orders-filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .order-summary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .app-body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--line);
        max-height: none;
    }
}

@media (max-width: 700px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .orders-sync-form,
    .orders-filter-grid {
        grid-template-columns: 1fr;
    }

    .content-area {
        padding: var(--space-3);
    }

    .card {
        padding: var(--space-4);
    }
}



/* UI Phase B - operational table readability polish */
.orders-toolbar {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
    padding: 8px 10px;
    margin-bottom: 12px;
}

.orders-toolbar button {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
    font-weight: 500;
}

.orders-toolbar button:hover {
    background: #f5f8fc;
    border-color: var(--line-strong);
}

.orders-toolbar button.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 600;
}

.orders-toolbar button.btn-primary:hover {
    background: #0d4f93;
    border-color: #0d4f93;
}

.selection-scope-note {
    margin: 0 0 12px;
    border: 1px dashed #c8d5e5;
    border-radius: 8px;
    background: #f4f8fd;
    padding: 8px 10px;
    color: #445169;
    font-size: 13px;
}

.selection-scope-note strong {
    color: #22324b;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.status-success {
    background: #ecfdf3;
    border-color: #b7e5c8;
    color: #0f766e;
}

.status-warning {
    background: #fffaeb;
    border-color: #f5deb1;
    color: #9a6700;
}

.status-danger {
    background: #fef3f2;
    border-color: #f3c3c0;
    color: #b42318;
}

.status-neutral,
.status-muted {
    background: #f3f4f6;
    border-color: #dde2ea;
    color: #5b6778;
}

.status-info {
    background: #eff6ff;
    border-color: #c9def8;
    color: #1e4f8f;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.table-actions a,
.table-actions button,
.table-actions span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
}

.table-actions a {
    border: 1px solid var(--line);
    background: #fff;
    color: #213048;
    text-decoration: none;
}

.table-actions a:hover {
    border-color: var(--line-strong);
    text-decoration: none;
}

.table-actions button {
    padding: 4px 8px;
    font-size: 12px;
}

.table-actions span {
    border: 1px solid #dde2ea;
    background: #f3f4f6;
    color: #5f6b7c;
}

.action-placeholder {
    color: #8c96a6;
    font-size: 12px;
}

.settings-table tbody tr:hover td {
    background: #fafcff;
}

.settings-table td.cell-actions,
.settings-table th.cell-actions {
    min-width: 180px;
}

.settings-table td.cell-select,
.settings-table th.cell-select {
    width: 46px;
    text-align: center;
    vertical-align: middle;
}

.settings-table td .js-order-select,
.settings-table td .js-product-select,
.settings-table th .js-order-select-all,
.settings-table th .js-product-select-all {
    margin: 0 auto;
    display: block;
}

.settings-table td.dataTables_empty,
.settings-table td.dt-empty,
.table-empty-cell {
    text-align: center;
    color: #697588;
    padding: 16px 10px;
    font-size: 13px;
}


/* UI Phase C - form and operator messaging clarity */
.workflow-note {
    margin: 0 0 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.35;
}

.workflow-note.info {
    background: #eef6ff;
    border-color: #c9def8;
    color: #234a7a;
}

.workflow-note.warning {
    background: #fff8e8;
    border-color: #f2d9a2;
    color: #8a5a00;
}

.workflow-note.muted {
    background: #f6f8fb;
    border-color: #dde5ef;
    color: #4f5d73;
}

.field-help {
    margin: 0;
    font-size: 12px;
    color: #5f6d82;
}

.orders-sync-form .workflow-note,
.orders-filter-grid .workflow-note,
.orders-sync-form .field-help,
.orders-filter-grid .field-help {
    grid-column: 1 / -1;
}

.settings-grid-form .workflow-note {
    margin-bottom: 0;
}

.form-action-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #d7e0ea;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.form-action-note {
    color: #51607a;
    font-size: 12px;
}

.form-action-footer button {
    margin-left: auto;
}

.settings-message,
.orders-sync-message {
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 9px 10px;
    margin-bottom: 10px;
    min-height: 0;
}

.settings-message:empty,
.orders-sync-message:empty {
    display: none;
}

.settings-message.success,
.orders-sync-message.success {
    background: #ecfdf3;
    border-color: #b7e5c8;
    color: var(--success);
}

.settings-message.error,
.orders-sync-message.error {
    background: #fef3f2;
    border-color: #f3c3c0;
    color: var(--danger);
}

.settings-message.info,
.orders-sync-message.info {
    background: #eef6ff;
    border-color: #c9def8;
    color: #234a7a;
}


/* UI Phase D - final consistency cleanup */
.page-card > h1 {
    font-size: 25px;
    font-weight: 700;
    letter-spacing: 0.01em;
    margin: 0 0 4px;
}

.page-card > p:first-of-type {
    margin-top: 6px;
    margin-bottom: 16px;
    color: #5c6980;
    line-height: 1.5;
    font-size: 14px;
}

.page-card h2 {
    font-size: 18px;
    font-weight: 650;
    line-height: 1.3;
    margin: 0 0 10px;
}

.page-card h3 {
    margin: 16px 0 10px;
    font-size: 15px;
    line-height: 1.35;
    color: #2f3b4d;
}

.section-heading h2 {
    margin: 0;
}

button.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
    font-weight: 500;
}

button.btn-secondary:hover {
    background: #f5f8fc;
    border-color: var(--line-strong);
}

button.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 600;
}

button.btn-primary:hover {
    background: #0d4f93;
    border-color: #0d4f93;
}

.settings-toolbar {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
    padding: 8px 10px;
    margin-bottom: 12px;
}

.settings-toolbar button {
    min-height: 34px;
}

.orders-toolbar a,
.settings-toolbar a {
    font-size: 13px;
    font-weight: 500;
}

.table-actions {
    gap: 7px;
}

.table-actions a,
.table-actions button,
.table-actions span {
    min-height: 28px;
    padding: 4px 9px;
}

.status-badge {
    min-height: 24px;
    padding: 3px 10px;
    font-size: 12px;
}

.order-summary-grid > div {
    background: #fff;
    border: 1px solid #e3e9f1;
    border-radius: 8px;
    padding: 8px 10px;
}

.orders-table-wrap {
    margin-top: 8px;
}

.top-actions .link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-alt);
    color: var(--text);
    padding: 0 8px;
    text-decoration: none;
    font-weight: 500;
}

.top-actions .link-button:hover {
    background: #f5f8fc;
    border-color: var(--line-strong);
    text-decoration: none;
}


/* Product batch edit correction */
.products-batch-edit-header {
    display: grid;
    gap: 8px;
    grid-template-columns: 180px 180px;
    align-items: center;
    margin-bottom: 12px;
}

.products-batch-edit-table input[type="number"] {
    min-width: 120px;
}

.products-batch-edit-form .settings-form-actions {
    margin-top: 14px;
}

/* Product sync ergonomics - collapsible sections */
.page-accordion {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 12px;
    overflow: hidden;
}

.page-accordion-summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    cursor: pointer;
    font-weight: 600;
}

.page-accordion-summary::-webkit-details-marker {
    display: none;
}

.page-accordion-summary h2 {
    margin: 0;
    font-size: 17px;
}

.page-accordion[open] > .page-accordion-summary {
    border-bottom: 1px solid var(--line);
}

.page-accordion-meta {
    color: var(--muted);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.page-accordion-body {
    padding: 12px;
}

.products-sync-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.products-sync-actions button {
    min-height: 34px;
}

