/* ==========================================================================
   BillEase Design System — 4. Components
   Reusable building blocks. Every page composes these; page CSS may only
   arrange them. Legacy class names used by existing markup/JS are mapped
   onto the same rules (listed next to each canonical class) so older
   screens render with the same component instead of a parallel style.
   ========================================================================== */

/* ---- Icons ------------------------------------------------------------- */
.ic {
    width: 20px;
    height: 20px;
    flex: none;
    display: inline-block;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }
.ic-xl { width: 32px; height: 32px; }

/* Icon tile: coloured rounded square holding an icon */
.icon-tile,
.menu-icon,
.metric-icon,
.invoice-dot {
    width: 42px;
    height: 42px;
    flex: none;
    display: inline-grid;
    place-items: center;
    border-radius: 13px;
    background: var(--app-primary-container);
    color: var(--app-primary);
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
}

.icon-tile .ic,
.menu-icon .ic,
.metric-icon .ic,
.invoice-dot .ic {
    width: 21px;
    height: 21px;
}

.icon-tile.sm { width: 36px; height: 36px; border-radius: 11px; }
.icon-tile.lg { width: 52px; height: 52px; border-radius: 16px; }
.icon-tile.lg .ic { width: 26px; height: 26px; }

.tone-blue, .icon-tile.blue, .menu-icon.blue, .metric-icon.blue { background: var(--app-info-container); color: var(--app-info); }
.tone-green, .icon-tile.green, .menu-icon.green, .metric-icon.green { background: var(--app-success-container); color: var(--app-success); }
.tone-amber, .icon-tile.amber, .menu-icon.amber, .metric-icon.amber,
.tone-orange, .icon-tile.orange { background: var(--app-warning-container); color: var(--app-warning); }
.tone-red, .icon-tile.red, .menu-icon.red, .metric-icon.red { background: var(--app-error-container); color: var(--app-error); }
.tone-violet, .icon-tile.violet, .menu-icon.violet, .metric-icon.violet,
.tone-primary { background: var(--app-primary-container); color: var(--app-primary); }
.tone-cyan, .icon-tile.cyan, .menu-icon.cyan { background: var(--app-accent-container); color: var(--app-accent); }
.tone-grey, .icon-tile.grey { background: var(--app-inactive-container); color: var(--app-inactive); }

/* ---- Cards ------------------------------------------------------------- */
.card,
.panel,
.form-panel,
.hardware-panel {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--r-lg);
    padding: var(--sp-4);
    box-shadow: var(--shadow-soft);
    min-width: 0;
}

.card > * + *,
.panel > * + *,
.form-panel > * + *,
.hardware-panel > * + * {
    margin-top: var(--sp-3);
}

.card.flat { box-shadow: none; }
.card.tonal { background: var(--app-surface-variant); border-color: transparent; box-shadow: none; }
.card.primary-tonal { background: var(--app-primary-container); border-color: transparent; box-shadow: none; color: var(--app-on-primary-container); }
.card.danger-zone { border-color: color-mix(in srgb, var(--app-error) 30%, var(--app-border)); }
.card.pad-0 { padding: 0; overflow: hidden; }

a.card {
    display: block;
    color: inherit;
    transition: box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}

a.card:hover { box-shadow: var(--shadow-medium); }
a.card:active { transform: scale(0.99); }

@media (min-width: 768px) {
    .card,
    .panel,
    .form-panel,
    .hardware-panel {
        padding: var(--sp-5);
    }
}

.card-head,
.panel-head,
.section-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
    min-width: 0;
}

.card-head > div:first-child,
.panel-head > div:first-child,
.section-row > div:first-child {
    min-width: 0;
}

.card-head h2,
.card-head h3,
.panel-head h2,
.panel-head h3,
.section-row h2,
.section-row h3,
.card-title {
    font-size: var(--fs-card-title);
    font-weight: 700;
    line-height: 1.3;
}

.card-head p,
.panel-head p {
    margin: 2px 0 0;
    color: var(--app-text-muted);
    font-size: var(--fs-support);
}

.panel-head > a,
.card-head > a,
.section-row > a {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 36px;
    padding: 0 var(--sp-2);
    margin: -6px -8px 0 0;
    border-radius: var(--r-full);
    color: var(--app-primary);
    font-size: var(--fs-body-sm);
    font-weight: 650;
}

.panel-head > a:hover,
.card-head > a:hover,
.section-row > a:hover {
    background: var(--app-primary-container);
}

/* Compact eyebrow label — used sparingly above a card title. */
.eyebrow,
.soft-label,
.doc-kicker,
.auth-kicker {
    display: block;
    margin: 0 0 2px;
    color: var(--app-primary);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.4;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-top: var(--sp-2);
}

.section-title h2 {
    font-size: var(--fs-section);
}

.section-title a {
    font-size: var(--fs-body-sm);
    font-weight: 650;
}

/* ---- Metric (KPI) cards -------------------------------------------------- */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
}

@media (max-width: 519.98px) {
    .metric-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
    .metric-grid.cols-3 .metric-card { padding: 10px; }
    .metric-grid.cols-3 .metric-top { display: none; }
    .metric-grid.cols-3 .metric-value { font-size: 15px; }
    .metric-grid.cols-3 .metric-sub { display: none; }
}

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

.metric-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 12px 14px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-soft);
    color: inherit;
}

a.metric-card {
    transition: box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}

a.metric-card:hover { box-shadow: var(--shadow-medium); }
a.metric-card:active { transform: scale(0.98); }

.metric-card .metric-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
}

.metric-card .metric-top {
    margin-bottom: 4px;
}

.metric-card .icon-tile {
    width: 32px;
    height: 32px;
    border-radius: 10px;
}

.metric-card .icon-tile .ic { width: 18px; height: 18px; }

.metric-card .metric-label {
    color: var(--app-text-muted);
    font-size: var(--fs-support);
    font-weight: 600;
    line-height: 1.3;
}

.metric-card .metric-value {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.metric-card .metric-sub {
    color: var(--app-text-subtle);
    font-size: var(--fs-caption);
    font-weight: 600;
}

.metric-card.compact { padding: 12px; }
.metric-card.compact .metric-value { font-size: 17px; }

/* ---- Buttons ----------------------------------------------------------- */
.btn,
.primary-flow-btn,
.wizard-next,
.soft-btn,
.btn-soft,
.danger-button,
.secondary-action-button,
.btn-main,
.action-primary,
.auth-primary,
.empty-action,
:where(.app-content, .ui-sheet, .modal, .code-sheet, .public-shell) :where(form, .panel, .card, .sheet, .form-actions) > :where(button:not([class])),
:where(.app-content .row-actions > button) {
    --btn-bg: var(--app-surface-variant);
    --btn-fg: var(--app-text);
    --btn-bd: transparent;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: var(--control-h);
    padding: 0 var(--sp-5);
    border: 1px solid var(--btn-bd);
    border-radius: var(--r-sm);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-family: var(--app-font);
    font-size: 15px;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}

.btn:hover,
.soft-btn:hover,
.btn-soft:hover,
:where(.app-content, .ui-sheet, .modal, .code-sheet, .public-shell) :where(form, .panel, .card, .sheet, .form-actions) > :where(button:not([class])):hover {
    filter: brightness(0.97);
}

.btn:active,
.primary-flow-btn:active,
.wizard-next:active,
.soft-btn:active,
.danger-button:active,
:where(.app-content, .ui-sheet, .modal, .code-sheet, .public-shell) :where(form, .panel, .card, .sheet, .form-actions) > :where(button:not([class])):active {
    transform: scale(0.98);
}

.btn:disabled,
.btn.is-disabled,
.primary-flow-btn:disabled,
.wizard-next:disabled,
.soft-btn:disabled,
.danger-button:disabled,
:where(.app-content, .ui-sheet, .modal, .code-sheet) :where(form, .panel, .card, .sheet, .form-actions) > :where(button:not([class])):disabled {
    opacity: 0.5;
    pointer-events: none;
    box-shadow: none;
}

/* Primary: filled. One per card/screen. */
.btn-primary,
.primary-flow-btn,
.wizard-next,
.btn.primary,
.btn-main,
.action-primary,
.auth-primary {
    --btn-bg: var(--app-primary);
    --btn-fg: var(--app-on-primary);
    box-shadow: 0 1px 2px rgba(var(--app-primary-rgb), 0.2), 0 4px 12px rgba(var(--app-primary-rgb), 0.18);
}

.btn-primary:hover,
.primary-flow-btn:hover,
.wizard-next:hover,
.btn.primary:hover,
.auth-primary:hover {
    --btn-bg: var(--app-primary-hover);
    filter: none;
}

/* Full-width primary actions at the end of a form */
.primary-flow-btn,
.wizard-next,
.auth-primary,
.btn-block {
    width: 100%;
}

/* Tonal: soft brand container */
.btn-tonal,
.soft-btn,
.btn-soft,
.empty-action {
    --btn-bg: var(--app-primary-container);
    --btn-fg: var(--app-on-primary-container);
}

/* Secondary: neutral tonal */
.btn-secondary {
    --btn-bg: var(--app-secondary-container);
    --btn-fg: var(--app-text);
}

/* Outlined */
.btn-outline,
.secondary-action-button {
    --btn-bg: var(--app-surface);
    --btn-fg: var(--app-text);
    --btn-bd: var(--app-border-strong);
}

.btn-outline:hover,
.secondary-action-button:hover {
    --btn-bg: var(--app-surface-variant);
    filter: none;
}

/* Text */
.btn-text {
    --btn-bg: transparent;
    --btn-fg: var(--app-primary);
    padding: 0 var(--sp-3);
}

.btn-text:hover {
    --btn-bg: var(--app-primary-container);
    filter: none;
}

/* Danger — only destructive actions */
.btn-danger,
.danger-button {
    --btn-bg: var(--app-error);
    --btn-fg: #fff;
}

.btn-danger-tonal {
    --btn-bg: var(--app-error-container);
    --btn-fg: var(--app-on-error-container);
}

.btn-success {
    --btn-bg: var(--app-success);
    --btn-fg: #fff;
}

.btn-whatsapp {
    --btn-bg: #1f9d55;
    --btn-fg: #fff;
}

.btn-sm,
.soft-btn,
.btn-soft {
    min-height: 40px;
    padding: 0 var(--sp-4);
    font-size: var(--fs-body-sm);
    border-radius: 12px;
}

.btn-xs {
    min-height: 32px;
    padding: 0 var(--sp-3);
    font-size: var(--fs-support);
    border-radius: 10px;
}

.btn-lg {
    min-height: 54px;
    font-size: 16px;
    border-radius: var(--r-md);
}

.btn .ic,
.soft-btn .ic,
.primary-flow-btn .ic { width: 19px; height: 19px; }

/* Loading state (set via UI.busy(button)) */
.is-loading {
    color: transparent !important;
    pointer-events: none;
}

.is-loading > * {
    visibility: hidden;
}

.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2.5px solid var(--btn-fg, currentColor);
    border-right-color: transparent;
    animation: ui-spin 0.7s linear infinite;
}

@keyframes ui-spin {
    to { transform: rotate(360deg); }
}

.btn-row,
.action-bar,
.row-actions,
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    align-items: center;
}

.btn-row.end { justify-content: flex-end; }
.btn-row > .btn-grow { flex: 1 1 0; }

.action-bar {
    padding: var(--sp-3);
    background: var(--app-surface-variant);
    border-radius: var(--r-md);
}

/* Icon button (44px tap target) */
.icon-btn,
.close-round,
.sheet-close-button {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    border: 1px solid var(--app-border);
    border-radius: var(--r-full);
    background: var(--app-surface);
    color: var(--app-text);
    cursor: pointer;
    position: relative;
    transition: background-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}

.icon-btn:hover,
.close-round:hover,
.sheet-close-button:hover {
    background: var(--app-surface-variant);
}

.icon-btn:active { transform: scale(0.94); }

.icon-btn.tonal { background: var(--app-primary-container); color: var(--app-primary); border-color: transparent; }
.icon-btn.filled { background: var(--app-primary); color: var(--app-on-primary); border-color: transparent; }
.icon-btn .dot {
    position: absolute;
    top: 7px;
    right: 7px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: var(--r-full);
    background: var(--app-error);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--app-background);
}

/* Floating action button — one per screen, primary action only */
.fab {
    position: fixed;
    right: calc(var(--page-pad) + 2px);
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
    z-index: 45;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    height: 56px;
    padding: 0 20px 0 16px;
    border: 0;
    border-radius: var(--r-md);
    background: var(--app-primary);
    color: var(--app-on-primary);
    font-weight: 700;
    font-size: 15px;
    box-shadow: var(--shadow-floating);
    transition: transform var(--dur-fast) var(--ease-standard);
}

.fab:active { transform: scale(0.96); }
.fab .ic { width: 22px; height: 22px; }

@media (min-width: 1024px) {
    .fab { bottom: 28px; right: 28px; }
}

/* ---- Form fields ------------------------------------------------------- */
.field,
.smart-field,
.auth-field,
.inline-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    margin: 0;
}

.field + .field,
.smart-field + .smart-field,
.field + .btn,
.smart-field + .primary-flow-btn,
.two-col + .smart-field,
.smart-field + .two-col,
.two-col + .primary-flow-btn,
.three-col + .primary-flow-btn,
.smart-field + button {
    margin-top: var(--sp-3);
}

.field-label,
.field > span:first-child,
.smart-field > span:first-child,
.auth-field > span:first-child,
.inline-field > span:first-child,
:where(.app-content, .ui-sheet, .modal, .code-sheet) :where(label:not([class])) {
    color: var(--app-text);
    font-size: var(--fs-support);
    font-weight: 650;
    line-height: 1.35;
    letter-spacing: 0;
}

:where(.app-content, .ui-sheet, .modal, .code-sheet) :where(label:not([class])) {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: var(--sp-3);
}

.field-help,
.field small,
.smart-field > small {
    color: var(--app-text-muted);
    font-size: var(--fs-caption);
    font-weight: 500;
    line-height: 1.4;
}

.field-error {
    color: var(--app-error);
    font-size: var(--fs-caption);
    font-weight: 600;
}

/* Text-like controls get the one input style everywhere (zero specificity so
   page components such as quantity steppers can refine them). */
.input,
:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(
    input:not([type]),
    input[type="text"],
    input[type="search"],
    input[type="tel"],
    input[type="email"],
    input[type="url"],
    input[type="number"],
    input[type="password"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="month"],
    input[type="time"],
    select,
    textarea
) {
    width: 100%;
    min-width: 0;
    min-height: var(--control-h);
    padding: 0 14px;
    border: 1px solid var(--app-border-strong);
    border-radius: var(--r-sm);
    background-color: var(--app-surface);
    color: var(--app-text);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard), background-color var(--dur-fast) var(--ease-standard);
    -webkit-appearance: none;
    appearance: none;
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(textarea),
textarea.input {
    min-height: 96px;
    padding: 12px 14px;
    resize: vertical;
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(input, select, textarea)::placeholder {
    color: var(--app-text-subtle);
    font-weight: 450;
    opacity: 1;
}

.input:hover,
:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]), select, textarea):hover {
    border-color: color-mix(in srgb, var(--app-primary) 35%, var(--app-border-strong));
}

.input:focus,
:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea):focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 4px rgba(var(--app-primary-rgb), 0.14);
    outline: none;
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(input, select, textarea):disabled,
:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(input, textarea)[readonly] {
    background-color: var(--app-surface-variant);
    color: var(--app-text-muted);
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(input, select, textarea)[aria-invalid="true"],
.field.has-error :is(input, select, textarea) {
    border-color: var(--app-error);
    box-shadow: 0 0 0 4px rgba(217, 54, 54, 0.12);
}

/* Custom select shell — keeps the native, accessible <select>. */
select.input,
:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(select:not([multiple])) {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6679' stroke-width='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;
    background-size: 18px;
    cursor: pointer;
    text-overflow: ellipsis;
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(select[multiple]) {
    padding: 8px;
    min-height: 120px;
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(input[type="date"], input[type="month"], input[type="time"], input[type="datetime-local"]) {
    padding-right: 12px;
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) input::-webkit-calendar-picker-indicator {
    opacity: 0.6;
    cursor: pointer;
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) input[type="number"]::-webkit-inner-spin-button,
:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) input[type="number"] {
    -moz-appearance: textfield;
}

/* File input */
:where(.app-content, .ui-sheet, .modal, .code-sheet, .public-shell) input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1.5px dashed var(--app-border-strong);
    border-radius: var(--r-sm);
    background: var(--app-surface-variant);
    color: var(--app-text-muted);
    font-size: var(--fs-support);
}

:where(.app-content, .ui-sheet, .modal, .code-sheet, .public-shell) input[type="file"]::file-selector-button {
    margin-right: 12px;
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: var(--app-primary-container);
    color: var(--app-on-primary-container);
    font-weight: 650;
    cursor: pointer;
}

/* Checkbox / radio — brand accent, comfortable size */
:where(.app-content, .act-main, .ui-sheet, .modal, .code-sheet, .public-shell, .auth-page) :where(input[type="checkbox"], input[type="radio"]) {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--app-primary);
    flex: none;
    cursor: pointer;
}

.check-row,
.remove-logo-check {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: var(--tap);
    font-size: var(--fs-body-sm);
    font-weight: 550;
    cursor: pointer;
}

/* Input group: leading/trailing adornments (search icon, +91, scan) */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-group > :is(input, select) {
    flex: 1 1 auto;
}

.input-group > .ic,
.input-group > .lead {
    position: absolute;
    left: 14px;
    color: var(--app-text-subtle);
    pointer-events: none;
    font-weight: 650;
}

.input-group > .ic ~ :is(input, select),
.input-group > .lead ~ :is(input, select),
.input-group.has-lead > :is(input, select) {
    padding-left: 44px;
}

.input-group > .trail {
    position: absolute;
    right: 4px;
    display: flex;
    gap: 2px;
}

.input-group > .trail .icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--app-text-muted);
}

.input-group > .trail .icon-btn:hover {
    background: var(--app-surface-variant);
    color: var(--app-primary);
}

.input-group.has-trail > :is(input, select) {
    padding-right: 52px;
}

.input-group.has-trail-2 > :is(input, select) {
    padding-right: 92px;
}

/* Search bar */
.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar > .ic {
    position: absolute;
    left: 14px;
    color: var(--app-text-subtle);
    pointer-events: none;
}

.search-bar input {
    padding-left: 44px !important;
    padding-right: 44px !important;
    border-radius: var(--r-full) !important;
    background-color: var(--app-surface) !important;
}

.search-bar .search-clear {
    position: absolute;
    right: 4px;
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--app-text-muted);
    border-radius: var(--r-full);
    display: none;
    place-items: center;
}

.search-bar.has-value .search-clear {
    display: grid;
}

/* Form grids */
.two-col,
.three-col,
.grid-2,
.grid-3,
.gst-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-3);
}

@media (min-width: 560px) {
    .two-col,
    .grid-2,
    .gst-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .three-col,
    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    .three-col,
    .grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.two-col > .span-all,
.three-col > .span-all,
.grid-2 > .span-all,
.grid-3 > .span-all {
    grid-column: 1 / -1;
}

.two-col .smart-field + .smart-field,
.three-col .smart-field + .smart-field,
.grid-2 .field + .field,
.grid-3 .field + .field,
.gst-grid .smart-field + .smart-field {
    margin-top: 0;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-4);
}

.form-actions > .btn { flex: 1 1 160px; }

/* Progressive disclosure: "More options" */
.disclosure,
details.gst-details {
    border: 1px solid var(--app-border);
    border-radius: var(--r-md);
    background: var(--app-surface);
    overflow: hidden;
}

.disclosure > summary,
details.gst-details > summary {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 50px;
    padding: 0 var(--sp-4);
    cursor: pointer;
    list-style: none;
    font-weight: 650;
    font-size: var(--fs-body-sm);
    color: var(--app-text);
}

.disclosure > summary::-webkit-details-marker,
details.gst-details > summary::-webkit-details-marker {
    display: none;
}

.disclosure > summary::after,
details.gst-details > summary::after {
    content: "";
    margin-left: auto;
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    opacity: 0.6;
    transition: transform var(--dur-base) var(--ease-standard);
}

.disclosure[open] > summary::after,
details.gst-details[open] > summary::after {
    transform: rotate(180deg);
}

.disclosure > summary small {
    color: var(--app-text-subtle);
    font-weight: 500;
}

.disclosure > .disclosure-body,
details.gst-details > :not(summary) {
    padding: 0 var(--sp-4) var(--sp-4);
}

.disclosure > .disclosure-body > * + * {
    margin-top: var(--sp-3);
}

/* ---- Switch (Material 3 style) ---------------------------------------- */
.switch {
    position: relative;
    display: inline-flex;
    flex: none;
    width: 52px;
    height: 32px;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.switch .track {
    position: absolute;
    inset: 0;
    border-radius: var(--r-full);
    background: var(--app-surface-sunken);
    border: 2px solid var(--app-border-strong);
    transition: background-color var(--dur-base) var(--ease-standard), border-color var(--dur-base) var(--ease-standard);
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--app-inactive);
    transform: translateY(-50%);
    transition: all var(--dur-base) var(--ease-emphasized);
}

.switch input:checked + .track {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.switch input:checked + .track::after {
    left: 24px;
    width: 22px;
    height: 22px;
    background: #fff;
}

.switch input:focus-visible + .track {
    outline: 3px solid rgba(var(--app-primary-rgb), 0.4);
    outline-offset: 2px;
}

.switch input:disabled + .track {
    opacity: 0.5;
}

/* Settings-style row holding a switch */
.switch-row,
.setup-toggle-card,
.hardware-toggle,
.catalog-publish-toggle,
.gst-inclusive-toggle {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 56px;
    padding: var(--sp-3) 0;
    cursor: pointer;
}

.switch-row + .switch-row {
    border-top: 1px solid var(--app-border);
}

.switch-row .switch-text {
    flex: 1 1 auto;
    min-width: 0;
}

.switch-row .switch-text b {
    display: block;
    font-size: var(--fs-body-sm);
    font-weight: 650;
}

.switch-row .switch-text small {
    display: block;
    color: var(--app-text-muted);
    font-size: var(--fs-caption);
}

/* ---- Segmented control & tabs ------------------------------------------ */
.segmented {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: var(--r-full);
    background: var(--app-surface-sunken);
    overflow-x: auto;
    scrollbar-width: none;
}

.segmented::-webkit-scrollbar { display: none; }

.segmented > :is(a, button, label) {
    flex: 1 0 auto;
    display: inline-flex;
    flex-direction: row;
    margin: 0;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 var(--sp-4);
    border: 0;
    border-radius: var(--r-full);
    background: transparent;
    color: var(--app-text-muted);
    font-size: var(--fs-body-sm);
    font-weight: 650;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur-base) var(--ease-standard), color var(--dur-base) var(--ease-standard), box-shadow var(--dur-base) var(--ease-standard);
}

.segmented > label { position: relative; }

.segmented > label > input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.segmented > :is(.active, [aria-selected="true"], [aria-pressed="true"]),
.segmented > label:has(input:checked) {
    background: var(--app-surface);
    color: var(--app-text);
    box-shadow: var(--shadow-soft), 0 0 0 1px var(--app-border);
}

.segmented > label:has(input:focus-visible) {
    outline: 3px solid rgba(var(--app-primary-rgb), 0.4);
}

.tabs {
    display: flex;
    gap: var(--sp-1);
    border-bottom: 1px solid var(--app-border);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs > :is(a, button) {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--tap);
    padding: 0 var(--sp-4);
    border: 0;
    background: transparent;
    color: var(--app-text-muted);
    font-size: var(--fs-body-sm);
    font-weight: 650;
    white-space: nowrap;
}

.tabs > :is(.active, [aria-selected="true"]) {
    color: var(--app-primary);
}

.tabs > :is(.active, [aria-selected="true"])::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--app-primary);
}

/* ---- Chips ------------------------------------------------------------- */
.chip-row {
    display: flex;
    gap: var(--sp-2);
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.chip-row::-webkit-scrollbar { display: none; }
.chip-row.wrap { flex-wrap: wrap; overflow: visible; }

.chip {
    flex: none;
    display: inline-flex;
    flex-direction: row;
    margin: 0;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--app-border-strong);
    border-radius: 10px;
    background: var(--app-surface);
    color: var(--app-text);
    font-size: var(--fs-support);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.chip .ic { width: 16px; height: 16px; }

.chip:hover { background: var(--app-surface-variant); }

.chip.active,
.chip[aria-pressed="true"],
.chip.is-selected,
label.chip:has(input:checked) {
    background: var(--app-primary-container);
    border-color: transparent;
    color: var(--app-on-primary-container);
}

label.chip { position: relative; }

label.chip input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

label.chip:has(input:focus-visible) {
    outline: 3px solid rgba(var(--app-primary-rgb), 0.4);
}

/* Status chip — consistent semantics */
.status-chip,
.status,
.badge,
.count-chip,
.kyc-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    padding: 2px 10px;
    border-radius: var(--r-full);
    background: var(--app-inactive-container);
    color: var(--app-inactive);
    font-size: var(--fs-caption);
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    text-transform: none;
    letter-spacing: 0;
}

.status-chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-chip.no-dot::before { display: none; }

.status-chip.success, .status.paid, .status.success, .status.active, .status.complete, .status.delivered, .badge.success, .kyc-status.complete {
    background: var(--app-success-container);
    color: var(--app-on-success-container);
}

.status-chip.warning, .status-chip.pending, .status.due, .status.pending, .status.partial, .badge.warning, .kyc-status.pending {
    background: var(--app-warning-container);
    color: var(--app-on-warning-container);
}

.status-chip.error, .status.error, .status.cancelled, .status.returned, .status.rejected, .badge.error {
    background: var(--app-error-container);
    color: var(--app-on-error-container);
}

.status-chip.info, .status.info, .status.new, .badge.info {
    background: var(--app-info-container);
    color: var(--app-on-info-container);
}

.status-chip.primary, .badge.primary {
    background: var(--app-primary-container);
    color: var(--app-on-primary-container);
}

.count-chip {
    min-width: 26px;
    justify-content: center;
    background: var(--app-error);
    color: #fff;
}

.count-chip.zero,
.count-chip:empty {
    background: var(--app-inactive-container);
    color: var(--app-inactive);
}

/* ---- Lists (settings style) ------------------------------------------- */
.list,
.smart-list,
.menu-cards {
    display: flex;
    flex-direction: column;
    background: var(--app-surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--app-border);
    overflow: hidden;
}

/* Lists nested in a card sit flush inside it */
.card .list,
.panel .smart-list,
.card .smart-list,
.panel .list {
    border: 0;
    border-radius: 0;
    margin-left: calc(var(--sp-4) * -1);
    margin-right: calc(var(--sp-4) * -1);
    background: transparent;
}

@media (min-width: 768px) {
    .card .list,
    .panel .smart-list,
    .card .smart-list,
    .panel .list {
        margin-left: calc(var(--sp-5) * -1);
        margin-right: calc(var(--sp-5) * -1);
    }
}

.list-item,
.smart-list > a,
.smart-list > div,
.smart-list > form,
.menu-cards > a,
.menu-cards > button,
.list-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 64px;
    padding: var(--sp-3) var(--sp-4);
    color: var(--app-text);
    text-decoration: none;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    font: inherit;
    transition: background-color var(--dur-fast) var(--ease-standard);
}

@media (min-width: 768px) {
    .card .list-item,
    .panel .smart-list > * {
        padding-left: var(--sp-5);
        padding-right: var(--sp-5);
    }
}

.list > .switch-row {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
}

.list-item + .list-item,
.smart-list > * + *,
.menu-cards > * + *,
.list-row + .list-row {
    border-top: 1px solid var(--app-border);
}

a.list-item:hover,
button.list-item:hover,
.smart-list > a:hover,
.menu-cards > a:hover,
.menu-cards > button:hover {
    background: var(--app-surface-variant);
}

a.list-item:active,
.smart-list > a:active,
.menu-cards > a:active {
    background: var(--app-surface-sunken);
}

.list-item .list-text,
.menu-cards > * > div,
.smart-list .grow {
    flex: 1 1 auto;
    min-width: 0;
}

.list-item b,
.list-item .list-title,
.menu-cards b,
.smart-list b,
.list-row b {
    display: block;
    font-size: var(--fs-body-sm);
    font-weight: 650;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.list-item small,
.list-item .list-sub,
.menu-cards small,
.smart-list small,
.list-row small {
    display: block;
    color: var(--app-text-muted);
    font-size: var(--fs-caption);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.list-item .list-trail,
.smart-list .align-right {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    text-align: right;
}

.list-item .list-trail strong,
.smart-list strong {
    font-size: var(--fs-body-sm);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.list-item > .chev,
.menu-cards em {
    flex: none;
    color: var(--app-text-subtle);
    font-style: normal;
    font-size: 20px;
}

.list-item > .chev .ic { width: 18px; height: 18px; }

.list-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 0;
    padding-left: 0;
    padding-right: 0;
}

.list-header {
    padding: var(--sp-4) var(--sp-4) var(--sp-2);
    color: var(--app-text-subtle);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.list-group-title {
    margin: var(--sp-2) var(--sp-1) calc(var(--sp-2) * -1);
    color: var(--app-text-muted);
    font-size: var(--fs-support);
    font-weight: 700;
}

/* ---- Data table (desktop) → cards (mobile) ----------------------------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--r-md);
    -webkit-overflow-scrolling: touch;
}

.data-table,
.table-wrap > table,
:where(.app-content) .card > table,
:where(.app-content) .panel > table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-body-sm);
    font-variant-numeric: tabular-nums;
}

.data-table th,
.table-wrap > table th,
:where(.app-content) .panel > table th,
:where(.app-content) .card > table th {
    position: sticky;
    top: 0;
    padding: 10px 12px;
    background: var(--app-surface-variant);
    color: var(--app-text-muted);
    font-size: var(--fs-caption);
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--app-border);
}

.data-table th:first-child,
.table-wrap > table th:first-child { border-top-left-radius: var(--r-xs); }
.data-table th:last-child,
.table-wrap > table th:last-child { border-top-right-radius: var(--r-xs); }

.data-table td,
.table-wrap > table td,
:where(.app-content) .panel > table td,
:where(.app-content) .card > table td {
    padding: 12px;
    border-bottom: 1px solid var(--app-border);
    vertical-align: middle;
}

.data-table tbody tr:hover td,
.table-wrap > table tbody tr:hover td {
    background: var(--app-surface-variant);
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table .num, .data-table th.num { text-align: right; }

/* Mobile: rows become stacked cards. Cells need data-label attributes;
   UI.enhanceTables() adds them automatically from the header row. */
@media (max-width: 767.98px) {
    .data-table.responsive thead,
    .table-wrap > table.responsive thead {
        display: none;
    }

    .data-table.responsive,
    .data-table.responsive tbody {
        display: block;
        width: 100%;
    }

    /* Each row becomes a compact two-column card */
    .data-table.responsive tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px 12px;
        padding: var(--sp-3) 0;
        border-bottom: 1px solid var(--app-border);
    }

    .data-table.responsive tr:last-child { border-bottom: 0; }

    .data-table.responsive td {
        display: flex;
        flex-direction: column;
        gap: 1px;
        min-width: 0;
        padding: 0;
        border: 0;
        text-align: left;
        font-size: var(--fs-support);
        overflow-wrap: anywhere;
    }

    .data-table.responsive td::before {
        content: attr(data-label);
        color: var(--app-text-subtle);
        font-size: 11px;
        font-weight: 600;
    }

    .data-table.responsive td:first-child {
        grid-column: 1 / -1;
        font-weight: 700;
        font-size: var(--fs-body-sm);
    }

    .data-table.responsive td:first-child::before { display: none; }
    .data-table.responsive tbody tr:hover td { background: transparent; }

    /* Footer totals become a tinted summary card */
    .data-table.responsive tfoot { display: block; width: 100%; }
    .data-table.responsive tfoot tr { background: var(--app-surface-variant); border-radius: var(--r-sm); padding: var(--sp-3); border: 0; }
    .data-table.responsive tfoot :is(th, td) { display: flex; flex-direction: column; gap: 1px; padding: 0; border: 0; text-align: left; font-weight: 700; }
    .data-table.responsive tfoot :is(th, td):empty { display: none; }
    .data-table.responsive tfoot :is(th, td)[data-label]:not(:first-child)::before { content: attr(data-label); color: var(--app-text-subtle); font-size: var(--fs-caption); font-weight: 600; }
    .data-table.responsive tfoot :is(th, td):first-child { grid-column: 1 / -1; }
}

/* ---- Notices / inline banners ----------------------------------------- */
.notice,
.alert,
.fake-warning,
.public-note {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--app-info-container);
    color: var(--app-on-info-container);
    font-size: var(--fs-body-sm);
    font-weight: 550;
    line-height: 1.45;
    border: 0;
}

.notice::before,
.alert::before {
    content: "";
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    background: currentColor;
    -webkit-mask: var(--notice-icon) center / contain no-repeat;
    mask: var(--notice-icon) center / contain no-repeat;
    --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E");
}

.notice-ok,
.notice.success,
.alert.success {
    background: var(--app-success-container);
    color: var(--app-on-success-container);
}

.notice-ok::before,
.notice.success::before,
.alert.success::before {
    --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E");
}

.notice-error,
.notice.error,
.alert.error,
.fake-warning {
    background: var(--app-error-container);
    color: var(--app-on-error-container);
}

.notice-error::before,
.notice.error::before,
.alert.error::before {
    --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E");
}

.notice-warn,
.notice.warn,
.notice.warning,
.alert.warning {
    background: var(--app-warning-container);
    color: var(--app-on-warning-container);
}

.notice-warn::before,
.notice.warn::before,
.notice.warning::before,
.alert.warning::before {
    --notice-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
}

.notice.neutral {
    background: var(--app-surface-variant);
    color: var(--app-text-muted);
}

.notice > div { flex: 1 1 auto; min-width: 0; }


/* ---- Empty & error states --------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: var(--sp-8) var(--sp-5);
    color: var(--app-text-muted);
}

.empty-state > span:first-child,
.empty-state .empty-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: var(--sp-2);
    border-radius: 20px;
    background: var(--app-primary-container);
    color: var(--app-primary);
    font-size: 28px;
}

.empty-state .empty-icon .ic { width: 30px; height: 30px; }

.empty-state b,
.empty-state h3 {
    color: var(--app-text);
    font-size: var(--fs-card-title);
    font-weight: 700;
}

.empty-state small,
.empty-state p {
    max-width: 320px;
    margin: 0;
    font-size: var(--fs-body-sm);
    line-height: 1.5;
}

.empty-state .btn,
.empty-state .empty-action {
    margin-top: var(--sp-3);
}

.empty-state.error .empty-icon {
    background: var(--app-error-container);
    color: var(--app-error);
}

/* ---- Result / success state (green circular check) ------------------- */
.result-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sp-2);
    padding: var(--sp-6) var(--sp-4);
}

.result-icon {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin-bottom: var(--sp-2);
    border-radius: 50%;
    background: var(--app-success-container);
    color: var(--app-success);
    animation: result-pop var(--dur-slow) var(--ease-emphasized);
}

.result-icon .ic { width: 40px; height: 40px; stroke-width: 2.4; }
.result-icon.error { background: var(--app-error-container); color: var(--app-error); }
.result-icon.warning { background: var(--app-warning-container); color: var(--app-warning); }
.result-icon.info { background: var(--app-info-container); color: var(--app-info); }

.result-state h2 { font-size: 22px; }
.result-state p { color: var(--app-text-muted); max-width: 340px; }

@keyframes result-pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ---- Skeleton & spinner ------------------------------------------------ */
.skeleton {
    display: block;
    border-radius: var(--r-xs);
    background: linear-gradient(90deg, var(--app-surface-sunken) 25%, var(--app-surface-variant) 50%, var(--app-surface-sunken) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
    min-height: 14px;
}

@keyframes skeleton-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid rgba(var(--app-primary-rgb), 0.2);
    border-top-color: var(--app-primary);
    animation: ui-spin 0.7s linear infinite;
}

/* ---- Toast -------------------------------------------------------------- */
.toast-region {
    position: fixed;
    left: 50%;
    top: calc(var(--safe-top) + 12px);
    z-index: 1000;
    width: min(420px, calc(100% - 24px));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: #1c2233;
    color: #fff;
    box-shadow: var(--shadow-floating);
    font-size: var(--fs-body-sm);
    font-weight: 550;
    line-height: 1.4;
    pointer-events: auto;
    animation: toast-in var(--dur-slow) var(--ease-emphasized);
}

.toast.leaving {
    animation: toast-out var(--dur-base) var(--ease-standard) forwards;
}

.toast .toast-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
}

.toast .toast-icon .ic { width: 17px; height: 17px; stroke-width: 2.5; }
.toast.success .toast-icon { background: var(--app-success); }
.toast.error .toast-icon { background: var(--app-error); }
.toast.warning .toast-icon { background: var(--app-warning); }
.toast.info .toast-icon { background: var(--app-info); }
.toast .toast-text { flex: 1 1 auto; min-width: 0; }
.toast .toast-text b { display: block; }
.toast .toast-text small { display: block; opacity: 0.8; font-size: var(--fs-caption); }

@keyframes toast-in {
    from { transform: translateY(-12px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@keyframes toast-out {
    to { transform: translateY(-8px); opacity: 0; }
}

@media (min-width: 1024px) {
    .toast-region {
        top: auto;
        bottom: 24px;
        left: auto;
        right: 24px;
        transform: none;
    }
}

/* ---- Bottom sheet / dialog / top offcanvas ------------------------------ */
.sheet-layer {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: var(--app-scrim);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-standard);
}

.sheet-layer.open { opacity: 1; }

.ui-sheet {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: calc(var(--vvh) - 16px);
    display: flex;
    flex-direction: column;
    background: var(--app-surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--shadow-floating);
    transform: translateY(24px);
    transition: transform var(--dur-slow) var(--ease-emphasized);
    padding-bottom: var(--safe-bottom);
    overflow: hidden;
}

.sheet-layer.open .ui-sheet { transform: none; }

.ui-sheet .sheet-grip {
    width: 36px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: 4px;
    background: var(--app-border-strong);
    flex: none;
}

.ui-sheet .sheet-head {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4) var(--sp-2) var(--sp-5);
    flex: none;
}

.ui-sheet .sheet-head h2 {
    flex: 1 1 auto;
    font-size: var(--fs-section);
}

.ui-sheet .sheet-body {
    padding: var(--sp-2) var(--sp-5) var(--sp-4);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.ui-sheet .sheet-body > * + * { margin-top: var(--sp-3); }

.ui-sheet .sheet-foot {
    display: flex;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5) var(--sp-5);
    border-top: 1px solid var(--app-border);
    flex: none;
}

.ui-sheet .sheet-foot .btn { flex: 1 1 0; min-width: 0; padding: 0 12px; white-space: normal; line-height: 1.2; }
.ui-sheet .sheet-foot.stacked { flex-direction: column; }

/* Confirmation dialog content */
.confirm-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sp-2);
    padding: var(--sp-5) var(--sp-5) var(--sp-3);
}

.confirm-body .result-icon {
    width: 60px;
    height: 60px;
    margin: 0 0 var(--sp-1);
}

.confirm-body .result-icon .ic { width: 30px; height: 30px; }
.confirm-body h2 { font-size: 20px; }
.confirm-body p { color: var(--app-text-muted); font-size: var(--fs-body-sm); margin: 0; }
.confirm-body .field { width: 100%; text-align: left; margin-top: var(--sp-2); }

/* Choice list inside sheets (e.g. "Product not found" options) */
.sheet-options {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.sheet-option {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    min-height: 60px;
    padding: var(--sp-3);
    border: 1px solid var(--app-border);
    border-radius: var(--r-md);
    background: var(--app-surface);
    color: var(--app-text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}

.sheet-option:hover {
    background: var(--app-surface-variant);
    border-color: var(--app-border-strong);
}

.sheet-option b { display: block; font-size: var(--fs-body-sm); }
.sheet-option small { display: block; color: var(--app-text-muted); font-size: var(--fs-caption); }
.sheet-option > div { flex: 1 1 auto; min-width: 0; }

@media (min-width: 768px) {
    .sheet-layer.as-dialog,
    .sheet-layer {
        align-items: center;
        padding: var(--sp-6);
    }

    .ui-sheet {
        border-radius: var(--r-xl);
        max-height: calc(var(--vvh) - 64px);
        transform: translateY(12px) scale(0.98);
        padding-bottom: 0;
    }

    .ui-sheet .sheet-grip { display: none; }
    .ui-sheet .sheet-head { padding-top: var(--sp-5); }
}

/* Top offcanvas (store cart) */
.sheet-layer.from-top {
    align-items: flex-start;
    padding: 0;
}

.sheet-layer.from-top .ui-sheet {
    max-width: 640px;
    border-radius: 0 0 var(--r-xl) var(--r-xl);
    transform: translateY(-24px);
    padding-top: var(--safe-top);
    padding-bottom: 0;
}

.sheet-layer.from-top.open .ui-sheet { transform: none; }

.sheet-layer.from-top .sheet-grip {
    order: 99;
    margin: 0 auto 10px;
    display: block;
}

body.sheet-open {
    overflow: hidden;
}

/* ---- Hero / summary banner --------------------------------------------- */
.hero-card {
    position: relative;
    overflow: hidden;
    padding: var(--sp-5);
    border-radius: var(--r-lg);
    background: var(--app-primary);
    color: var(--app-on-primary);
    box-shadow: 0 10px 28px rgba(var(--app-primary-rgb), 0.28);
}

.hero-card::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -80px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

.hero-card :is(h1, h2, h3, b, strong) { color: inherit; }
.hero-card small,
.hero-card .hero-label { color: rgba(255, 255, 255, 0.78); font-size: var(--fs-support); font-weight: 600; }

.hero-card .hero-value {
    display: block;
    margin: 4px 0 2px;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.hero-card .hero-split {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-2);
    margin-top: var(--sp-4);
}

.hero-card .hero-split > * {
    min-width: 0;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.12);
}

.hero-card .hero-split b {
    display: block;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 400px) {
    .hero-card .hero-split b { font-size: 15px; }
}

.hero-card .btn-on-hero {
    --btn-bg: #fff;
    --btn-fg: var(--app-primary);
}

/* ---- Action tiles (quick actions) -------------------------------------- */
.action-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-3);
}

@media (min-width: 600px) {
    .action-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .action-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.action-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: var(--sp-2);
    min-width: 0;
    min-height: 96px;
    padding: 14px 6px 12px;
    border: 1px solid var(--app-border);
    border-radius: var(--r-md);
    background: var(--app-surface);
    color: var(--app-text);
    text-align: center;
    font-size: var(--fs-support);
    font-weight: 650;
    line-height: 1.25;
    box-shadow: var(--shadow-soft);
    transition: box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}

.action-tile:hover { box-shadow: var(--shadow-medium); }
.action-tile:active { transform: scale(0.97); }
.action-tile .icon-tile { width: 44px; height: 44px; border-radius: 14px; }
.action-tile span:last-child { overflow-wrap: anywhere; }

/* ---- Price / plan card ------------------------------------------------- */
.price-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-3);
}

@media (min-width: 900px) {
    .price-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
}

.price-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding: var(--sp-5);
    border: 1.5px solid var(--app-border);
    border-radius: var(--r-lg);
    background: var(--app-surface);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: border-color var(--dur-base) var(--ease-standard), box-shadow var(--dur-base) var(--ease-standard);
}

.price-card:has(input:checked),
.price-card.selected {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(var(--app-primary-rgb), 0.14), var(--shadow-medium);
}

.price-card.featured {
    border-color: var(--app-primary);
}

.price-card .ribbon {
    position: absolute;
    top: -12px;
    left: var(--sp-5);
    padding: 3px 12px;
    border-radius: var(--r-full);
    background: var(--app-primary);
    color: var(--app-on-primary);
    font-size: var(--fs-caption);
    font-weight: 750;
}

.price-card .plan-name { font-size: var(--fs-card-title); font-weight: 700; }
.price-card .plan-price { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.price-card .plan-price small { font-size: var(--fs-body-sm); color: var(--app-text-muted); font-weight: 600; letter-spacing: 0; }
.price-card .plan-note { color: var(--app-text-muted); font-size: var(--fs-caption); }

.price-card ul,
.feature-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-body-sm);
}

.price-card li,
.feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.price-card li .ic,
.feature-list li .ic {
    width: 18px;
    height: 18px;
    color: var(--app-success);
    margin-top: 1px;
}

.price-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* ---- Timeline ------------------------------------------------------------ */
.timeline {
    display: flex;
    flex-direction: column;
}

.timeline-item {
    position: relative;
    display: flex;
    gap: var(--sp-3);
    padding-bottom: var(--sp-4);
}

.timeline-item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 20px;
    top: 44px;
    bottom: 4px;
    width: 2px;
    background: var(--app-border);
}

/* ---- Key/value rows ----------------------------------------------------- */
.kv {
    display: grid;
    gap: 0;
}

.kv > div,
.spec-row {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: 10px 0;
    border-bottom: 1px dashed var(--app-border);
    font-size: var(--fs-body-sm);
}

.kv > div:last-child,
.spec-row:last-child { border-bottom: 0; }
.kv > div > span:first-child,
.spec-row > span:first-child { color: var(--app-text-muted); }
.kv > div > :last-child { font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.kv .grand { font-size: 18px; font-weight: 800; color: var(--app-text); }

/* ---- Theme picker card -------------------------------------------------- */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
}

@media (min-width: 700px) {
    .theme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-2) var(--sp-3);
    border: 2px solid var(--app-border);
    border-radius: var(--r-md);
    background: var(--app-surface);
    cursor: pointer;
    transition: border-color var(--dur-base) var(--ease-standard), box-shadow var(--dur-base) var(--ease-standard);
}

.theme-card input { position: absolute; opacity: 0; pointer-events: none; }

.theme-card:has(input:checked) {
    border-color: var(--tc, var(--app-primary));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc, var(--app-primary)) 18%, transparent);
}

.theme-card:has(input:focus-visible) { outline: 3px solid rgba(var(--app-primary-rgb), 0.4); }

.theme-card .theme-preview {
    height: 84px;
    border-radius: 12px;
    background: var(--tb, #f4f6fb);
    padding: 8px;
    display: grid;
    grid-template-rows: 14px 1fr 12px;
    gap: 6px;
    overflow: hidden;
}

.theme-card .theme-preview i:nth-child(1) { background: var(--tc); border-radius: 6px; }
.theme-card .theme-preview i:nth-child(2) { background: #fff; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.theme-card .theme-preview i:nth-child(3) { width: 55%; background: var(--tc); opacity: .35; border-radius: 6px; }

.theme-card b {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    font-size: var(--fs-support);
}

.theme-card b .ic { width: 18px; height: 18px; color: var(--tc); opacity: 0; }
.theme-card:has(input:checked) b .ic { opacity: 1; }

/* ---- Quantity stepper (shared: billing, store cart, returns) ------------ */
.stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--app-border-strong);
    border-radius: var(--r-full);
    background: var(--app-surface);
    overflow: hidden;
}

.stepper button {
    min-height: 0;
    padding: 0;
    border-radius: 0;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--app-primary);
    font-size: 20px;
    font-weight: 700;
}

.stepper button:hover { background: var(--app-primary-container); }

.stepper input,
.stepper output {
    width: 52px;
    min-height: 40px !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    text-align: center;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

/* ---- Avatar / logo holders -------------------------------------------- */
.logo-holder {
    display: grid;
    place-items: center;
    max-width: 250px;
    min-height: 48px;
    overflow: hidden;
}

.logo-holder img {
    display: block;
    max-width: 100%;
    max-height: 64px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* ---- Info tip ------------------------------------------------------------ */
.info-tip {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-left: 4px;
    border: 0;
    border-radius: 50%;
    background: var(--app-surface-sunken);
    color: var(--app-text-muted);
    font-size: 11px;
    font-weight: 800;
    vertical-align: middle;
    cursor: help;
}

.info-tip .ic { width: 13px; height: 13px; }
/* 44px hit area around the 20px visual */
.info-tip { position: relative; }
.info-tip::after { content: ""; position: absolute; inset: -12px; }

/* ---- Step indicator ------------------------------------------------------ */
.steps {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.steps > span {
    flex: 1 1 0;
    height: 4px;
    border-radius: 4px;
    background: var(--app-surface-sunken);
}

.steps > span.done,
.steps > span.active { background: var(--app-primary); }

/* ---- Divider with text --------------------------------------------------- */
.divider-text {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: var(--app-text-subtle);
    font-size: var(--fs-caption);
    font-weight: 600;
}

.divider-text::before,
.divider-text::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: var(--app-border);
}

/* ---- PWA install affordance: only visible when the browser supports it -- */
.pwa-install-only {
    display: none !important;
}

html.pwa-installable .pwa-install-only {
    display: flex !important;
}

/* ---- Page-owned modal sheets ---------------------------------------------
   Markup pattern used by existing screens (billing product sheet, scanner,
   product master chooser, code studio):
     <div class="modal" id="x"><div class="sheet">…</div></div>
   toggled with .open. Styled identically to UI.sheet().                    */
.modal {
    position: fixed;
    inset: 0;
    z-index: 880;
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: var(--app-scrim);
    animation: modal-fade var(--dur-base) var(--ease-standard);
}

.modal.open,
.modal.active {
    display: flex;
}

@keyframes modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal > .sheet {
    width: 100%;
    max-width: 560px;
    max-height: calc(var(--vvh) - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-bottom: 96px;
    padding: 8px var(--sp-5) calc(var(--sp-5) + var(--safe-bottom));
    background: var(--app-surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--shadow-floating);
    animation: sheet-up var(--dur-slow) var(--ease-emphasized);
}

.modal > .sheet > * + * {
    margin-top: var(--sp-3);
}

@keyframes sheet-up {
    from { transform: translateY(28px); opacity: 0.6; }
    to { transform: none; opacity: 1; }
}

.sheet-handle {
    width: 36px;
    height: 4px;
    margin: 4px auto 6px;
    border-radius: 4px;
    background: var(--app-border-strong);
}

.sheet-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
}

.sheet-title h3 {
    margin: 0;
    font-size: var(--fs-section);
    font-weight: 700;
}

.sheet-title small {
    display: block;
    color: var(--app-text-muted);
    font-size: var(--fs-support);
}

.sheet-save,
.sheet-secondary {
    --btn-bg: var(--app-primary);
    --btn-fg: var(--app-on-primary);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    width: 100%;
    min-height: 52px;
    padding: 0 var(--sp-5);
    border: 0;
    border-radius: var(--r-sm);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.sheet-secondary {
    --btn-bg: var(--app-surface-variant);
    --btn-fg: var(--app-text);
}

@media (min-width: 768px) {
    .modal {
        align-items: center;
        padding: var(--sp-6);
    }

    .modal > .sheet {
        border-radius: var(--r-xl);
        padding-bottom: var(--sp-5);
    }

    .modal > .sheet .sheet-handle {
        display: none;
    }
}

/* Page-owned slide-up sheet with its own backdrop button (labels studio, EMI):
   <div class="code-sheet"><button class="code-sheet-backdrop"></button><section class="code-sheet-panel">… */
.code-sheet {
    position: fixed;
    inset: 0;
    z-index: 880;
    visibility: hidden;
    pointer-events: none;
}

.code-sheet.open {
    visibility: visible;
    pointer-events: auto;
}

.code-sheet-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    border: 0;
    background: var(--app-scrim);
    opacity: 0;
    transition: opacity var(--dur-base) var(--ease-standard);
}

.code-sheet.open .code-sheet-backdrop { opacity: 1; }

.code-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: min(100%, 560px);
    max-height: calc(var(--vvh) * 0.9);
    margin: 0 auto;
    padding: 8px var(--sp-5) calc(var(--sp-5) + var(--safe-bottom));
    overflow-y: auto;
    background: var(--app-surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--shadow-floating);
    transform: translateY(102%);
    transition: transform var(--dur-slow) var(--ease-emphasized);
}

.code-sheet.open .code-sheet-panel { transform: none; }
.code-sheet-panel > * + * { margin-top: var(--sp-3); }

.code-sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
}

.code-sheet-head h3 { font-size: var(--fs-section); }

/* ---- Period filter -------------------------------------------------- */
.period-filter { display: flex; flex-direction: column; gap: var(--sp-2); }
.period-custom { display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--sp-2); align-items: end; }
.period-custom[hidden] { display: none; }
.period-label { margin: 0; font-size: var(--fs-caption); }
@media (max-width: 420px) { .period-custom { grid-template-columns: 1fr 1fr; } .period-custom .btn { grid-column: 1 / -1; } }


/* ---- Keyboard- and viewport-safe overlays ---------------------------------
   --vvh / --vv-top follow window.visualViewport (set in app.js), so a sheet
   shrinks above the on-screen keyboard instead of being covered by it.
   Defaults keep older WebViews without dvh/visualViewport working.        */
:root { --vvh: 100vh; --vv-top: 0px; }
.modal,
.sheet-layer,
.code-sheet {
    top: var(--vv-top);
    bottom: auto;
    height: var(--vvh);
}
.ui-sheet .sheet-body { scroll-padding-bottom: 24px; }

/* Primary action that stays reachable at the bottom of a scrolling sheet */
.sheet-sticky-actions {
    position: sticky;
    bottom: calc(-1 * (var(--sp-5) + var(--safe-bottom)));
    z-index: 2;
    margin: var(--sp-3) calc(-1 * var(--sp-5)) calc(-1 * (var(--sp-5) + var(--safe-bottom)));
    padding: var(--sp-3) var(--sp-5) calc(var(--sp-4) + var(--safe-bottom));
    background: var(--app-surface);
    box-shadow: 0 -10px 18px -14px rgba(16, 24, 40, 0.35);
}
.modal > .sheet > .sheet-sticky-actions { margin-top: var(--sp-3); }

/* Pages with a floating action button reserve room so the last row is never under it */
body.has-fab .app-content,
body:has(> .app-shell .fab) .app-content {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 56px + var(--sp-8) + var(--sp-4));
}
@media (min-width: 1024px) {
    body.has-fab .app-content,
    body:has(> .app-shell .fab) .app-content { padding-bottom: calc(56px + var(--sp-8) * 2); }
}

/* Horizontal chip rows: intentional scroll, with a fade on the side that has more */
.chip-row { scroll-snap-type: x proximity; scroll-padding-inline: var(--page-pad); }
.chip-row > * { scroll-snap-align: start; }
.chip-row.can-scroll-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
.chip-row.can-scroll-left.can-scroll-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 36px), transparent); }
.chip-row.can-scroll-left:not(.can-scroll-right) { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px); mask-image: linear-gradient(to right, transparent, #000 28px); }
.chip-count { font-weight: 700; font-variant-numeric: tabular-nums; opacity: 0.75; }
.chip.active .chip-count { opacity: 1; }

/* Amounts never break mid-number: KPI values keep one line and scale to the card */
.metric-card { container-type: inline-size; }
.metric-card .metric-value { white-space: nowrap; overflow-wrap: normal; font-size: min(20px, 12.5cqi); }
@media (max-width: 519.98px) {
    .metric-grid.cols-3 .metric-value { font-size: min(15px, 13cqi); }
}
