[hidden] { display: none !important; }

body[data-portal] { min-width: 320px; background: #f4f5f8; color: #171821; }
.portal-shell { min-height: 100vh; }
.portal-topbar { position: sticky; z-index: 20; top: 0; height: 72px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e6e7ec; background: rgba(255,255,255,.97); }
.portal-topbar .wordmark { flex: 0 0 auto; font-size: 29px; }
.portal-topbar-right { display: flex; align-items: center; gap: 18px; }
.portal-role-pill { padding: 0; color: #686a77; background: transparent; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.portal-role-agent { color: #397849; }
.portal-logout { min-height: 36px; padding: 0 12px; border: 1px solid #e1e2e8; border-radius: 8px; color: #4d4f5a; background: #fff; font-size: 13px; font-weight: 600; transition: border-color .16s ease, color .16s ease, background .16s ease; }
.portal-logout:hover { border-color: #d2caff; color: #4524c5; background: #f8f7ff; }
.portal-main { max-width: none; margin: 0; padding: 0; }

.portal-login { width: min(1120px, 100%); min-height: calc(100vh - 72px); margin: 0 auto; padding: 64px 40px; display: grid; grid-template-columns: 1.2fr .85fr; align-items: center; gap: clamp(40px, 8vw, 108px); }
.portal-login-copy h1, .portal-heading h1 { margin: 0; color: #171821; font: 700 clamp(38px, 4.4vw, 58px)/1.05 'Manrope', sans-serif; letter-spacing: -.055em; }
.portal-login-copy h1 em { color: var(--purple); font-style: normal; }
.portal-login-copy > p:last-child { max-width: 390px; margin-top: 20px; color: #6c6e79; font-size: 15px; line-height: 1.65; }
.portal-login-card { padding: 30px; border: 1px solid #e1e3e9; border-radius: 14px; background: #fff; box-shadow: 0 14px 38px rgba(23,24,33,.06); }
.portal-login-card h2 { margin: 0; color: #171821; font: 700 24px/1.2 'Manrope', sans-serif; letter-spacing: -.04em; }
.portal-login-card > p:not(.portal-error) { margin: 8px 0 24px; color: #71737e; font-size: 13px; }
.portal-login-card label, .portal-form label { display: grid; gap: 7px; margin-bottom: 16px; color: #50525e; font-size: 12px; font-weight: 600; }
.portal-login-card input, .portal-form input, .portal-form select, .portal-form textarea { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid #dfe1e8; border-radius: 8px; outline: none; color: #171821; background: #fff; font: 400 13px/1.4 'DM Sans', sans-serif; transition: border-color .16s ease, box-shadow .16s ease; }
.portal-form textarea { min-height: 88px; padding: 10px 12px; resize: vertical; }
.portal-form input[type="file"] { padding: 9px 10px; }
.portal-login-card input:focus, .portal-form input:focus, .portal-form select:focus, .portal-form textarea:focus { border-color: #9d8af0; box-shadow: 0 0 0 3px rgba(90,53,222,.12); }
.portal-login-card input:focus-visible, .portal-form input:focus-visible, .portal-form select:focus-visible, .portal-form textarea:focus-visible, .portal-tab:focus-visible, .portal-small-button:focus-visible, .portal-logout:focus-visible { outline: 3px solid rgba(90,53,222,.28); outline-offset: 2px; }
.portal-primary-button { width: 100%; min-height: 46px; margin-top: 6px; display: flex; align-items: center; justify-content: center; gap: 10px; border-radius: 8px; color: #fff; background: var(--purple); font-size: 13px; font-weight: 700; transition: background .16s ease, transform .16s ease; }
.portal-primary-button:hover { background: var(--purple-dark); transform: translateY(-1px); }
.portal-demo-note { margin-top: 16px; padding: 10px 12px; border: 1px solid #eaebf0; border-radius: 8px; color: #777985; background: #f8f9fb; font-size: 11px; line-height: 1.5; }
.portal-demo-note code { color: #4e36bc; font-size: 11px; }
.portal-error { min-height: 16px; margin: 10px 0 0; color: #b54141; font-size: 12px; }

body[data-portal="admin"] #portal-app { min-height: calc(100vh - 72px); display: grid; grid-template-columns: 232px minmax(0, 1fr); }
body[data-portal="admin"] .portal-sidebar { position: sticky; top: 72px; height: calc(100vh - 72px); padding: 24px 14px; overflow-y: auto; border-right: 1px solid #e6e7ec; background: #fff; }
body[data-portal="agent"] #portal-app { max-width: 1320px; margin: 0 auto; padding: 54px 52px 88px; }
.portal-nav { display: grid; align-content: start; gap: 5px; }
.portal-tab { width: 100%; min-height: 46px; padding: 0 13px; display: flex; align-items: center; gap: 12px; border-radius: 8px; color: #616370; background: transparent; text-align: left; font: 500 14px/1.2 'DM Sans', sans-serif; transition: color .16s ease, background .16s ease; }
.portal-tab svg { width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.portal-tab:hover { color: #262735; background: #f5f5f8; }
.portal-tab.active { color: #4b31c1; background: #f0edff; font-weight: 700; }
body[data-portal="admin"] .portal-workspace { width: min(100%, 1600px); min-width: 0; margin: 0 auto; padding: 38px clamp(26px, 4vw, 60px) 72px; }
.portal-heading { margin-bottom: 30px; display: flex; align-items: end; justify-content: space-between; gap: 22px; }
.portal-heading .eyebrow { margin-bottom: 8px; color: #6d6f7b; font-size: 11px; letter-spacing: .08em; }
.portal-heading h1 { font-size: clamp(29px, 3vw, 36px); letter-spacing: -.045em; }
.portal-back-link { padding: 8px 0; display: inline-flex; align-items: center; gap: 8px; color: #4e36bc; font-size: 13px; font-weight: 600; white-space: nowrap; }
.portal-back-link:hover { color: #352397; }
.portal-back-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.portal-content { min-width: 0; }

.portal-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.portal-kpi { min-height: 136px; padding: 18px; border: 1px solid #e2e4eb; border-radius: 12px; background: #fff; }
.portal-kpi-heading { display: flex; align-items: center; gap: 10px; }
.portal-kpi-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 9px; color: #5439c8; background: #f0edff; }
.portal-kpi-icon-1 { color: #317456; background: #eaf5ef; }
.portal-kpi-icon-2 { color: #5b55a7; background: #f0effa; }
.portal-kpi-icon-3 { color: #596273; background: #f0f2f5; }
.portal-kpi-icon svg, .portal-overview-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.portal-kpi-label { color: #6f717d; font-size: 12px; font-weight: 500; }
.portal-kpi-value { margin-top: 15px; color: #171821; font: 700 30px/1 'Manrope', sans-serif; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.portal-panel { min-width: 0; margin-top: 22px; padding: 22px 0; border-top: 1px solid #e2e4eb; background: transparent; }
.portal-panel + .portal-panel { margin-top: 0; }
.portal-overview-total { display: grid; grid-template-columns: 48px minmax(0,1fr); align-items: start; gap: 16px; padding: 23px; border: 1px solid #e2e4eb; border-radius: 12px; background: #fff; }
.portal-overview-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; color: #5238c5; background: #f0edff; }
.portal-overview-icon svg { width: 21px; height: 21px; }
.portal-overview-copy { min-width: 0; }
.portal-panel-header, .portal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.portal-panel h2, .portal-toolbar h2 { margin: 0; color: #20212a; font: 650 17px/1.3 'Manrope', sans-serif; letter-spacing: -.025em; }
.portal-overview-total .portal-panel-header .eyebrow { margin: 0 0 5px; color: #737581; font-size: 10px; letter-spacing: .09em; }
.portal-panel-note { color: #777985; font-size: 12px; line-height: 1.5; }
.portal-overview-total .portal-kpi-value { margin-top: 13px; font-size: 38px; }
.portal-overview-total > .portal-overview-copy > .portal-panel-note { margin: 8px 0 0; }
.portal-qa-cleanup { margin-top: 18px; padding: 20px; border: 1px solid #dad5f4; border-radius: 12px; background: #fbfaff; }
.portal-qa-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.portal-qa-heading .eyebrow { margin: 0 0 5px; color: #6554a6; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.portal-qa-run { padding: 6px 9px; border: 1px solid #e2def6; border-radius: 999px; color: #50427e; background: #fff; font: 600 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.portal-qa-cleanup > p { max-width: 720px; margin: 10px 0 14px; color: #686a77; font-size: 12px; line-height: 1.55; }
.portal-qa-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.portal-qa-actions .portal-small-button:first-child { border-color: #5238c5; color: #fff; background: #5238c5; }
.portal-qa-actions .portal-small-button:first-child:hover { background: #432bac; }
.portal-qa-counts { margin-top: 14px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.portal-qa-counts span { min-height: 54px; padding: 9px 11px; display: grid; align-content: center; gap: 3px; border: 1px solid #e5e2f1; border-radius: 8px; color: #737581; background: #fff; font-size: 10px; }
.portal-qa-counts strong { color: #282632; font: 700 16px/1.1 'Manrope', sans-serif; }
.portal-qa-blockers, .portal-qa-success { margin: 12px 0 0; padding: 11px 12px; border-radius: 8px; font-size: 12px; line-height: 1.5; }
.portal-qa-blockers { display: grid; gap: 4px; color: #7c3a2a; background: #fff2ee; }
.portal-qa-success { color: #236247; background: #eaf5ef; }
.portal-qa-confirm { max-width: 480px; margin-top: 12px; padding: 14px; border-color: #e5e2f1; }
.portal-qa-confirm label { margin-bottom: 8px; }
.portal-qa-confirm code { color: #4b31c1; font-size: 11px; }
.portal-qa-confirm .portal-form-actions { margin-top: 8px; }

.portal-table-wrap { max-width: 100%; margin: 18px 0 0; overflow-x: auto; border-top: 1px solid #e2e4eb; border-bottom: 1px solid #e2e4eb; scrollbar-color: #d8d9e0 transparent; scrollbar-width: thin; }
.portal-table { width: 100%; min-width: 760px; border-collapse: collapse; color: #454752; font: 400 13px/1.45 'DM Sans', sans-serif; }
.portal-table th { padding: 13px 14px; color: #70727e; background: #fafbfc; font-size: 10px; font-weight: 700; letter-spacing: .07em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.portal-table td { padding: 15px 14px; border-top: 1px solid #eaebef; color: #51535f; vertical-align: middle; }
.portal-table tbody tr { transition: background .14s ease; }
.portal-table tbody tr:hover { background: #fbfbfd; }
.portal-table td:first-child { white-space: normal; }
.portal-table td strong { color: #20212a; font-weight: 650; }
.portal-table td:last-child { text-align: right; }
.portal-status { padding: 5px 9px; display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; color: #5c5e69; background: #f0f1f4; font-size: 11px; font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.portal-status::before { width: 6px; height: 6px; content: ''; border-radius: 50%; background: currentColor; opacity: .72; }
.portal-status.active, .portal-status.paid, .portal-status.completed { color: #26704c; background: #eaf5ef; }
.portal-status.pending, .portal-status.new, .portal-status.processing { color: #86650c; background: #fbf3da; }
.portal-status.inactive, .portal-status.failed, .portal-status.cancelled, .portal-status.refunded { color: #9b4545; background: #f9eded; }
.portal-empty { padding: 42px 16px !important; color: #777985 !important; text-align: center; font-size: 13px; }
.portal-toolbar { margin: 0 0 12px; }
.portal-toolbar .eyebrow { margin: 0 0 5px; color: #777985; font-size: 10px; letter-spacing: .08em; }
.portal-small-button { min-height: 35px; padding: 0 12px; border: 1px solid #dfe1e8; border-radius: 8px; color: #343641; background: #fff; font: 600 12px/1 'DM Sans', sans-serif; white-space: nowrap; transition: border-color .16s ease, color .16s ease, background .16s ease, transform .16s ease; }
.portal-small-button:hover { border-color: #c9bffa; color: #4b31c1; background: #f8f7ff; }
.portal-small-button.is-danger { border-color: #ead0d0; color: #9b4545; background: #fff; }
.portal-small-button.is-danger:hover { border-color: #d9aaaa; color: #8b3030; background: #fff5f5; }
.portal-form-actions .portal-small-button.is-danger { border-color: #ead0d0; color: #9b4545; background: #fff; }
.portal-form-actions .portal-small-button.is-danger:hover { border-color: #d9aaaa; color: #8b3030; background: #fff5f5; transform: none; }
.portal-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.portal-toolbar > .portal-small-button, .portal-form-actions .portal-small-button { border-color: #5238c5; color: #fff; background: #5238c5; }
.portal-toolbar > .portal-small-button:hover, .portal-form-actions .portal-small-button:hover { border-color: #432bac; color: #fff; background: #432bac; transform: translateY(-1px); }
.portal-form-actions .portal-small-button.is-danger:hover { border-color: #d9aaaa; color: #8b3030; background: #fff5f5; transform: none; }
.portal-confirm-backdrop { position: fixed; z-index: 1000; inset: 0; padding: 20px; display: grid; place-items: center; background: rgba(27,28,36,.44); backdrop-filter: blur(3px); }
.portal-confirm-dialog { width: min(100%, 440px); padding: 26px; border: 1px solid #e2e4eb; border-radius: 16px; background: #fff; box-shadow: 0 24px 70px rgba(25,23,45,.2); }
.portal-confirm-dialog .eyebrow { margin: 0 0 8px; color: #9b4545; font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.portal-confirm-dialog h2 { margin: 0; color: #20212a; font: 700 21px/1.25 'Manrope', sans-serif; letter-spacing: -.03em; overflow-wrap: anywhere; }
.portal-confirm-dialog > p:not(.eyebrow) { margin: 12px 0 0; color: #646673; font: 400 13px/1.6 'DM Sans', sans-serif; }
.portal-confirm-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 8px; }
.portal-confirm-actions .portal-small-button.is-danger { border-color: #b94a4a; color: #fff; background: #b94a4a; }
.portal-confirm-actions .portal-small-button.is-danger:hover { border-color: #9e3636; color: #fff; background: #9e3636; }
.portal-form { margin-top: 18px; padding: 22px; border: 1px solid #e2e4eb; border-radius: 12px; background: #fff; }
.portal-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.portal-form .full { grid-column: 1 / -1; }
.portal-form-actions { margin-top: 4px; display: flex; justify-content: flex-end; gap: 8px; }
.portal-table + .portal-form, .portal-table-wrap + .portal-form { margin-top: 20px; }
.portal-layout { display: grid; grid-template-columns: 190px minmax(0,1fr); align-items: start; gap: 28px; }
.agent-layout .portal-sidebar { position: static; height: auto; padding: 8px; border: 1px solid #e2e4eb; border-radius: 12px; background: #fff; }
.agent-layout .portal-tab { justify-content: flex-start; }
.agent-layout .portal-tab svg { display: none; }
.order-detail-card { margin-top: 18px; padding: 18px; border: 1px solid #e2e4eb; border-radius: 12px; background: #fff; }
.order-detail-card h3 { margin: 0; color: #20212a; font: 700 17px/1.3 'Manrope', sans-serif; letter-spacing: -.03em; }
.order-detail-meta { margin-top: 16px; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; color: #51535f; font-size: 12px; line-height: 1.5; }
.order-detail-meta span { display: grid; gap: 5px; }
.order-detail-meta strong { color: #777985; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.order-detail-footer { margin-top: 14px; display: grid; gap: 8px; }
.order-detail-footer > strong { color: #20212a; font: 700 16px/1.3 'Manrope', sans-serif; }
.order-detail-footer .portal-form { margin-top: 8px; }
.storefront-story-section + .storefront-story-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #e8e9ee; }
.storefront-story-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: #20212a; font-size: 13px; }
.storefront-story-heading span { color: #777985; font-size: 12px; }
.portal-link-box { margin-top: 18px; padding: 16px; border: 1px solid #ddd8fb; border-radius: 10px; color: #4b31c1; background: #f8f7ff; font-size: 12px; }
.portal-link-box code { display: block; margin-top: 8px; color: #352397; font-size: 12px; word-break: break-all; }
.variant-manager { margin-top: 24px; padding: 22px; border: 1px solid #dcdde6; border-radius: 14px; background: #fbfbfd; }
.variant-manager h3 { margin: 0; color: #20212a; font: 700 19px/1.3 'Manrope', sans-serif; }
.variant-manager h4 { margin: 0 0 12px; color: #20212a; font-size: 14px; }
.variant-manager-loading, .variant-manager-error { margin-top: 22px; padding: 18px; border-radius: 10px; background: #f5f5f9; color: #555766; font-size: 13px; }
.variant-manager-error { color: #9b3838; background: #fff3f2; }
.variant-manager .portal-panel-note { max-width: 760px; }
.variant-row-form { margin-top: 12px; }
.variant-row-heading { margin-bottom: 12px; display: flex; align-items: center; gap: 10px; color: #20212a; }
.variant-track-field { display: flex !important; align-items: center; justify-content: space-between; gap: 12px !important; }
.portal-form .variant-track-field input[type="checkbox"] { width: 18px; min-height: 18px; margin: 0; accent-color: #5b48cf; }
.variant-existing-options { margin-top: 16px; }
.variant-row-form .portal-form-actions { justify-content: flex-end; }
.variant-create-form { border-color: #dcd8f6; }
body[data-portal] .toast { bottom: 24px; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; box-shadow: 0 10px 30px rgba(23,24,33,.18); }

@media (max-width: 1050px) {
    body[data-portal="admin"] #portal-app { grid-template-columns: 210px minmax(0,1fr); }
    body[data-portal="admin"] .portal-workspace { padding: 34px 28px 60px; }
    .portal-kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 720px) {
    .portal-topbar { height: 64px; padding: 0 18px; }
    .portal-topbar .wordmark { font-size: 27px; }
    .portal-topbar-right { gap: 10px; }
    .portal-role-pill { display: none; }
    .portal-logout { min-height: 34px; padding: 0 10px; font-size: 12px; }
    .portal-login { min-height: calc(100vh - 64px); padding: 42px 20px 60px; display: block; }
    .portal-login-copy { margin-bottom: 32px; }
    .portal-login-copy h1 { font-size: clamp(40px, 12vw, 52px); }
    .portal-login-card { padding: 24px 20px; }
    body[data-portal="admin"] #portal-app { min-height: calc(100vh - 64px); display: block; }
    body[data-portal="agent"] #portal-app { padding: 27px 18px 52px; }
    body[data-portal="admin"] .portal-sidebar { position: sticky; z-index: 15; top: 64px; width: 100%; height: auto; padding: 8px 12px; overflow: visible; border-right: 0; border-bottom: 1px solid #e6e7ec; }
    .portal-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
    .portal-nav::-webkit-scrollbar { display: none; }
    .portal-tab { width: auto; min-height: 40px; padding: 0 11px; flex: 0 0 auto; gap: 7px; font-size: 12px; }
    .portal-tab svg { width: 16px; height: 16px; flex-basis: 16px; }
    body[data-portal="admin"] .portal-workspace { padding: 27px 18px 52px; }
    .portal-heading { margin-bottom: 22px; align-items: flex-start; }
    .portal-heading h1 { font-size: clamp(26px, 7.2vw, 32px); }
    .portal-heading .eyebrow { margin-bottom: 7px; }
    .portal-back-link { font-size: 12px; }
    .portal-kpi-grid { gap: 9px; }
    .portal-kpi { min-height: 116px; padding: 14px; }
    .portal-kpi-icon { width: 32px; height: 32px; flex-basis: 32px; }
    .portal-kpi-icon svg { width: 17px; height: 17px; }
    .portal-kpi-heading { gap: 8px; }
    .portal-kpi-label { font-size: 11px; }
    .portal-kpi-value { margin-top: 13px; font-size: 26px; }
    .portal-overview-total { grid-template-columns: 38px minmax(0,1fr); gap: 12px; padding: 17px; }
    .portal-overview-icon { width: 36px; height: 36px; }
    .portal-overview-icon svg { width: 18px; height: 18px; }
    .portal-overview-total .portal-panel-header { display: block; }
    .portal-overview-total .portal-panel-header > .portal-panel-note { display: block; margin-top: 8px; }
    .portal-overview-total h2 { font-size: 15px; }
    .portal-overview-total .portal-kpi-value { font-size: clamp(26px, 7vw, 34px); }
    .portal-qa-cleanup { padding: 16px 14px; }
    .portal-qa-heading { align-items: flex-start; }
    .portal-qa-run { max-width: 42%; overflow-wrap: anywhere; }
    .portal-qa-counts { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .portal-panel { padding: 18px 0; }
    .portal-toolbar, .portal-panel-header { align-items: flex-start; }
    .portal-toolbar h2, .portal-panel h2 { font-size: 16px; }
    .portal-table { min-width: 760px; }
    .portal-form { padding: 17px 14px; }
    .portal-form-grid { grid-template-columns: 1fr; }
    .portal-form .full { grid-column: auto; }
    .portal-form label { margin-bottom: 13px; }
    .portal-form-actions { justify-content: stretch; }
    .portal-form-actions button { flex: 1; }
    .portal-layout { display: block; }
    .agent-layout .portal-sidebar { margin-bottom: 16px; display: flex; gap: 4px; overflow-x: auto; }
    .agent-layout .portal-tab { width: auto; flex: 0 0 auto; }
    .order-detail-meta { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
