* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f7f8;
    color: #1b242c;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

body.customer-portal-shell {
    background: #f7f8fa;
}

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

code {
    background: #edf1f3;
    border-radius: 4px;
    padding: 2px 5px;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid #dfe6ea;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.customer-portal-shell .topbar {
    border-bottom-color: rgba(17, 31, 43, 0.08);
    box-shadow: 0 8px 28px rgba(23, 38, 52, 0.06);
}

.brand,
.nav,
.nav form {
    align-items: center;
    display: flex;
    gap: 12px;
}

.brand-logo {
    display: block;
    height: 38px;
    object-fit: contain;
    max-width: 140px;
    width: auto;
}

.brand-name {
    color: #1b242c;
    font-size: 18px;
    font-weight: 700;
}

.nav a,
.nav-user {
    color: #4e5d68;
    font-size: 14px;
}

.page {
    margin: 0 auto;
    max-width: 1180px;
    padding: 32px 24px 56px;
}

.auth-shell {
    align-content: center;
    display: grid;
    gap: 22px;
    min-height: calc(100vh - 128px);
    justify-items: center;
}

.auth-logo {
    display: block;
    max-width: min(300px, 78vw);
    width: 100%;
}

.auth-panel {
    background: #ffffff;
    border: 1px solid #dfe6ea;
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(23, 38, 52, 0.08);
    display: grid;
    gap: 16px;
    max-width: 420px;
    padding: 28px;
    width: 100%;
}

.auth-help {
    color: #60707c;
    font-size: 13px;
    margin: -4px 0 0;
}

.section-head,
.mini-head,
.portal-hero {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 22px;
}

.compact-head {
    margin: 18px 0 10px;
}

.portal-hero {
    background: var(--brand-primary);
    color: #ffffff;
    isolation: isolate;
    margin: -32px -24px 30px;
    overflow: hidden;
    padding: 38px 24px;
    position: relative;
}

.portal-hero::after {
    background: var(--brand-accent);
    bottom: 0;
    content: "";
    height: 5px;
    left: 0;
    opacity: 0.95;
    position: absolute;
    right: 0;
    z-index: 0;
}

.portal-hero > * {
    position: relative;
    z-index: 1;
}

.portal-hero-copy {
    align-items: center;
    display: flex;
    gap: 20px;
    min-width: 0;
}

.portal-logo-card {
    align-items: center;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.14);
    display: flex;
    flex: 0 0 auto;
    height: 100px;
    justify-content: center;
    padding: 16px;
    width: 180px;
}

.portal-hero img {
    background: #ffffff;
    border-radius: 6px;
    max-height: 70px;
    max-width: 220px;
    object-fit: contain;
    padding: 10px;
}

.portal-logo-card img {
    background: transparent;
    border-radius: 0;
    max-height: 100%;
    max-width: 100%;
    padding: 0;
}

.portal-hero-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: flex-end;
}

.portal-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.portal-action-buttons .button {
    white-space: nowrap;
}

.portal-subtitle {
    color: rgba(255, 255, 255, 0.78);
    font-weight: 700;
    margin: 9px 0 0;
}

.portal-stats {
    align-items: stretch;
    display: flex;
    gap: 8px;
}

.portal-stats span {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    display: grid;
    min-width: 88px;
    padding: 10px 12px;
    text-align: center;
}

.portal-stats strong {
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
}

.portal-stats small {
    color: rgba(255, 255, 255, 0.76);
    font-size: 12px;
    font-weight: 700;
    margin-top: 5px;
    text-transform: uppercase;
}

.portal-section {
    display: grid;
    gap: 10px;
}

.business-card-order-section {
    margin-bottom: 0;
}

.portal-secondary-grid {
    align-items: start;
}

.eyebrow {
    color: var(--brand-accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 6px;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.1;
}

h2 {
    font-size: 19px;
    margin-bottom: 14px;
}

p {
    line-height: 1.5;
}

.button {
    align-items: center;
    background: var(--brand-primary);
    border: 1px solid var(--brand-primary);
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
}

.button.ghost {
    background: #ffffff;
    color: var(--brand-primary);
}

.button.danger {
    background: #9f2d2d;
    border-color: #9f2d2d;
}

.button.small {
    min-height: 32px;
    padding: 6px 10px;
}

.button.full {
    width: 100%;
}

.grid {
    display: grid;
    gap: 24px;
    margin: 26px 0;
}

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

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

.portal-primary-grid {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.portal-column-stack {
    align-content: start;
    display: grid;
    gap: 24px;
}

.customer-detail-grid {
    margin-bottom: 36px;
}

.customer-detail-section + .customer-detail-section {
    margin-top: 36px;
}

.customer-order-stack {
    display: grid;
    gap: 28px;
}

.customer-order-section {
    display: grid;
    gap: 14px;
}

.customer-order-head {
    align-items: flex-end;
    border-bottom: 1px solid #dfe6ea;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding-bottom: 14px;
}

.customer-order-head h2 {
    margin-bottom: 8px;
}

.meta-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.list {
    background: #ffffff;
    border: 1px solid #dfe6ea;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(23, 38, 52, 0.05);
    overflow: hidden;
}

.compact-list .list-row {
    min-height: 58px;
}

.list-row {
    align-items: center;
    border-bottom: 1px solid #edf1f3;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-height: 64px;
    padding: 13px 16px;
}

.list-row:hover {
    background: #fbfcfd;
}

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

.list-row span:first-child {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.list-row-main {
    display: grid;
    flex: 1;
    gap: 4px;
    min-width: 0;
}

.row-actions {
    align-items: center;
    display: flex;
    gap: 10px;
}

.row-actions form {
    margin: 0;
}

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

.inventory-card {
    background: #ffffff;
    border: 1px solid #dfe6ea;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(23, 38, 52, 0.05);
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    min-height: 266px;
    overflow: hidden;
}

.inventory-image-link {
    align-items: center;
    background: #ffffff;
    border-right: 1px solid #edf1f3;
    display: flex;
    justify-content: center;
    min-height: 132px;
    padding: 10px;
}

.inventory-image-link:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: -2px;
}

.inventory-thumb {
    aspect-ratio: 1 / 1;
    background: transparent;
    display: block;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.inventory-thumb.small-thumb {
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #edf1f3;
    flex: 0 0 auto;
    height: 52px;
    padding: 3px;
    width: 52px;
}

.inventory-list-row {
    justify-content: flex-start;
}

.inventory-list-row .list-row-main {
    flex: 1;
}

.inventory-card-body {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.inventory-card-body p {
    color: #60707c;
    margin: 5px 0 0;
}

.inventory-meta {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inventory-meta span {
    background: #edf1f3;
    border-radius: 999px;
    color: #4e5d68;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 9px;
}

.inventory-order-form {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(82px, 110px) auto;
    justify-content: start;
}

.inventory-order-form label {
    font-size: 13px;
}

.inventory-order-form input {
    min-height: 36px;
}

small {
    color: #60707c;
}

.empty {
    color: #60707c;
    margin: 0;
    padding: 18px;
}

.pill {
    background: #edf1f3;
    border-radius: 999px;
    color: #4e5d68;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 9px;
    text-transform: uppercase;
}

.pill.active,
.pill.submitted {
    background: #e5f4ec;
    color: #1f7048;
}

.pill.received,
.pill.in_print {
    background: #e8f1fb;
    color: #275f92;
}

.pill.complete {
    background: #e6f4f1;
    color: #116a64;
}

.pill.paused,
.pill.draft,
.pill.cancelled {
    background: #fff1dd;
    color: #8a5612;
}

.form-grid {
    background: #ffffff;
    border: 1px solid #dfe6ea;
    border-radius: 8px;
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 28px;
    padding: 22px;
}

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

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

.order-selector {
    margin-bottom: 24px;
}

.span-2 {
    grid-column: span 2;
}

label {
    color: #33424e;
    display: grid;
    font-weight: 700;
    gap: 7px;
}

input,
select,
textarea {
    border: 1px solid #cfd9df;
    border-radius: 6px;
    color: #1b242c;
    font: inherit;
    min-height: 42px;
    padding: 9px 10px;
    width: 100%;
}

textarea {
    resize: vertical;
}

.code-box {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
    line-height: 1.45;
}

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

.check input[type="checkbox"] {
    min-height: auto;
    width: auto;
}

.form-actions {
    align-items: end;
    display: flex;
}

.flash {
    border-radius: 6px;
    margin: 16px auto 0;
    max-width: 1120px;
    padding: 12px 16px;
}

.flash.success {
    background: #e5f4ec;
    color: #1f7048;
}

.flash.error {
    background: #fdeaea;
    color: #973333;
}

.flash.info {
    background: #e8f1fb;
    color: #275f92;
}

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

.template-tile {
    background: #ffffff;
    border: 1px solid #dfe6ea;
    border-radius: 8px;
    display: grid;
    overflow: hidden;
}

.template-tile img {
    aspect-ratio: 5 / 3;
    background: #edf1f3;
    object-fit: cover;
    width: 100%;
}

.template-tile span {
    display: grid;
    gap: 4px;
    padding: 14px;
}

.customer-template-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.customer-template-card {
    background: #ffffff;
    border: 1px solid #dfe6ea;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(23, 38, 52, 0.05);
    display: grid;
    overflow: hidden;
}

.customer-template-preview {
    background: #ffffff;
    border-bottom: 1px solid #edf1f3;
    display: grid;
    min-height: 138px;
    padding: 14px;
    place-items: center;
}

.customer-template-preview:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: -2px;
}

.customer-template-preview img {
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(23, 38, 52, 0.12);
    display: block;
    max-height: 148px;
    max-width: 100%;
    object-fit: contain;
}

.customer-template-body {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 14px;
}

.customer-template-body strong,
.customer-template-body small {
    min-width: 0;
}

.customer-template-body small {
    grid-column: 1;
}

.customer-template-body .button {
    grid-column: 2;
    grid-row: 1 / span 2;
    white-space: nowrap;
}

.proof-builder,
.proof-viewer {
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
}

.template-preview,
.proof-images {
    background: #ffffff;
    border: 1px solid #dfe6ea;
    border-radius: 8px;
}

.template-preview {
    display: grid;
    min-height: 360px;
    place-items: center;
    padding: 20px;
}

.template-preview img {
    box-shadow: 0 12px 30px rgba(23, 38, 52, 0.12);
    max-height: 520px;
    max-width: 100%;
}

.proof-form,
.proof-viewer aside {
    background: #ffffff;
    border: 1px solid #dfe6ea;
    border-radius: 8px;
    display: grid;
    gap: 16px;
    padding: 20px;
}

.proof-images {
    display: grid;
    gap: 20px;
    padding: 20px;
}

.proof-images figure {
    display: grid;
    gap: 8px;
    margin: 0;
}

.proof-images img {
    box-shadow: 0 12px 30px rgba(23, 38, 52, 0.12);
    display: block;
    height: auto;
    max-width: 100%;
}

.proof-images figcaption {
    color: #60707c;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

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

.copy-field {
    background: #f5f7f8;
    color: #4e5d68;
}

.field-error {
    color: #973333;
}

.status-line {
    background: #e5f4ec;
    border-radius: 6px;
    color: #1f7048;
    margin: 0;
    padding: 12px;
}

@media (max-width: 900px) {
    .grid.two,
    .grid.three,
    .inventory-card,
    .inventory-order-form,
    .form-grid,
    .form-grid.compact,
    .form-grid.wide,
    .template-grid,
    .proof-builder,
    .proof-viewer {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .topbar,
    .section-head,
    .portal-hero,
    .customer-order-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .portal-hero-copy {
        align-items: flex-start;
        flex-direction: column;
    }

    .portal-logo-card {
        height: 92px;
        width: min(220px, 100%);
    }

    .portal-hero-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .portal-action-buttons {
        justify-content: flex-start;
    }

    .portal-stats {
        flex-wrap: wrap;
        width: 100%;
    }

    .portal-stats span {
        flex: 1 1 92px;
    }

    .nav {
        flex-wrap: wrap;
    }

    .inventory-image-link {
        border-bottom: 1px solid #edf1f3;
        border-right: 0;
    }

    .inventory-thumb {
        max-height: 240px;
    }

    .customer-template-body {
        grid-template-columns: 1fr;
    }

    .customer-template-body small,
    .customer-template-body .button {
        grid-column: auto;
        grid-row: auto;
    }
}
