:root {
    --ink: #242631;
    --muted: #646875;
    --paper: #ffffff;
    --canvas: #f4f5f8;
    --line: #e3e5eb;
    --brand: #772443;
    --brand-dark: #5c1832;
    --brand-soft: #f6eaf0;
    --accent: #bd7b36;
    --danger: #a73c49;
    --shadow: 0 12px 36px rgba(30, 33, 47, .05);
    --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 5%, rgba(119, 36, 67, .08), transparent 28rem),
        var(--canvas);
    font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
button, input, select { font: inherit; }

.skip-link {
    position: fixed;
    top: -5rem;
    left: 1rem;
    z-index: 100;
    padding: .75rem 1rem;
    border-radius: 0 0 10px 10px;
    color: white;
    background: var(--brand-dark);
}
.skip-link:focus { top: 0; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(36, 38, 49, .1);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(18px);
}

.site-header__inner {
    width: min(1180px, calc(100% - 2rem));
    min-height: 74px;
    margin: auto;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    color: var(--ink);
    text-decoration: none;
}

.brand__mark, .login-brand {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px 14px 14px 5px;
    color: white;
    background: linear-gradient(145deg, var(--brand), var(--brand-dark));
    box-shadow: 0 8px 18px rgba(119, 36, 67, .22);
    font: 800 1.3rem/1 Georgia, serif;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.05rem; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: .72rem; }

.main-nav { display: flex; align-self: stretch; gap: .25rem; }
.main-nav a {
    display: flex;
    align-items: center;
    padding: 0 .9rem;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}
.main-nav a:hover, .main-nav a.active { color: var(--brand); border-color: var(--brand); }

.nav-toggle { display: none; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: .88rem; }
.user-menu form { margin: 0; }
.link-button { padding: 0; border: 0; color: var(--brand); background: transparent; cursor: pointer; font-weight: 700; }

.page-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 3rem 0 5rem; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.7rem; }
.page-header.compact { max-width: 850px; }
.page-header h1 { margin: .2rem 0 .35rem; font: 750 clamp(2rem, 5vw, 3.4rem)/1.05 Georgia, serif; letter-spacing: -.035em; }
.page-intro { max-width: 720px; margin: 0; color: var(--muted); font-size: 1.05rem; }
.eyebrow { margin: 0; color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow a { color: inherit; }
.muted { color: var(--muted); }

.card { border: 1px solid rgba(30, 33, 47, .08); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: .68rem 1rem;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 750;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); text-decoration: none; }
.button--primary { color: white; background: var(--brand); box-shadow: 0 8px 18px rgba(119, 36, 67, .18); }
.button--primary:hover { color: white; background: var(--brand-dark); }
.button--secondary { border-color: #dcc4ce; color: var(--brand); background: var(--brand-soft); }
.button--secondary:hover { background: #ead6df; }
.button--ghost { border-color: var(--line); color: var(--ink); background: white; }
.button--danger { border-color: #e5baba; color: var(--danger); background: #fff5f5; }
.button--small { min-height: 36px; padding: .45rem .75rem; font-size: .86rem; }
.button--wide { width: 100%; }
.text-link { align-self: center; font-weight: 700; }

.alert { margin-bottom: 1rem; padding: .9rem 1rem; border: 1px solid; border-radius: 12px; font-weight: 650; }
.alert--success { border-color: #9dc9b5; color: #15533f; background: #e7f6ef; }
.alert--error { border-color: #e7b0b0; color: #8c2f2f; background: #fff0f0; }
.alert--warning { border-color: #e5c184; color: #704713; background: #fff8e8; }
.alert--info { border-color: #b8ccd8; color: #34586c; background: #eef7fb; }

.toolbar, .search-card, .action-bar { margin-bottom: 1.25rem; padding: 1rem 1.15rem; }
.filter-form, .search-form, .search-control, .action-bar { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; }
.filter-form label, .search-form label { color: var(--muted); font-size: .82rem; font-weight: 750; }
.filter-form label { display: grid; gap: .3rem; }
.search-form { display: block; }
.search-control { margin-top: .4rem; }
.search-control input { flex: 1 1 300px; }
.action-bar form { margin: 0 0 0 auto; }

input, select {
    width: 100%;
    min-height: 46px;
    padding: .68rem .78rem;
    border: 1px solid #cdd1dc;
    border-radius: 10px;
    color: var(--ink);
    background: white;
}
input:focus, select:focus { outline: 3px solid rgba(164, 84, 118, .18); border-color: var(--brand); }

.table-card { overflow: hidden; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem 1.15rem; border-bottom: 1px solid #eceef2; text-align: left; vertical-align: middle; }
thead th { color: var(--muted); background: #f8f9fb; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: #fcf7fa; }
.table-action, .numeric { text-align: right; }
.cell-note { display: block; margin-top: .15rem; color: var(--muted); font-weight: 500; }
.quantity-input { max-width: 120px; }

.status { display: inline-flex; align-items: center; width: fit-content; padding: .34rem .65rem; border-radius: 999px; color: #42504a; background: #eceeea; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.status--draft { color: #73501e; background: #fff0cb; }
.status--quotation { color: #2f5f76; background: #e2f2fa; }
.status--confirmed, .status--posted, .status--assigned { color: #185d49; background: #dcf2e9; }
.status--processing, .status--picked, .status--packed, .status--shipped { color: #684f91; background: #eee7f8; }
.status--done, .status--paid { color: #355765; background: #e5f0f4; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem; border-bottom: 1px solid #eceef2; }
.section-heading h2 { margin: 0; font-size: 1.18rem; }
.section-heading p { margin: .15rem 0 0; color: var(--muted); }
.empty-state { max-width: 520px; margin: auto; padding: 4rem 1.5rem; text-align: center; }
.empty-state > span { display: block; margin-bottom: .7rem; font-size: 2.2rem; }
.empty-state h2 { margin: 0; }
.empty-state p { margin: .4rem 0 1.2rem; color: var(--muted); }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.summary-item { padding: 1.05rem 1.15rem; }
.summary-item span, .summary-item strong { display: block; }
.summary-item span { margin-bottom: .25rem; color: var(--muted); font-size: .76rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }

.order-builder { overflow: hidden; }
.builder-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 240px)); gap: 1rem; padding: 1.15rem; background: #f8f9fb; }
.builder-fields--single { grid-template-columns: minmax(0, 240px); }
.builder-fields label, .stack-form label { display: grid; gap: .35rem; color: var(--muted); font-size: .83rem; font-weight: 750; }
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; padding: 1.15rem; }
.product-option { position: relative; display: flex; min-height: 76px; align-items: center; gap: .7rem; padding: .8rem; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; background: white; }
.product-option:hover { border-color: #cfa9ba; background: #fcf8fa; }
.product-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.product-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.product-option__check { display: grid; flex: 0 0 24px; height: 24px; place-items: center; border: 1px solid #cdd1dc; border-radius: 50%; color: transparent; }
.product-option input:checked + .product-option__check { border-color: var(--brand); color: white; background: var(--brand); }
.product-option strong, .product-option small { display: block; }
.product-option strong { line-height: 1.25; }
.product-option small { margin-top: .2rem; color: var(--muted); }
.sticky-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: .7rem; padding: 1rem 1.15rem; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .95); backdrop-filter: blur(12px); }

.site-footer { width: min(1180px, calc(100% - 2rem)); margin: auto; padding: 1.5rem 0 2.5rem; border-top: 1px solid rgba(36, 38, 49, .12); display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; }

.login-layout { min-height: calc(100vh - 6rem); display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(2rem, 8vw, 7rem); }
.login-intro { max-width: 620px; }
.login-brand { width: 62px; height: 62px; margin-bottom: 2rem; border-radius: 20px 20px 20px 7px; font-size: 2rem; }
.login-intro h1 { margin: .35rem 0 1rem; font: 750 clamp(2.7rem, 7vw, 5.4rem)/.98 Georgia, serif; letter-spacing: -.05em; }
.login-intro > p:last-child { max-width: 520px; color: var(--muted); font-size: 1.15rem; }
.login-card { width: 100%; max-width: 460px; justify-self: end; padding: clamp(1.4rem, 4vw, 2.4rem); }
.login-card h2 { margin: .2rem 0 .3rem; font: 700 1.8rem/1.2 Georgia, serif; }
.stack-form { display: grid; gap: 1rem; margin-top: 1.5rem; }

.error-state { max-width: 650px; margin: 8vh auto; padding: 3rem; text-align: center; }
.error-state > span { display: grid; width: 58px; height: 58px; margin: 0 auto 1rem; place-items: center; border-radius: 50%; color: white; background: var(--accent); font-size: 2rem; font-weight: 800; }
.error-state h1 { margin: .3rem 0; font: 750 2.2rem/1.1 Georgia, serif; }
.error-state p:not(.eyebrow) { margin: .7rem 0 1.4rem; color: var(--muted); }

@media (max-width: 860px) {
    .site-header__inner { flex-wrap: wrap; gap: .75rem; padding: .7rem 0; }
    .nav-toggle { display: inline-flex; margin-left: auto; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 9px; background: white; font-weight: 700; }
    .main-nav { display: none; order: 4; width: 100%; align-self: auto; }
    .main-nav--open { display: grid; }
    .main-nav a { min-height: 44px; padding: .5rem .7rem; border: 0; border-radius: 8px; }
    .main-nav a.active { background: var(--brand-soft); }
    .user-menu > span { display: none; }
    .page-header { align-items: start; flex-direction: column; gap: 1rem; }
    .summary-grid { grid-template-columns: 1fr; }
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    .login-layout { grid-template-columns: 1fr; padding: 2rem 0; }
    .login-intro { display: none; }
    .login-card { justify-self: center; }
}

@media (max-width: 620px) {
    .page-shell { width: min(100% - 1rem, 1180px); padding-top: 1.5rem; }
    .page-header h1 { font-size: 2.15rem; }
    .product-grid, .builder-fields { grid-template-columns: 1fr; }
    .action-bar { align-items: stretch; }
    .action-bar > *, .action-bar form, .action-bar .button { width: 100%; margin-left: 0; }
    .sticky-actions { position: static; }
    .responsive-table { overflow: visible; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    tbody tr { padding: .7rem 0; border-bottom: 1px solid var(--line); }
    tbody tr:last-child { border-bottom: 0; }
    th, td { display: grid; grid-template-columns: minmax(90px, 38%) 1fr; gap: .75rem; padding: .45rem 1rem; border: 0; text-align: right; }
    th::before, td::before { content: attr(data-label); color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
    .table-action, .numeric { text-align: right; }
    .table-action::before { content: ''; }
    .quantity-input { max-width: none; }
    .site-footer { flex-direction: column; gap: .25rem; }
}
