/* Nexus page frame and explicit shared components */
:root {
    --app-navy: #243f70;
    --app-orange: var(--nexus-accent, #EE7326);
    --app-ink: #243962;
    --app-muted: #6f7887;
    --app-line: #dce3ec;
    --app-surface: #ffffff;
    --app-canvas: #f3f6fa;
}

.app-content-frame {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding: 28px 32px 44px;
}

.app-page,
.debtor-page,
.sales-page,
.stock-class-page,
.account-detail-page {
    box-sizing: border-box;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

.iq-sync-page { max-width: 1280px; }

.app-page {
    display: grid;
    gap: 18px;
    color: var(--app-ink);
}

.app-page-header,
.debtor-header,
.sales-header,
.stock-class-header,
.account-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin: 0;
}

.app-page-header h1,
.debtor-header h1,
.sales-header h1,
.stock-class-header h1,
.account-heading h1 {
    margin: 0;
    color: var(--app-navy);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.05;
    letter-spacing: -.04em;
    outline: none;
}

.app-page-header p { margin: 7px 0 0; color: var(--app-muted); }
.app-eyebrow { margin: 0 0 4px !important; color: var(--app-orange) !important; font-size: .78rem; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }

.app-card {
    box-sizing: border-box;
    width: 100%;
    padding: 20px;
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(20,43,77,.04);
}
.app-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.app-section-heading h2 { margin: 0; color: var(--app-orange); font-size: 1.15rem; }
.app-section-heading p { margin: 5px 0 0; color: var(--app-muted); }

.app-form-grid { display: grid; gap: 12px; }
.app-form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.app-form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.app-form-grid label { display: grid; gap: 6px; min-width: 0; }
.app-form-grid label > span { color: #5f6b7d; font-size: .76rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.app-form-grid input,
.app-form-grid select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    color: var(--app-ink);
    background: #fff;
    border: 1px solid #cfd7e3;
    border-radius: 10px;
    font: inherit;
}
.app-form-grid input:focus,
.app-form-grid select:focus { outline: 3px solid rgba(236,116,40,.13); border-color: var(--app-orange); }
.app-check-row { display: inline-flex; align-items: center; gap: 9px; margin-top: 15px; color: var(--app-ink); font-weight: 700; }
.app-check-row input { width: 18px; height: 18px; accent-color: var(--app-orange); }
.app-actions { display: flex; gap: 10px; margin-top: 16px; }
.app-button { border: 0; border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 800; cursor: pointer; }
.app-button-primary { color: #fff; background: var(--app-orange); box-shadow: 0 2px 5px rgba(154,73,20,.16); }
.app-notice { margin: 14px 0 0; padding: 11px 13px; border-radius: 10px; }
.app-notice.success { color: #286b3c; background: #eaf6ee; border: 1px solid #bfe0ca; }
.app-notice.error { color: #a23b31; background: #fff0ee; border: 1px solid #efc6c1; }
.app-empty { color: var(--app-muted); text-align: center; }

.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dashboard-card {
    display: flex;
    min-height: 190px;
    flex-direction: column;
    padding: 22px;
    color: var(--app-ink);
    text-decoration: none;
    background: #fff;
    border: 1px solid var(--app-line);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(20,43,77,.04);
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.dashboard-card:hover { color: var(--app-ink); transform: translateY(-2px); border-color: #bcc8d8; box-shadow: 0 8px 22px rgba(20,43,77,.09); }
.dashboard-card-kicker { color: var(--app-orange); font-size: .76rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.dashboard-card h2 { margin: 7px 0 7px; color: var(--app-navy); }
.dashboard-card p { margin: 0; color: var(--app-muted); }
.dashboard-card-action { margin-top: auto; padding-top: 18px; color: var(--app-orange); font-weight: 800; }
.dashboard-card-disabled { opacity: .62; }
.dashboard-modules { margin: 0; color: var(--app-muted); }

@media (max-width: 1050px) {
    .app-form-grid-3,
    .app-form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .app-content-frame { padding: 16px 12px 30px; }
    .dashboard-grid,
    .app-form-grid-3,
    .app-form-grid-4 { grid-template-columns: 1fr; }
    .dashboard-card { min-height: 160px; }
    .app-page-header,
    .debtor-header,
    .sales-header,
    .stock-class-header,
    .account-heading { display: grid; }
}


/* Aligned Tenants and IQ Synchronisation */

.app-count-badge {
    display: inline-flex;
    align-items: center;
    padding: 9px 13px;

    color: var(--app-navy);
    white-space: nowrap;
    font-weight: 800;

    background: #edf2f8;
    border-radius: 999px;
}

.app-table-wrap {
    width: 100%;
    overflow-x: auto;

    border: 1px solid var(--app-line);
    border-radius: 13px;
}

.app-table {
    width: 100%;
    min-width: 780px;

    background: #fff;
    border-collapse: collapse;
}

.app-table th {
    padding: 11px 13px;

    color: #fff;
    text-align: left;
    white-space: nowrap;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;

    background: var(--app-navy);
}

.app-table td {
    padding: 12px 13px;
    border-bottom: 1px solid #e8edf3;
    vertical-align: middle;
}

.app-table tbody tr:last-child td {
    border-bottom: 0;
}

.app-table tbody tr:hover {
    background: #f7f9fc;
}

.app-table-action {
    width: 1%;
    text-align: right !important;
    white-space: nowrap;
}

.app-code-pill,
.app-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;

    color: #40516c;
    font-size: .82rem;
    font-weight: 750;

    background: #edf2f7;
    border-radius: 999px;
}

.app-code-pill {
    color: var(--app-navy);
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace;
}

.app-link-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;

    color: #ce6729;
    font-weight: 800;
    text-decoration: none;
}

.app-link-action:hover {
    color: var(--app-orange);
}

.tenant-module-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tenant-modules {
    margin: 18px 0 0;
    padding: 0;

    border: 0;
}

.tenant-modules legend {
    margin-bottom: 9px;

    color: #5f6b7d;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.tenant-module-options {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.tenant-module-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 10px 12px;

    color: var(--app-ink);
    font-weight: 700;

    background: #f8fafc;
    border: 1px solid #d5deea;
    border-radius: 10px;

    cursor: pointer;
}

.tenant-module-option:has(input:checked) {
    color: var(--app-navy);
    background: #eef4fb;
    border-color: #aebdd2;
}

.tenant-module-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--app-orange);
}

/*
 * IQ Synchronisation now uses the same page header and card language
 * as the rest of Nexus. Operation order and component behaviour remain
 * controlled by IqSync.razor.
 */

.iq-sync-page {
    width: 100%;
    max-width: 1440px;
    padding: 0;
}

.iq-sync-page .iq-sync-card {
    padding: 20px;

    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: 16px;

    box-shadow: 0 2px 8px rgba(20, 43, 77, .04);
}

.iq-sync-page .iq-sync-card h3,
.iq-sync-page .iq-sync-card h4 {
    margin: 0 0 6px;
    color: var(--app-orange);
    font-size: 1.15rem;
}

.iq-sync-page .iq-sync-action,
.iq-sync-page .iq-sync-card button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: auto;
    margin: 2px 0 0;
    padding: 11px 16px;

    color: #fff;
    font: inherit;
    font-weight: 800;

    background: var(--app-orange);
    border: 0;
    border-radius: 10px;

    box-shadow: 0 2px 5px rgba(154, 73, 20, .16);
    cursor: pointer;
}

.iq-sync-page .iq-sync-log {
    max-height: 620px;
    overflow: auto;
}

.iq-sync-page .iq-sync-hero {
    display: none;
}

@media (max-width: 760px) {
    .app-count-badge {
        justify-self: start;
    }

    .tenant-module-options {
        display: grid;
        grid-template-columns: 1fr;
    }

    .iq-sync-page .iq-sync-action,
    .iq-sync-page .iq-sync-card button {
        width: 100%;
    }
}


/* Unified remaining pages v3 */
.app-page-header{padding:0!important;border:0!important;background:transparent!important;box-shadow:none!important}
.app-page-header h1{outline:0!important;border:0!important;box-shadow:none!important}
.app-count-badge{display:inline-flex;align-items:center;padding:9px 13px;color:var(--app-navy);white-space:nowrap;font-weight:800;background:#edf2f8;border-radius:999px}
.app-table-wrap{width:100%;overflow-x:auto;border:1px solid var(--app-line);border-radius:13px}.app-table{width:100%;min-width:780px;background:#fff;border-collapse:collapse}.app-table th{padding:11px 13px;color:#fff;text-align:left;white-space:nowrap;font-size:.75rem;font-weight:800;letter-spacing:.04em;text-transform:uppercase;background:var(--app-navy)}.app-table td{padding:12px 13px;border-bottom:1px solid #e8edf3;vertical-align:middle}.app-table-action{width:1%;text-align:right!important;white-space:nowrap}.app-code-pill,.app-pill{display:inline-flex;align-items:center;padding:5px 9px;color:#40516c;font-size:.82rem;font-weight:750;background:#edf2f7;border-radius:999px}.app-code-pill{color:var(--app-navy);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.app-link-action{display:inline-flex;gap:5px;color:#ce6729;font-weight:800;text-decoration:none}.tenant-module-list,.tenant-module-options{display:flex;flex-wrap:wrap;gap:7px}.tenant-modules{margin:18px 0 0;padding:0;border:0}.tenant-modules legend{margin-bottom:9px;color:#5f6b7d;font-size:.76rem;font-weight:800;letter-spacing:.05em;text-transform:uppercase}.tenant-module-option{display:inline-flex;align-items:center;gap:8px;padding:10px 12px;color:var(--app-ink);font-weight:700;background:#f8fafc;border:1px solid #d5deea;border-radius:10px}.tenant-module-option input{width:18px;height:18px;accent-color:var(--app-orange)}
.app-form-grid small{color:var(--app-muted);font-weight:400;line-height:1.4}.app-check-card{display:inline-flex;align-items:center;gap:10px;margin-top:18px;padding:13px 15px;color:var(--app-navy);font-weight:800;background:#f6f8fb;border-radius:11px}.app-check-card input{width:19px;height:19px;accent-color:var(--app-orange)}
.iq-sync-page{width:100%!important;max-width:1440px!important;padding:0!important}.iq-sync-page .iq-sync-card{padding:20px!important;background:var(--app-surface)!important;border:1px solid var(--app-line)!important;border-radius:16px!important;box-shadow:0 2px 8px rgba(20,43,77,.04)!important}.iq-sync-page .iq-sync-card h3,.iq-sync-page .iq-sync-card h4{margin:0 0 6px!important;color:var(--app-orange)!important;font-size:1.15rem!important}.iq-sync-page .iq-sync-action,.iq-sync-page .iq-sync-card button{width:auto!important;margin:2px 0 0!important;padding:11px 16px!important;color:#fff!important;background:var(--app-orange)!important;border:0!important;border-radius:10px!important;font:inherit!important;font-weight:800!important;box-shadow:0 2px 5px rgba(154,73,20,.16)!important}.iq-sync-page .iq-sync-log{max-height:620px;overflow:auto}.iq-sync-page .iq-sync-hero{display:none!important}
@media(max-width:760px){.app-count-badge{justify-self:start}.tenant-module-options{display:grid;grid-template-columns:1fr}.iq-sync-page .iq-sync-action,.iq-sync-page .iq-sync-card button{width:100%!important}}


/* Phase 1 IQ branch configuration */
.iq-branches-card{margin-top:0}.branch-table td{vertical-align:middle}.branch-default{display:inline-flex;margin-left:8px;padding:3px 7px;color:#286b3c;background:#eaf6ee;border-radius:999px;font-size:.72rem;font-weight:800}.branch-actions{display:flex;justify-content:flex-end;gap:7px;white-space:nowrap}.app-button-secondary{color:var(--app-navy);background:#edf2f7;border:1px solid #d5deea;box-shadow:none}.branch-editor{margin-top:18px;padding-top:18px;border-top:1px solid var(--app-line)}.branch-editor h3{margin:0 0 13px;color:var(--app-orange)}.branch-form-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.branch-help{margin:10px 0 0;color:var(--app-muted);font-size:.88rem}@media(max-width:1000px){.branch-form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.branch-actions{flex-wrap:wrap}}@media(max-width:700px){.branch-form-grid{grid-template-columns:1fr}.branch-actions{display:grid}.branch-actions button{width:100%}}

/* STABLE APPLICATION CONTENT WIDTH */
/*
 * The shell is a row flex container. width:0 with flex-grow makes the
 * content column consume the remaining viewport width instead of using
 * the active tab's intrinsic content width.
 */
.shell > .content {
    box-sizing: border-box;
    flex: 1 1 0% !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: none !important;
}

.shell > .content > .app-content-frame {
    box-sizing: border-box;
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
}

.shell > .content > .app-content-frame > .fx-head,
.shell > .content > .app-content-frame > .fx-tabs,
.shell > .content > .app-content-frame > .fx-card,
.shell > .content > .app-content-frame > .fx-quick,
.shell > .content > .app-content-frame > .fx-toast,
.shell > .content > .app-content-frame > .oc-shell {
    box-sizing: border-box;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
}

@media (max-width: 760px) {
    .shell > .content {
        width: auto !important;
        flex: 1 1 auto !important;
    }
}


/* NEXUS MAIN FLEX WIDTH - AUTHORITATIVE */
/*
 * MainLayout renders <main class="nexus-main"> as the direct flex child of
 * .shell. It must grow to the remaining viewport width independently of the
 * active tab's intrinsic content width.
 */
.shell > main.nexus-main {
    box-sizing: border-box !important;
    flex: 1 1 0% !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: none !important;
}

.shell > main.nexus-main > .app-content-frame {
    box-sizing: border-box !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
}

.shell > main.nexus-main > .app-content-frame > .fx-head,
.shell > main.nexus-main > .app-content-frame > .fx-tabs,
.shell > main.nexus-main > .app-content-frame > .fx-card,
.shell > main.nexus-main > .app-content-frame > .fx-quick,
.shell > main.nexus-main > .app-content-frame > .fx-toast,
.shell > main.nexus-main > .app-content-frame > .oc-shell {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

@media (max-width: 760px) {
    .shell > main.nexus-main {
        flex: 1 1 auto !important;
        width: auto !important;
    }
}


/* NEXUS FULL WIDTH PAGE ROOTS - AUTHORITATIVE */
/*
 * main.nexus-main now owns a stable remaining-viewport width.
 * Every application page root fills app-content-frame consistently.
 */
.shell > main.nexus-main > .app-content-frame {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
}

/* Current top-level Nexus page families. */
.app-content-frame > .app-page,
.app-content-frame > .debtor-page,
.app-content-frame > .sales-page,
.app-content-frame > .stock-class-page,
.app-content-frame > .account-detail-page,
.app-content-frame > .iq-sync-page,
.app-content-frame > .stores-page,
.app-content-frame > .field-page,
.app-content-frame > .dashboard-page,
.app-content-frame > .tenants-page,
.app-content-frame > .availability-page,
.app-content-frame > .iq-setup-page {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Legacy direct page structures that do not yet have an app-page root. */
.app-content-frame > .cards,
.app-content-frame > .panel,
.app-content-frame > .grid,
.app-content-frame > form {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
}

/* Tables use the page width but retain horizontal scrolling in their wrappers. */
.app-content-frame .app-table-wrap,
.app-content-frame .debtor-table-wrap,
.app-content-frame .sales-table-wrap,
.app-content-frame .stock-table-wrap {
    box-sizing: border-box;
    width: 100% !important;
    max-width: none !important;
}

/* Keep intentional compact content compact. */
.app-content-frame .login-card,
.app-content-frame .modal,
.app-content-frame .dialog,
.app-content-frame .pager,
.app-content-frame .debtor-pager,
.app-content-frame .stock-pager {
    width: auto;
}

@media (max-width: 760px) {
    .app-content-frame > .app-page,
    .app-content-frame > .debtor-page,
    .app-content-frame > .sales-page,
    .app-content-frame > .stock-class-page,
    .app-content-frame > .account-detail-page,
    .app-content-frame > .iq-sync-page {
        width: 100% !important;
    }
}


/* Phase 3A branch stock */
.iq-sync-card .notice small{display:block;margin-top:6px;color:inherit;opacity:.75}

/* Commerce stores card layout */
.commerce-store-grid{display:grid;gap:18px}
.commerce-store-card{overflow:hidden;background:#fff;border:1px solid #d7e0eb;border-radius:16px;box-shadow:0 8px 24px rgba(23,43,77,.07)}
.commerce-store-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;padding:20px 22px;background:linear-gradient(135deg,#f8fafc 0%,#eef4fb 100%);border-bottom:1px solid #dce5ef}
.commerce-store-identity{display:flex;align-items:flex-start;gap:14px;min-width:0}
.commerce-store-icon{display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;color:#fff;font-size:.78rem;font-weight:900;letter-spacing:.04em;background:var(--app-navy);border-radius:12px}
.commerce-store-title-row{display:flex;align-items:center;flex-wrap:wrap;gap:10px}.commerce-store-title-row h3{margin:0;color:var(--app-navy);font-size:1.18rem}
.commerce-store-meta{display:flex;align-items:center;flex-wrap:wrap;gap:7px;margin-top:5px;color:#64748b;font-size:.86rem}.commerce-store-meta span:after{content:"•";margin-left:7px}.commerce-store-meta a{max-width:560px;color:#526781;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.commerce-status{display:inline-flex;padding:5px 9px;font-size:.72rem;font-weight:850;border-radius:999px}.commerce-status.is-enabled{color:#17643a;background:#dcf7e8}.commerce-status.is-disabled{color:#7b4350;background:#f7e5e8}
.commerce-store-head-actions,.commerce-store-foot-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
.commerce-store-sections{display:grid;grid-template-columns:1fr 1fr;gap:0}
.commerce-config-section{padding:20px 22px}.commerce-config-section+ .commerce-config-section{border-left:1px solid #e2e8f0}
.commerce-section-title{display:grid;gap:3px;margin-bottom:10px}.commerce-section-title span{color:var(--app-navy);font-size:.82rem;font-weight:900;letter-spacing:.055em;text-transform:uppercase}.commerce-section-title small{color:#738197}
.commerce-setting-row{display:grid;grid-template-columns:minmax(180px,1fr) minmax(190px,auto);align-items:center;gap:18px;min-height:70px;padding:13px 0;border-top:1px solid #edf1f5}.commerce-setting-row:first-of-type{border-top:0}.commerce-setting-row>div:first-child{display:grid;gap:3px}.commerce-setting-row strong{color:#253a5a}.commerce-setting-row small{color:#758397}.commerce-setting-row.compact{min-height:64px}
.commerce-setting-value{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:9px;text-align:right}.commerce-setting-value>span{color:#364b68;font-weight:750}
.commerce-inline-editor{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:8px}.commerce-inline-editor select{max-width:270px;padding:9px 10px;border:1px solid #cfd9e6;border-radius:9px;background:#fff}
.commerce-toggle{display:inline-flex;align-items:center;justify-self:end;gap:8px;color:#344966;font-weight:800}.commerce-toggle input{width:38px;height:20px;appearance:none;position:relative;margin:0;background:#cbd5e1;border-radius:999px;cursor:pointer;transition:.18s}.commerce-toggle input:before{content:"";position:absolute;top:3px;left:3px;width:14px;height:14px;background:#fff;border-radius:50%;box-shadow:0 1px 3px rgba(0,0,0,.25);transition:.18s}.commerce-toggle input:checked{background:var(--app-orange)}.commerce-toggle input:checked:before{transform:translateX(18px)}.commerce-toggle input:disabled{cursor:not-allowed;opacity:.55}
.commerce-store-card-foot{display:flex;align-items:center;justify-content:space-between;gap:18px;padding:15px 22px;background:#fafbfd;border-top:1px solid #e2e8f0}.commerce-last-connected{display:grid;gap:2px}.commerce-last-connected span{color:#718096;font-size:.72rem;font-weight:850;letter-spacing:.05em;text-transform:uppercase}.commerce-last-connected strong{color:#344966;font-size:.9rem}
.app-link-action.muted{color:#69778b}
@media(max-width:1050px){.commerce-store-sections{grid-template-columns:1fr}.commerce-config-section+.commerce-config-section{border-left:0;border-top:1px solid #e2e8f0}}
@media(max-width:720px){.commerce-store-card-head,.commerce-store-card-foot{align-items:stretch;flex-direction:column}.commerce-store-head-actions,.commerce-store-foot-actions{width:100%}.commerce-store-head-actions .app-button,.commerce-store-foot-actions .app-button{flex:1}.commerce-setting-row{grid-template-columns:1fr;gap:8px}.commerce-setting-value,.commerce-inline-editor{justify-content:flex-start;text-align:left}.commerce-toggle{justify-self:start}.commerce-store-meta a{max-width:260px}.commerce-config-section{padding:17px}.commerce-store-card-head,.commerce-store-card-foot{padding:17px}}

/* PSA preview global zebra rows */
.psa-preview-table {
    width: 100%;
    min-width: 1180px;
    table-layout: fixed;
    border-collapse: collapse;
}

.psa-preview-table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

.psa-preview-table tbody tr:nth-child(even) {
    background-color: #edf2f7;
}

.psa-preview-table tbody tr:hover {
    background-color: #fff2e8;
}

.psa-preview-table th,
.psa-preview-table td {
    padding: 10px 12px;
    border-right: 1px solid #d8e0ea;
    border-bottom: 1px solid #dfe6ee;
    vertical-align: top;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.psa-preview-table th:last-child,
.psa-preview-table td:last-child {
    border-right: 0;
}

.psa-preview-table th:nth-child(1),
.psa-preview-table td:nth-child(1) { width: 105px; }
.psa-preview-table th:nth-child(2),
.psa-preview-table td:nth-child(2) { width: 270px; }
.psa-preview-table th:nth-child(3),
.psa-preview-table td:nth-child(3) { width: 100px; }
.psa-preview-table th:nth-child(4),
.psa-preview-table td:nth-child(4) { width: 125px; }
.psa-preview-table th:nth-child(5),
.psa-preview-table td:nth-child(5) { width: 150px; }
.psa-preview-table th:nth-child(6),
.psa-preview-table td:nth-child(6) { width: auto; }
.psa-preview-table th:nth-child(7),
.psa-preview-table td:nth-child(7) { width: 90px; }

.psa-preview-table td:nth-child(1),
.psa-preview-table td:nth-child(3),
.psa-preview-table td:nth-child(4),
.psa-preview-table td:nth-child(5),
.psa-preview-table td:nth-child(7) {
    white-space: nowrap;
}



/* PSA company tables - global final rules */
.psa-company-table {
    width: 100%;
    min-width: 1180px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

.psa-company-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 12px 14px;
    background: var(--app-navy);
    border-right: 1px solid rgba(255,255,255,.28);
    border-bottom: 1px solid #19365f;
}

.psa-company-table thead th:last-child {
    border-right: 0;
}

.psa-company-table tbody td {
    padding: 11px 14px;
    vertical-align: middle;
    line-height: 1.35;
    color: #243f68;
    background-color: #fff !important;
    border-right: 1px solid #dfe6ef;
    border-bottom: 1px solid #dfe6ef;
    overflow-wrap: anywhere;
    transition: background-color .12s ease;
}

.psa-company-table tbody td:last-child {
    border-right: 0;
}

.psa-company-table tbody tr:nth-child(even) > td {
    background-color: #f4f7fb !important;
}

.psa-company-table tbody tr:hover > td,
.psa-company-table tbody tr:nth-child(even):hover > td {
    background-color: #fff0dc !important;
}

.psa-company-table tbody tr:last-child > td {
    border-bottom: 0;
}

.psa-company-table tbody td:first-child,
.psa-company-table .psa-source-cell {
    color: #17365f;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 850;
}

.psa-company-table tbody td:nth-child(2),
.psa-company-table .psa-name-cell {
    color: #203a62;
    font-weight: 750;
}

.psa-company-table tbody td:last-child,
.psa-company-table .psa-row-action-cell {
    width: 132px !important;
    padding: 7px 12px !important;
    text-align: right !important;
    white-space: nowrap;
    border-left: 1px solid #d3dce8;
}

.psa-company-action-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 112px;
    min-width: 112px;
    min-height: 36px;
    margin: 0;
    padding: 7px 10px;
    color: #bd520f !important;
    font-size: .78rem;
    font-weight: 850;
    line-height: 1;
    text-decoration: none;
    background: #fff7ed !important;
    border: 1px solid #eda66e !important;
    border-radius: 8px;
    cursor: pointer;
}

.psa-company-action-button:hover:not(:disabled) {
    color: #fff !important;
    background: #d85f13 !important;
    border-color: #d85f13 !important;
}

.psa-company-action-button:focus-visible {
    outline: 3px solid rgba(216,95,19,.25);
    outline-offset: 2px;
}

/* Active Companies columns. */
.psa-active-company-table th:nth-child(1),
.psa-active-company-table td:nth-child(1) { width: 110px; }
.psa-active-company-table th:nth-child(2),
.psa-active-company-table td:nth-child(2) { width: 285px; }
.psa-active-company-table th:nth-child(3),
.psa-active-company-table td:nth-child(3) { width: 105px; }
.psa-active-company-table th:nth-child(4),
.psa-active-company-table td:nth-child(4) { width: 135px; white-space: nowrap; }
.psa-active-company-table th:nth-child(5),
.psa-active-company-table td:nth-child(5) { width: 155px; white-space: nowrap; }
.psa-active-company-table th:nth-child(7),
.psa-active-company-table td:nth-child(7) { width: 132px; }

/* Excluded Companies columns and matching action alignment. */
.psa-excluded-company-table th:nth-child(1),
.psa-excluded-company-table td:nth-child(1) { width: 110px; }
.psa-excluded-company-table th:nth-child(2),
.psa-excluded-company-table td:nth-child(2) { width: 340px; }
.psa-excluded-company-table th:nth-child(3),
.psa-excluded-company-table td:nth-child(3) { width: 230px; }
.psa-excluded-company-table th:nth-child(4),
.psa-excluded-company-table td:nth-child(4) { width: 185px; white-space: nowrap; }
.psa-excluded-company-table th:nth-child(5),
.psa-excluded-company-table td:nth-child(5) { width: 180px; white-space: nowrap; }
.psa-excluded-company-table th:nth-child(6),
.psa-excluded-company-table td:nth-child(6) { width: 132px; }

.psa-preview-row.psa-action-conflict td:first-child { box-shadow: inset 4px 0 0 #d99215; }
.psa-preview-row.psa-action-would-update td:first-child { box-shadow: inset 4px 0 0 #2f6fb3; }
.psa-preview-row.psa-action-would-create td:first-child { box-shadow: inset 4px 0 0 #6d7f96; }
.psa-preview-row.psa-action-unchanged td:first-child { box-shadow: inset 4px 0 0 #2d8a57; }

@media (max-width: 900px) {
    .psa-company-table tbody td:last-child {
        position: sticky;
        right: 0;
        z-index: 2;
        box-shadow: -4px 0 8px rgba(23,54,95,.08);
    }
}


/* PSA preview guaranteed row interaction */
.psa-active-company-table tbody tr > td,
.psa-excluded-company-table tbody tr > td {
    background-color: #fff !important;
    border-bottom: 1px solid #d9e2ec !important;
}

.psa-active-company-table tbody tr:nth-child(even) > td,
.psa-excluded-company-table tbody tr:nth-child(even) > td {
    background-color: #f2f6fb !important;
}

.psa-active-company-table tbody tr:hover > td,
.psa-active-company-table tbody tr:nth-child(even):hover > td,
.psa-excluded-company-table tbody tr:hover > td,
.psa-excluded-company-table tbody tr:nth-child(even):hover > td {
    background-color: #ffedd5 !important;
}

.psa-active-company-table .psa-row-action-cell,
.psa-excluded-company-table tbody td:last-child {
    width: 132px !important;
    min-width: 132px !important;
    text-align: right !important;
    vertical-align: middle !important;
}

.psa-active-company-table .psa-company-action-button,
.psa-excluded-company-table .psa-company-action-button {
    width: 112px !important;
    min-width: 112px !important;
    height: 36px !important;
    min-height: 36px !important;
    margin: 0 !important;
}

/* PSA preview line cleanup */
/* Remove old action/status accent bars from the left edge of PSA rows. */
.psa-preview-table,
.psa-preview-table thead,
.psa-preview-table tbody,
.psa-preview-table tr,
.psa-preview-table th,
.psa-preview-table td,
.psa-preview-table tr::before,
.psa-preview-table td::before {
    border-left: 0 !important;
    box-shadow: none !important;
}

.psa-preview-table tr::before,
.psa-preview-table td::before {
    content: none !important;
    display: none !important;
}

/* The action column must match in both the active and excluded lists. */
.psa-preview-table th:last-child,
.psa-preview-table td:last-child {
    border-left: 0 !important;
    border-right: 0 !important;
}

/* Keep normal separators between data columns, but never before the action button. */
.psa-preview-table td:nth-last-child(2),
.psa-preview-table th:nth-last-child(2) {
    border-right: 0 !important;
}

.psa-preview-table .app-link-action {
    border-left: 0 !important;
    box-shadow: none !important;
}



/* Selected IQ trading branch */
.nav-branch-current {
    margin-top: 4px;
    color: rgba(255,255,255,.78);
    font-size: .75rem;
    font-weight: 700;
}

.nav-branch-selector {
    display: grid;
    gap: 4px;
    margin-top: 8px;
}

.nav-branch-selector span {
    color: rgba(255,255,255,.68);
    font-size: .68rem;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.nav-branch-selector select {
    width: 100%;
    min-height: 34px;
    padding: 6px 28px 6px 9px;
    color: #17365f;
    font-size: .78rem;
    font-weight: 750;
    background: #fff;
    border: 1px solid rgba(255,255,255,.48);
    border-radius: 8px;
}


/* PSA preview filter pills */
.psa-filter-pill {
    cursor: pointer;
    font: inherit;
    border: 1px solid transparent;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.psa-filter-pill:hover {
    border-color: rgba(23, 54, 95, .35);
}

.psa-filter-pill:focus-visible {
    outline: 2px solid #17365f;
    outline-offset: 2px;
}

.psa-filter-pill.is-active {
    background: #17365f;
    border-color: #17365f;
    color: #fff;
}


/* PSA services workspace */
.psa-preview-section {
    margin-top: 1.25rem;
    padding: 1rem;
    border: 1px solid rgba(23, 54, 95, .14);
    border-radius: 14px;
    background: #fff;
}

.psa-preview-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.psa-preview-section-header h3 { margin: 0; }
.psa-preview-section-header p { margin: .25rem 0 0; color: #637083; }
.psa-preview-summary { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: flex-end; }
.psa-summary-create { background: #eaf7ef; color: #17643a; }
.psa-summary-update { background: #fff6dd; color: #765600; }
.psa-summary-conflict { background: #fdeceb; color: #992f28; }

.psa-service-write-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1rem 0;
    padding: .9rem 1rem;
    border: 1px solid #bed8c8;
    border-radius: 12px;
    background: #f4fbf6;
}

.psa-service-write-panel small { display: block; margin-top: .2rem; color: #58675e; }
.psa-service-warning { margin: .75rem 0 1rem; }
.app-notice.warning { background: #fff7df; border-color: #e6c96b; color: #6d5200; }
.app-button-danger { background: #a8322d; border-color: #a8322d; color: #fff; }
.app-button-danger:hover { background: #8d2925; border-color: #8d2925; }
.psa-period-cell { white-space: nowrap; font-weight: 600; }

@media (max-width: 850px) {
    .psa-preview-section-header,
    .psa-service-write-panel { flex-direction: column; align-items: stretch; }
    .psa-preview-summary { justify-content: flex-start; }
}

/* Keep the PSA preview readable on narrower screens. */
.psa-preview-table {
    width: 100%;
    min-width: 1180px;
    table-layout: auto;
}

.psa-preview-table th,
.psa-preview-table td {
    word-break: normal;
    overflow-wrap: normal;
    white-space: normal;
    vertical-align: top;
}

/* Stable widths for compact columns. */
.psa-preview-table .psa-source-cell {
    min-width: 110px;
    width: 110px;
}

.psa-preview-table .psa-name-cell {
    min-width: 270px;
    width: 30%;
}

.psa-preview-table .psa-id-cell {
    min-width: 105px;
    width: 105px;
}

.psa-preview-table .psa-action-cell {
    min-width: 135px;
    width: 135px;
}

.psa-preview-table .psa-match-cell {
    min-width: 180px;
    width: 180px;
}

/* Give


/* PSA SERVICES TABLE FINAL OVERRIDE */
.psa-services-section .psa-preview-table th:last-child,
.psa-services-section .psa-preview-table td:last-child {
    display: none !important;
}
.psa-services-section .psa-preview-table {
    width: 100% !important;
    min-width: 1320px !important;
    table-layout: fixed !important;
}
.psa-services-section .psa-preview-table th,
.psa-services-section .psa-preview-table td {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
}
.psa-services-section .psa-preview-table th:nth-child(1),
.psa-services-section .psa-preview-table td:nth-child(1) { width: 110px !important; }
.psa-services-section .psa-preview-table th:nth-child(2),
.psa-services-section .psa-preview-table td:nth-child(2) { width: 300px !important; }
.psa-services-section .psa-preview-table th:nth-child(3),
.psa-services-section .psa-preview-table td:nth-child(3) { width: 105px !important; }
.psa-services-section .psa-preview-table th:nth-child(4),
.psa-services-section .psa-preview-table td:nth-child(4) { width: 120px !important; }
.psa-services-section .psa-preview-table th:nth-child(5),
.psa-services-section .psa-preview-table td:nth-child(5) { width: 145px !important; }
.psa-services-section .psa-preview-table th:nth-child(6),
.psa-services-section .psa-preview-table td:nth-child(6) { width: 180px !important; }
.psa-services-section .psa-preview-table th:nth-child(7),
.psa-services-section .psa-preview-table td:nth-child(7),
.psa-services-section .psa-preview-table .psa-difference-cell {
    width: 360px !important;
    min-width: 360px !important;
    max-width: none !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
}
.psa-services-section .app-table-wrap {
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
}


/* PSA SERVICE ADOPTION FINAL OVERRIDE */
.psa-services-section .psa-preview-table th:last-child,
.psa-services-section .psa-preview-table td:last-child {
    display: table-cell !important;
    width: 120px !important;
    min-width: 120px !important;
    white-space: nowrap !important;
}
.psa-services-section .psa-preview-table th:nth-child(7),
.psa-services-section .psa-preview-table td:nth-child(7),
.psa-services-section .psa-preview-table .psa-difference-cell {
    width: 340px !important;
    min-width: 340px !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
}
.psa-services-section .psa-adopt-button {
    min-width: 84px;
}

/* PSA PAGE OVERFLOW CONTAINMENT */

/*
 * The Services table is wider than the viewport. Keep that overflow inside
 * its own table wrapper instead of allowing it to widen the whole page.
 */
.psa-preview-section,
.psa-services-section,
.psa-preview-section > *,
.psa-services-section > *,
.psa-services-section .app-table-wrap {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

.psa-services-section {
    width: 100% !important;
    overflow: hidden;
}

.psa-services-section .app-table-wrap {
    display: block;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

/*
 * The table can remain wide, but only the wrapper may scroll.
 * It must not establish the minimum width of the page.
 */
.psa-services-section .psa-preview-table {
    width: 1320px !important;
    min-width: 1320px !important;
    max-width: none !important;
    margin: 0;
}

/* Keep the Services summary and write controls inside the card. */
.psa-preview-section-header,
.psa-service-write-panel,
.psa-service-adoption-panel {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
}

.psa-preview-section-header > *,
.psa-service-write-panel > *,
.psa-service-adoption-panel > * {
    min-width: 0;
}

/*
 * Prevent buttons from forcing their parent wider while keeping their
 * text readable.
 */
.psa-services-section .app-actions {
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
}

.psa-services-section .app-button {
    max-width: 100%;
}

/* Preserve the Adopt action column. */
.psa-services-section .psa-preview-table th:last-child,
.psa-services-section .psa-preview-table td:last-child {
    display: table-cell !important;
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
    white-space: nowrap !important;
}

/* Keep the explanation column readable. */
.psa-services-section .psa-preview-table th:nth-child(7),
.psa-services-section .psa-preview-table td:nth-child(7),
.psa-services-section .psa-difference-cell {
    width: 340px !important;
    min-width: 340px !important;
    max-width: 340px !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
}


/* PSA PREVIEW GRID BLOWOUT FIX */
/* .app-page is a grid. Its auto minimum track was expanding to the
   intrinsic width of the preview table after Run Preview. */
.app-content-frame > .app-page {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 1440px !important;
    grid-template-columns: minmax(0, 1fr) !important;
}

/* Grid children default to min-width:auto. Let PSA cards shrink to the
   available main-content width instead of widening the entire shell. */
.app-content-frame > .app-page > *,
.app-content-frame > .app-page > .app-card,
.app-content-frame > .app-page .psa-preview-section,
.app-content-frame > .app-page .psa-services-section {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Keep the wide Services table local to its wrapper. */
.app-content-frame > .app-page .psa-services-section .app-table-wrap {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
}

.app-content-frame > .app-page .psa-services-section .psa-preview-table {
    width: 1440px !important;
    min-width: 1440px !important;
    max-width: none !important;
}

/* Prevent preview content from establishing a page-wide intrinsic width. */
.app-content-frame > .app-page .psa-preview-section-header,
.app-content-frame > .app-page .psa-service-write-panel,
.app-content-frame > .app-page .psa-service-adoption-panel {
    min-width: 0 !important;
    max-width: 100% !important;
    flex-wrap: wrap !important;
}


/* PSA SERVICES FIT WITHOUT HORIZONTAL SCROLL */
/* Override earlier 1320/1440px table rules. The Services table now shares
   the available card width instead of requiring horizontal scrolling. */
.app-content-frame > .app-page .psa-services-section .app-table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
}

.app-content-frame > .app-page .psa-services-section .psa-preview-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: fixed !important;
}

.psa-services-section .psa-preview-table th,
.psa-services-section .psa-preview-table td {
    min-width: 0 !important;
    max-width: none !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    hyphens: none !important;
}

/* Services columns: Source, Name, ID, Period, Action, Match, Difference, Adopt. */
.psa-services-section .psa-preview-table th:nth-child(1),
.psa-services-section .psa-preview-table td:nth-child(1) { width: 8% !important; }
.psa-services-section .psa-preview-table th:nth-child(2),
.psa-services-section .psa-preview-table td:nth-child(2) { width: 21% !important; }
.psa-services-section .psa-preview-table th:nth-child(3),
.psa-services-section .psa-preview-table td:nth-child(3) { width: 8% !important; }
.psa-services-section .psa-preview-table th:nth-child(4),
.psa-services-section .psa-preview-table td:nth-child(4) { width: 9% !important; }
.psa-services-section .psa-preview-table th:nth-child(5),
.psa-services-section .psa-preview-table td:nth-child(5) { width: 11% !important; }
.psa-services-section .psa-preview-table th:nth-child(6),
.psa-services-section .psa-preview-table td:nth-child(6) { width: 13% !important; }
.psa-services-section .psa-preview-table th:nth-child(7),
.psa-services-section .psa-preview-table td:nth-child(7),
.psa-services-section .psa-preview-table .psa-difference-cell {
    width: 23% !important;
    min-width: 0 !important;
    max-width: none !important;
}
.psa-services-section .psa-preview-table th:nth-child(8),
.psa-services-section .psa-preview-table td:nth-child(8),
.psa-services-section .psa-preview-table th:last-child,
.psa-services-section .psa-preview-table td:last-child {
    display: table-cell !important;
    width: 7% !important;
    min-width: 0 !important;
    max-width: none !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    white-space: normal !important;
}

.psa-services-section .psa-adopt-button {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 9px 8px !important;
}

@media (max-width: 1100px) {
    .psa-services-section .psa-preview-table {
        font-size: .9rem;
    }
    .psa-services-section .psa-preview-table th,
    .psa-services-section .psa-preview-table td {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

.nav-branch-logo{display:block;max-width:150px;max-height:64px;margin:8px 0 10px;object-fit:contain;border-radius:6px;background:#fff;padding:4px}

@media print { .no-print { display: none !important; } }

/* Procurement */
.app-muted{color:var(--app-muted)}
.app-input-narrow{width:6.5rem}
.app-row-muted{opacity:.6}
.app-inline-check{display:inline-flex;align-items:center;gap:8px}
.app-visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
