:root {
    --blue: #2463eb;
    --blue-soft: #eef4ff;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6b7587;
    --border: #e4e9f1;
    --success: #137a4f;
    --success-bg: #eaf8f1;
    --warning: #a75d00;
    --warning-bg: #fff4df;
    --danger: #b42318;
    --danger-bg: #fff0ee;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 238px minmax(0, 1fr);
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    color: #d7e1f2;
    background: #101828;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    padding: 0 10px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: white;
    background: var(--blue);
    border-radius: 12px;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 3px;
    color: #8fa0b9;
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar nav a {
    padding: 12px 14px;
    color: #c3cee0;
    text-decoration: none;
    border-radius: 10px;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    color: white;
    background: #24324b;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 16px 10px 2px;
    color: #8492a8;
    font-size: 12px;
}

.main {
    min-width: 0;
    padding: 28px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.header h1 {
    margin: 0 0 6px;
    font-size: 25px;
}

.header p {
    margin: 0;
    color: var(--muted);
}

.user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: white;
    background: var(--blue);
    border-radius: 50%;
    font-weight: 700;
}

.error {
    margin-bottom: 18px;
    padding: 14px 16px;
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid #f4c7c3;
    border-radius: 12px;
}

.search-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.search-card input {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 11px;
    outline: none;
}

.search-card input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-soft);
}

.search-card button {
    padding: 0 20px;
    color: var(--blue);
    background: white;
    border: 1px solid var(--border);
    border-radius: 11px;
    font-weight: 700;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stats article {
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.stats span {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 14px;
}

.stats strong {
    font-size: 28px;
}

.orders-panel {
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    margin: 0 0 5px;
    font-size: 19px;
}

.panel-header p {
    margin: 0;
    color: var(--muted);
}

.readonly {
    padding: 6px 9px;
    color: #175cd3;
    background: var(--blue-soft);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px 16px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    background: #fafbfc;
    font-size: 12px;
    text-transform: uppercase;
}

td {
    font-size: 14px;
}

td small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.products {
    max-width: 310px;
    color: #475467;
    line-height: 1.45;
}

.status {
    display: inline-flex;
    padding: 6px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

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

.status-warning {
    color: var(--warning);
    background: var(--warning-bg);
}

.status-danger {
    color: var(--danger);
    background: var(--danger-bg);
}

.status-info {
    color: #175cd3;
    background: var(--blue-soft);
}

.view-btn {
    padding: 8px 12px;
    color: var(--muted);
    background: #f7f8fa;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.mobile-list {
    display: none;
}

@media (max-width: 1050px) {
    .layout {
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .sidebar {
        padding: 20px 10px;
    }

    .brand {
        justify-content: center;
        padding: 0;
    }

    .brand > div:last-child,
    .sidebar-bottom {
        display: none;
    }

    .sidebar nav a {
        padding: 12px 5px;
        font-size: 11px;
        text-align: center;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .layout {
        display: block;
    }

    .sidebar {
        position: fixed;
        z-index: 50;
        right: 0;
        bottom: 0;
        left: 0;
        height: 70px;
        display: block;
        padding: 8px;
    }

    .brand,
    .sidebar-bottom,
    .sidebar nav a:nth-child(n+6) {
        display: none;
    }

    .sidebar nav {
        height: 100%;
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
    }

    .sidebar nav a {
        display: grid;
        place-items: center;
        padding: 8px 3px;
        font-size: 10px;
    }

    .main {
        padding: 18px 14px 88px;
    }

    .header {
        align-items: flex-start;
    }

    .header h1 {
        font-size: 21px;
    }

    .header p,
    .user span:last-child {
        display: none;
    }

    .search-card {
        grid-template-columns: 1fr;
    }

    .search-card button {
        min-height: 44px;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stats article {
        padding: 16px;
    }

    .stats strong {
        font-size: 24px;
    }

    .table-wrap {
        display: none;
    }

    .mobile-list {
        display: grid;
        gap: 10px;
        padding: 12px;
    }

    .mobile-order {
        padding: 15px;
        border: 1px solid var(--border);
        border-radius: 14px;
    }

    .mobile-top,
    .mobile-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .mobile-order h3 {
        margin: 14px 0 5px;
        font-size: 16px;
    }

    .mobile-order p {
        margin: 0 0 14px;
        color: var(--muted);
    }

    .mobile-products {
        margin-bottom: 15px;
        color: #475467;
        font-size: 13px;
        line-height: 1.45;
    }

    .mobile-bottom {
        color: var(--muted);
        font-size: 12px;
    }

    .mobile-bottom strong {
        color: var(--text);
        font-size: 14px;
    }
}

.view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.view-btn:hover {
    color: var(--blue);
    border-color: #bfd0f7;
    background: var(--blue-soft);
}

.mobile-view-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    margin-top: 14px;
    color: var(--blue);
    background: var(--blue-soft);
    border-radius: 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 750;
}

.details-body {
    min-height: 100vh;
    background: var(--bg);
}

.details-shell {
    width: min(1320px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 50px;
}

.details-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 18px;
}

.back-link {
    color: var(--blue);
    text-decoration: none;
    font-weight: 700;
}

.back-link:hover {
    text-decoration: underline;
}

.details-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 24px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
}

.details-heading h1 {
    margin: 8px 0 6px;
    font-size: 27px;
}

.details-heading p {
    margin: 0;
    color: var(--muted);
}

.source-label {
    display: inline-flex;
    padding: 5px 8px;
    color: #175cd3;
    background: var(--blue-soft);
    border-radius: 7px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.details-heading-side {
    display: grid;
    justify-items: end;
    gap: 14px;
}

.order-grand-total {
    font-size: 26px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.details-card {
    padding: 21px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 17px;
}

.details-card h2 {
    margin: 0 0 17px;
    font-size: 18px;
}

.details-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.details-list > div {
    display: grid;
    grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.4fr);
    gap: 15px;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--border);
}

.details-list > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.details-list dt {
    color: var(--muted);
    font-size: 13px;
}

.details-list dd {
    margin: 0;
    font-weight: 650;
    text-align: right;
}

.details-list a {
    color: var(--blue);
    text-decoration: none;
}

.address-block {
    color: #344054;
    font-style: normal;
    line-height: 1.7;
}

.details-products-card {
    margin-bottom: 18px;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 16px;
}

.section-title-row h2 {
    margin-bottom: 5px;
}

.section-title-row p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.details-table-wrap {
    overflow-x: auto;
}

.details-table {
    min-width: 760px;
}

.details-table th:first-child {
    width: 42%;
}

.product-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.product-options span {
    padding: 5px 8px;
    color: #344054;
    background: #f3f5f8;
    border-radius: 7px;
    font-size: 12px;
}

.details-table td small {
    margin-top: 9px;
}

.order-totals {
    width: min(440px, 100%);
    margin: 20px 0 0 auto;
    padding: 14px 17px;
    background: #f8fafc;
    border-radius: 12px;
}

.order-totals > div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.order-totals > div:last-child {
    border-bottom: 0;
}

.order-totals > div:last-child strong {
    color: var(--blue);
    font-size: 18px;
}

.comment-box {
    min-height: 90px;
    padding: 14px;
    color: #344054;
    background: #f8fafc;
    border-radius: 11px;
    line-height: 1.6;
}

.break-text {
    overflow-wrap: anywhere;
}

.history-list {
    display: grid;
    gap: 0;
}

.history-entry {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 13px;
    padding-bottom: 20px;
}

.history-entry:not(:last-child)::before {
    content: "";
    position: absolute;
    top: 14px;
    bottom: 0;
    left: 5px;
    width: 2px;
    background: var(--border);
}

.history-dot {
    position: relative;
    z-index: 1;
    width: 12px;
    height: 12px;
    margin-top: 4px;
    background: var(--blue);
    border: 3px solid #dce8ff;
    border-radius: 50%;
}

.history-header {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.history-header time,
.history-content small {
    color: var(--muted);
    font-size: 12px;
}

.history-content p {
    margin: 9px 0;
    color: #475467;
    line-height: 1.55;
}

.empty-state {
    padding: 20px;
    color: var(--muted);
    background: #f8fafc;
    border-radius: 11px;
    text-align: center;
}

.details-error {
    padding: 30px;
    background: var(--panel);
    border: 1px solid #f4c7c3;
    border-radius: 17px;
}

.details-error h1 {
    margin-top: 0;
    color: var(--danger);
}

.mobile-product-list {
    display: none;
}

@media (max-width: 760px) {
    .details-shell {
        width: min(100% - 24px, 1320px);
        padding-top: 14px;
    }

    .details-heading {
        display: grid;
        padding: 18px;
    }

    .details-heading h1 {
        font-size: 22px;
    }

    .details-heading-side {
        justify-items: start;
    }

    .order-grand-total {
        font-size: 23px;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 11px;
    }

    .details-card {
        padding: 17px;
    }

    .details-list > div {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .details-list dd {
        text-align: left;
    }

    .details-table-wrap {
        display: none;
    }

    .mobile-product-list {
        display: grid;
        gap: 10px;
    }

    .mobile-product-card {
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
    }

    .mobile-product-top,
    .mobile-product-bottom {
        display: flex;
        justify-content: space-between;
        gap: 12px;
    }

    .mobile-product-top span {
        white-space: nowrap;
    }

    .mobile-product-model {
        margin: 9px 0;
        color: var(--muted);
        font-size: 12px;
    }

    .mobile-product-bottom {
        margin-top: 13px;
        color: var(--muted);
        font-size: 13px;
    }

    .mobile-product-bottom strong {
        color: var(--text);
    }

    .history-header {
        display: grid;
        gap: 4px;
    }

    .order-totals {
        margin-top: 15px;
    }
}

.mapping-stats {
    margin-bottom: 18px;
}

.mappings-section {
    margin-bottom: 18px;
}

.mappings-warning {
    border-color: #f2c879;
}

.mappings-warning h2 {
    color: var(--warning);
}

@media (max-width: 760px) {
    .mapping-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mappings-section .details-table-wrap {
        display: block;
        overflow-x: auto;
    }

    .mappings-section .details-table {
        min-width: 760px;
    }
}

.unified-search {
    grid-template-columns: minmax(0, 1fr) 180px auto;
}

.unified-search select {
    min-height: 48px;
    padding: 0 12px;
    color: var(--text);
    background: white;
    border: 1px solid var(--border);
    border-radius: 11px;
}

.source-badge {
    display: inline-flex;
    margin-top: 7px;
    padding: 4px 7px;
    border-radius: 7px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.source-opencart {
    color: #175cd3;
    background: #eef4ff;
}

.source-skroutz {
    color: #067647;
    background: #ecfdf3;
}

.mapping-note {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
}

@media (max-width: 760px) {
    .unified-search {
        grid-template-columns: 1fr;
    }

    .unified-search select {
        width: 100%;
    }
}
