:root {
    color-scheme: light;
    --bg: #f8f1e7;
    --surface: rgba(255, 250, 245, 0.88);
    --line: rgba(33, 48, 73, 0.12);
    --text: #1f2d3d;
    --muted: #6d7587;
    --primary: #0f766e;
    --primary-strong: #115e59;
    --accent: #f97316;
    --warning: #9a3412;
    --shadow-xl: 0 26px 70px rgba(31, 45, 61, 0.12);
    --shadow-md: 0 12px 32px rgba(31, 45, 61, 0.08);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --footer-height: calc(80px + env(safe-area-inset-bottom, 0px));
}

* {
    box-sizing: border-box;
    touch-action: manipulation;
}

[hidden] {
    display: none !important;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    font-family: "Trebuchet MS", "Aptos", sans-serif;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(249, 115, 22, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.18), transparent 32%),
        linear-gradient(180deg, #fffaf2 0%, #f7efe3 50%, #f4eadb 100%);
}

.login-shell {
    width: min(520px, calc(100vw - 1.2rem));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    place-items: center;
    padding: 1rem 0;
}

.login-card {
    width: 100%;
    display: grid;
    gap: 1rem;
    padding: 1.2rem;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-xl);
}

.login-logo {
    display: block;
    width: min(300px, 100%);
    height: auto;
}

.login-error {
    min-height: 1.2rem;
    color: #b91c1c;
    font-weight: 700;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    padding: 0.9rem 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.55);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

textarea {
    resize: vertical;
    min-height: 96px;
}

h1,
h2,
h3,
h4,
p {
    margin: 0;
}

h1,
h2 {
    font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell {
    width: min(1180px, calc(100vw - 1.2rem));
    max-width: 100%;
    overflow-x: clip;
    margin: 0 auto;
    padding: 1rem 0 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.1rem 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.user-chip {
    padding: 0.7rem 0.85rem;
    border-radius: 999px;
    color: var(--primary-strong);
    background: rgba(15, 118, 110, 0.08);
    font-weight: 700;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-logo {
    display: block;
    width: min(330px, calc(100vw - 2rem));
    height: auto;
    max-height: 88px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.08em;
    box-shadow: var(--shadow-md);
}

.eyebrow {
    margin: 0 0 0.15rem;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary);
}

.app-main {
    padding-bottom: calc(var(--footer-height) + 1rem);
}

.view {
    display: none;
    animation: rise-in 0.35s ease;
}

.view.is-active {
    display: block;
}

.hero-card,
.panel,
.form-card,
.summary-card,
.item-row,
.result-card,
.client-resume,
.dialog-shell {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-xl);
}

.hero-card,
.panel {
    border-radius: var(--radius-xl);
    padding: 1.2rem;
    margin-bottom: 1rem;
}

.hero-card {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(145deg, rgba(255, 250, 245, 0.94), rgba(255, 244, 231, 0.86)),
        var(--surface);
}

.hero-card::after {
    content: "";
    position: absolute;
    inset: auto -40px -50px auto;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.22), transparent 68%);
    pointer-events: none;
}

.hero-text,
.hero-note,
.muted-line {
    line-height: 1.5;
    color: var(--muted);
}

.hero-text {
    margin-top: 0.8rem;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1.2rem;
}

.stat-chip {
    padding: 0.85rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.stat-chip span {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
}

.stat-chip strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.4rem;
}

.panel-header,
.section-heading,
.toolbar,
.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
}

.panel-header,
.section-heading {
    margin-bottom: 1rem;
}

.panel-actions {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.toolbar {
    margin-bottom: 1rem;
    align-items: flex-end;
}

.toolbar-centered {
    width: min(720px, 100%);
    margin-inline: auto;
}

.grow {
    flex: 1;
}

.align-end {
    margin-bottom: 0.15rem;
}

.search-button {
    min-width: 120px;
}

.subpanel {
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.46);
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin-top: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.9rem;
}

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

.wide-field {
    grid-column: 1 / -1;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.field span {
    font-size: 0.86rem;
    color: var(--muted);
    font-weight: 600;
}

.primary-button,
.secondary-button,
.ghost-button,
.pill-button {
    border-radius: 999px;
    padding: 0.85rem 1.1rem;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.pill-button:hover {
    transform: translateY(-1px);
}

.primary-button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
    color: #fff;
    box-shadow: 0 12px 30px rgba(15, 118, 110, 0.28);
}

.secondary-button {
    background: linear-gradient(135deg, #fff5ea 0%, #ffe8d2 100%);
    color: var(--warning);
}

.ghost-button {
    background: rgba(255, 255, 255, 0.74);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.68);
}

.pill-button {
    background: rgba(249, 115, 22, 0.12);
    color: var(--warning);
    padding-inline: 0.95rem;
    width: 100%;
}

.client-resume {
    border-radius: 20px;
    padding: 1rem;
    background: linear-gradient(160deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0.84));
}

.client-resume.empty {
    background: linear-gradient(160deg, rgba(109, 117, 135, 0.07), rgba(255, 255, 255, 0.84));
}

.client-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    margin-bottom: 0.5rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.42rem 0.7rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.11);
    color: var(--primary-strong);
    font-size: 0.8rem;
    font-weight: 700;
}

.info-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.85rem;
}

.info-pills span {
    padding: 0.45rem 0.65rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    font-size: 0.82rem;
    color: var(--muted);
}

.item-list,
.result-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.item-row {
    border-radius: 24px;
    padding: 1rem;
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.88), rgba(247, 250, 249, 0.94)),
        rgba(255, 255, 255, 0.9);
}

.item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    gap: 0.75rem;
}

.item-number {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(15, 118, 110, 0.12);
    color: var(--primary-strong);
    font-weight: 700;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.item-grid .wide {
    grid-column: 1 / -1;
}

.summary-card {
    margin-top: 1rem;
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    background:
        linear-gradient(155deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0.92)),
        var(--surface);
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0;
    color: var(--muted);
}

.summary-row strong {
    color: var(--text);
}

.summary-row.total {
    margin-top: 0.35rem;
    padding-top: 0.8rem;
    border-top: 1px dashed rgba(31, 45, 61, 0.14);
    font-size: 1.05rem;
}

.summary-row.total strong {
    color: var(--primary-strong);
    font-size: 1.3rem;
}

.pdf-card {
    margin-top: 1rem;
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    background:
        linear-gradient(155deg, rgba(249, 115, 22, 0.09), rgba(255, 255, 255, 0.94)),
        var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: var(--shadow-md);
}

.split-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.result-card {
    width: 100%;
    padding: 1rem;
    border-radius: 20px;
    text-align: left;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-md);
}

.result-card:hover {
    background: rgba(255, 255, 255, 0.88);
}

.product-result-card {
    cursor: pointer;
}

.product-result-card:focus-visible {
    outline: none;
    border-color: rgba(15, 118, 110, 0.45);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12), var(--shadow-md);
}

.result-card.is-active {
    border-color: rgba(15, 118, 110, 0.28);
    box-shadow: 0 16px 40px rgba(15, 118, 110, 0.12);
}

.result-card strong {
    display: block;
    font-size: 1rem;
}

.result-card-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
}

.result-card p {
    margin-top: 0.32rem;
    color: var(--muted);
    line-height: 1.45;
}

.meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.65rem;
}

.meta-line span {
    padding: 0.32rem 0.55rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.08);
    color: var(--primary-strong);
    font-size: 0.78rem;
    font-weight: 700;
}

.card-actions {
    display: flex;
    gap: 0.65rem;
    margin-top: 0.85rem;
    justify-content: flex-end;
}

.order-result-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: start;
}

.order-card-actions {
    margin-top: 0;
}

.danger-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(220, 38, 38, 0.32);
    border-radius: 8px;
    color: #dc2626;
    background: #fff1f2;
    box-shadow: none;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.danger-icon-button:hover {
    color: #fff;
    background: #dc2626;
    transform: translateY(-1px);
}

.danger-icon-button svg {
    width: 21px;
    height: 21px;
    fill: currentColor;
}

.card-action-button {
    flex: 0 0 auto;
    min-width: 82px;
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
    box-shadow: none;
}

.success-button,
.danger-button {
    border-radius: 999px;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.success-button {
    color: #fff;
    background: linear-gradient(135deg, #16a34a 0%, #166534 100%);
    box-shadow: 0 10px 24px rgba(22, 101, 52, 0.18);
}

.danger-button {
    color: #fff;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    box-shadow: 0 12px 30px rgba(185, 28, 28, 0.22);
}

.form-card {
    border-radius: 22px;
    padding: 1rem;
}

.product-form-actions,
.seller-form-actions,
.order-bottom-actions {
    margin-top: 1rem;
}

.order-bottom-actions {
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.footer-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(1180px, 100vw);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 0.5rem;
    padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(248, 241, 231, 0.4), rgba(248, 241, 231, 0.92));
    backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 255, 255, 0.72);
}

.nav-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 62px;
    padding: 0.55rem 0.3rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--muted);
    box-shadow: var(--shadow-md);
}

.nav-button span {
    max-width: 100%;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    overflow-wrap: anywhere;
}

.nav-button svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.nav-button.is-active {
    background: linear-gradient(145deg, var(--primary), var(--accent));
    color: #fff;
}

.picker-dialog {
    border: 0;
    padding: 0;
    width: min(760px, calc(100vw - 1rem));
    background: transparent;
}

.picker-dialog::backdrop {
    background: rgba(19, 27, 43, 0.44);
    backdrop-filter: blur(8px);
}

.dialog-shell {
    border-radius: 28px;
    padding: 1rem;
    background: linear-gradient(180deg, rgba(255, 248, 240, 0.98), rgba(248, 241, 231, 0.92));
}

.dialog-results {
    max-height: min(58vh, 460px);
    overflow: auto;
    margin-top: 1rem;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--footer-height) + 0.8rem);
    transform: translateX(-50%) translateY(12px);
    opacity: 0;
    pointer-events: none;
    padding: 0.85rem 1rem;
    border-radius: 999px;
    background: rgba(31, 45, 61, 0.9);
    color: #fff;
    box-shadow: var(--shadow-md);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.hidden {
    display: none;
}

@media (min-width: 760px) {
    .hero-card {
        display: grid;
        grid-template-columns: 1.8fr 1fr;
        align-items: center;
        gap: 1rem;
    }

    .split-layout {
        grid-template-columns: minmax(300px, 0.95fr) minmax(420px, 1.05fr);
    }

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

    .item-grid {
        grid-template-columns: 0.8fr 1.1fr 1fr 0.85fr 0.85fr 0.9fr;
    }

    .item-grid .wide {
        grid-column: auto;
    }
}

@media (max-width: 759px) {
    .app-shell {
        width: calc(100vw - 0.8rem);
    }

    .login-shell,
    .app-shell,
    .app-main,
    .view,
    .panel,
    .subpanel,
    .form-card,
    .item-row,
    .result-card {
        max-width: 100%;
        overflow-x: clip;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .panel-actions {
        width: 100%;
    }

    .panel-actions > * {
        flex: 1;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .toolbar-centered {
        width: 100%;
    }

    .toolbar .field,
    .toolbar .grow {
        width: 100%;
        flex: 0 0 auto;
    }

    .align-end {
        width: 100%;
    }

    .form-grid-orders {
        grid-template-columns: 1fr;
    }

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

    .footer-nav {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 0.3rem;
        padding: 0.45rem 0.35rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    }

    .nav-button {
        gap: 0.25rem;
        min-height: 58px;
        padding: 0.45rem 0.1rem;
        border-radius: 8px;
    }

    .nav-button span {
        font-size: 0.68rem;
    }

    .nav-button svg {
        width: 20px;
        height: 20px;
    }
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
