/*
 * Order pages: checkout, payment, My orders, order detail, the staff pack and ship pages,
 * the counter pages and the shop computer's "order placed" screen.
 * Builds on ctg-shop.css (cards, buttons, fields) and ctg-theme.css (colours).
 */

/* ---------- Small pieces ---------- */

html body .ctg-strong { font-weight: 800; color: var(--ctg-text); }
html body .ctg-small { font-size: 0.85rem; margin: 0; }
html body .ctg-text-warn { color: var(--ctg-warn) !important; }
.ctg-stack { display: grid; gap: 16px; min-width: 0; align-content: start; }
.ctg-narrow { max-width: 520px; margin: 0 auto; }
html body .ctg-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
html body .ctg-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
html body .ctg-button-sm { padding: 6px 12px; font-size: 0.85rem; }
html body .ctg-button-lg { padding: 12px 20px; font-size: 1rem; }
html body .ctg-button-danger { background: transparent; border-color: var(--ctg-bad); color: var(--ctg-bad); }
html body .ctg-button-danger:hover { background: rgba(248, 113, 113, 0.12); border-color: var(--ctg-bad); color: var(--ctg-bad); }
html body .ctg-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 1.6rem; height: 1.4rem; padding: 0 7px; margin-left: 6px;
    border-radius: 999px; background: var(--ctg-surface-2); border: 1px solid var(--ctg-line-strong);
    font-size: 0.75rem; font-weight: 700; color: var(--ctg-muted); vertical-align: middle; font-variant-numeric: tabular-nums;
}
html body .ctg-chip {
    display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--ctg-line-strong);
    font-size: 0.75rem; font-weight: 700; color: var(--ctg-text); white-space: nowrap; vertical-align: middle;
}
html body .ctg-chip-warn { border-color: var(--ctg-warn); color: var(--ctg-warn); }
html body .ctg-chip-bad { border-color: var(--ctg-bad); color: var(--ctg-bad); background: rgba(248, 113, 113, 0.08); }
html body .ctg-address { display: grid; gap: 2px; font-style: normal; margin: 0; color: var(--ctg-text); }
html body .ctg-address strong { font-size: 1.02rem; }
html body .ctg-note { display: grid; gap: 2px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--ctg-line); }
html body .ctg-note .ctg-muted { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; }

/* Page title row with the status on the right */
html body .ctg-order-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 20px; margin: 0 0 18px; }
html body .ctg-order-head .ctg-h1 { margin: 0; }
html body .ctg-order-head .ctg-lead { margin-top: 6px; font-size: 0.92rem; }
.ctg-order-head-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Status pill ---------- */

html body .ctg-status {
    --tone: var(--ctg-muted);
    display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 9px; border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
    background: color-mix(in srgb, var(--tone) 12%, transparent);
    color: var(--tone); font-size: 0.8rem; font-weight: 700; white-space: nowrap; line-height: 1.4;
}
html body .ctg-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
html body .ctg-status-lg { font-size: 0.92rem; padding: 6px 14px 6px 12px; }
html body .ctg-status-wait { --tone: var(--ctg-warn); }
html body .ctg-status-todo { --tone: #a5b4fc; }
html body .ctg-status-move { --tone: var(--ctg-accent); }
html body .ctg-status-done { --tone: var(--ctg-ok); }
html body .ctg-status-off { --tone: var(--ctg-muted); }

/* ---------- Progress steps ---------- */

html body .ctg-order-progress { padding: 18px 20px 14px; margin: 0 0 16px; }
html body .ctg-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
html body .ctg-step { position: relative; display: grid; justify-items: center; align-content: start; gap: 4px; text-align: center; padding: 0 4px; color: var(--ctg-dim); }
/* The line between two dots */
html body .ctg-step + .ctg-step::before {
    content: ''; position: absolute; top: 14px; right: calc(50% + 18px); left: calc(-50% + 18px); height: 2px;
    background: var(--ctg-line-strong); border-radius: 2px;
}
html body .ctg-step.is-done + .ctg-step.is-done::before { background: var(--ctg-accent); }
html body .ctg-step-dot {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    border: 2px solid var(--ctg-line-strong); background: var(--ctg-surface-solid);
    font-size: 0.8rem; font-weight: 800; color: var(--ctg-dim);
}
html body .ctg-step.is-done .ctg-step-dot { background: var(--ctg-accent); border-color: var(--ctg-accent); color: var(--ctg-on-accent); }
html body .ctg-step.is-current .ctg-step-dot { box-shadow: 0 0 0 5px rgba(125, 211, 252, 0.18); }
html body .ctg-step-label { font-size: 0.82rem; font-weight: 700; line-height: 1.25; }
html body .ctg-step.is-done .ctg-step-label { color: var(--ctg-text); }
html body .ctg-step-time { font-size: 0.72rem; color: var(--ctg-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 479px) {
    html body .ctg-order-progress { padding: 14px 8px 10px; }
    html body .ctg-step { padding: 0 1px; }
    html body .ctg-step-label { font-size: 0.72rem; }
    html body .ctg-step-time { display: none; }
}

/* ---------- History timeline ---------- */

html body .ctg-timeline { list-style: none; margin: 0; padding: 0; }
html body .ctg-timeline-item { --tone: var(--ctg-muted); position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding-bottom: 16px; }
html body .ctg-timeline-item:last-child { padding-bottom: 0; }
/* The line down from each dot */
html body .ctg-timeline-item:not(:last-child)::before { content: ''; position: absolute; left: 10px; top: 18px; bottom: 2px; width: 2px; background: var(--ctg-line); border-radius: 2px; }
html body .ctg-timeline-dot { width: 12px; height: 12px; margin: 4px 0 0 5px; border-radius: 50%; background: var(--ctg-surface-solid); border: 2px solid var(--tone); box-sizing: border-box; }
html body .ctg-timeline-item.is-latest .ctg-timeline-dot { background: var(--tone); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 22%, transparent); }
html body .ctg-timeline-body p { margin: 0; }
html body .ctg-timeline-title { font-weight: 700; color: var(--ctg-text); }
html body .ctg-timeline-item:not(.is-latest) .ctg-timeline-title { font-weight: 600; color: color-mix(in srgb, var(--ctg-text) 85%, transparent); }
html body .ctg-timeline-detail { font-size: 0.88rem; color: var(--ctg-muted); }
html body .ctg-timeline-meta { font-size: 0.78rem; color: var(--ctg-dim); font-variant-numeric: tabular-nums; display: flex; gap: 4px; flex-wrap: wrap; }
html body .ctg-tone-wait { --tone: var(--ctg-warn); }
html body .ctg-tone-todo { --tone: #a5b4fc; }
html body .ctg-tone-move { --tone: var(--ctg-accent); }
html body .ctg-tone-done { --tone: var(--ctg-ok); }
html body .ctg-tone-bad { --tone: var(--ctg-bad); }

/* ---------- Callouts (pay now, ready for pick up, canceled) ---------- */

html body .ctg-callout {
    --tone: var(--ctg-accent);
    border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent);
    border-left: 4px solid var(--tone);
    background: color-mix(in srgb, var(--tone) 8%, var(--ctg-surface));
    border-radius: var(--ctg-radius); padding: 16px 18px; margin: 0 0 16px;
    display: grid; gap: 8px;
}
.ctg-stack > .ctg-callout { margin: 0; }
html body .ctg-callout .ctg-h2 { margin: 0; color: var(--tone); }
html body .ctg-callout p { margin: 0; }
html body .ctg-callout-wait { --tone: var(--ctg-warn); }
html body .ctg-callout-move { --tone: var(--ctg-accent); }
html body .ctg-callout-off { --tone: var(--ctg-muted); }
html body .ctg-callout-bad { --tone: var(--ctg-bad); color: var(--ctg-text); }
html body .ctg-deposit { font-size: 0.95rem; }
html body .ctg-deposit-number { font-size: 1.15rem; font-weight: 800; margin-right: 10px; }

/* ---------- Card lines (order items) ---------- */

html body .ctg-lines, html body .ctg-pick { list-style: none; margin: 0; padding: 0; display: grid; }
html body .ctg-line, html body .ctg-pick-row {
    display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 14px; align-items: center;
    padding: 10px 0; border-top: 1px solid var(--ctg-line);
}
html body .ctg-line:first-child, html body .ctg-pick-row:first-child { border-top: 0; padding-top: 0; }
html body .ctg-line:last-child, html body .ctg-pick-row:last-child { padding-bottom: 0; }
html body .ctg-line-thumb { width: 52px; aspect-ratio: 5 / 7; object-fit: contain; border-radius: 4px; background: var(--ctg-surface-2); display: block; }
.ctg-line-info { min-width: 0; }
html body .ctg-line-info p { margin: 0; }
html body .ctg-line-eyebrow { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ctg-muted); }
html body .ctg-line-name { display: block; color: var(--ctg-text); font-weight: 700; line-height: 1.3; }
html body a.ctg-line-name:hover { color: var(--ctg-accent); }
html body .ctg-line-each { font-size: 0.85rem; color: var(--ctg-muted); font-variant-numeric: tabular-nums; }
html body .ctg-line-missing { color: var(--ctg-warn); font-weight: 600; margin-left: 6px; }
html body .ctg-line-total { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ctg-text); }
html body .ctg-line.is-removed { opacity: 0.55; }
html body .ctg-line.is-removed .ctg-line-total { text-decoration: line-through; }

/* Staff pick rows: location, picture, card, found */
html body .ctg-pick-row { grid-template-columns: auto 52px minmax(0, 1fr) auto; }
html body .ctg-pick-found { display: grid; gap: 4px; margin: 0; font-size: 0.72rem; font-weight: 600; color: var(--ctg-muted); letter-spacing: 0.04em; text-transform: uppercase; }
html body .ctg-pick-found .ctg-select { width: auto; min-width: 92px; padding: 8px 10px; font-size: 0.95rem; font-weight: 700; text-transform: none; }
html body .ctg-pick-qty { font-size: 1.3rem; font-weight: 800; color: var(--ctg-text); min-width: 2.6rem; font-variant-numeric: tabular-nums; }
html body .ctg-loc {
    display: inline-block; min-width: 4.8rem; text-align: center; padding: 4px 8px; border-radius: var(--ctg-radius);
    background: var(--ctg-surface-2); border: 1px solid var(--ctg-accent); color: var(--ctg-accent);
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-weight: 800; font-size: 0.85rem; letter-spacing: 0.02em; white-space: nowrap;
}
html body .ctg-loc.is-none { border-style: dashed; border-color: var(--ctg-line-strong); color: var(--ctg-dim); font-family: var(--ctg-font); font-weight: 600; }
@media (max-width: 639px) {
    html body .ctg-pick-row { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 6px 12px; }
    html body .ctg-pick-row .ctg-loc, html body .ctg-pick-row .ctg-pick-qty { grid-column: 1 / -1; justify-self: start; }
    html body .ctg-pick-row .ctg-line-thumb, html body .ctg-line-thumb { width: 44px; }
    html body .ctg-line { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; }
}

/* Small card list in the checkout summary */
html body .ctg-mini-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 320px; overflow-y: auto; }
html body .ctg-mini-lines li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 0.88rem; }
html body .ctg-mini-lines img { width: 30px; aspect-ratio: 5 / 7; object-fit: contain; border-radius: 3px; background: var(--ctg-surface-2); }
html body .ctg-mini-name { min-width: 0; color: var(--ctg-text); font-weight: 600; line-height: 1.3; }
html body .ctg-mini-name small { color: var(--ctg-muted); font-weight: 600; margin-left: 6px; }
html body .ctg-mini-price { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Checkout section numbers */
html body .ctg-h2-step { display: flex; align-items: center; gap: 10px; }
html body .ctg-step-num {
    width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
    background: var(--ctg-accent); color: var(--ctg-on-accent); font-size: 0.82rem; font-weight: 800;
}
html body .checkout-form > .ctg-form { gap: 16px; }

/* ---------- My orders list ---------- */

html body .ctg-order-list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 10px; }
html body .ctg-order-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 16px; align-items: center;
    padding: 12px 16px; color: var(--ctg-text); text-decoration: none; transition: border-color 0.15s ease;
}
html body .ctg-order-row:hover { border-color: var(--ctg-accent); color: var(--ctg-text); }
html body .ctg-order-row:hover .ctg-order-row-title { color: var(--ctg-accent); }
.ctg-order-pics { display: flex; width: 96px; }
html body .ctg-order-pics img { width: 40px; aspect-ratio: 5 / 7; object-fit: contain; border-radius: 3px; background: var(--ctg-surface-2); box-shadow: 0 0 0 2px var(--ctg-surface-solid); }
html body .ctg-order-pics img + img { margin-left: -22px; }
.ctg-order-row-main { display: grid; gap: 2px; min-width: 0; }
html body .ctg-order-row-title { font-weight: 800; font-size: 1.02rem; }
html body .ctg-order-row-sub { font-size: 0.85rem; color: var(--ctg-muted); }
html body .ctg-order-row-total { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; min-width: 6rem; text-align: right; }
@media (max-width: 639px) {
    html body .ctg-order-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px; }
    .ctg-order-pics { width: 60px; grid-row: span 2; }
    html body .ctg-order-pics img { width: 34px; }
    html body .ctg-order-pics img + img { margin-left: -26px; }
    html body .ctg-order-row .ctg-status { grid-column: 2; justify-self: start; }
    html body .ctg-order-row-total { grid-column: 3; grid-row: 1; min-width: 0; }
}

/* ---------- Payment page ---------- */

html body .ctg-pay-card { display: grid; gap: 14px; padding: 28px; }
html body .ctg-pay-card .ctg-h1 { margin: 0; }
html body .ctg-pay-card .ctg-eyebrow { margin: 0; }
html body .ctg-pay-amount { margin: 0; font-size: 2.4rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
html body .ctg-pay-card .ctg-dl { padding: 14px 0; border-top: 1px solid var(--ctg-line); border-bottom: 1px solid var(--ctg-line); }
html body .ctg-pay-card .ctg-dl dd { text-align: right; }
html body .ctg-pay-card .ctg-button { width: 100%; }
html body .ctg-pay-secure::before { content: '🔒 '; }

/* ---------- Staff: tabs, tables, task cards ---------- */

html body .ctg-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
html body .ctg-tab {
    display: inline-flex; align-items: center; gap: 2px; padding: 7px 12px; border-radius: var(--ctg-radius);
    border: 1px solid var(--ctg-line-strong); background: var(--ctg-surface); color: var(--ctg-muted);
    font-weight: 700; font-size: 0.9rem; text-decoration: none;
}
html body .ctg-tab:hover { color: var(--ctg-text); background: var(--ctg-surface-2); }
html body .ctg-tab.is-current { color: var(--ctg-text); border-color: var(--ctg-accent); background: rgba(125, 211, 252, 0.1); }
html body .ctg-tab-count.is-busy { background: var(--ctg-accent); border-color: var(--ctg-accent); color: var(--ctg-on-accent); }
html body .ctg-tab .ctg-tab-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; height: 1.3rem; padding: 0 6px; margin-left: 6px;
    border-radius: 999px; border: 1px solid var(--ctg-line-strong); font-size: 0.75rem; font-variant-numeric: tabular-nums;
}
html body .ctg-tab .ctg-tab-count.is-busy { background: var(--ctg-accent); border-color: var(--ctg-accent); color: var(--ctg-on-accent); }

html body .ctg-table-card { padding: 0; overflow: hidden; }
html body .ctg-table-title { padding: 14px 16px 0; }
html body .ctg-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; color: var(--ctg-text); }
html body .ctg-table th {
    text-align: left; padding: 10px 14px; background: var(--ctg-surface-solid); border-bottom: 1px solid var(--ctg-line-strong);
    color: var(--ctg-dim); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
html body .ctg-table-title + .ctg-table { margin-top: 12px; }
html body .ctg-table td { padding: 11px 14px; border-bottom: 1px solid var(--ctg-line); vertical-align: middle; }
html body .ctg-table tbody tr:last-child td { border-bottom: 0; }
html body .ctg-table tbody tr:hover { background: var(--ctg-surface-2); }
html body .ctg-table .num { text-align: right; font-variant-numeric: tabular-nums; }
html body .ctg-table tr.is-flagged { box-shadow: inset 3px 0 0 var(--ctg-bad); }
html body .ctg-table tr.is-open { box-shadow: inset 3px 0 0 var(--ctg-warn); }
html body .ctg-table tr.is-closed td { color: var(--ctg-muted); }
html body .ctg-table tr.is-closed td .ctg-strong { color: var(--ctg-muted); }
html body .ctg-table-action { text-align: right; white-space: nowrap; }
html body .ctg-table-thumb { width: 28px; aspect-ratio: 5 / 7; object-fit: contain; border-radius: 3px; background: var(--ctg-surface-2); flex: none; }
html body .ctg-table-card-name { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
html body .ctg-check-col { width: 36px; }
html body .ctg-check-col input { width: 18px; height: 18px; accent-color: var(--ctg-accent); }
html body tr:has(.ctg-check-col input:checked) td { opacity: 0.5; text-decoration: line-through; }
/* Phones: each row becomes a small card */
@media (max-width: 719px) {
    html body .ctg-table-stack thead { display: none; }
    html body .ctg-table-stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--ctg-line); }
    html body .ctg-table-stack td { padding: 0; border: 0; text-align: left !important; }
    html body .ctg-table-stack td[data-label]::before { content: attr(data-label); display: block; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ctg-dim); font-weight: 700; }
    html body .ctg-table-stack .ctg-table-action, html body .ctg-table-stack td[data-label="Card"] { grid-column: 1 / -1; }
    html body .ctg-table-stack .ctg-table-action .ctg-button { width: 100%; }
}

html body .ctg-task { display: grid; gap: 14px; }
html body .ctg-task-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
html body .ctg-task-head .ctg-h2 { margin: 0; }
html body .ctg-inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
html body .ctg-inline-form .ctg-field { flex: 1 1 220px; }
html body .ctg-field-inline { max-width: 320px; }
html body .ctg-refund-account { padding: 14px; border: 1px dashed var(--ctg-warn) !important; border-radius: var(--ctg-radius); }
html body .ctg-refund-account legend { float: none; width: auto; padding: 0 6px; margin: 0 0 0 -6px; font-size: 0.88rem; }
html body .ctg-refund-account legend .ctg-muted { font-weight: 500; }
.ctg-refund-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

html body .ctg-danger-zone { padding: 0; }
html body .ctg-danger-zone > summary { list-style: none; cursor: pointer; padding: 14px 20px; font-weight: 700; color: var(--ctg-bad); }
html body .ctg-danger-zone > summary::-webkit-details-marker { display: none; }
html body .ctg-danger-zone > summary::after { content: ' ▸'; color: var(--ctg-dim); }
html body .ctg-danger-zone[open] > summary::after { content: ' ▾'; }
html body .ctg-danger-zone form { display: grid; gap: 12px; padding: 0 20px 18px; justify-items: start; }

html body .my-order-grid > .ctg-cart-summary { align-self: start; }
html body .ctg-cart-summary .ctg-dl:not(.ctg-cart-totals) dd { text-align: right; }

/* ---------- Shop computer: order placed ---------- */

.ctg-terminal-done { display: grid; place-items: center; padding: 24px 0 48px; }
html body .ctg-terminal-card { width: 100%; max-width: 560px; padding: 40px 28px; text-align: center; display: grid; justify-items: center; gap: 10px; }
html body .ctg-terminal-card p { margin: 0; }
html body .ctg-terminal-check { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: rgba(74, 222, 128, 0.14); color: var(--ctg-ok); border: 2px solid var(--ctg-ok); }
html body .ctg-terminal-card .ctg-eyebrow { color: var(--ctg-ok); justify-content: center; margin-top: 6px; }
html body .ctg-terminal-label { color: var(--ctg-muted); font-weight: 600; }
html body .ctg-terminal-number { font-size: clamp(5rem, 16vw, 8rem); font-weight: 800; line-height: 1; letter-spacing: -0.03em; color: var(--ctg-text); font-variant-numeric: tabular-nums; }
html body .ctg-terminal-card .ctg-lead { margin: 8px 0 14px; text-align: center; }

@media print {
    .ctg-shop-header, .ctg-sets, .ctg-shop-footer, .ctg-sets-open, .ctg-no-print, .ctg-back { display: none !important; }
}

/* Order pages use the full width layout (no set menu), kept to a readable width */
.ctg-order-page { max-width: 1240px; margin: 0 auto; }
