:root {
    --ink: #062652;
    --muted: #52677c;
    --forest: #031631;
    --forest-soft: #e6f5f8;
    --accent: #13b7d4;
    --accent-deep: #087f99;
    --cream: #eef3f5;
    --paper: #fff;
    --line: rgba(9, 54, 94, .14);
    --shadow: 0 18px 50px rgba(10, 49, 78, .09);
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    background: var(--cream);
    color: var(--ink);
    font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 74% 12%, rgba(22, 174, 201, .13), transparent 34rem),
        radial-gradient(circle at 12% 7%, rgba(26, 90, 146, .09), transparent 30rem),
        linear-gradient(145deg, #f8fafb, #eef3f5 58%, #e5edf1);
}

button, a { font: inherit; }
a { color: inherit; }
h1, h2, p { margin-top: 0; }

h1, h2 {
    font-family: "Manrope", system-ui, sans-serif;
    font-weight: 500;
    letter-spacing: -.045em;
}

.site-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
}

.site-header, .site-footer {
    width: min(1280px, calc(100% - 64px));
    margin-inline: auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 104px;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    display: block;
    width: 180px;
    height: auto;
}

.site-context {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

main { display: block; }

.site-footer {
    display: flex;
    min-height: 82px;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.footer-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--accent);
}

.landing, .message-page, .order-page {
    width: min(1100px, calc(100% - 48px));
    margin-inline: auto;
}

.login-page, .portal-page {
    width: min(1100px, calc(100% - 48px));
    margin-inline: auto;
}

.login-page {
    display: grid;
    min-height: calc(100vh - 186px);
    place-items: center;
    padding-block: 48px;
}

.login-card {
    width: min(480px, 100%);
    padding: clamp(28px, 5vw, 48px);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .86);
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin-bottom: 12px;
    color: var(--forest);
    font-size: clamp(32px, 5vw, 46px);
}

.login-card > p {
    color: var(--muted);
    line-height: 1.65;
}

.login-form {
    display: grid;
    gap: 17px;
    margin-top: 26px;
}

.login-form label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.login-form input {
    width: 100%;
    min-height: 48px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: 500 15px "Manrope", sans-serif;
    outline: none;
}

.login-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(19, 183, 212, .14);
}

.portal-action { width: 100%; margin-top: 4px; }

.form-error {
    margin-top: 18px;
    padding: 12px 14px;
    border: 1px solid rgba(155, 50, 42, .18);
    border-radius: 8px;
    background: rgba(155, 50, 42, .08);
    color: #7d2c25;
    font-size: 13px;
    line-height: 1.5;
}

.portal-page { padding-block: clamp(38px, 6vw, 70px); }

.portal-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.portal-heading h1 {
    margin-bottom: 8px;
    color: var(--forest);
    font-size: clamp(36px, 5vw, 54px);
}

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

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

.secondary-action, .open-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 15px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, .75);
    color: var(--forest);
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

.open-order {
    min-height: 34px;
    border-color: rgba(19, 183, 212, .35);
    background: var(--forest-soft);
    color: var(--accent-deep);
    font-size: 12px;
}

.portal-orders {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.portal-table td { white-space: nowrap; }
.portal-table td:first-child { color: var(--forest); }
.empty-orders { margin: 0; padding: 34px; color: var(--muted); text-align: center; }

.profile-page { max-width: 940px; }

.profile-form {
    display: grid;
    gap: 18px;
}

.profile-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 19px 22px;
    padding: 26px;
}

.profile-grid label {
    display: grid;
    align-content: start;
    gap: 7px;
    color: var(--ink);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.profile-grid .field-wide { grid-column: span 2; }

.city-fields {
    display: grid;
    grid-template-columns: 120px minmax(220px, 1fr);
    gap: 22px;
}

.profile-grid input, .profile-grid select {
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: 500 14px "Manrope", sans-serif;
    outline: none;
    text-transform: none;
}

.profile-grid input:focus, .profile-grid select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(19, 183, 212, .14);
}

.profile-grid input[readonly],
.profile-grid input:disabled {
    background: #f2f5f4;
    color: var(--muted);
    cursor: not-allowed;
    opacity: 1;
}

.profile-grid small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.5;
    text-transform: none;
}

.profile-grid .validation-message {
    color: #7d2c25;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.profile-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 4px;
}

.profile-actions .primary-action,
.profile-actions .secondary-action {
    box-sizing: border-box;
    min-height: 44px;
    margin-top: 0;
    padding: 10px 18px;
    border-radius: 8px;
    font: 700 14px "Manrope", sans-serif;
    line-height: 1;
}

.profile-actions .primary-action { border: 0; cursor: pointer; }
.profile-actions .primary-action:disabled { cursor: wait; opacity: .65; }

.form-success, .sync-status {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(33, 119, 90, .2);
    border-radius: 9px;
    background: rgba(33, 119, 90, .08);
    color: #185f49;
    font-size: 13px;
    font-weight: 650;
}

.sync-status {
    display: grid;
    gap: 4px;
    border-color: rgba(8, 127, 153, .2);
    background: rgba(19, 183, 212, .08);
    color: var(--accent-deep);
}

.sync-status small { color: var(--muted); font-weight: 500; }
.sync-status--error { border-color: rgba(155, 50, 42, .2); background: rgba(155, 50, 42, .08); color: #7d2c25; }
.sync-status--success { border-color: rgba(33, 119, 90, .2); background: rgba(33, 119, 90, .08); color: #185f49; }
.validation-summary { margin: 0; }

.landing, .message-page {
    display: grid;
    min-height: calc(100vh - 168px);
    place-items: center;
    padding-block: 54px;
}

.landing-card, .message-card, .loading-card {
    width: min(620px, 100%);
    padding: clamp(32px, 6vw, 64px);
    border: 1px solid rgba(20, 53, 47, .09);
    border-radius: 12px;
    background: rgba(255, 255, 255, .82);
    box-shadow: var(--shadow);
    text-align: center;
    backdrop-filter: blur(18px);
}

.eyebrow, .section-kicker, .message-code {
    display: block;
    margin-bottom: 12px;
    color: var(--accent-deep);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.landing-card h1, .message-card h1 {
    margin-bottom: 18px;
    color: var(--forest);
    font-size: clamp(34px, 6vw, 54px);
    line-height: 1.05;
}

.landing-card > p, .message-card > p {
    max-width: 470px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.7;
}

.privacy-note {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding: 12px 16px;
    border-radius: 999px;
    background: var(--forest-soft);
    color: var(--forest);
    font-size: 13px;
    font-weight: 600;
}

.privacy-icon {
    width: 9px;
    height: 9px;
    border: 2px solid var(--accent-deep);
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(19, 183, 212, .14);
}

.primary-action {
    margin-top: 28px;
    padding: 13px 22px;
    border: 0;
    border-radius: 8px;
    background: var(--forest);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

.primary-action:hover { background: #082f64; }

.order-page { padding-block: clamp(44px, 7vw, 84px); }

.login-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 20px;
    padding: 17px 20px;
    border: 1px solid rgba(8, 127, 153, .24);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    background: rgba(230, 245, 248, .86);
    box-shadow: 0 10px 28px rgba(10, 49, 78, .05);
}

.login-hint div { display: grid; gap: 4px; }
.login-hint strong { color: var(--forest); font-size: 14px; }
.login-hint span { color: var(--muted); font-size: 12px; }

.login-hint-action {
    flex: 0 0 auto;
    padding: 8px 13px;
    border-radius: 7px;
    background: var(--forest);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.login-hint-action:hover { background: #082f64; }

.price-blurred {
    display: inline-block;
    filter: blur(5px);
    pointer-events: none;
    user-select: none;
}

.order-navigation {
    width: min(1100px, calc(100% - 48px));
    margin-inline: auto;
    padding-top: clamp(28px, 4vw, 52px);
}

.order-navigation + .order-page { padding-top: 20px; }
.order-back-action { align-self: center; }
.order-back-form { display: flex; align-items: center; margin: 0; }

.order-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 34px;
}

.order-hero h1 {
    margin-bottom: 10px;
    color: var(--forest);
    font-size: clamp(36px, 5.2vw, 58px);
    font-weight: 500;
    line-height: .98;
}

.customer-name {
    margin: 0;
    color: var(--muted);
    font-size: clamp(17px, 2vw, 21px);
}

.purchase-order {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.purchase-order span {
    font-weight: 600;
}

.purchase-order strong {
    color: var(--accent-deep);
    font-weight: 700;
}

.hero-meta {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    gap: 12px;
}

.status-badge {
    min-width: 112px;
    padding: 14px 18px;
    border: 1px solid rgba(8, 127, 153, .18);
    border-radius: 9px;
    background: rgba(230, 245, 248, .82);
    color: var(--forest);
    text-align: center;
}

.status-badge span {
    display: block;
    margin-bottom: 2px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.status-badge strong { font-size: 18px; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
    margin-bottom: 26px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, .76);
    box-shadow: 0 12px 34px rgba(10, 49, 78, .05);
    backdrop-filter: blur(12px);
}

.summary-item {
    min-height: 118px;
    padding: 24px;
    border-right: 1px solid var(--line);
}

.summary-item:last-child { border-right: 0; }

.summary-item span, .detail-card span, .note-card > span {
    display: block;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.summary-item strong {
    display: block;
    color: var(--ink);
    font-size: 16px;
    line-height: 1.45;
}

.summary-item .money {
    color: var(--forest);
    font-size: 20px;
}

.order-section {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 26px 30px;
    border-bottom: 1px solid var(--line);
}

.section-heading .section-kicker { margin-bottom: 5px; }

.section-heading h2 {
    margin: 0;
    color: var(--forest);
    font-size: 24px;
}

.item-count {
    padding: 7px 11px;
    border-radius: 999px;
    background: var(--cream);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

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

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.items-table th, .items-table td {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.items-table th {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.items-table .description {
    width: 100%;
    min-width: 230px;
    color: var(--ink);
    font-weight: 600;
    white-space: normal;
}

.items-table .numeric { text-align: right; }

.items-table .total-cell {
    color: var(--forest);
    font-weight: 700;
}

.items-table tbody tr:last-child td { border-bottom: 0; }

.items-table tfoot td {
    padding-block: 21px;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: #f9faf9;
    color: var(--forest);
    font-weight: 700;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.detail-card, .note-card {
    padding: 22px 24px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(10px);
}

.detail-card strong {
    display: block;
    color: var(--ink);
    line-height: 1.5;
}

.detail-card small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    line-height: 1.4;
}

.detail-card .vendor-order {
    color: var(--accent-deep);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
}

.delivery-card {
    display: grid;
    grid-column: span 2;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 0;
}

.delivery-field {
    min-width: 0;
    padding: 22px 24px;
}

.delivery-field + .delivery-field {
    border-left: 1px solid var(--line);
}

.fiscal-card {
    border-color: rgba(19, 183, 212, .48);
    background: linear-gradient(135deg, rgba(255, 255, 255, .94), rgba(222, 246, 250, .92));
    box-shadow: 0 14px 36px rgba(8, 127, 153, .12);
}

.fiscal-card strong {
    color: var(--forest);
    font-size: 19px;
}

.fiscal-card--hero {
    min-width: 230px;
    padding: 15px 18px;
    border: 1px solid rgba(19, 183, 212, .55);
    border-radius: 9px;
}

.fiscal-card--hero span {
    display: block;
    margin-bottom: 3px;
    color: var(--accent-deep);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.fiscal-card--hero strong {
    display: block;
    color: var(--forest);
    font-size: 20px;
    line-height: 1.35;
}

.fiscal-card--hero small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.note-card { margin-top: 16px; }

.order-observation {
    position: relative;
    overflow: hidden;
    margin-top: 18px;
    padding: 25px 28px;
    border-color: rgba(8, 127, 153, .2);
    background: linear-gradient(100deg, rgba(255, 255, 255, .84), rgba(234, 246, 248, .72));
    box-shadow: 0 12px 34px rgba(10, 49, 78, .06);
}

.order-observation::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
    content: "";
}

.order-observation > span {
    color: var(--accent-deep);
}

.note-card p {
    margin: 0;
    color: var(--ink);
    line-height: 1.65;
    white-space: pre-wrap;
}

.updated-note {
    margin: 26px 0 0;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.loading-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 15vh auto;
    padding: 28px;
    color: var(--muted);
}

.loading-card p { margin: 0; }

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--line);
    border-top-color: var(--forest);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.request-id {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1000;
    display: none;
    max-width: calc(100% - 36px);
    padding: 14px 42px 14px 16px;
    border-radius: 12px;
    background: #7d2c25;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .2);
    color: #fff;
}

#blazor-error-ui .reload {
    margin-left: 8px;
    font-weight: 700;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 11px;
    right: 14px;
    cursor: pointer;
}

h1:focus { outline: none; }

@media (max-width: 850px) {
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary-item:nth-child(2) { border-right: 0; }
    .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .details-grid { grid-template-columns: 1fr; }
    .delivery-card { grid-column: auto; }
    .order-hero { align-items: flex-start; }
    .hero-meta { flex-direction: column; }
}

@media (max-width: 640px) {
    .site-header, .site-footer, .landing, .message-page, .order-page, .order-navigation,
    .login-page, .portal-page {
        width: min(100% - 28px, 1100px);
    }

    .site-header { min-height: 84px; }
    .brand-logo { width: 145px; }
    .site-context { font-size: 10px; }
    .portal-heading { align-items: flex-start; }
    .portal-heading-actions { width: 100%; flex-wrap: wrap; }
    .order-page { padding-block: 38px; }
    .order-hero { flex-direction: column; }
    .order-hero h1 { font-size: 34px; }

    .hero-meta {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .login-hint { align-items: flex-start; flex-direction: column; }

    .fiscal-card--hero { flex: 1; min-width: 0; }

    .status-badge {
        min-width: 82px;
        padding: 11px 12px;
    }

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

    .delivery-field + .delivery-field {
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .summary-grid { grid-template-columns: 1fr; }

    .summary-item {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .summary-item:nth-child(3) { border-bottom: 1px solid var(--line); }
    .summary-item:last-child { border-bottom: 0; }
    .section-heading { padding: 22px 20px; }
    .items-table thead { display: none; }

    .items-table, .items-table tbody, .items-table tr, .items-table td {
        display: block;
        width: 100%;
    }

    .items-table tbody tr {
        padding: 17px 18px;
        border-bottom: 1px solid var(--line);
    }

    .items-table tbody tr:last-child { border-bottom: 0; }

    .items-table td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 18px;
        padding: 5px 0;
        border: 0;
        text-align: right;
        white-space: normal;
    }

    .items-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

    .items-table .description {
        min-width: 0;
        text-align: right;
    }

    .items-table .numeric { text-align: right; }
    .items-table tfoot { display: block; }

    .items-table tfoot tr {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 18px;
        background: #f9faf9;
    }

    .items-table tfoot td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        background: transparent;
    }

    .items-table tfoot td:first-child {
        flex: 1;
        text-align: left;
    }

    .profile-grid { grid-template-columns: 1fr; padding: 20px; }
    .profile-grid .field-wide { grid-column: auto; }
    .city-fields { grid-template-columns: 92px minmax(0, 1fr); gap: 14px; }
    .profile-actions { align-items: stretch; flex-direction: column-reverse; }
    .profile-actions .primary-action, .profile-actions .secondary-action { width: 100%; }
}

@media print {
    body { background: #fff; }
    .site-header, .site-footer { width: 100%; }

    .order-page {
        width: 100%;
        padding: 24px 0;
    }

    .order-section, .summary-grid { box-shadow: none; }
}
