/* ══════════════════════════════════════════════════════════════════════════
   ShopCore Sales — the shell and its shared pieces (ss-*).

   Phone first: a bottom bar within reach of a thumb, one column, tiles two
   across. From 900px a desk: the screens move to the top bar, the bottom bar
   goes, columns open up. Built only on the shared tokens (--brand, --layer,
   --fg-*, --stroke-*), so the brand colours and the dark theme carry over.
   ────────────────────────────────────────────────────────────────────────── */

:root { --ss-top-h: 56px; --ss-bottom-h: 64px; }

.ss-icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }
.ss-small { font-size: var(--fs-caption, 12px); }
.ss-spacer { flex: 1; }
.ss-neg { color: var(--money-neg, var(--err-fg)); }

/* ── Shell ─────────────────────────────────────────────────────────────── */

.ss-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: var(--canvas); }

.ss-content {
    flex: 1;
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 16px 14px calc(var(--ss-bottom-h) + 20px + env(safe-area-inset-bottom));
}

.ss-boot { display: flex; gap: 12px; align-items: center; justify-content: center; min-height: 100vh; color: var(--fg-3); }

/* ── Top bar ───────────────────────────────────────────────────────────── */

.ss-top {
    position: sticky; top: 0; z-index: 400;
    display: flex; align-items: center; gap: 10px;
    height: var(--ss-top-h);
    padding: 0 14px; padding-top: env(safe-area-inset-top);
    background: var(--layer);
    border-bottom: 1px solid var(--stroke-2);
}
.ss-brand { display: flex; align-items: center; gap: 8px; color: var(--fg-1); text-decoration: none; }
.ss-brand-logo { width: 28px; height: 28px; object-fit: contain; }
.ss-brand-name { font-weight: var(--fw-semibold, 600); white-space: nowrap; }
.ss-brand-name b { color: var(--brand); }

.ss-top-nav { display: none; gap: 2px; margin-left: 18px; overflow-x: auto; }
.ss-top-link {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 11px; border-radius: var(--r-md, 6px);
    color: var(--fg-2); text-decoration: none; white-space: nowrap; font-size: 13.5px;
}
.ss-top-link:hover { background: var(--subtle-hover); color: var(--fg-1); }
.ss-top-link.on { background: var(--brand-tint); color: var(--brand); font-weight: var(--fw-semibold, 600); }

.ss-scope-chip {
    display: none;
    padding: 3px 10px; border-radius: var(--r-pill, 999px);
    background: var(--brand-tint); color: var(--brand); font-size: 12px; font-weight: 600;
}
.ss-me { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px; border-radius: var(--r-md, 6px); cursor: pointer; color: inherit; }
.ss-me:hover { background: var(--subtle-hover); }
.ss-me-text { display: none; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.ss-me-text small { color: var(--fg-3); font-size: 11.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ss-avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    border-radius: 50%; background: var(--brand-tint); color: var(--brand);
    font-weight: 700; letter-spacing: .02em; user-select: none;
}

/* ── Bottom bar (phone) ────────────────────────────────────────────────── */

.ss-bottom {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 450;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    height: calc(var(--ss-bottom-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--layer);
    border-top: 1px solid var(--stroke-2);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .05);
}
.ss-bottom-btn {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; color: var(--fg-3); text-decoration: none;
    font-size: 11px; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ss-bottom-btn.on { color: var(--brand); }
.ss-bottom-btn.on::before {
    content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--brand);
}
.ss-bottom-btn.primary .ss-icon {
    width: 40px !important; height: 40px !important; padding: 9px; margin-top: -14px;
    border-radius: 50%; background: var(--brand); color: var(--brand-on, #fff);
    box-shadow: var(--shadow-8);
}
.ss-badge {
    position: absolute; top: 6px; right: calc(50% - 20px);
    min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
    background: var(--err-fg); color: #fff; font-size: 10.5px; font-style: normal; line-height: 17px; text-align: center;
}

/* ── More sheet ────────────────────────────────────────────────────────── */

.ss-sheet-backdrop { position: fixed; inset: 0; z-index: 600; background: rgba(10, 16, 22, .35); animation: ss-fade .15s ease; }
.ss-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 610;
    max-height: 86vh; overflow-y: auto;
    padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
    background: var(--layer); border-radius: 16px 16px 0 0; box-shadow: var(--shadow-28);
    animation: ss-rise .2s var(--ease-decel, ease-out);
}
.ss-sheet-grip { width: 40px; height: 4px; margin: 4px auto 12px; border-radius: 2px; background: var(--stroke-2); }
.ss-sheet-who { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--stroke-2); }
.ss-sheet-who div { display: flex; flex-direction: column; }
.ss-sheet-who small { color: var(--fg-3); }
.ss-sheet-group { margin: 16px 0 8px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-3); }
.ss-sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ss-sheet-tile {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 6px; border-radius: var(--r-lg, 8px); background: var(--layer-alt);
    color: var(--fg-1); text-decoration: none; font-size: 12.5px; text-align: center;
}
.ss-sheet-tile:hover { background: var(--brand-tint); color: var(--brand); }
.ss-sheet-list { display: flex; flex-direction: column; }
.ss-sheet-list a, .ss-sheet-list button {
    padding: 12px 4px; border: 0; border-bottom: 1px solid var(--stroke-1); background: none;
    color: var(--fg-1); text-align: left; text-decoration: none; font: inherit; cursor: pointer;
}

@keyframes ss-rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ss-fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Refused ───────────────────────────────────────────────────────────── */

.ss-refused { display: flex; align-items: center; justify-content: center; min-height: 70vh; padding: 20px; }
.ss-refused-card {
    max-width: 520px; padding: 32px 28px; text-align: center;
    background: var(--layer); border: 1px solid var(--stroke-2); border-radius: var(--r-xl, 12px); box-shadow: var(--shadow-4);
}
.ss-refused-card h2 { margin: 10px 0 8px; }
.ss-refused-icon { display: inline-flex; padding: 14px; border-radius: 50%; background: var(--warn-bg); color: var(--warn-fg); }
.ss-refused-actions { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }

/* ── Shared pieces ─────────────────────────────────────────────────────── */

.ss-seg { display: inline-flex; padding: 3px; border-radius: var(--r-pill, 999px); background: var(--layer-alt); border: 1px solid var(--stroke-1); }
.ss-seg-btn {
    min-width: 64px; padding: 6px 14px; border: 0; border-radius: var(--r-pill, 999px);
    background: none; color: var(--fg-2); font: inherit; font-size: 13px; cursor: pointer;
}
.ss-seg-btn.on { background: var(--layer); color: var(--brand); font-weight: 600; box-shadow: var(--shadow-2); }

.ss-greet { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.ss-greet h1 { margin: 2px 0; font-size: 22px; }
.ss-greet-date { color: var(--fg-3); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.ss-greet-actions { display: flex; align-items: center; gap: 8px; }

.ss-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.ss-cols { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.ss-cols > * { min-width: 0; }

.ss-trend-foot { display: flex; justify-content: space-between; margin-top: 6px; }

.ss-list { list-style: none; margin: 0; padding: 0; }
.ss-list-row { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--stroke-1); }
.ss-list-row:last-child { border-bottom: 0; }
.ss-list-main { flex: 1; min-width: 0; }
.ss-list-title { display: flex; gap: 8px; align-items: baseline; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ss-list-title .fx-muted { overflow: hidden; text-overflow: ellipsis; }
.ss-list-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; color: var(--fg-3); font-size: 12px; }
.ss-list-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }

.ss-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--stroke-strong); }
.ss-dot.err { background: var(--err-fg); } .ss-dot.warn { background: var(--warn-fg); } .ss-dot.info { background: var(--info-fg); }
.ss-pill { padding: 1px 8px; border-radius: var(--r-pill, 999px); font-size: 11px; font-weight: 600; background: var(--slate-bg); color: var(--slate-fg); }
.ss-pill.err { background: var(--err-bg); color: var(--err-fg); }
.ss-pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.ss-pill.info { background: var(--info-bg); color: var(--info-fg); }
.ss-pill.ok { background: var(--ok-bg); color: var(--ok-fg); }

/* Team board: cards on a phone, a table on a desk — same markup. */
.ss-board-head { display: none; }
.ss-board-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--stroke-1); font-variant-numeric: tabular-nums;
}
.ss-board-row:last-child { border-bottom: 0; }
.ss-board-who { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.ss-board-row > span[data-label]::before { content: attr(data-label); display: block; color: var(--fg-3); font-size: 11px; }

.ss-facts { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.ss-facts > div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--stroke-1); }
.ss-facts > div:last-child { border-bottom: 0; }
.ss-facts dt { color: var(--fg-3); }
.ss-facts dd { margin: 0; text-align: right; font-weight: 500; }

.ss-profile-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.ss-profile-head h2 { margin: 0; }

/* ── Desk ──────────────────────────────────────────────────────────────── */

@media (min-width: 900px) {
    .ss-content { padding: 22px 26px 32px; }
    .ss-bottom { display: none; }
    .ss-top { padding: 0 22px; }
    .ss-top-nav { display: flex; }
    .ss-scope-chip { display: inline-block; }
    .ss-me-text { display: flex; }

    .ss-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ss-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .ss-sheet {
        left: auto; right: 16px; top: calc(var(--ss-top-h) + 6px); bottom: auto;
        width: 380px; border-radius: var(--r-xl, 12px);
        animation: ss-fade .15s ease;
    }
    .ss-sheet-grip { display: none; }

    .ss-board-head, .ss-board-row {
        display: grid; grid-template-columns: 2fr repeat(5, 1fr); gap: 12px; align-items: center;
    }
    .ss-board-head { padding: 9px 16px; color: var(--fg-3); font-size: 12px; border-bottom: 1px solid var(--stroke-2); }
    .ss-board-head span:not(:first-child), .ss-board-row > span:not(:first-child) { text-align: right; }
    .ss-board-who { grid-column: auto; }
    .ss-board-row > span[data-label]::before { display: none; }
}

@media (min-width: 1200px) {
    .ss-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ── Lists, records and their controls (customers onwards) ─────────────── */

.ss-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.ss-toolbar > :first-child { flex: 1 1 220px; min-width: 0; }
.ss-sort { width: auto; flex: 0 0 auto; }
.ss-mb { margin-bottom: 12px; }
.ss-block { display: block; }
.ss-credit { color: var(--ok-fg); }
.ss-muted-row { color: var(--fg-3); background: var(--layer-alt); }

.ss-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.ss-chips::-webkit-scrollbar { display: none; }
.ss-chip {
    flex: 0 0 auto; padding: 6px 12px; border-radius: var(--r-pill, 999px);
    border: 1px solid var(--stroke-2); background: var(--layer); color: var(--fg-2);
    font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.ss-chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-on, #fff); }

.ss-tabs {
    position: sticky; top: var(--ss-top-h); z-index: 50;
    display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
    margin: 0 -14px 14px; padding: 0 14px; background: var(--canvas); border-bottom: 1px solid var(--stroke-2);
}
.ss-tabs::-webkit-scrollbar { display: none; }
.ss-tab {
    flex: 0 0 auto; padding: 11px 14px; border: 0; border-bottom: 2px solid transparent; background: none;
    color: var(--fg-2); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.ss-tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.ss-tab i { font-style: normal; margin-left: 5px; padding: 0 6px; border-radius: 9px; background: var(--layer-alt); color: var(--fg-3); font-size: 11px; }

.ss-back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; color: var(--fg-2); text-decoration: none; font-size: 13px; }
.ss-rec-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ss-rec-title { min-width: 0; }
.ss-rec-title h1 { margin: 0; font-size: 21px; line-height: 1.2; }

.ss-contact-actions, .ss-doc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ss-contact-actions .fx-btn, .ss-doc-actions .fx-btn { display: inline-flex; align-items: center; gap: 5px; }

.ss-card-list { display: flex; flex-direction: column; background: var(--layer); border: 1px solid var(--stroke-2); border-radius: var(--r-lg, 8px); overflow: hidden; }
.ss-cust {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    border-bottom: 1px solid var(--stroke-1); color: inherit; text-decoration: none;
}
.ss-cust:last-child { border-bottom: 0; }
.ss-cust:hover { background: var(--subtle-hover); }
.ss-cust-main { flex: 1; min-width: 0; }
.ss-cust-name { display: flex; align-items: center; gap: 6px; overflow: hidden; }
.ss-cust-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-cust-money { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ss-contact { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--stroke-1); }
.ss-contact:last-child { border-bottom: 0; }
.ss-contact .ss-contact-actions { margin-top: 8px; }

.ss-pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 12px 0; }
.ss-pager > span { margin-right: auto; }

.ss-kind {
    flex-shrink: 0; width: 38px; padding: 4px 0; border-radius: var(--r-sm, 4px); text-align: center;
    font-size: 10.5px; font-weight: 700; background: var(--slate-bg); color: var(--slate-fg);
}
.ss-kind.quotation { background: var(--info-bg); color: var(--info-fg); }
.ss-kind.order { background: var(--plum-bg); color: var(--plum-fg); }
.ss-kind.invoice { background: var(--ok-bg); color: var(--ok-fg); }
.ss-kind.creditnote { background: var(--warn-bg); color: var(--warn-fg); }

.ss-statement { display: flex; flex-direction: column; gap: 12px; }
.ss-statement-dates { display: flex; flex-wrap: wrap; gap: 10px; }
.ss-statement-dates label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--fg-3); flex: 1 1 140px; }
.ss-statement-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 599px) {
    .ss-list-row .ss-doc-actions { width: 100%; justify-content: flex-end; }
    .ss-list-row:has(.ss-doc-actions) { flex-wrap: wrap; }
}
@media (min-width: 900px) {
    .ss-tabs { margin: 0 0 16px; padding: 0; }
}
