/* ==========================================================================
   Invicta ordering portal - Windows 11 (Fluent) look in Moduflex colours.
   Brand: blue #6faac4 / deep blue #2f7ba0 / grey #8d9097, Bahnschrift + Arial.
   ========================================================================== */

:root {
    --brand-blue: #6faac4;
    --accent: #2f7ba0;
    --accent-hover: #2a6f91;
    --accent-pressed: #245f7c;
    --accent-subtle: #e8f1f6;
    --brand-grey: #8d9097;

    --ink: #1f2326;
    --ink-2: #5b6066;
    --ink-3: #8d9097;

    --mica: #f3f4f6;
    --surface: #ffffff;
    --surface-alt: #fbfbfc;
    --hover: #f5f7f9;
    --stroke: #e6e8eb;
    --stroke-control: #d5d8dc;
    --stroke-bottom: #8f959b;

    --ok-bg: #e9f4ee;  --ok: #237a4b;
    --err-bg: #fbe9e7; --err: #b23b2e;
    --warn-bg: #fff6e0; --warn: #8a5a00;

    --r-ctl: 4px;
    --r-card: 8px;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.02);
    --shadow-raised: 0 8px 24px rgba(16, 24, 32, 0.10), 0 1px 3px rgba(16, 24, 32, 0.06);
    --font: "Bahnschrift", "Segoe UI Variable Text", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font);
    font-weight: 300;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 85% -120px, rgba(111, 170, 196, 0.18), transparent 70%),
        radial-gradient(900px 400px at -10% -80px, rgba(111, 170, 196, 0.10), transparent 70%),
        var(--mica);
    background-attachment: fixed;
    min-height: 100vh;
}
strong, b { font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; color: var(--ink); margin: 0; letter-spacing: -0.005em; }
h1 { font-size: 1.75rem; line-height: 1.25; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }
.muted { color: var(--ink-2); }
.small { font-size: 0.82rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pre { white-space: pre-line; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor;
          stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Title bar ------------------------------------------------------- */
.titlebar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 24px;
    height: 60px; padding: 0 28px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--stroke);
}
.brand { display: flex; align-items: center; gap: 14px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { height: 34px; width: auto; display: block; }
.wordmark { color: var(--brand-blue); font-weight: 600; font-size: 1.2rem; letter-spacing: 0.08em; }
.brand-sub { color: var(--ink-2); font-size: 0.9rem; padding-left: 14px; border-left: 1px solid var(--stroke); }

.navview { display: flex; gap: 4px; height: 100%; align-items: center; }
.navview a {
    position: relative; display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: var(--r-ctl);
    color: var(--ink-2); font-size: 0.92rem;
}
.navview a:hover { background: rgba(0, 0, 0, 0.04); color: var(--ink); text-decoration: none; }
.navview a.active { color: var(--ink); font-weight: 400; }
.navview a.active::after {
    content: ""; position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%);
    width: 18px; height: 3px; border-radius: 3px; background: var(--accent);
}
.titlebar .spacer { flex: 1; }
.account { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--accent-subtle); color: var(--accent);
    font-size: 0.8rem; font-weight: 600;
}
.account-name { font-size: 0.88rem; color: var(--ink-2); }

/* ---- Page ------------------------------------------------------------ */
main { max-width: 1080px; margin: 0 auto; padding: 32px 28px 120px; }
main.narrow { max-width: 440px; padding-top: 8vh; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between;
             gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 6px 0 0; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 0.85rem;
          color: var(--ink-2); margin-bottom: 8px; }
.crumbs a { color: var(--ink-2); }
.crumbs svg.ico { width: 12px; height: 12px; }

/* ---- Cards ----------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--stroke);
    border-radius: var(--r-card); box-shadow: var(--shadow-card);
    padding: 20px 24px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between;
             gap: 12px; margin-bottom: 14px; }
.card-head p { margin: 2px 0 0; }
.card.flush { padding: 0; overflow: hidden; }

/* ---- Buttons --------------------------------------------------------- */
.btn, .btn-sub, .btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 32px; padding: 5px 14px;
    font: inherit; font-size: 0.92rem; font-weight: 400;
    border-radius: var(--r-ctl); cursor: pointer;
    transition: background 0.08s ease, border-color 0.08s ease;
    white-space: nowrap;
}
.btn:hover, .btn-sub:hover, .btn-ghost:hover { text-decoration: none; }
.btn {
    background: var(--accent); color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-color: rgba(0, 0, 0, 0.32);
}
.btn:hover { background: var(--accent-hover); }
.btn:active { background: var(--accent-pressed); color: rgba(255, 255, 255, 0.8); }
.btn:disabled { background: #c5c8cc; border-color: transparent; color: #fff; cursor: default; }
.btn.lg { min-height: 40px; padding: 8px 22px; font-size: 1rem; }
.btn-sub {
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--stroke-control); border-bottom-color: #c3c7cb;
}
.btn-sub:hover { background: var(--hover); }
.btn-sub:active { background: #f0f2f4; color: var(--ink-2); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.05); color: var(--ink); }
.btn-ghost.danger:hover { color: var(--err); background: var(--err-bg); }
.btn-icon { min-height: 32px; width: 32px; padding: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- Inputs ---------------------------------------------------------- */
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-group label { font-size: 0.88rem; color: var(--ink); font-weight: 400; }
.hint { font-size: 0.8rem; color: var(--ink-2); }
.input {
    width: 100%; min-height: 34px; padding: 6px 11px;
    font: inherit; font-size: 0.95rem; color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--stroke-control); border-bottom-color: var(--stroke-bottom);
    border-radius: var(--r-ctl); outline: none;
}
.input:hover { background: var(--surface-alt); }
.input:focus {
    background: #fff; border-color: var(--stroke-control);
    border-bottom: 2px solid var(--accent); padding-bottom: 5px;
}
.input[aria-invalid="true"] { border-bottom: 2px solid var(--err); padding-bottom: 5px; }
textarea.input { resize: vertical; min-height: 80px; }
select.input {
    appearance: none; cursor: pointer; padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f666d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
select.input:invalid, select.input option[value=''] { color: var(--ink-2); }
.unit-input { position: relative; }
.unit-input .input { padding-right: 38px; text-align: right; }
.unit-input::after {
    content: "mm"; position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
    font-size: 0.8rem; color: var(--ink-3); pointer-events: none;
}
.check { display: flex; align-items: center; gap: 10px; font-size: 0.92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ---- InfoBar (messages) ---------------------------------------------- */
.infobar {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 16px; margin-bottom: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06); border-radius: var(--r-card);
    font-size: 0.92rem;
}
.infobar svg.ico { width: 18px; height: 18px; margin-top: 1px; }
.infobar ul { margin: 0; padding-left: 18px; }
.infobar.ok { background: var(--ok-bg); }
.infobar.ok svg.ico { color: var(--ok); }
.infobar.error { background: var(--err-bg); }
.infobar.error svg.ico { color: var(--err); }
.infobar.info { background: var(--accent-subtle); }
.infobar.info svg.ico { color: var(--accent); }

/* ---- Test-system banner (never shown on the live portal) ------------- */
.testbar {
    display: flex; gap: 6px 14px; align-items: baseline; flex-wrap: wrap;
    padding: 8px 28px; font-size: 0.88rem;
    background: var(--warn-bg); color: var(--warn);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.testbar strong { font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---- Order list ------------------------------------------------------ */
.listview { list-style: none; margin: 0; padding: 0; }
.list-item {
    display: grid; grid-template-columns: 40px 1fr auto auto 16px; gap: 16px; align-items: center;
    padding: 14px 20px; color: var(--ink); border-top: 1px solid var(--stroke);
}
.listview li:first-child .list-item { border-top: 0; }
.list-item:hover { background: var(--hover); text-decoration: none; }
.tile { width: 40px; height: 40px; border-radius: var(--r-card); display: grid; place-items: center;
        background: var(--accent-subtle); color: var(--accent); }
.tile svg.ico { width: 20px; height: 20px; }
.list-title { font-weight: 400; }
.list-meta { font-size: 0.82rem; color: var(--ink-2); }
.list-amount { font-weight: 600; }
.list-item .chev { color: var(--ink-3); }
.badge {
    display: inline-block; padding: 1px 8px; margin-left: 8px; border-radius: 10px;
    background: var(--accent-subtle); color: var(--accent); font-size: 0.75rem; font-weight: 400;
    vertical-align: 2px;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.muted-badge { background: var(--hover); color: var(--ink-2); }
.reference-field { max-width: 420px; margin-bottom: 0; }
.empty { text-align: center; padding: 56px 24px; }
.empty .tile { margin: 0 auto 14px; width: 56px; height: 56px; }
.empty .tile svg.ico { width: 26px; height: 26px; }
.empty p { margin: 4px 0 18px; }

/* ---- Order form ------------------------------------------------------ */
.deck-head, .deck-row {
    display: grid; grid-template-columns: 28px 1fr 120px 32px;
    gap: 12px; align-items: center;
}
.deck-head { padding: 0 0 8px; font-size: 0.8rem; color: var(--ink-2); border-bottom: 1px solid var(--stroke); }
.deck-row { padding: 10px 0; border-bottom: 1px solid var(--stroke); }
.deck-row > * { min-width: 0; }
.deck-row .idx { color: var(--ink-3); font-size: 0.85rem; text-align: center; }
.deck-row .qty { text-align: right; }
.deck-row .msg { grid-column: 2 / -1; font-size: 0.8rem; color: var(--err); margin-top: -4px; }
.deck-row .msg:empty { display: none; }
.add-row { margin-top: 12px; }
.postcode-field { max-width: 240px; }
.postcode-field .input { text-transform: uppercase; }
.msg-error { color: var(--err); }
.msg-error:empty { display: none; }

.commandbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--stroke);
}
.commandbar-inner {
    max-width: 1080px; margin: 0 auto; padding: 12px 28px;
    display: flex; align-items: center; justify-content: flex-end; gap: 20px;
}
.total-block { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; }
.total-label { color: var(--ink-2); font-size: 0.88rem; }
.total-note { color: var(--ink-2); font-size: 0.78rem; text-align: right; }
.total-value { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Review ---------------------------------------------------------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.summary { position: sticky; top: 76px; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0;
                border-bottom: 1px solid var(--stroke); font-size: 0.92rem; }
.summary-line .qty { color: var(--ink-2); }
.summary-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; }
.summary-total span:last-child { font-size: 1.35rem; font-weight: 600; }
.summary .btn { width: 100%; margin: 18px 0 4px; }
.contact-note { margin: 14px 0 0; font-size: 0.85rem; }
.contact-note[hidden] { display: none; }

/* ---- Order detail ---------------------------------------------------- */
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th { text-align: left; font-weight: 400; font-size: 0.8rem; color: var(--ink-2);
                padding: 8px 12px; border-bottom: 1px solid var(--stroke); }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--stroke); }
table.data tfoot td { border-bottom: 0; padding-top: 14px; }
table.data th.num, table.data td.num { text-align: right; }
.facts { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; font-size: 0.92rem; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; }
details.expander { background: var(--surface); border: 1px solid var(--stroke);
                   border-radius: var(--r-card); margin-bottom: 8px; box-shadow: var(--shadow-card); }
details.expander summary {
    list-style: none; cursor: pointer; padding: 14px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
details.expander summary::-webkit-details-marker { display: none; }
details.expander summary:hover { background: var(--hover); border-radius: var(--r-card); }
details.expander[open] summary { border-bottom: 1px solid var(--stroke); border-radius: var(--r-card) var(--r-card) 0 0; }
details.expander summary .chev { transition: transform 0.15s ease; color: var(--ink-2); }
details.expander[open] summary .chev { transform: rotate(180deg); }
details.expander .body { padding: 16px 20px; }
.changes { margin: 0 0 14px; padding-left: 18px; color: var(--accent); font-size: 0.9rem; }
.section-title { margin: 28px 0 10px; font-size: 0.95rem; color: var(--ink-2); font-weight: 400; }

/* ---- Sign-in --------------------------------------------------------- */
.auth-card { padding: 36px 36px 28px; box-shadow: var(--shadow-raised); }
.auth-logo { display: block; height: 44px; width: auto; margin: 0 0 24px; }
.auth-card h1 { font-size: 1.5rem; }
.auth-card .lead { margin: 6px 0 24px; color: var(--ink-2); }
.auth-card .btn { width: 100%; margin-top: 8px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 0.88rem; }

/* ---- Success --------------------------------------------------------- */
.success { text-align: center; padding: 48px 32px; }
.success .tick { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 18px;
                 display: grid; place-items: center; background: var(--ok-bg); color: var(--ok); }
.success .tick svg.ico { width: 30px; height: 30px; stroke-width: 2; }
.success p { max-width: 520px; margin: 8px auto 24px; color: var(--ink-2); }
.success .actions { justify-content: center; }

.linkbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.inline { display: inline; margin: 0; }

/* ---- Small screens --------------------------------------------------- */
/* ---- Working screen (busy.js) ---------------------------------------- */
.busy-overlay {
    position: fixed; inset: 0; z-index: 100; display: none;
    align-items: center; justify-content: center; padding: 16px;
    background: rgba(243, 245, 247, 0.82); backdrop-filter: blur(3px);
}
.busy-overlay.show { display: flex; animation: busy-in 0.15s ease-out; }
body.busy { overflow: hidden; }
.busy-card {
    width: 100%; max-width: 400px; padding: 32px 28px; text-align: center;
    background: var(--surface); border: 1px solid var(--stroke);
    border-radius: var(--r-card); box-shadow: var(--shadow-raised); outline: none;
}
.busy-card h2 { margin: 18px 0 6px; }
.busy-card p { margin: 0; }
.busy-card .hint { margin-top: 12px; }
.busy-spinner {
    width: 44px; height: 44px; margin: 0 auto; border-radius: 50%;
    border: 4px solid var(--accent-subtle); border-top-color: var(--accent);
    animation: busy-spin 0.8s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }
@keyframes busy-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .busy-spinner { animation-duration: 2.4s; }
    .busy-overlay.show { animation: none; }
}

@media (max-width: 860px) {
    .split { grid-template-columns: 1fr; }
    .summary { position: static; }
    .account-name, .brand-sub { display: none; }
}
@media (max-width: 640px) {
    .titlebar { padding: 0 14px; gap: 10px; }
    .navview a span { display: none; }
    main { padding: 20px 14px 140px; }
    h1 { font-size: 1.4rem; }
    .card { padding: 16px; }
    .grid-2 { grid-template-columns: 1fr; }
    .deck-head { display: none; }
    .deck-row { grid-template-columns: minmax(0, 1fr) 72px 32px; gap: 8px; }
    .deck-row .idx { display: none; }
    .deck-row .remove { grid-column: 3; grid-row: 1; }
    .deck-row .msg { grid-column: 1 / -1; grid-row: 2; }
    .commandbar .total-label { display: none; }
    .postcode-field { max-width: none; }
    .reference-field { max-width: none; }
    .list-item { grid-template-columns: 1fr auto; padding: 12px 14px; }
    .list-item .tile, .list-item .chev, .list-item .list-date { display: none; }
    .facts { grid-template-columns: 1fr; gap: 2px; }
    .facts dd { margin-bottom: 8px; }
    .commandbar-inner { padding: 10px 14px; gap: 12px; }
}
