/**
 * UI polish: contrast, icons, sections, controls (loads after app.css).
 */

/* ── Sidebar nav icons ── */
.nav-link {
  border-left: 3px solid transparent;
  border-right: none;
}

.nav-link.active {
  border-left-color: var(--accent-brand);
  border-right: none;
}

.nav-icon {
  flex-shrink: 0;
  width: 1.15rem;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.92;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(var(--primary-rgb), 0.35);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.sidebar-brand-text {
  color: #fff;
  line-height: 1.2;
}

/* ── Grouped sidebar nav ── */
.nav-group {
  margin-bottom: 2px;
}

.nav-group-label {
  padding: 10px clamp(10px, 1vw, 18px) 4px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.nav-group-active .nav-group-label {
  color: #a5b4fc;
}

/* ── Section sub-nav tabs ── */
.sub-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: clamp(8px, 1.2vh, 16px);
  padding: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sub-nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sub-nav-link:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.sub-nav-link.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── Breadcrumbs ── */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.breadcrumbs-current {
  color: var(--text);
  font-weight: 600;
}

.breadcrumbs-sep {
  margin: 0 6px;
  color: var(--border);
  user-select: none;
}

/* ── Home grouped sections ── */
.home-section {
  margin-bottom: clamp(20px, 3vh, 36px);
}

.home-section:last-child {
  margin-bottom: 0;
}

.home-section-title {
  margin: 0 0 4px;
  font-size: clamp(1rem, 0.8vw + 0.85rem, 1.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.home-section-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
  max-width: 52ch;
}

.page-tabs .tabs {
  margin-bottom: clamp(12px, 1.5vh, 18px);
}

.page-settings-block {
  margin-top: clamp(20px, 3vh, 32px);
  padding-top: clamp(12px, 2vh, 20px);
  border-top: 1px solid var(--border);
}

.page-settings-moved-hint {
  margin-bottom: 16px;
  padding: 12px 14px;
}

/* ── Home tiles ── */
.tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.tile:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
  text-decoration: none;
}

.tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 600;
}

.tile h3 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.tile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* ── Section cards ── */
.table-card,
.ui-section.card {
  overflow: hidden;
}

.table-card-head,
.ui-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.panel-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.table-card-empty {
  padding: 14px;
  color: var(--muted);
  margin: 0;
}

/* ── Form controls focus (accessible) ── */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.btn:focus-visible,
.tab:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.input-name {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.input-name::placeholder {
  color: var(--muted) !important;
}

/* ── Import panel icons (theme-aware) ── */
.import-panel-icon,
.ui-section-num {
  color: var(--text);
}

.import-panel-icon-serial,
.ui-section-icon-serial {
  background: color-mix(in srgb, var(--warning) 18%, var(--surface));
  color: var(--warning);
}

.import-panel-icon-account,
.ui-section-icon-account {
  background: color-mix(in srgb, var(--primary) 15%, var(--surface));
  color: var(--primary);
}

.import-panel-icon-url,
.ui-section-icon-url {
  background: var(--info-soft);
  color: var(--info-text);
}

.delivery-info-box,
.sku-inline {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px dashed var(--border);
}

.product-header {
  background: linear-gradient(135deg, var(--surface) 0%, var(--primary-soft) 100%);
  border-color: var(--border);
}

/* ── Public redeem ── */
.public-shell {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-shell-public {
  background:
    radial-gradient(ellipse 100% 40% at 50% -2%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 60%),
    var(--bg, var(--surface-muted));
}

.public-header {
  background: transparent;
  border-bottom: none;
  padding-bottom: clamp(4px, 1vh, 10px);
}

.public-brand {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-icon {
  color: var(--primary);
}

.public-tagline {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.public-footer {
  color: var(--muted);
  border-top: none;
  background: transparent;
  padding-top: 0;
}

.redeem-card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: calc(var(--radius) + 6px);
  box-shadow:
    0 12px 40px rgba(15, 23, 42, 0.12),
    0 0 0 1px color-mix(in srgb, var(--primary) 6%, transparent);
  overflow: hidden;
  position: relative;
  padding: 0;
  color: var(--text);
}

/* ── Hero section ── */
.redeem-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(28px, 4vh, 40px) var(--card-pad, 18px) clamp(20px, 3vh, 28px);
  background: linear-gradient(
    170deg,
    color-mix(in srgb, var(--primary) 10%, var(--surface)) 0%,
    color-mix(in srgb, var(--primary) 4%, var(--surface)) 100%
  );
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 15%, var(--border));
  position: relative;
}

.redeem-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #818cf8));
  border-radius: calc(var(--radius) + 6px) calc(var(--radius) + 6px) 0 0;
}

.redeem-hero-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--primary), color-mix(in srgb, var(--primary) 72%, #000));
  color: #fff;
  margin-bottom: 16px;
  box-shadow:
    0 8px 24px color-mix(in srgb, var(--primary) 40%, transparent),
    0 2px 8px color-mix(in srgb, var(--primary) 25%, transparent);
}

.redeem-hero-title {
  margin: 0 0 6px;
  font-size: clamp(1.45rem, 4vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.redeem-hero-sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
  max-width: 44ch;
}

.redeem-shop-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 5px 14px 5px 10px;
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--success) 30%, var(--border));
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.redeem-shop-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent);
  animation: redeem-pulse 2.2s ease-in-out infinite;
}

@keyframes redeem-pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 10%, transparent); }
}

/* ── Form wrapper ── */
.redeem-form-wrap {
  padding: clamp(20px, 3vh, 28px) var(--card-pad, 18px) clamp(16px, 2.5vh, 22px);
}

.redeem-trust-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 12px 0 0;
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--muted) 80%, transparent);
  line-height: 1.4;
}

.redeem-error-wrap {
  padding: 0 var(--card-pad, 18px) var(--card-pad, 18px);
}

.credential-row {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text);
}

.credential-row.highlight {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

.credential-label {
  color: var(--muted);
}

.credential-row code,
.credential-row a {
  color: var(--text);
}

.tile-store {
  background: linear-gradient(135deg, var(--surface) 0%, var(--primary-soft) 100%);
  border-color: color-mix(in srgb, var(--primary) 22%, var(--border));
  border-radius: calc(var(--radius) + 2px);
  padding: 18px 20px;
}

.tile-store .tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.2rem;
  background: color-mix(in srgb, var(--primary) 15%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
  color: var(--primary);
}

.tile-store h3 {
  font-size: 1rem;
  font-weight: 700;
}

.tile-store p {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Ops status cards ── */
.ops-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.ops-section-desc {
  color: var(--muted);
}

/* ── Stat active readable ── */
.stat-card .value {
  color: var(--text);
}

.stat-active .label,
.stat-active .value {
  color: var(--text);
}

.option-card-delivery {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.option-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}

.option-card:has(input:checked) .option-card-icon {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}

.option-card strong {
  color: var(--text);
}

.tab.active .tab-label {
  color: var(--primary);
}

.tab-panel {
  padding-top: 4px;
}

/* ── Dark: fix remaining light-only patches ── */
[data-theme="dark"] .btn-danger:hover {
  filter: brightness(1.08);
}

[data-theme="dark"] .card-delivery {
  border-color: color-mix(in srgb, var(--success) 50%, var(--border));
}

[data-theme="dark"] tr:hover td {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

[data-theme="dark"] .flash-dismiss {
  color: var(--text);
}

[data-theme="dark"] .order-item-thumb-placeholder {
  background: var(--surface-muted);
  color: var(--muted);
}

/* ── Responsive UX (all screens) ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  width: auto;
  height: auto;
}

.app-shell {
  overflow-x: clip;
}

.main {
  padding-left: max(var(--page-x), env(safe-area-inset-left, 0px));
  padding-right: max(var(--page-x), env(safe-area-inset-right, 0px));
  padding-bottom: max(clamp(24px, 3vh, 56px), env(safe-area-inset-bottom, 0px));
}

.app-shell-public .public-main,
.app-shell-public .public-header,
.app-shell-public .public-footer {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.table-card-head {
  flex-wrap: wrap;
  row-gap: 8px;
}

.table-card-head .panel-title {
  flex: 1 1 auto;
  min-width: 0;
}

.table-card-head .btn,
.table-card-head .badge {
  flex-shrink: 0;
}

.table-wrap--scroll {
  position: relative;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.table-wrap--scroll::after {
  content: "";
  position: sticky;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  margin-left: -20px;
  float: right;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 85%, transparent));
  opacity: 0;
  transition: opacity 0.2s;
}

.shops-layout .table-wrap--scroll,
.shops-page .table-wrap--scroll {
  overflow-x: visible;
}

.shops-layout .shops-table,
.shops-page .shops-table {
  min-width: 0;
}

@supports (selector(:has(*))) {
  .table-wrap--scroll:has(table) {
    /* show fade hint when content overflows — always subtle on narrow viewports */
  }
}

@media (max-width: 1120px) {
  .sidebar {
    padding-left: max(0px, env(safe-area-inset-left, 0px));
    padding-right: max(0px, env(safe-area-inset-right, 0px));
  }

  .nav-link {
    flex-shrink: 0;
  }
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  padding: 10px var(--card-pad) 14px;
}

.page-header-compact .page-header-actions {
  width: auto;
  flex: 0 1 auto;
}

.filter-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inv-shops-hint {
  margin: 0 12px 10px;
  font-size: 0.78rem;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
}

.inv-store-alert {
  margin-bottom: 12px;
}

.inv-store-row-low {
  background: color-mix(in srgb, var(--warn) 6%, transparent);
}

.inv-store-recent {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 12px 12px;
}

.inv-store-recent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.inv-store-recent-row:last-child {
  border-bottom: none;
}

.inv-store-recent-row:hover {
  color: var(--primary);
}

.inv-store-product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px 12px;
}

.inv-store-product-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius, 10px);
  background: var(--surface);
}

.inv-store-product-card.is-low {
  border-color: color-mix(in srgb, var(--warn) 40%, var(--border));
}

.inv-store-product-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.inv-store-product-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 10px;
  font-size: 0.88rem;
}

.home-store-alert {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.table-scroll-hint {
  display: none;
  margin: 0;
  padding: 6px 12px 0;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

/* Ops panels: card-style rows when tables are too wide for the column */
@media (max-width: 1399px) {
  .ops-panels .data-table--responsive thead {
    display: none;
  }

  .ops-panels .data-table--responsive tbody tr,
  .ops-panels .data-table--responsive tfoot tr {
    display: block;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }

  .ops-panels .data-table--responsive tbody tr:last-child {
    border-bottom: none;
  }

  .ops-panels .data-table--responsive td,
  .ops-panels .data-table--responsive tfoot td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border: none;
    text-align: right;
    max-width: none;
  }

  .ops-panels .data-table--responsive td::before,
  .ops-panels .data-table--responsive tfoot td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-align: left;
    flex: 0 0 38%;
  }

  .ops-panels .data-table--responsive td[data-label=""]::before,
  .ops-panels .data-table--responsive tfoot td[data-label=""]::before {
    content: none;
  }

  .ops-panels .data-table--responsive .col-actions {
    flex-direction: column;
    align-items: stretch;
    white-space: normal;
  }

  .ops-panels .data-table--responsive .col-actions .btn {
    width: 100%;
    max-width: none;
  }

  .ops-panels .table-wrap--scroll {
    overflow-x: visible;
  }
}

/* Stacked table rows on narrow screens */
@media (max-width: 720px) {
  .table-wrap--scroll::after {
    opacity: 1;
  }

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

  .page-header,
  .page-header-compact {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header-actions {
    width: 100%;
  }

  .page-header-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .table-card-head-toolbar .per-page-form {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .table-card-head > .btn {
    width: 100%;
    justify-content: center;
  }

  .data-table--responsive thead {
    display: none;
  }

  .data-table--responsive tbody tr,
  .data-table--responsive tfoot tr {
    display: block;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }

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

  .data-table--responsive td,
  .data-table--responsive tfoot td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border: none;
    text-align: right;
    max-width: none;
  }

  .data-table--responsive td::before,
  .data-table--responsive tfoot td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-align: left;
    flex: 0 0 38%;
  }

  .data-table--responsive td[data-label=""]::before,
  .data-table--responsive tfoot td[data-label=""]::before {
    content: none;
  }

  .data-table--responsive .col-actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    white-space: normal;
  }

  .data-table--responsive .col-actions .btn {
    width: 100%;
    max-width: none;
  }

  .tile-grid-compact {
    grid-template-columns: 1fr;
  }

  .shops-table {
    min-width: 0;
  }

  .shops-sync-col {
    min-width: 0;
    max-width: none;
  }

  .shops-action-stack,
  .shops-link-stack {
    align-items: stretch;
    width: 100%;
  }

  .shops-action-stack .btn,
  .shops-link-stack .btn {
    width: 100%;
    justify-content: center;
  }

  .service-status-actions .btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 6.5rem;
    justify-content: center;
  }

  .ops-section-issues {
    overflow-wrap: anywhere;
  }

  .table-scroll-hint {
    display: block;
  }

  .import-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .credential-row {
    flex-direction: column;
    align-items: stretch;
  }

  .credential-label {
    min-width: 0;
  }

  .credential-row code,
  .credential-row a,
  .credential-row .pw-mask {
    word-break: break-all;
  }

  .redeem-card {
    max-width: 100%;
  }

  .ops-pre {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .stats-compact {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card .value {
    font-size: 1.1rem;
  }

  .btn,
  .nav-link,
  .stat-link {
    min-height: 40px;
  }

  .btn-sm {
    min-height: 38px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .col-truncate {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

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

  .data-table--responsive .col-actions .btn + .btn {
    margin-top: 6px;
  }
}

@media (min-width: 721px) and (max-width: 1120px) {
  .stats-compact {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

/* ── UX polish (nav, forms, feedback) ── */
.sidebar-nav-hint {
  display: none;
  margin: 0;
  padding: 0 12px 6px;
  font-size: 0.68rem;
  color: var(--sidebar-muted);
  text-align: right;
}

@media (max-width: 1120px) {
  .sidebar-nav-hint {
    display: block;
    flex: 1 1 100%;
    order: 99;
  }

  .sidebar-footer {
    flex: 1 1 100%;
    order: 100;
  }
}

.btn-settings-icon {
  width: auto;
  padding: 8px 9px;
  flex-shrink: 0;
}

.home-quick-grid {
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
}

.home-section-compact {
  margin-bottom: clamp(14px, 2vh, 24px);
}

.home-stats-row {
  max-width: 36rem;
}

.stat-card-warn .value {
  color: var(--warning);
}

.filter-bar-search {
  flex: 1 1 12rem;
  min-width: 0;
}

.filter-bar-search input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
}

.password-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.password-input-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.pagination-current {
  font-weight: 700;
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
}

.toast-host {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(320px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  animation: toast-in 0.2s ease;
}

.toast-error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
}

.toast-success {
  border-color: var(--ok-border, #86efac);
  background: var(--ok-soft, #f0fdf4);
  color: var(--ok, #16a34a);
}

.toast-info {
  border-color: var(--info-border, #93c5fd);
  background: var(--info-soft, #eff6ff);
  color: var(--info, #2563eb);
}

/* Persistent toast (new-orders banner) — stays until the user clicks */
.toast-persist {
  pointer-events: auto;
  cursor: default;
}

.toast-out {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

body.is-loading {
  cursor: progress;
}

body.is-loading .main {
  opacity: 0.72;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.app-shell-buyer .public-header-actions .public-user-chip,
.app-shell-buyer .public-header-actions .logout-form {
  display: none;
}

/* ── Per-product stock on catalog list ── */
.col-stock {
  min-width: 11rem;
}

.stock-per-product {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.stock-per-product-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stock-per-product-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stock-per-product-total strong {
  font-size: 0.88rem;
  font-weight: 700;
}

@media (max-width: 720px) {
  .stock-per-product {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

.stock-type-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.product-inline-meta .stock-type-breakdown {
  margin-top: 4px;
  padding-top: 0;
  border-top: none;
  width: 100%;
}

.stock-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-size: 0.78rem;
}

.stock-type-icon {
  opacity: 0.85;
  font-size: 0.82rem;
}

.stock-type-label {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stock-type-chip strong {
  font-size: 0.85rem;
  font-weight: 700;
}

/* ── Auth login ── */
.login-page {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: min(68vh, 560px);
  padding: clamp(4px, 1.5vh, 16px) 0;
}

.login-page::before {
  content: "";
  position: absolute;
  inset: -20% -30% auto;
  height: 240px;
  background: radial-gradient(
    ellipse 70% 80% at 50% 0%,
    color-mix(in srgb, var(--primary) 14%, transparent),
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

.login-page-inner {
  position: relative;
  z-index: 1;
  width: 100%;
}

.login-card {
  background: linear-gradient(
    165deg,
    var(--surface) 0%,
    color-mix(in srgb, var(--primary) 5%, var(--surface)) 55%,
    var(--surface) 100%
  );
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: calc(var(--radius) + 6px);
  box-shadow:
    var(--shadow-lg),
    0 0 0 1px color-mix(in srgb, var(--primary) 8%, transparent);
  padding: clamp(20px, 3.5vw, 32px);
  overflow: hidden;
}

.login-hero {
  margin-bottom: clamp(18px, 2.5vh, 26px);
  text-align: center;
}

.login-hero-compact {
  margin-bottom: 16px;
}

.login-brand-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.login-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--primary), color-mix(in srgb, var(--primary) 75%, #000));
  color: var(--on-primary);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 38%, transparent);
}

.login-brand-name {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.login-hero h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.login-card-sub {
  margin: 0 auto;
  max-width: 28ch;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.login-feature-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.login-feature-chips li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-muted));
  border: 1px solid color-mix(in srgb, var(--primary) 14%, var(--border));
}

.login-chip-icon {
  font-size: 0.68rem;
  opacity: 0.9;
}

.login-form {
  margin: 0;
}

.public-main:has(.alert-error) .auth-input-shell {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}

.public-main:has(.alert-error) .auth-field:focus-within .auth-input-shell {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent);
}

.auth-fields {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2vh, 20px);
  margin-bottom: clamp(18px, 2.2vh, 24px);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.auth-field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.auth-field-hint {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.auth-field-foot {
  margin: 2px 0 0;
  font-size: 0.74rem;
  line-height: 1.35;
}

.auth-input-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 12px;
  min-height: 50px;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-input-shell-password {
  padding-right: 6px;
}

.auth-field:focus-within .auth-input-shell {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.auth-input-icon {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--muted);
  transition: color 0.15s ease;
}

.auth-field:focus-within .auth-input-icon {
  color: var(--primary);
}

.auth-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 12px 0;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
}

.auth-input::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.auth-input:focus {
  outline: none;
}

.auth-toggle-pw {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.auth-toggle-pw:hover,
.auth-toggle-pw:focus-visible {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  outline: none;
}

.login-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 28%, transparent);
}

.login-submit:hover,
.login-submit:focus-visible {
  box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 36%, transparent);
}

.login-submit-arrow {
  transition: transform 0.15s ease;
}

.login-submit:hover .login-submit-arrow,
.login-submit:focus-visible .login-submit-arrow {
  transform: translateX(3px);
}

.login-trust-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: clamp(16px, 2vh, 20px) 0 0;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--muted);
}

.login-trust-icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--muted);
}

.app-shell-mobile .login-page,
.login-page-mobile {
  min-height: auto;
  padding: 0;
}

.app-shell-mobile .login-page::before,
.login-page-mobile::before {
  height: 160px;
}

.app-shell-mobile .login-card,
.login-page-mobile .login-card {
  max-width: none;
  padding: 18px 16px 20px;
}

.app-shell-mobile .login-submit,
.login-page-mobile .login-submit {
  min-height: 52px;
  font-size: 1.02rem;
}

.app-shell-mobile .auth-input-shell,
.login-page-mobile .auth-input-shell {
  min-height: 52px;
}

.app-shell-mobile .auth-input,
.login-page-mobile .auth-input {
  font-size: 16px;
}

/* ── UI visual review fixes ── */
.public-header-minimal {
  padding-bottom: 4px;
}

.public-header-minimal .public-header-row {
  justify-content: flex-end;
}

.public-brand-spacer {
  flex: 1;
}

.error-page-card {
  max-width: 36rem;
}

.error-page-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.error-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.home-settings-hub {
  max-width: 52rem;
}

.pipeline-discovered-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.pipeline-discovered-hint .btn {
  margin-left: auto;
}

/* ── Dashboard: active shop chip ── */
.dashboard-shop-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.dashboard-active-shop-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--success) 28%, var(--border));
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.dashboard-active-shop-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* ── Dashboard: compact pack credits banner ── */
.dashboard-credits-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 0.83rem;
  position: relative;
  z-index: 2;
}

.dashboard-credits-label {
  font-weight: 600;
  color: var(--text);
  font-size: 0.83rem;
}

.dashboard-credits-badge {
  font-size: 0.78rem;
  padding: 2px 8px;
}

.dashboard-credits-detail {
  color: var(--muted);
}

.dashboard-credits-actions {
  margin-left: auto;
  flex-shrink: 0;
}

.dashboard-credits-grants {
  position: relative;
}

.dashboard-credits-grants summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
}
.dashboard-credits-grants summary::-webkit-details-marker { display: none; }

.dashboard-credits-grants[open] {
  width: 100%;
}

.dashboard-credits-grants[open] .shops-credit-ledger-list {
  margin: 6px 0 2px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Dashboard: store tiles (By store page) ── */
.tile-store-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.tile-store-head .tile-icon {
  margin: 0;
  flex-shrink: 0;
}

.tile-store-head h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-store-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tile-store-stat {
  font-size: 0.82rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--muted);
}

.tile-store-stat--warn {
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 30%, var(--border));
  color: var(--text);
}

.tile-store-stat--ok {
  background: color-mix(in srgb, var(--success) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--success) 25%, var(--border));
  color: var(--muted);
}

.tile-store-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.dashboard-order-filters .filter-bar-search {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 16rem;
}

.filter-bar--stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.filter-bar-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.filter-bar-form--action {
  flex: 0 0 auto;
}

.filter-bar-form label {
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
}

.filter-bar-form select,
.filter-bar-form input[type="search"] {
  min-height: 36px;
}

.dashboard-order-filters .filter-bar-form .btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.pipeline-conn-banner {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 12px;
  z-index: 2;
}

.pipeline-conn-banner .alert-body {
  flex: 1 1 14rem;
  min-width: 0;
}

.pipeline-conn-banner-aside {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.pipeline-conn-banner .flash-dismiss {
  position: static;
  flex-shrink: 0;
}

.dashboard-banner-actions,
.dashboard-credits-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.dashboard-banner-actions .btn,
.dashboard-credits-actions .btn {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  cursor: pointer;
  text-decoration: none;
}

.btn-on-warn {
  background: #92400e;
  color: #fff;
  border: 1px solid #78350f;
  white-space: nowrap;
}

.btn-on-warn:hover {
  background: #78350f;
  color: #fff;
  text-decoration: none;
}

[data-theme="dark"] .alert-warn {
  background: color-mix(in srgb, var(--warning) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 42%, var(--border));
  color: var(--text);
}

[data-theme="dark"] .alert-warn .hint {
  color: var(--muted);
}

[data-theme="dark"] .btn-on-warn {
  background: color-mix(in srgb, var(--warning) 78%, #1a1208);
  border-color: color-mix(in srgb, var(--warning) 55%, #000);
  color: #fff;
}

[data-theme="dark"] .btn-on-warn:hover {
  background: color-mix(in srgb, var(--warning) 88%, #000);
  color: #fff;
}

.empty-cta-form .empty-cta {
  margin-top: 12px;
  min-width: 12rem;
}

.dashboard-order-filters .filter-bar-search label {
  flex: 0 0 auto;
  margin: 0;
}

.dashboard-order-filters .filter-bar-search input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
}

.dashboard-order-filters .filter-bar-search .btn {
  flex: 0 0 auto;
}

/* ── Dashboard: stage-colored stat cards ── */
.stat-card--ok     { border-left: 3px solid var(--success); }
.stat-card--info   { border-left: 3px solid var(--info-text); }
.stat-card--warn   { border-left: 3px solid var(--warning); }
.stat-card--danger { border-left: 3px solid var(--danger); }
.stat-card--muted  { border-left: 3px solid var(--border); }

.stat-card--ok.stat-active     { border-color: var(--success);   background: color-mix(in srgb, var(--success) 10%, var(--surface)); }
.stat-card--info.stat-active   { border-color: var(--info-text); background: var(--info-soft); }
.stat-card--warn.stat-active   { border-color: var(--warning);   background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.stat-card--danger.stat-active { border-color: var(--danger);    background: var(--danger-soft); }
.stat-card--muted.stat-active  { border-color: var(--muted);     background: var(--surface-muted); }

.users-create-form .field input,
.users-create-form .field select {
  width: 100%;
}

.users-actions-cell {
  min-width: 14rem;
}

.users-action-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.users-action-form:last-child {
  margin-bottom: 0;
}

.users-action-form input[type="password"] {
  flex: 1 1 10rem;
  min-width: 8rem;
}

.users-grant-form select {
  flex: 1 1 8rem;
  min-width: 6rem;
}

.users-edit-row td {
  padding-top: 0;
  background: var(--surface-2, #f8f9fb);
}

.users-edit-form {
  margin: 0.5rem 0 1rem;
  padding: 1rem;
}

.users-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: 0.75rem 1rem;
}

.users-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.users-delete-inline-form {
  margin: 0 0 1rem 1rem;
}

.users-mobile-edit {
  margin-top: 0.75rem;
}

.users-mobile-edit summary {
  list-style: none;
  cursor: pointer;
}

.users-mobile-edit summary::-webkit-details-marker {
  display: none;
}

.settings-redeem-copy-form .form-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 16.5rem));
  justify-content: start;
}

.settings-redeem-copy-form .field-wide {
  grid-column: 1 / -1;
}

.redeem-color-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.redeem-color-field .redeem-color-picker {
  width: 2.75rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  flex-shrink: 0;
}

.redeem-color-field input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
}

.redeem-logo-preview {
  margin-bottom: 10px;
}

.redeem-logo-preview-img,
.public-brand-logo {
  display: block;
  max-height: 48px;
  max-width: 160px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.public-brand-logo {
  margin-right: 8px;
}

.public-brand:has(.public-brand-logo) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.redeem-branding-dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.redeem-branding-dl dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 4px;
}

.redeem-branding-dl dd {
  margin: 0;
}

.redeem-swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  vertical-align: -2px;
  margin-right: 6px;
}

.public-support-link {
  margin-top: 8px;
}

.public-support-link a {
  color: var(--primary);
  font-weight: 500;
}

.redeem-page-themed .public-shell {
  background: transparent;
}

.mobile-quick-card::after {
  content: "›";
  position: absolute;
  top: 14px;
  right: 12px;
  color: var(--muted);
  font-size: 1.1rem;
}

.mobile-quick-card {
  position: relative;
  padding-right: 28px;
}

/* ── Tool form fields (catalog, settings, dashboard) ── */
.card-form-compact {
  padding: clamp(12px, 1.4vw, 16px) clamp(14px, 1.6vw, 18px);
  max-width: 36rem;
}

.card-form-compact .panel-title {
  margin-bottom: 4px;
}

.card-form-compact .hint {
  margin-bottom: 12px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.card-form-compact .form-grid,
.tool-form .form-grid {
  max-width: 32rem;
}

.form-grid--paired {
  grid-template-columns: 1fr;
}

@media (min-width: 520px) {
  .form-grid--paired {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.app-shell .field input[type="text"],
.app-shell .field input[type="url"],
.app-shell .field input[type="email"],
.app-shell .field input[type="password"],
.app-shell .field input[type="number"],
.app-shell .field input[type="search"],
.app-shell .field textarea,
.app-shell .field select {
  background: color-mix(in srgb, var(--surface-muted) 55%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--border) 88%, var(--text) 6%);
  min-height: 2.375rem;
  box-shadow: inset 0 1px 2px color-mix(in srgb, var(--text) 5%, transparent);
}

.app-shell .field textarea {
  min-height: 5.5rem;
}

.app-shell .field input:hover:not(:disabled):not(:focus),
.app-shell .field textarea:hover:not(:disabled):not(:focus),
.app-shell .field select:hover:not(:disabled):not(:focus) {
  border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
  background: var(--surface);
}

.app-shell .field input::placeholder,
.app-shell .field textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 88%, transparent);
}

.app-shell .field.field-tight label,
.app-shell .field.field-tight .label-compact {
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  letter-spacing: 0.01em;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

.card-form-compact .form-actions,
.tool-form .form-actions {
  margin-top: 10px;
}

.form-actions--inline {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.form-inline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
  max-width: 24rem;
}

.form-inline-row .field {
  flex: 1 1 10rem;
  min-width: 0;
  margin-bottom: 0;
}

.form-inline-row .form-actions {
  flex: 0 0 auto;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.product-import-block form .form-actions,
.import-panel form .form-actions {
  margin-top: 10px;
  padding-top: 0;
  border-top: none;
}

.users-create-form.tool-form {
  padding: 0 var(--card-pad) var(--card-pad);
}

.shops-credential-grid {
  max-width: 38rem;
}

/* ── Inventory store: shop context banner ── */
.inv-store-shop-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--success) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--success) 28%, var(--border));
  font-size: 0.83rem;
  color: var(--text);
}

.inv-store-shop-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent);
}

/* ── Inventory: product selector rail ── */
.inv-product-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.inv-product-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  min-width: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.inv-product-chip:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}

.inv-product-chip--active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent);
}

.inv-chip-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 16ch;
}

.inv-product-chip--active .inv-chip-name {
  color: var(--primary);
}

.inv-chip-split {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
}

.inv-chip-avail {
  color: var(--success);
  font-weight: 700;
}

.inv-chip-sold {
  color: var(--muted);
}

/* ── Inventory: serial masking ── */
.inv-serial-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.inv-serial-mask {
  letter-spacing: 0.06em;
  color: var(--muted);
  font-size: 0.78rem;
}

.inv-serial-text {
  font-size: 0.78rem;
}

.inv-serial-btn {
  flex-shrink: 0;
  padding: 1px 7px;
  height: auto;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  line-height: 1.6;
}

.inv-serial-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.inv-show-all-btn {
  margin-left: auto;
  font-size: 0.75rem;
}

/* ── Inventory: row state tints ── */
.inv-row-sold td {
  color: var(--muted);
}

.inv-row-sold .badge,
.inv-row-sold a,
.inv-row-sold strong,
.inv-row-sold code {
  opacity: 0.8;
}

/* ── Inventory: filter bar layout ── */
.inv-filter-bar .filter-bar-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inv-filter-bar .filter-bar-field label {
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.inv-filter-bar .filter-bar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 14rem;
  min-width: 0;
}

.inv-filter-bar .filter-bar-search label {
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.inv-filter-bar .filter-bar-search input {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 720px) {
  .inv-product-chip {
    flex: 0 1 auto;
  }
  .inv-chip-name {
    max-width: 12ch;
  }
}

/* ── Payment review shared styles ───────────────────────────────── */
.payment-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.payment-status-pending  { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); }
.payment-status-approved { background: var(--success-soft); color: var(--success-text); border: 1px solid var(--success); }
.payment-status-rejected { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.payment-note-input {
  width: 100%;
  min-width: 140px;
  resize: vertical;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}
.payment-note-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus-ring); }
.payment-review-form { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.payment-review-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.reviewed-note { font-size: 12px; color: var(--muted); max-width: 220px; }
