@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700;800&display=swap');

:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-2: #f9fafb;
    --text: #16181d;
    --muted: #667085;
    --line: #d9dde5;
    --strong: #0f766e;
    --strong-dark: #115e59;
    --blue: #1d4ed8;
    --amber: #b45309;
    --red: #b91c1c;
    --green: #047857;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Nunito Sans", "Aptos", "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
    font-size: 14.5px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin: 0 auto;
    max-width: 1480px;
    padding: 14px 24px;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
    min-width: 240px;
}

.brand-mark {
    align-items: center;
    background: #fff;
    border: 1px solid #d8dee8;
    border-radius: 6px;
    display: inline-flex;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    overflow: hidden;
    width: 34px;
}

.brand-mark img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.brand-title {
    font-weight: 800;
    line-height: 1.2;
}

.brand-subtitle,
.muted {
    color: var(--muted);
}

.actions,
.nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nav-link {
    border-radius: 6px;
    color: #475467;
    font-weight: 700;
    padding: 8px 10px;
}

.nav-link:hover,
.nav-link.active {
    background: #eef6f5;
    color: var(--strong-dark);
}

.container {
    margin: 0 auto;
    max-width: 1480px;
    padding: 22px 24px 40px;
}

.page-head {
    align-items: flex-start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.18;
    margin: 0;
}

.page-kicker {
    color: var(--muted);
    margin: 5px 0 0;
}

.grid {
    display: grid;
    gap: 14px;
}

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

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

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

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel-body {
    padding: 16px;
}

.section-title {
    align-items: center;
    display: flex;
    font-size: 16px;
    font-weight: 800;
    gap: 8px;
    justify-content: space-between;
    margin: 0 0 12px;
}

.metric {
    min-height: 96px;
}

.metric-label {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 10px;
}

.metric-note {
    color: var(--muted);
    display: block;
    margin-top: 8px;
}

.btn,
button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 800;
    gap: 8px;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--strong);
    color: #fff;
}

.btn-primary:hover {
    background: var(--strong-dark);
}

.btn-secondary {
    background: #fff;
    border-color: #cfd5df;
    color: #273142;
}

.btn-secondary:hover {
    background: #f3f5f7;
}

.btn-warning {
    background: #fff7ed;
    border-color: #fed7aa;
    color: var(--amber);
}

.btn-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--red);
}

.disabled {
    opacity: .48;
    pointer-events: none;
}

.pill {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    padding: 6px 9px;
}

.pill-green {
    background: #ecfdf3;
    color: var(--green);
}

.pill-blue {
    background: #eff6ff;
    color: var(--blue);
}

.pill-amber {
    background: #fffbeb;
    color: var(--amber);
}

.pill-red {
    background: #fef2f2;
    color: var(--red);
}

.pill-gray {
    background: #eef0f3;
    color: #475467;
}

.related-inline {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.related-link {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    display: inline-flex;
    font-size: 12px;
    gap: 6px;
    min-height: 30px;
    padding: 4px 8px 4px 4px;
    text-decoration: none;
}

.related-link:hover {
    border-color: #98a2b3;
}

.automation-note {
    border: 1px solid;
    border-radius: 8px;
    display: grid;
    font-size: 12px;
    gap: 6px;
    line-height: 1.35;
    padding: 8px;
}

.automation-note-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.automation-note-error {
    background: #fef3f2;
    border-color: #fecdca;
    color: #b42318;
}

.automation-explain {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    color: #92400e;
    display: grid;
    gap: 8px;
    line-height: 1.45;
    margin-top: 12px;
    padding: 12px;
}

.automation-status-compact {
    align-items: flex-start;
    border: 1px solid;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    font-size: 12px;
    gap: 6px;
    line-height: 1.25;
    max-width: 170px;
    padding: 8px;
    white-space: normal;
}

.platform-logo {
    align-items: center;
    background: #fff;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    color: #475467;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 900;
    height: 36px;
    justify-content: center;
    overflow: hidden;
    padding: 5px 7px;
    width: 46px;
}

.platform-logo-lg {
    font-size: 15px;
    height: 48px;
    width: 64px;
}

.platform-logo img {
    display: block;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.platform-ml {
    background: #fffdf0;
    border-color: #f5c400;
    color: #263238;
    width: 38px;
}

.platform-shopee {
    background: #fff;
    border-color: #ffd8cd;
    width: 86px;
}

.platform-orquestador {
    background: #eef4ff;
    border-color: #b8ccff;
    width: 72px;
}

.platform-logo-lg.platform-ml {
    width: 48px;
}

.platform-logo-lg.platform-shopee {
    width: 124px;
}

.platform-logo-lg.platform-orquestador {
    width: 96px;
}

.platform-generic {
    background: #475467;
}

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

table {
    border-collapse: collapse;
    min-width: 1080px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--panel-2);
    color: #475467;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.listing-table {
    min-width: 1320px;
}

.listing-table th:last-child,
.listing-table td:last-child {
    width: 178px;
}

.orders-table {
    min-width: 1280px;
}

.market-row td {
    border-bottom: 8px solid #fff;
}

.row-even {
    background: #fbfcfe;
}

.row-odd {
    background: #f4f7fb;
}

.platform-ml-row {
    box-shadow: inset 4px 0 0 #f5c400;
}

.platform-shopee-row {
    box-shadow: inset 4px 0 0 #ee4d2d;
}

.platform-orquestador-row {
    box-shadow: inset 4px 0 0 #0f766e;
}

.order-click-row {
    cursor: pointer;
}

.order-click-row:hover {
    background: #eef6f5;
}

.product-cell,
.account-chip,
.integration-head,
.user-row,
.compact-item {
    align-items: center;
    display: flex;
    gap: 12px;
}

.product-cell {
    align-items: flex-start;
    min-width: 380px;
}

.product-cell-compact {
    min-width: 340px;
}

.product-image {
    align-items: center;
    background: #eef0f3;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    color: #667085;
    display: inline-flex;
    flex: 0 0 auto;
    font-weight: 800;
    height: 72px;
    justify-content: center;
    overflow: hidden;
    width: 72px;
}

.product-image-sm {
    height: 46px;
    width: 46px;
}

.product-image-xl {
    height: 132px;
    width: 132px;
}

.product-image img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.account-chip {
    align-items: flex-start;
    min-width: 170px;
}

.account-chip .item-meta {
    display: block;
}

.text-link {
    color: var(--blue);
    display: inline-block;
    font-weight: 700;
}

.item-title {
    font-weight: 800;
    max-width: 360px;
}

.item-meta {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.number {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.amount-cell,
.cost-cell {
    min-width: 190px;
}

.amount-main,
.amount-line {
    align-items: baseline;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.amount-main {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    border-radius: 6px;
    color: #066346;
    margin-bottom: 8px;
    padding: 7px 8px;
}

.amount-main span,
.amount-line span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.amount-main strong {
    color: #066346;
    font-size: 16px;
}

.amount-line {
    min-height: 24px;
}

.amount-line strong {
    color: var(--text);
    font-weight: 800;
}

.amount-negative strong {
    color: #9f1239;
}

.amount-positive strong {
    color: var(--green);
}

.amount-total {
    border-top: 1px dashed var(--line);
    margin-top: 4px;
    padding-top: 5px;
}

.amount-total strong {
    color: var(--blue);
}

.order-summary-cell {
    min-width: 178px;
}

.summary-line {
    align-items: baseline;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    min-height: 24px;
}

.summary-line span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.summary-line strong {
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
}

.summary-receivable {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    border-radius: 6px;
    margin: 5px 0;
    padding: 6px 8px;
}

.summary-receivable strong {
    color: var(--green);
    font-size: 16px;
}

.summary-negative strong {
    color: #9f1239;
}

.btn-compact {
    font-size: 12px;
    min-height: 30px;
    padding: 5px 9px;
}

.order-detail-trigger {
    margin-top: 7px;
    width: 100%;
}

.financial-modal-panel {
    max-width: 1120px;
}

.financial-kpis {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.financial-kpi {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.financial-kpi span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.financial-kpi strong {
    display: block;
    font-size: 22px;
    line-height: 1.1;
    margin-top: 8px;
}

.financial-kpi-green {
    background: #ecfdf3;
    border-color: #abefc6;
}

.financial-kpi-green strong {
    color: var(--green);
}

.financial-kpi-red {
    background: #fef2f2;
    border-color: #fecaca;
}

.financial-kpi-red strong {
    color: var(--red);
}

.financial-modal-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.financial-block {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.financial-ledger {
    display: grid;
    gap: 0;
}

.ledger-row {
    align-items: baseline;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    min-height: 36px;
    padding: 8px 0;
}

.ledger-row:last-child {
    border-bottom: 0;
}

.ledger-row span {
    color: #344054;
}

.ledger-row strong {
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
}

.ledger-positive strong {
    color: var(--green);
}

.ledger-negative strong {
    color: #9f1239;
}

.ledger-sub {
    background: #f8fafc;
    margin-left: 12px;
    padding-left: 10px;
}

.ledger-sub span {
    color: var(--muted);
    font-size: 12px;
}

.ledger-total {
    border-top: 2px solid var(--line);
    margin-top: 4px;
}

.ledger-total span,
.ledger-total strong {
    color: var(--text);
    font-weight: 900;
}

.financial-note {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #344054;
    line-height: 1.45;
    padding: 12px;
}

.form-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(110px, 1fr));
}

.filter-bar {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(230px, 1.4fr) repeat(4, minmax(140px, 1fr)) auto;
}

.filter-actions {
    align-items: center;
    display: flex;
    gap: 8px;
    padding-bottom: 1px;
}

.filter-bar-compact {
    grid-template-columns: minmax(180px, 260px) minmax(240px, 1fr) auto;
}

.searchable-select {
    position: relative;
}

.searchable-select-control {
    background: #fff;
    border-color: #cfd5df;
    color: var(--text);
    justify-content: space-between;
    min-height: 40px;
    text-align: left;
    width: 100%;
}

.searchable-select-control span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.searchable-select-control::after {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #475467;
    content: "";
    flex: 0 0 auto;
}

.searchable-select-menu {
    background: #fff;
    border: 1px solid #cfd5df;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(16, 24, 40, .16);
    display: grid;
    gap: 8px;
    left: 0;
    padding: 8px;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 25;
}

.searchable-select-menu[hidden] {
    display: none;
}

.searchable-select-search {
    min-height: 38px;
}

.searchable-select-options {
    display: grid;
    gap: 4px;
    max-height: 280px;
    overflow: auto;
}

.searchable-select-option {
    background: #fff;
    border: 0;
    border-radius: 6px;
    color: var(--text);
    justify-content: flex-start;
    min-height: 36px;
    padding: 8px 10px;
    text-align: left;
    white-space: normal;
    width: 100%;
}

.searchable-select-option:hover,
.searchable-select-option.is-selected {
    background: #eef6f5;
    color: var(--strong-dark);
}

.searchable-select-option[hidden] {
    display: none;
}

.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    align-items: center;
    background: rgba(16, 24, 40, .46);
    display: grid;
    inset: 0;
    padding: 24px;
    position: fixed;
    z-index: 30;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(16, 24, 40, .22);
    margin: 0 auto;
    max-height: calc(100vh - 48px);
    max-width: 980px;
    overflow: auto;
    width: min(980px, 100%);
}

.modal-head {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 16px;
}

.modal-head .section-title {
    margin: 0;
}

.modal-body {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.modal-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

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

.simulator-results {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.simulator-result {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 88px;
    padding: 12px;
}

.simulator-result strong {
    display: block;
    font-size: 20px;
    line-height: 1.15;
    margin-top: 10px;
}

.simulator-result .metric-note {
    font-size: 12px;
    line-height: 1.3;
}

.row-actions {
    align-items: stretch;
    display: grid;
    gap: 8px;
    justify-items: stretch;
    min-width: 150px;
}

.row-actions form,
.row-actions .btn,
.row-actions button {
    width: 100%;
}

.actions-cell {
    white-space: normal;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    color: #344054;
    font-size: 12px;
    font-weight: 800;
}

input,
select {
    background: #fff;
    border: 1px solid #cfd5df;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 38px;
    padding: 8px 10px;
    width: 100%;
}

.readonly-field {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #cfd5df;
    border-radius: 6px;
    display: flex;
    min-height: 38px;
    padding: 8px 10px;
}

.check-row {
    align-items: center;
    display: flex;
    gap: 8px;
}

.check-row input {
    min-height: 16px;
    width: 16px;
}

.flash {
    border: 1px solid;
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 12px 14px;
}

.flash-success {
    background: #ecfdf3;
    border-color: #abefc6;
    color: #067647;
}

.flash-error {
    background: #fef3f2;
    border-color: #fecdca;
    color: #b42318;
}

.login-shell {
    align-items: center;
    display: grid;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    margin: 0 auto;
    max-width: 520px;
    width: 100%;
}

.stack {
    display: grid;
    gap: 12px;
}

.empty {
    color: var(--muted);
    padding: 26px;
    text-align: center;
}

.split-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.split-actions form {
    display: flex;
}

.account-row,
.user-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    justify-content: space-between;
    padding: 12px;
}

.app-config {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.app-config summary {
    cursor: pointer;
    font-weight: 800;
}

.app-config form {
    margin-top: 12px;
}

.user-row form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.compact-list {
    display: grid;
    gap: 8px;
}

.compact-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: inherit;
    display: grid;
    grid-template-columns: 46px minmax(260px, 1fr) 120px 90px 90px;
    padding: 10px 12px;
    text-decoration: none;
}

.compact-item:hover {
    border-color: #98a2b3;
    box-shadow: 0 8px 18px rgba(16, 24, 40, .08);
}

.listing-hero-grid {
    align-items: center;
    display: grid;
    gap: 18px;
    grid-template-columns: 132px minmax(320px, 1fr) minmax(260px, .7fr);
}

.listing-title {
    font-size: 22px;
    line-height: 1.22;
    margin: 0 0 6px;
}

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

.listing-kpis strong {
    display: block;
    font-size: 20px;
    margin-top: 6px;
}

.data-grid {
    display: grid;
    gap: 10px 14px;
    grid-template-columns: minmax(140px, 1fr) auto;
}

.data-grid span {
    color: var(--muted);
}

.related-listings {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
}

.related-listing-row {
    align-items: center;
    color: var(--text);
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 0;
    text-decoration: none;
}

.related-listing-row + .related-listing-row {
    border-top: 1px solid var(--line);
}

.related-listing-row strong,
.related-listing-row .item-meta {
    display: block;
}

.related-listing-metrics {
    align-items: flex-end;
    display: grid;
    gap: 6px;
    justify-items: end;
}

@media (max-width: 1100px) {
    .grid-4,
    .grid-3,
    .grid-2,
    .form-grid,
    .filter-bar,
    .financial-kpis,
    .financial-modal-grid,
    .simulator-grid,
    .simulator-results {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .topbar-inner,
    .page-head {
        align-items: stretch;
        flex-direction: column;
    }

    .container {
        padding: 16px;
    }

    .grid-4,
    .grid-3,
    .grid-2,
    .form-grid,
    .filter-bar,
    .financial-kpis,
    .financial-modal-grid,
    .simulator-grid,
    .simulator-results {
        grid-template-columns: 1fr;
    }

    .modal-backdrop {
        padding: 12px;
    }

    .modal-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .modal-actions .btn-primary,
    .modal-actions .btn-secondary {
        width: 100%;
    }

    .related-listing-row {
        grid-template-columns: 1fr;
    }

    .related-listing-metrics {
        align-items: start;
        justify-items: start;
    }

    .actions {
        justify-content: flex-start;
    }

    .compact-item {
        grid-template-columns: 46px 1fr;
    }

    .listing-hero-grid {
        grid-template-columns: 1fr;
    }

    .listing-kpis {
        grid-template-columns: 1fr;
    }

    .user-row {
        align-items: stretch;
        flex-direction: column;
    }
}
