/* ==========================================================================
   Natural Stone slab catalog. Laid out and styled like the Digital
   Dashboard: dark by default, light on request, terracotta as the one
   accent. Mobile first.

   Every colour, size, weight and radius is a token from the theme
   (themes/ns-catalog/style.css), and the same rules serve dark and light:
   only the token values change. scripts/check-tokens.sh fails the build on
   a literal value in this file.
   ========================================================================== */

/* ---------------------------------------------------------------- shell */

.ns-body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
}

.ns-has-tabbar {
    --tabbar-h: calc(60px + env(safe-area-inset-bottom));
}

.ns-app {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.ns-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--tabbar-h);
}

.ns-muted {
    color: var(--ink-3);
}

.ns-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.ns-icon {
    flex: none;
}

/* Rail: the Digital Dashboard's left column, desktop only. */
.ns-rail {
    display: none;
}

@media (min-width: 900px) {
    .ns-app {
        grid-template-columns: var(--rail-w) minmax(0, 1fr);
    }

    .ns-bare .ns-app {
        grid-template-columns: minmax(0, 1fr);
    }

    .ns-has-tabbar {
        --tabbar-h: 0px;
    }

    .ns-rail {
        position: sticky;
        top: 0;
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-1);
        padding: var(--space-5) 0 var(--space-4);
        background: var(--bg-glass);
        border-right: 1px solid var(--line);
        z-index: 30;
    }
}

.ns-rail__logo {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: var(--space-6);
    color: var(--ink);
}

.ns-logo-mark {
    width: 32px;
    height: auto;
}

.ns-rail__nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.ns-rail__item {
    position: relative;
    width: 64px;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-2) 0;
    border: 0;
    border-radius: var(--radius-pop);
    background: transparent;
    color: var(--ink-3);
    text-decoration: none;
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.ns-rail__item:hover {
    color: var(--ink);
    background: var(--hover);
}

.ns-rail__item.is-active {
    color: var(--ink);
    background: var(--surface-2);
}

.ns-rail__item.is-active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: var(--radius-pill);
    background: var(--accent);
}

.ns-rail__label {
    font-size: var(--cs-text-2xs);
    font-weight: var(--fw-medium);
    line-height: 1;
}

.ns-rail__spacer {
    flex: 1;
}

.ns-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-top: var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: var(--cs-text-xs);
    font-weight: var(--fw-semibold);
}

/* The theme toggle shows the mode you would switch to: a sun in dark mode,
   a moon in light mode. */
.ns-theme-dark,
.ns-theme-light {
    display: inline-flex;
}

.ns-theme-light,
html.ns-light .ns-theme-dark {
    display: none;
}

html.ns-light .ns-theme-light {
    display: inline-flex;
}

/* Top bar */
.ns-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-height: var(--bar-h);
    padding: 0 var(--space-4);
    padding-top: env(safe-area-inset-top);
    background: var(--bg-glass);
    border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    backdrop-filter: saturate(140%) blur(14px);
}

.ns-bar__brand {
    display: flex;
    align-items: center;
    color: var(--ink);
}

.ns-bar__brand .cs-logo {
    height: 20px !important;
}

.ns-bar__context {
    display: none;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    font-size: var(--cs-text-sm);
    color: var(--ink-3);
    white-space: nowrap;
}

.ns-bar__product {
    padding-left: var(--space-4);
    border-left: 1px solid var(--line-strong);
}

.ns-bar__page {
    color: var(--ink);
    font-weight: var(--fw-medium);
    overflow: hidden;
    text-overflow: ellipsis;
}

.ns-bar__end {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

.ns-bar__who {
    display: none;
    text-align: right;
    font-size: var(--cs-text-sm);
    font-weight: var(--fw-medium);
    line-height: var(--lh-tight);
    margin-right: var(--space-2);
}

.ns-bar__who small {
    display: block;
    font-size: var(--cs-text-xs);
    font-weight: var(--fw-regular);
    color: var(--ink-3);
}

.ns-iconbtn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--ctl-border);
    border-radius: var(--radius-ctl);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.ns-iconbtn:hover {
    background: var(--hover);
    border-color: var(--ink-2);
}

.ns-iconbtn .ns-rail__label {
    display: none;
}

@media (min-width: 640px) {
    .ns-bar__context {
        display: flex;
    }
}

@media (min-width: 900px) {
    .ns-bar {
        padding: 0 var(--space-8);
    }

    .ns-body:not(.ns-bare) .ns-bar__brand {
        display: none;
    }

    .ns-body:not(.ns-bare) .ns-bar__product {
        padding-left: 0;
        border-left: 0;
    }

    .ns-bar__who {
        display: block;
    }

    .ns-body:not(.ns-bare) .ns-bar__theme,
    .ns-bar__out {
        display: none;
    }
}

/* Phone tab bar */
.ns-tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-glass);
    border-top: 1px solid var(--line);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    backdrop-filter: saturate(140%) blur(14px);
}

.ns-tabbar__link {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 60px;
    font-size: var(--cs-text-xs);
    font-weight: var(--fw-medium);
    color: var(--ink-3);
    text-decoration: none;
}

.ns-tabbar__link.is-active {
    color: var(--ink);
}

.ns-tabbar__link.is-active::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 30%;
    right: 30%;
    height: 2px;
    border-radius: var(--radius-pill);
    background: var(--accent);
}

@media (min-width: 900px) {
    .ns-tabbar {
        display: none;
    }
}

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

.ns-content {
    flex: 1;
}

.ns-page {
    width: 100%;
    max-width: var(--page-max-w);
    margin: 0 auto;
    padding: var(--space-6) var(--space-4) var(--space-12);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.ns-page--narrow {
    max-width: 46rem;
}

/* A wide table or a long serial scrolls inside its box; it never widens the page. */
.ns-page > *,
.ns-receive > * {
    min-width: 0;
    max-width: 100%;
}

@media (min-width: 900px) {
    .ns-page {
        padding: var(--space-8) var(--space-8) var(--space-12);
        gap: var(--space-6);
    }
}

.ns-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.ns-eyebrow {
    margin-bottom: var(--space-2);
    font-size: var(--cs-text-xs);
    color: var(--ink-3);
}

.ns-h1,
.ns-head h1 {
    font-size: var(--cs-display-sm);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    color: var(--ink);
}

.ns-lede {
    margin-top: var(--space-2);
    max-width: 44rem;
    font-size: var(--cs-text);
    color: var(--ink-2);
}

.ns-lede strong {
    color: var(--ink);
    font-weight: var(--fw-semibold);
}

.ns-btn.ns-head__action {
    display: none; /* the tab bar carries it on a phone */
}

@media (min-width: 900px) {
    .ns-btn.ns-head__action {
        display: inline-flex;
    }
}

h2 {
    font-size: var(--cs-text-lg);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
}

/* -------------------------------------------------------------- controls */

.ns-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--ctl-h);
    padding: 0 var(--space-4);
    font-size: var(--cs-text-sm);
    font-weight: var(--fw-medium);
    line-height: var(--lh-tight);
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-ctl);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.ns-btn .ns-icon {
    width: 18px;
    height: 18px;
}

.ns-btn--primary {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--ink-inverse);
}

.ns-btn--primary:hover {
    background: var(--ink-2);
    border-color: var(--ink-2);
}

/* No coloured buttons: the one primary per screen is ink. Terracotta
   marks state only (active tab, selection, focus). */

.ns-btn--secondary {
    background: var(--surface);
    border-color: var(--ctl-border);
    color: var(--ink);
}

.ns-btn--secondary:hover {
    background: var(--hover);
    border-color: var(--ink-2);
}

.ns-btn--ghost {
    background: transparent;
    color: var(--ink-3);
}

.ns-btn--ghost:hover {
    background: var(--hover);
    color: var(--ink);
}

.ns-btn--block {
    width: 100%;
}

/* A text action inside a sentence, e.g. "New container" on the receive page. */
.ns-linkbtn {
    background: none;
    border: 0;
    padding: var(--space-1) 0;
    font: inherit;
    color: var(--accent-strong);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
}

.ns-linkbtn:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.ns-btn--lg {
    min-height: 48px;
    font-size: var(--cs-text);
}

.ns-btn--sm {
    min-height: 32px;
    padding: 0 var(--space-3);
    font-size: var(--cs-text-xs);
}

.ns-btn:disabled,
.ns-btn[aria-busy='true'] {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.ns-link {
    padding: 0;
    background: none;
    border: 0;
    font-size: inherit;
    font-weight: var(--fw-medium);
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--line-strong);
    text-underline-offset: 3px;
    cursor: pointer;
}

.ns-link:hover {
    text-decoration-color: var(--ink);
}

.ns-link--danger {
    color: var(--critical);
    text-decoration-color: var(--critical-line);
}

.ns-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    align-self: flex-start;
    min-height: 36px;
    font-size: var(--cs-text-sm);
    font-weight: var(--fw-medium);
    color: var(--ink-3);
    text-decoration: none;
}

.ns-back .ns-icon {
    width: 18px;
    height: 18px;
}

.ns-back:hover {
    color: var(--ink);
}

.ns-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
    margin-bottom: var(--space-4);
}

.ns-field--short {
    max-width: 16rem;
}

.ns-field__label {
    font-size: var(--cs-text-sm);
    font-weight: var(--fw-medium);
    color: var(--ink-2);
}

.ns-field__label small {
    font-size: var(--cs-text-sm);
    font-weight: var(--fw-regular);
    color: var(--ink-3);
}

.ns-input {
    width: 100%;
    min-height: var(--ctl-h);
    padding: var(--space-2) var(--space-3);
    font-size: var(--cs-text); /* 16px: iOS zooms the page on anything smaller */
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--ctl-border);
    border-radius: var(--radius-ctl);
    appearance: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ns-input::placeholder {
    color: var(--ink-4);
}

select.ns-input {
    padding-right: var(--space-8);
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

select.ns-input option {
    background: var(--surface-2);
    color: var(--ink);
}

textarea.ns-input {
    resize: vertical;
    line-height: var(--lh-base);
}

.ns-input:hover {
    border-color: var(--ink-2);
}

.ns-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.ns-input--code {
    font-family: var(--font-mono);
    font-size: var(--cs-text-lg);
    text-align: center;
}

.ns-input--serial {
    font-family: var(--font-mono);
    font-size: var(--cs-text-lg);
}

.ns-inputgroup {
    display: flex;
    gap: var(--space-2);
}

.ns-fieldrow {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 var(--space-3);
}

.ns-fieldrow--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ns-fieldrow--3 {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .ns-fieldrow--3 {
        grid-template-columns: 2fr 1.5fr 1.5fr;
    }
}

.ns-error {
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    font-size: var(--cs-text-sm);
    color: var(--critical);
    background: var(--critical-soft);
    border: 1px solid var(--critical-line);
    border-radius: var(--radius-ctl);
}

/* --------------------------------------------------------------- panels */

.ns-panel {
    margin: 0;
    padding: var(--space-5) var(--space-5) var(--space-2);
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
}

.ns-panel legend,
.ns-panel > h2 {
    float: left;
    width: 100%;
    margin: 0 0 var(--space-2);
    padding: 0;
    font-size: var(--cs-text);
    font-weight: var(--fw-semibold);
}

/* The legend is floated so it sits inside the panel instead of on its
   border; everything after it starts below it. */
.ns-panel > :not(legend) {
    clear: both;
}

.ns-panel > .ns-muted {
    clear: both;
    margin-bottom: var(--space-4);
    font-size: var(--cs-text-sm);
}

.ns-panel > .ns-btn {
    margin-bottom: var(--space-4);
}

/* ----------------------------------------------------------- status chips */

.ns-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 24px;
    padding: 0 var(--space-3) 0 var(--space-2);
    font-size: var(--cs-text-xs);
    font-weight: var(--fw-medium);
    line-height: 1;
    white-space: nowrap;
    border-radius: var(--radius-pill);
}

.ns-chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: var(--radius-pill);
    background: currentColor;
}

.ns-chip--available { color: var(--st-available); background: var(--st-available-soft); }
.ns-chip--photos_sent { color: var(--st-sent); background: var(--st-sent-soft); }
.ns-chip--reserved { color: var(--st-reserved); background: var(--st-reserved-soft); }
.ns-chip--sold { color: var(--st-sold); background: var(--st-sold-soft); }

.ns-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--ink-4);
}

.ns-dot--available { background: var(--st-available); }
.ns-dot--photos_sent { background: var(--st-sent); }
.ns-dot--reserved { background: var(--st-reserved); }
.ns-dot--sold { background: var(--st-sold); }

/* ------------------------------------------------------- catalog: tiles */

.ns-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    background: var(--surface);
    border: 1px solid var(--line);
}

.ns-kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
    padding: var(--space-4);
    color: inherit;
    text-decoration: none;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    transition: background var(--transition-fast);
}

.ns-kpi:hover {
    background: var(--hover);
}

.ns-kpi--all {
    grid-column: 1 / -1;
    border-top: 0;
    border-left: 0;
    background: var(--hero-wash);
}

.ns-kpi:nth-child(2n) {
    border-left: 0;
}

.ns-kpi.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -1px;
    height: 2px;
    background: var(--accent);
}

.ns-kpi__label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--cs-text-xs);
    color: var(--ink-3);
}

.ns-kpi__value {
    font-size: var(--cs-kpi);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.ns-kpi__hint {
    display: none;
    font-size: var(--cs-text-xs);
    color: var(--ink-3);
}

/* On a phone the strip stays short: All on one line, then four small tiles. */
@media (max-width: 899px) {
    .ns-kpi {
        padding: var(--space-3) var(--space-4);
    }

    .ns-kpi--all {
        flex-direction: row;
        align-items: baseline;
        justify-content: space-between;
    }

    .ns-kpi__value {
        font-size: var(--cs-text-lg);
    }
}

.ns-kpi__bar {
    position: absolute;
    left: var(--space-4);
    right: var(--space-4);
    bottom: 0;
    height: 2px;
    background: var(--line);
}

.ns-kpi__bar::after {
    content: "";
    display: block;
    height: 100%;
    width: calc(var(--share, 0) * 100%);
    background: var(--ink-4);
}

.ns-kpi.is-active .ns-kpi__bar::after {
    background: var(--accent);
}

@media (min-width: 900px) {
    .ns-kpis {
        grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
    }

    .ns-kpi {
        padding: var(--space-5);
        border-top: 0;
    }

    .ns-kpi__hint {
        display: block;
    }

    .ns-kpi--all {
        grid-column: auto;
    }

    .ns-kpi:nth-child(2n) {
        border-left: 1px solid var(--line);
    }

    .ns-kpi__bar {
        left: var(--space-5);
        right: var(--space-5);
    }
}

/* -------------------------------------------------- catalog: filter bar */

.ns-filterbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
}

.ns-search {
    position: relative;
    grid-column: 1 / -1;
}

.ns-search .ns-icon {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-4);
    pointer-events: none;
}

.ns-search .ns-input {
    padding-left: var(--space-10);
}

.ns-filterbar__go {
    display: none;
}

.ns-filterbar__clear {
    grid-column: 1 / -1;
    justify-self: start;
}

@media (min-width: 900px) {
    .ns-filterbar {
        grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) auto auto;
        align-items: center;
    }

    .ns-search,
    .ns-filterbar__clear {
        grid-column: auto;
    }

    .ns-filterbar__go {
        display: inline-flex;
    }
}

.ns-resultline {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: calc(var(--space-2) * -1);
    font-size: var(--cs-text-sm);
    color: var(--ink-3);
}

.ns-resultline__hint {
    display: none;
    color: var(--ink-3);
}

@media (min-width: 900px) {
    .ns-resultline__hint {
        display: inline;
    }
}

/* ---------------------------------------------------- catalog: the grid */

.ns-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

@media (min-width: 640px) {
    .ns-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
}

@media (min-width: 1100px) {
    .ns-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1440px) {
    .ns-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.ns-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    transition: border-color var(--transition-fast), box-shadow var(--transition-normal), transform var(--transition-normal);
}

.ns-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.ns-card__media {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--surface-media);
}

.ns-card__media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--photo-fade);
    pointer-events: none;
}

.ns-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 700ms var(--ease);
}

.ns-card:hover .ns-card__media img {
    transform: scale(1.05);
}

.ns-card__nophoto {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-size: var(--cs-text-xs);
    color: var(--ink-3);
}

.ns-card__count {
    position: absolute;
    right: var(--space-2);
    bottom: var(--space-2);
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    font-size: var(--cs-text-xs);
    font-weight: var(--fw-medium);
    color: var(--ink-on-photo);
    background: var(--scrim-photo);
    border-radius: var(--radius-pill);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.ns-card__count .ns-icon {
    width: 14px;
    height: 14px;
}

.ns-card__status {
    position: absolute;
    left: var(--space-2);
    bottom: var(--space-2);
    z-index: 1;
}

.ns-card__status .ns-chip {
    background: var(--glass);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.ns-card__pick {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    width: var(--tap);
    height: var(--tap);
    cursor: pointer;
}

.ns-card__pick input {
    position: absolute;
    opacity: 0;
}

.ns-card__pick span {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    color: transparent;
    background: var(--scrim-photo);
    border: 2px solid var(--ink-on-photo);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.ns-card__pick .ns-icon {
    width: 16px;
    height: 16px;
}

.ns-card__pick input:checked + span {
    color: var(--ink-on-accent);
    background: var(--accent);
    border-color: var(--accent);
}

.ns-card__pick input:focus-visible + span {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.ns-card.is-picked {
    border-color: var(--accent-line);
    box-shadow: 0 0 0 1px var(--accent-line);
}

.ns-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-3) var(--space-4);
}

@media (min-width: 640px) {
    .ns-card__body {
        padding: var(--space-4);
    }
}

.ns-card__material {
    font-size: var(--cs-text-xs);
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ns-card__serial {
    font-family: var(--font-mono);
    font-size: var(--cs-text);
    font-weight: var(--fw-semibold);
    color: var(--ink);
    text-decoration: none;
    overflow-wrap: anywhere;
}

/* The whole card is the link, without nesting the checkbox inside an anchor. */
.ns-card__serial::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

.ns-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-2);
    font-size: var(--cs-text-xs);
    color: var(--ink-3);
}

.ns-card__meta span + span::before {
    content: "·";
    margin-right: var(--space-2);
    color: var(--ink-4);
}

.ns-card__customer {
    margin-top: var(--space-1);
    padding-top: var(--space-2);
    font-size: var(--cs-text-xs);
    color: var(--ink-2);
    border-top: 1px solid var(--line);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ns-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-12) var(--space-4);
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--line-strong);
}

.ns-empty h1,
.ns-empty h2 {
    font-size: var(--cs-text-lg);
}

.ns-empty .ns-btn {
    margin-top: var(--space-4);
}

.ns-empty__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-2);
    color: var(--ink-3);
    background: var(--surface-3);
    border-radius: var(--radius-pill);
}

.ns-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-4);
    font-size: var(--cs-text-sm);
}

.ns-sharebar {
    position: fixed;
    left: var(--space-3);
    right: var(--space-3);
    bottom: calc(var(--tabbar-h) + var(--space-3));
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pop);
    box-shadow: var(--shadow-pop);
}

.ns-sharebar__count {
    font-size: var(--cs-text-sm);
    color: var(--ink-2);
    white-space: nowrap;
}

.ns-sharebar__count strong {
    color: var(--ink);
}

.ns-sharebar__actions {
    display: flex;
    gap: var(--space-2);
}

@media (min-width: 900px) {
    .ns-sharebar {
        left: calc(50% + var(--rail-w) / 2);
        right: auto;
        bottom: var(--space-6);
        transform: translateX(-50%);
        gap: var(--space-8);
    }
}

/* ------------------------------------------------------------------ slab */

.ns-slab {
    display: grid;
    gap: var(--space-5);
}

@media (min-width: 1000px) {
    .ns-slab {
        grid-template-columns: minmax(0, 1.75fr) minmax(22rem, 1fr);
        gap: var(--space-6);
        align-items: start;
    }

    .ns-slab__side {
        position: sticky;
        top: calc(var(--bar-h) + var(--space-6));
    }
}

.ns-slab__photos {
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--line);
}

.ns-slab__side {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--line);
}

.ns-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
}

.ns-gallery--empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    aspect-ratio: 4 / 3;
    background: var(--surface-media);
}

.ns-gallery__item {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--surface-media);
}

.ns-gallery__item--lead {
    grid-column: 1 / -1;
}

.ns-gallery__item a {
    display: block;
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

.ns-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 700ms var(--ease);
}

.ns-gallery__item:hover img {
    transform: scale(1.03);
}

.ns-gallery__remove {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-size: var(--cs-text-xs);
    font-weight: var(--fw-medium);
    color: var(--ink-on-photo);
    background: var(--scrim-photo);
    border: 0;
    border-radius: var(--radius-pill);
    cursor: pointer;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

/* With a mouse, Remove appears on hover; on a touch screen it stays. */
@media (hover: hover) {
    .ns-gallery__remove {
        opacity: 0;
        transition: opacity var(--transition-fast);
    }

    .ns-gallery__item:hover .ns-gallery__remove,
    .ns-gallery__remove:focus-visible {
        opacity: 1;
    }
}

.ns-uploader {
    margin-top: var(--space-3);
}

.ns-uploader__list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
    margin: var(--space-3) 0;
}

@media (min-width: 640px) {
    .ns-uploader__list {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.ns-uploader__list:empty {
    display: none;
}

.ns-upload {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--surface-media);
}

.ns-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ns-upload__state {
    position: absolute;
    inset: auto 0 0 0;
    padding: var(--space-1) var(--space-2);
    font-size: var(--cs-text-xs);
    color: var(--ink-on-photo);
    background: var(--scrim-photo);
}

.ns-upload__bar {
    position: absolute;
    inset: auto 0 0 0;
    height: 3px;
    background: var(--accent);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform var(--transition-fast);
}

.ns-upload.is-failed .ns-upload__state {
    background: var(--critical-soft);
    color: var(--critical);
}

.ns-upload__remove {
    position: absolute;
    top: 0;
    right: 0;
    width: 36px;
    height: 36px;
    font-size: var(--cs-text-lg);
    line-height: 1;
    color: var(--ink-on-photo);
    background: var(--scrim-photo);
    border: 0;
    cursor: pointer;
}

.ns-slab__title {
    display: grid;
    gap: var(--space-2);
    justify-items: start;
}

.ns-slab__title .ns-eyebrow {
    margin-bottom: 0;
}

.ns-slab__title .ns-h1 {
    font-family: var(--font-mono);
    overflow-wrap: anywhere;
}

.ns-note {
    display: grid;
    gap: var(--space-1);
    padding: var(--space-4);
    font-size: var(--cs-text-sm);
    color: var(--ink-2);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-strong);
}

.ns-note--photos_sent { border-left-color: var(--st-sent); }
.ns-note--reserved { border-left-color: var(--st-reserved); background: var(--st-reserved-soft); }
.ns-note--sold { border-left-color: var(--st-sold); }

.ns-note strong {
    font-size: var(--cs-text);
    font-weight: var(--fw-semibold);
    color: var(--ink);
}

.ns-actions {
    display: grid;
    gap: var(--space-2);
}

.ns-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    padding: var(--space-5) 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.ns-facts__wide {
    grid-column: 1 / -1;
}

.ns-facts dt {
    margin-bottom: var(--space-1);
    font-size: var(--cs-text-xs);
    color: var(--ink-3);
}

.ns-facts dd {
    font-size: var(--cs-text-sm);
    color: var(--ink);
}

.ns-slab__tools {
    display: flex;
    gap: var(--space-5);
    font-size: var(--cs-text-sm);
}

.ns-history h2 {
    margin-bottom: var(--space-2);
    font-size: var(--cs-text);
}

.ns-history ol {
    position: relative;
}

.ns-history li {
    position: relative;
    display: grid;
    gap: 2px;
    padding: var(--space-2) 0 var(--space-2) var(--space-5);
    font-size: var(--cs-text-sm);
    color: var(--ink-2);
}

.ns-history li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 14px;
    width: 7px;
    height: 7px;
    border-radius: var(--radius-pill);
    background: var(--line-strong);
}

.ns-history li:first-child::before {
    background: var(--accent);
}

.ns-history li + li::after {
    content: "";
    position: absolute;
    left: 7px;
    top: -10px;
    height: 22px;
    width: 1px;
    background: var(--line-strong);
}

.ns-history small {
    font-size: var(--cs-text-xs);
}

/* --------------------------------------------------------------- receive */

.ns-receive {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.ns-photobtns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

/* Two buttons side by side on a phone: let the label wrap rather than
   push the page wider than the screen. */
.ns-photobtns .ns-btn {
    min-width: 0;
    padding: var(--space-2) var(--space-3);
    white-space: normal;
    text-align: center;
}

.ns-receive__submit {
    position: sticky;
    bottom: var(--tabbar-h);
    z-index: 5;
    margin: 0 calc(var(--space-4) * -1);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-glass);
    border-top: 1px solid var(--line);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

@media (min-width: 900px) {
    .ns-receive__submit {
        position: static;
        margin: 0;
        padding: 0;
        background: none;
        border: 0;
    }
}

.ns-receive__done {
    border-color: var(--st-available);
    background: var(--st-available-soft);
}

.ns-receive__done p {
    margin-bottom: var(--space-4);
}

.ns-receive__session h2 {
    margin-bottom: var(--space-2);
    font-size: var(--cs-text);
}

.ns-receive__session li {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    font-size: var(--cs-text-sm);
    border-top: 1px solid var(--line);
}

.ns-scanner {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    grid-template-rows: 1fr auto auto;
    gap: var(--space-4);
    padding: var(--space-4);
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
    color: var(--ink-on-photo);
    text-align: center;
    background: var(--cs-guide-black);
}

.ns-scanner video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------------------------------------------------------------- manage */

.ns-tabs {
    display: flex;
    gap: var(--space-1);
    padding: 3px;
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--ctl-border);
    border-radius: var(--radius-ctl);
}

.ns-tabs__tab {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 var(--space-4);
    font-size: var(--cs-text-sm);
    font-weight: var(--fw-medium);
    color: var(--ink-3);
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.ns-tabs__tab:hover {
    color: var(--ink);
}

.ns-tabs__tab.is-active {
    color: var(--ink);
    background: var(--surface-3);
}

.ns-inlineform {
    padding-bottom: var(--space-5);
}

.ns-tablewrap {
    position: relative; /* holds the table's visually-hidden labels inside it */
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
}

.ns-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--cs-text-sm);
}

.ns-table th,
.ns-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

.ns-table th {
    font-size: var(--cs-text-xs);
    font-weight: var(--fw-medium);
    color: var(--ink-3);
    background: var(--surface-2);
}

.ns-table tbody tr:hover {
    background: var(--hover);
}

.ns-table tr:last-child td {
    border-bottom: 0;
}

.ns-table__end {
    text-align: right;
}

/* ----------------------------------------------------------------- share */

.ns-sharehead {
    max-width: 46rem;
}

.ns-shareslab {
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--line);
}

.ns-shareslab header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.ns-shareslab h2 {
    margin-bottom: var(--space-1);
}

.ns-sharefoot {
    display: grid;
    gap: var(--space-2);
    padding-top: var(--space-4);
    font-size: var(--cs-text-sm);
    border-top: 1px solid var(--line);
}

@media (min-width: 768px) {
    .ns-shareslab .ns-gallery {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .ns-shareslab .ns-gallery__item--lead {
        grid-column: span 2;
        grid-row: span 2;
    }
}

/* ----------------------------------------------------------------- login */

.ns-login {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    color: var(--ink);
    /* A Caesarstone kitchen in black stone, the same photo as the Digital
       Dashboard's sign-in, veiled so the cards read at 4.5:1 or more. */
    background: var(--login-veil), var(--login-photo-sm) center 60% / cover no-repeat, var(--bg);
}

@media (min-width: 768px) {
    .ns-login {
        background-image: var(--login-veil), var(--login-photo-md);
    }
}

@media (min-width: 1280px) {
    .ns-login {
        background-image: var(--login-veil), var(--login-photo-lg);
    }
}

.ns-login__bar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-height: var(--bar-h);
    padding: 0 var(--space-5);
    background: var(--bg-glass);
    border-bottom: 1px solid var(--line);
}

.ns-login__logo {
    display: flex;
    color: var(--ink);
}

.ns-login__logo .cs-logo {
    height: 20px !important;
}

.ns-login__product {
    padding-left: var(--space-4);
    font-size: var(--cs-text-sm);
    color: var(--ink-3);
    border-left: 1px solid var(--line-strong);
}

.ns-login__stage {
    flex: 1;
    display: grid;
    align-content: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-8) var(--space-4);
}

.ns-login__card {
    width: 100%;
    max-width: 26rem;
    padding: var(--space-8) var(--space-6);
    background: var(--glass);
    border: 1px solid var(--line);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.ns-login__form h1 {
    margin-bottom: var(--space-2);
    font-size: var(--cs-display-sm);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
}

.ns-login__form > .ns-muted {
    margin-bottom: var(--space-6);
    color: var(--ink-2);
}

.ns-login__form .ns-btn + .ns-btn {
    margin-top: var(--space-2);
}

.ns-login__foot {
    margin-top: var(--space-5);
    font-size: var(--cs-text-xs);
    color: var(--ink-3);
    text-align: center;
}

.ns-login__card--pitch {
    display: none;
}

.ns-login__tag {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 var(--space-3);
    font-size: var(--cs-text-xs);
    font-weight: var(--fw-medium);
    color: var(--ink-2);
    border: 1px solid var(--line-strong);
}

.ns-login__card--pitch h2 {
    margin: var(--space-6) 0 var(--space-3);
    font-size: var(--cs-display-sm);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
}

.ns-login__card--pitch p {
    color: var(--ink-2);
}

.ns-login__points {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-6);
    font-size: var(--cs-text-sm);
    color: var(--ink-2);
}

.ns-login__points li {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.ns-login__points .ns-icon {
    color: var(--accent);
}

@media (min-width: 900px) {
    .ns-login__bar {
        padding: 0 var(--space-8);
    }

    .ns-login__stage {
        grid-template-columns: 26rem 28rem;
        align-items: stretch;
    }

    .ns-login__card {
        padding: var(--space-10) var(--space-8);
    }

    .ns-login__card--form {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .ns-login__card--pitch {
        display: block;
        max-width: none;
    }
}

/* ------------------------------------------------- dialog, toast, lightbox */

.ns-dialog {
    width: min(100% - var(--space-8), 30rem);
    padding: 0;
    color: var(--ink);
    background: var(--surface-2);
    border: 0;
    border-radius: var(--radius-pop);
    box-shadow: var(--shadow-pop);
}

.ns-dialog::backdrop {
    background: var(--scrim);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.ns-dialog__form {
    padding: var(--space-6);
}

.ns-dialog__form h2 {
    margin-bottom: var(--space-3);
}

.ns-dialog__form > .ns-muted {
    margin-bottom: var(--space-5);
    font-size: var(--cs-text-sm);
}

.ns-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-5);
}

.ns-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--space-5));
    z-index: 70;
    max-width: calc(100% - var(--space-8));
    padding: var(--space-3) var(--space-5);
    font-size: var(--cs-text-sm);
    font-weight: var(--fw-medium);
    color: var(--ink-inverse);
    background: var(--ink);
    border-radius: var(--radius-pop);
    box-shadow: var(--shadow-pop);
    transform: translateX(-50%);
}

.ns-toast.is-error {
    color: var(--ink-on-photo);
    background: var(--critical);
}

.ns-lightbox {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    background: var(--bg);
}

.ns-lightbox__img {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    object-fit: contain;
}

.ns-lightbox__close {
    position: absolute;
    top: calc(var(--space-4) + env(safe-area-inset-top));
    right: var(--space-4);
    z-index: 1;
}

.ns-lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 1;
    width: 48px;
    height: 48px;
    font-size: var(--cs-display-sm);
    line-height: 1;
    color: var(--ink);
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    transform: translateY(-50%);
    cursor: pointer;
}

.ns-lightbox__nav--prev { left: var(--space-3); }
.ns-lightbox__nav--next { right: var(--space-3); }

.ns-lightbox__bar {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
    font-size: var(--cs-text-sm);
    color: var(--ink-2);
    background: var(--bg-glass);
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
