/* ============================================================================
   USA Equipment Direct — Order Portal
   Design language: refined enterprise. Deep-navy rail, characterful display
   type (Bricolage Grotesque) over a clean grotesque body (Public Sans),
   soft depth, smooth motion. Built on CSS variables for one source of truth.
   ============================================================================ */

:root {
    /* Brand */
    --navy-900:#071a31; --navy-800:#0b2545; --navy-700:#103a6b; --navy-600:#1c4f8c;
    --brand:#d11a2a; --brand-600:#b1121f;        /* USA red accent */
    --gold:#f4b41a;

    /* Neutrals */
    --ink:#15202e; --slate:#56616f; --muted:#8b94a1;
    --line:#e8ebf1; --line-2:#eff2f7;
    --bg:#f3f5f9; --surface:#ffffff; --surface-2:#fafbfd;

    /* Status */
    --ok:#15a34a; --ok-bg:#e6f6ec;
    --warn:#bd7a08; --warn-bg:#fdf2da;
    --info:#1f6fd6; --info-bg:#e7f0fc;
    --danger:#d11a2a; --danger-bg:#fde8ea;

    /* Type */
    --font-display:'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
    --font-body:'Public Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-mono:'JetBrains Mono', ui-monospace, Menlo, monospace;

    /* Shape & depth */
    --r:16px; --r-md:12px; --r-sm:9px;
    --sh-sm:0 1px 2px rgba(11,37,69,.06), 0 1px 3px rgba(11,37,69,.05);
    --sh-md:0 6px 16px rgba(11,37,69,.08), 0 2px 6px rgba(11,37,69,.05);
    --sh-lg:0 24px 50px rgba(11,37,69,.18);
    --ring:0 0 0 3px rgba(28,79,140,.18);
    --ease:cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1,h2,h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
a { color: var(--navy-700); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--brand); }
code { font-family: var(--font-mono); font-size: .82em; color: var(--navy-700); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.inline { display: inline; }
::selection { background: rgba(209,26,42,.16); }

/* ---- App shell ------------------------------------------------------------ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 244px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 100%);
    color: #aebdd0;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
    margin: 16px; padding: 16px;
    background: #fff; border-radius: var(--r-md);
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.sidebar__brand img { display: block; width: 100%; max-width: 150px; height: auto; margin: 0 auto; }
.sidebar__nav { display: flex; flex-direction: column; padding: 8px 12px; gap: 3px; }
.nav-section {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
    color: #5f779a; padding: 14px 12px 8px; font-weight: 700;
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: #b8c5d8; font-weight: 600; font-size: 13.5px;
    position: relative; transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.10); color: #fff; }
.nav-link.active::before {
    content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--brand);
}
.nav-link__icon { display: inline-flex; }
.nav-link__icon svg { width: 18px; height: 18px; }
.sidebar__foot {
    margin-top: auto; padding: 16px 20px; font-size: 11px; color: #50688a;
    border-top: 1px solid rgba(255,255,255,.06); letter-spacing: .02em;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 32px; background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 40;
}
.topbar__eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); }
.topbar__title h1 { margin: 2px 0 0; font-size: 22px; color: var(--navy-800); line-height: 1.1; }
.topbar__user { display: flex; align-items: center; gap: 14px; }
.avatar {
    width: 38px; height: 38px; border-radius: 11px;
    background: linear-gradient(135deg, var(--navy-700), var(--navy-600));
    color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--sh-sm); letter-spacing: .02em;
}
.topbar__id { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__id strong { font-size: 13.5px; color: var(--ink); font-weight: 600; }
.topbar__id span { font-size: 11.5px; color: var(--muted); }

.content { padding: 30px 32px 56px; max-width: 1240px; width: 100%; }

/* Page-load reveal */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.content > * { animation: rise .5s var(--ease) both; }
.content > *:nth-child(1){animation-delay:.02s}
.content > *:nth-child(2){animation-delay:.08s}
.content > *:nth-child(3){animation-delay:.14s}
.content > *:nth-child(4){animation-delay:.20s}
@media (prefers-reduced-motion: reduce) { .content > * { animation: none; } }

/* ---- Cards ---------------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--sh-sm);
    margin-bottom: 24px; overflow: hidden;
}
.card--narrow { max-width: 660px; }
.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 18px 22px; border-bottom: 1px solid var(--line-2);
}
.card__head h2 { margin: 0; font-size: 16px; color: var(--navy-800); }
.card > .form, .card .form--compact { padding: 22px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.cols--wide-left { grid-template-columns: 1.9fr 1fr; }
.cols .card { margin-bottom: 0; }

/* ---- Tables --------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 700; padding: 13px 22px;
    border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.table td { padding: 14px 22px; border-bottom: 1px solid var(--line-2); }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { padding: 12px 22px; }
.table a { font-weight: 600; }

/* ---- Stat cards ----------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    padding: 20px 22px; box-shadow: var(--sh-sm);
    display: flex; flex-direction: column; gap: 6px;
    position: relative; overflow: hidden;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat-card::after {
    content:""; position:absolute; inset:0 auto 0 0; width:3px; background: var(--navy-600); opacity:.85;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.stat-card__num { font-family: var(--font-display); font-size: 32px; font-weight: 800; color: var(--navy-800); line-height: 1; letter-spacing: -.02em; }
.stat-card__label { font-size: 12.5px; color: var(--slate); font-weight: 500; }
.stat-card--accent { background: linear-gradient(140deg, var(--navy-700), var(--navy-900)); border-color: transparent; }
.stat-card--accent::after { background: var(--brand); opacity: 1; }
.stat-card--accent .stat-card__num { color: #fff; }
.stat-card--accent .stat-card__label { color: #b9c6da; }

/* ---- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent; border-radius: 10px;
    padding: 10px 17px; font-size: 13.5px; font-weight: 600; font-family: inherit;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: transform .12s var(--ease), background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn--primary { background: linear-gradient(180deg, var(--brand), var(--brand-600)); color: #fff; box-shadow: 0 2px 8px rgba(209,26,42,.28); }
.btn--primary:hover { color: #fff; box-shadow: 0 6px 18px rgba(209,26,42,.34); transform: translateY(-1px); }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--navy-800); }
.btn--ghost:hover { background: var(--surface-2); border-color: #d6dbe5; color: var(--navy-800); }
.btn--danger { background: #fff; border-color: #f0c2c7; color: var(--brand); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--block { width: 100%; }
.btn--sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn--lg { padding: 13px 24px; font-size: 14.5px; }
.btn--icon { padding: 9px; width: 38px; height: 38px; }
.btn--icon svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- Badges --------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
    text-transform: capitalize; background: var(--line-2); color: var(--slate);
}
.badge::before { content:""; width:6px; height:6px; border-radius:50%; background: currentColor; opacity:.8; }
.badge--lg { padding: 6px 15px; font-size: 13px; }
.badge--pending    { background:#eef1f6; color:#64707f; }
.badge--submitted  { background: var(--info-bg); color: var(--info); }
.badge--processing { background: var(--warn-bg); color: var(--warn); }
.badge--shipped    { background:#e3eefb; color:#1659b8; }
.badge--completed  { background: var(--ok-bg); color: var(--ok); }
.badge--cancelled  { background: var(--danger-bg); color: var(--danger); }

/* ---- Forms ---------------------------------------------------------------- */
.form label, .form--compact label { display: block; margin-bottom: 16px; }
.form label > span, .form--compact label > span, label.full > span {
    display: block; font-size: 12.5px; font-weight: 600; color: var(--navy-800); margin-bottom: 6px;
}
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], select, textarea {
    width: 100%; padding: 10px 13px; border: 1px solid var(--line);
    border-radius: 10px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: #aab2bf; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-600); box-shadow: var(--ring); }
input[type=search] {
    padding-left: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b94a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: 13px center; background-size: 16px;
}
.input-sm { padding: 8px 11px; font-size: 13px; border-radius: 8px; }
.form__section {
    font-family: var(--font-display); font-size: 13px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--navy-700); margin: 8px 0 16px;
    border-top: 1px solid var(--line-2); padding-top: 20px;
}
.form__section:first-child { border-top: 0; padding-top: 0; }
.form__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; color: var(--navy-800); margin-bottom: 16px; cursor: pointer; }
.check input, .catalog-cell input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); }
.check--inline { font-weight: 500; font-size: 13px; color: var(--slate); margin: 0; }
label.full { display: block; margin-bottom: 16px; }
textarea { resize: vertical; min-height: 70px; }

/* ---- Page head / search / filters ----------------------------------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head > div { display: flex; gap: 10px; align-items: center; }
.search, .filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters { padding: 16px 22px; border-bottom: 1px solid var(--line-2); }
.filters select { min-width: 180px; }
.search input { min-width: 280px; }

/* ---- Detail lists --------------------------------------------------------- */
.detail { display: grid; grid-template-columns: 140px 1fr; gap: 12px 18px; margin: 0; padding: 22px; }
.detail dt { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.detail dd { margin: 0; color: var(--ink); }
.notes { padding: 0 22px 20px; color: var(--slate); }

/* ---- Alerts --------------------------------------------------------------- */
.alert { padding: 13px 18px; border-radius: 12px; margin-bottom: 22px; font-weight: 500; font-size: 13.5px; border: 1px solid transparent; }
.alert--success { background: var(--ok-bg); color: #11702f; border-color: #bfe7cd; }
.alert--error { background: var(--danger-bg); color: #97121f; border-color: #f2c2c8; }
.alert ul { margin: 0; padding-left: 18px; }

/* ---- Pricing display ------------------------------------------------------ */
.price-was { text-decoration: line-through; color: var(--muted); font-size: 12.5px; margin-right: 5px; }
.price-now { color: var(--brand); font-weight: 700; }

/* ---- Product picker (admin catalog) --------------------------------------- */
.picker { position: relative; padding: 20px 22px 6px; }
.picker__results {
    position: absolute; top: calc(100% - 2px); left: 22px; right: 22px; z-index: 30;
    list-style: none; margin: 0; padding: 5px; max-height: 300px; overflow-y: auto;
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--sh-lg); display: none;
}
.picker__results.show { display: block; }
.picker__results li {
    padding: 11px 13px; border-radius: 9px; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    transition: background .12s var(--ease);
}
.picker__results li:hover { background: var(--surface-2); }
.picker__results .sku { color: var(--muted); font-size: 12px; }

/* Horizontal add bar */
.add-bar { display: grid; grid-template-columns: minmax(0,1fr) 116px 116px 132px auto; gap: 16px; align-items: end; padding: 18px 22px; }
.add-bar label { margin: 0; }
.add-bar label > span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.add-bar .btn { align-self: end; height: 42px; }
.custom-product { border-top: 1px solid var(--line-2); padding: 8px 22px 18px; }
.custom-product summary { cursor: pointer; font-weight: 600; color: var(--navy-700); padding: 10px 0; font-size: 13px; list-style: none; }
.custom-product summary::-webkit-details-marker { display: none; }
.custom-product summary::before { content: "+ "; color: var(--brand); font-weight: 800; }
.custom-product[open] summary::before { content: "− "; }
.custom-product .add-bar { padding: 6px 0 4px; }

/* ---- Editable catalog rows (aligned grid) --------------------------------- */
.catalog-row {
    display: grid;
    grid-template-columns: minmax(0,1fr) 100px 100px 100px 66px 170px;
    gap: 16px; align-items: center; padding: 14px 22px; margin: 0;
    border-bottom: 1px solid var(--line-2);
    transition: background .12s var(--ease);
}
.catalog-row:last-of-type { border-bottom: 0; }
.catalog-row:not(.catalog-row--head):hover { background: var(--surface-2); }
.catalog-row--head { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.catalog-row .product strong { display: block; line-height: 1.35; color: var(--ink); }
.catalog-source { font-size: 11.5px; color: var(--muted); }
.catalog-row input[type=number] { width: 100%; padding: 8px 10px; font-size: 13px; }
.catalog-cell.center { text-align: center; }
.catalog-cell.actions { display: flex; gap: 8px; justify-content: flex-end; }
.cell-label { display: none; }

/* ---- Dashboard CTAs ------------------------------------------------------- */
.cta-row { display: flex; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }

/* ---- Order entry ---------------------------------------------------------- */
.order-table .qty-col { width: 130px; }
.order-table .qty-input { width: 90px; text-align: center; }
.order-row.hidden { display: none; }
.order-row td { vertical-align: middle; }
.order-summary { position: sticky; top: 96px; }
.summary-total {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; margin-top: 4px;
    border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
    background: var(--surface-2);
}
.summary-total span { font-weight: 600; color: var(--slate); }
.summary-total strong { font-family: var(--font-display); font-size: 26px; color: var(--navy-800); letter-spacing: -.02em; }
.order-summary .full { padding: 18px 22px 0; }
.order-summary .btn--block { margin: 18px 22px 6px; width: calc(100% - 44px); }
.order-summary .small { padding: 0 22px 18px; }

/* ---- Order tracking ------------------------------------------------------- */
.order-track { display: flex; gap: 6px; margin-bottom: 24px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 24px 28px; box-shadow: var(--sh-sm); position: relative; }
.track-step { flex: 1; text-align: center; position: relative; color: var(--muted); }
.track-step::after { content:""; position:absolute; top:9px; left:50%; width:100%; height:2px; background: var(--line); z-index:0; }
.track-step:last-child::after { display:none; }
.track-dot { position: relative; z-index: 1; display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; margin: 0 auto 10px; border: 2px solid var(--line); transition: all .25s var(--ease); }
.track-step.done { color: var(--navy-800); font-weight: 600; }
.track-step.done .track-dot { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.track-step.done::after { background: var(--ok); }
.track-label { font-size: 12.5px; }

/* ---- Login / errors ------------------------------------------------------- */
body.centered {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background:
        radial-gradient(900px 500px at 50% -10%, rgba(28,79,140,.20), transparent 60%),
        linear-gradient(180deg, var(--navy-800), var(--navy-900));
    padding: 24px;
}
.login { width: 100%; max-width: 410px; text-align: center; }
.login__card { background: #fff; border-radius: 20px; box-shadow: var(--sh-lg); padding: 40px 36px; text-align: left; }
.login__logo { display: block; max-width: 170px; margin: 0 auto 22px; }
.login__card h1 { margin: 0 0 4px; font-size: 23px; color: var(--navy-800); text-align: center; }
.login__sub { color: var(--muted); margin: 0 0 26px; text-align: center; font-size: 13.5px; }
.login__footer { color: rgba(255,255,255,.6); margin-top: 22px; font-size: 12px; }
.login .btn { margin-top: 4px; }

.error-page { width: 100%; display: flex; justify-content: center; }
.error-card { text-align: center; background: #fff; padding: 48px 44px; border-radius: 20px; box-shadow: var(--sh-lg); }
.error-logo { max-width: 150px; margin-bottom: 18px; }
.error-card h1 { font-size: 60px; margin: 0 0 6px; color: var(--brand); letter-spacing: -.03em; }
.error-card p { color: var(--slate); margin: 0 0 22px; }

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 1040px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .cols, .cols--wide-left { grid-template-columns: 1fr; }
    .sidebar { width: 74px; }
    .sidebar__brand { margin: 12px; padding: 10px; }
    .nav-section, .nav-link__label, .sidebar__foot { display: none; }
    .nav-link { justify-content: center; padding: 12px; }
    .nav-link.active::before { left: -12px; }
    .topbar { padding: 16px 20px; }
    .content { padding: 22px 20px 48px; }
    .topbar__id { display: none; }
}
@media (max-width: 820px) {
    .add-bar { grid-template-columns: 1fr 1fr; }
    .add-bar .add-bar__product, .add-bar > .btn { grid-column: 1 / -1; }
    .catalog-row--head { display: none; }
    .catalog-row { grid-template-columns: 1fr 1fr; gap: 12px 16px; padding: 18px 20px; row-gap: 14px; }
    .catalog-row .product { grid-column: 1 / -1; }
    .catalog-cell.actions { grid-column: 1 / -1; justify-content: flex-start; }
    .cell-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
}
@media (max-width: 560px) {
    .stat-grid { grid-template-columns: 1fr; }
    .topbar__title h1 { font-size: 19px; }
}
