/* ==========================================================================
   components.css - reusable UI component styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--bg-surface);
  --btn-fg: var(--text-primary);
  --btn-bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"],
.btn.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

.btn--primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--text-on-brand);
  --btn-bd: var(--accent);
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--danger {
  --btn-bg: var(--danger-solid);
  --btn-fg: #fff;
  --btn-bd: var(--danger-solid);
}
.btn--danger:hover { filter: brightness(0.94); background: var(--danger-solid); }

.btn--success {
  --btn-bg: var(--success-solid);
  --btn-fg: #fff;
  --btn-bd: var(--success-solid);
}
.btn--success:hover { filter: brightness(0.95); background: var(--success-solid); }

.btn--ghost {
  --btn-bg: transparent;
  --btn-bd: transparent;
  --btn-fg: var(--text-secondary);
}
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn--subtle {
  --btn-bg: var(--accent-soft);
  --btn-bd: var(--accent-soft-border);
  --btn-fg: var(--accent-text);
}
.btn--subtle:hover { background: var(--accent-soft); filter: brightness(0.97); }

.btn--outline {
  --btn-bg: transparent;
}
.btn--outline:hover { background: var(--bg-hover); }

.btn--sm { height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { height: 46px; padding: 0 var(--sp-6); font-size: var(--fs-lg); }
.btn--xl { height: 56px; padding: 0 var(--sp-7); font-size: var(--fs-xl); font-weight: var(--fw-semibold); }
.btn--icon { padding: 0; width: 38px; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { width: 100%; }

.btn .spinner { width: 16px; height: 16px; }

.btn-group {
  display: inline-flex;
}
.btn-group .btn {
  border-radius: 0;
  margin-left: -1px;
}
.btn-group .btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.btn-group .btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-soft-border);
  z-index: 1;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  gap: 2px;
}
.segmented button {
  padding: var(--sp-1) var(--sp-3);
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  white-space: nowrap;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button[aria-pressed="true"] {
  background: var(--bg-surface);
  color: var(--text-strong);
  box-shadow: var(--shadow-xs);
}

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field--row { flex-direction: row; align-items: center; gap: var(--sp-3); }
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
}

.label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.label .req { color: var(--danger-solid); }
.label .opt { color: var(--text-disabled); font-weight: var(--fw-regular); }

.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--fs-md);
  transition: border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast);
}
.textarea { height: auto; min-height: 88px; padding: var(--sp-2) var(--sp-3); resize: vertical; line-height: var(--lh-normal); }
.input::placeholder, .textarea::placeholder { color: var(--text-disabled); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring-focus);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--bg-inset);
  color: var(--text-disabled);
  cursor: not-allowed;
}
.input[readonly] { background: var(--bg-inset); }

.input--invalid,
.select--invalid,
.textarea--invalid,
[aria-invalid="true"] {
  border-color: var(--danger-solid);
}
.input--invalid:focus { box-shadow: 0 0 0 3px var(--danger-100); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-8);
}

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .input { border-radius: 0; }
.input-group > :first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.input-group > :last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.input-group .input:not(:first-child) { margin-left: -1px; }
.input-group .input:focus { z-index: 2; }
.input-group__addon {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--sp-3);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.input-search {
  position: relative;
}
.input-search .input { padding-left: var(--sp-8); }
.input-search__icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.input-search kbd {
  position: absolute;
  right: var(--sp-2);
  top: 50%;
  transform: translateY(-50%);
}

.field-hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field-error { font-size: var(--fs-xs); color: var(--danger-fg); display: flex; gap: 4px; align-items: center; }

/* Checkbox & radio */
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--fs-md);
  user-select: none;
}
.check input {
  appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  display: grid;
  place-content: center;
  flex-shrink: 0;
  transition: background-color var(--dur-fast), border-color var(--dur-fast);
}
.check input[type="radio"] { border-radius: var(--radius-pill); }
.check input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.check input:checked::after {
  content: "";
  width: 10px; height: 10px;
}
.check input[type="checkbox"]:checked::after {
  width: 6px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.check input[type="radio"]:checked::after {
  border-radius: 50%;
  background: #fff;
}
.check input:focus-visible { box-shadow: var(--ring-focus); outline: none; }

/* Toggle switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
  /* only the switch and its words take the click, never the empty rest of the row */
  width: max-content;
  max-width: 100%;
  justify-self: start;
  align-self: start;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 40px; height: 22px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  padding: 2px;
  transition: background-color var(--dur-mid) var(--ease-out);
  flex-shrink: 0;
}
.switch__thumb {
  display: block; /* a span: without this it has no size and the knob is invisible */
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-mid) var(--ease-out);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring-focus); }

/* --------------------------------------------------------------------------
   Cards & panels
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card--pad { padding: var(--sp-5); }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}
.card__header h3 { font-size: var(--fs-lg); }
.card__body { padding: var(--sp-5); }
.card__footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Badges, chips, tags, pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.5;
  background: var(--bg-inset);
  color: var(--text-secondary);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge--success { background: var(--success-bg); color: var(--success-fg); }
.badge--warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.badge--info    { background: var(--info-bg);    color: var(--info-fg); }
.badge--brand   { background: var(--accent-soft); color: var(--accent-text); }
.badge--neutral { background: var(--bg-inset); color: var(--text-secondary); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.chip button {
  display: grid;
  place-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  color: var(--text-muted);
}
.chip button:hover { background: var(--bg-active); color: var(--text-primary); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-md);
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text-primary); }
.table th .sort-ind { margin-left: 4px; opacity: 0.4; }
.table th[aria-sort="ascending"] .sort-ind,
.table th[aria-sort="descending"] .sort-ind { opacity: 1; color: var(--accent-text); }
.table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background-color var(--dur-fast); }
.table tbody tr:hover { background: var(--bg-surface-2); }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.actions { text-align: right; white-space: nowrap; }
.table--compact tbody td { padding: var(--sp-2) var(--sp-3); }
.table--compact thead th { padding: var(--sp-2) var(--sp-3); }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.table-toolbar .grow { min-width: 200px; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* Pagination */
.pagination { display: inline-flex; align-items: center; gap: var(--sp-1); }
.pagination button {
  min-width: 32px;
  height: 32px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}
.pagination button:hover:not(:disabled) { background: var(--bg-hover); }
.pagination button[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-brand);
}
.pagination button:disabled { opacity: 0.4; pointer-events: none; }

/* --------------------------------------------------------------------------
   Modal / dialog
   -------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  z-index: var(--z-modal);
  opacity: 0;
  transition: opacity var(--dur-mid) var(--ease-out);
}
.overlay.is-open { opacity: 1; }
.overlay[data-align="top"] { align-items: flex-start; padding-top: 8vh; }

.modal {
  width: 100%;
  max-width: var(--modal-w, 520px);
  max-height: calc(100dvh - var(--sp-8));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition: transform var(--dur-mid) var(--ease-out), opacity var(--dur-mid);
}
.overlay.is-open .modal { transform: none; opacity: 1; }
.modal--sm { --modal-w: 420px; }
.modal--lg { --modal-w: 720px; }
.modal--xl { --modal-w: 960px; }
.modal--full { --modal-w: 1200px; }

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}
.modal__header h2 { font-size: var(--fs-xl); }
.modal__header p { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.modal__close {
  display: grid;
  place-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}
.modal__close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal__body {
  padding: var(--sp-5);
  overflow-y: auto;
  flex: 1;
}
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.modal__footer--between { justify-content: space-between; }

/* --------------------------------------------------------------------------
   Drawer
   -------------------------------------------------------------------------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-drawer);
  opacity: 0;
  transition: opacity var(--dur-mid) var(--ease-out);
}
.drawer-overlay.is-open { opacity: 1; }
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: min(var(--drawer-w, 440px), 100vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
}
.drawer.is-open { transform: none; }
.drawer[data-side="left"] { right: auto; left: 0; border-left: none; border-right: 1px solid var(--border); transform: translateX(-100%); }
.drawer[data-side="left"].is-open { transform: none; }
.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}
.drawer__body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.drawer__footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border-subtle); display: flex; gap: var(--sp-2); justify-content: flex-end; }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: var(--sp-3) var(--sp-3);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
}
.tabpanel { padding-top: var(--sp-5); }

/* --------------------------------------------------------------------------
   Dropdown menu
   -------------------------------------------------------------------------- */
.menu {
  position: absolute;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-1);
  z-index: var(--z-tooltip);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--dur-fast), transform var(--dur-fast);
}
.menu.is-open { opacity: 1; transform: none; }
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  color: var(--text-primary);
  text-align: left;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--bg-hover); outline: none; }
.menu__item svg { width: 16px; height: 16px; color: var(--text-muted); }
.menu__item--danger { color: var(--danger-fg); }
.menu__item--danger svg { color: var(--danger-fg); }
.menu__sep { height: 1px; background: var(--border-subtle); margin: var(--sp-1) 0; }
.menu__label { padding: var(--sp-2) var(--sp-3) var(--sp-1); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-disabled); }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toast-region {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: var(--z-toast);
  max-width: min(380px, calc(100vw - var(--sp-8)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-mid) var(--ease-out);
}
.toast.is-leaving { animation: toast-out var(--dur-mid) var(--ease-in-out) forwards; }
.toast__icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--text-strong); }
.toast__msg { font-size: var(--fs-sm); color: var(--text-secondary); }
.toast__close { flex-shrink: 0; color: var(--text-muted); width: 20px; height: 20px; display: grid; place-content: center; border-radius: var(--radius-xs); }
.toast__close:hover { background: var(--bg-hover); }
.toast--success { border-left-color: var(--success-solid); }
.toast--success .toast__icon { color: var(--success-solid); }
.toast--error { border-left-color: var(--danger-solid); }
.toast--error .toast__icon { color: var(--danger-solid); }
.toast--warning { border-left-color: var(--warning-solid); }
.toast--warning .toast__icon { color: var(--warning-solid); }
.toast--info { border-left-color: var(--info-solid); }
.toast--info .toast__icon { color: var(--info-solid); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(24px); height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }
}

/* --------------------------------------------------------------------------
   Alerts (inline)
   -------------------------------------------------------------------------- */
.alert {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  font-size: var(--fs-sm);
}
.alert__icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.alert__body { flex: 1; }
.alert__title { font-weight: var(--fw-semibold); color: var(--text-strong); margin-bottom: 2px; }
.alert--success { background: var(--success-bg); border-color: transparent; color: var(--success-fg); }
.alert--warning { background: var(--warning-bg); border-color: transparent; color: var(--warning-fg); }
.alert--danger  { background: var(--danger-bg);  border-color: transparent; color: var(--danger-fg); }
.alert--info    { background: var(--info-bg);    border-color: transparent; color: var(--info-fg); }
.alert--success .alert__title,
.alert--warning .alert__title,
.alert--danger .alert__title,
.alert--info .alert__title { color: inherit; }

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-9) var(--sp-5);
  color: var(--text-muted);
}
.empty-state__icon {
  display: grid;
  place-content: center;
  width: 56px; height: 56px;
  border-radius: var(--radius-xl);
  background: var(--bg-inset);
  color: var(--text-muted);
}
.empty-state__icon svg { width: 26px; height: 26px; }
.empty-state h3 { font-size: var(--fs-lg); color: var(--text-secondary); }
.empty-state p { font-size: var(--fs-sm); max-width: 46ch; }
.empty-state .btn { margin-top: var(--sp-2); }

/* --------------------------------------------------------------------------
   Skeleton / loading
   -------------------------------------------------------------------------- */
.skeleton {
  background: var(--bg-skeleton);
  background-size: 400% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton 1.4s ease infinite;
}
.skeleton--text { height: 0.8em; margin: 0.2em 0; }
.skeleton--title { height: 1.4em; width: 40%; }
.skeleton--circle { border-radius: 50%; }
.skeleton--btn { height: 38px; width: 120px; border-radius: var(--radius-md); }
@keyframes skeleton {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner--invert { border-color: rgba(255,255,255,0.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  min-height: 256px;
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
/* Loading looks like the page about to appear: its outline (a heading, a row of
   cards, a few lines) slightly out of focus, with a soft light sweeping left to
   right across it. No spinning circle. */
.loading-block > .spinner { display: none; }
.loading-block::before {
  content: '';
  position: absolute;
  inset: var(--sp-5) var(--sp-5) auto;
  height: 188px;
  z-index: -2;
  background:
    linear-gradient(var(--sk-bar) 0 0) 0 0 / 36% 14px,
    linear-gradient(var(--sk-bar) 0 0) 0 26px / 20% 9px,
    linear-gradient(var(--sk-card) 0 0) 0 54px / 32% 62px,
    linear-gradient(var(--sk-card) 0 0) 50% 54px / 32% 62px,
    linear-gradient(var(--sk-card) 0 0) 100% 54px / 32% 62px,
    linear-gradient(var(--sk-bar) 0 0) 0 136px / 94% 9px,
    linear-gradient(var(--sk-bar) 0 0) 0 156px / 80% 9px,
    linear-gradient(var(--sk-bar) 0 0) 0 176px / 62% 9px;
  background-repeat: no-repeat;
  filter: blur(2px);
  opacity: 0.9;
}
.loading-block::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, transparent 25%, var(--shimmer) 50%, transparent 75%);
  transform: translateX(-100%);
  animation: sk-sweep 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  pointer-events: none;
}
@keyframes sk-sweep { to { transform: translateX(100%); } }
.sk-tile { position: relative; overflow: hidden; min-height: 150px; border-radius: var(--radius-md); background: var(--sk-card); }
.sk-tile::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 25%, var(--shimmer) 50%, transparent 75%);
  transform: translateX(-100%);
  animation: sk-sweep 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* The first load of a panel: the whole app's outline, blurred, behind the sweep.
   Markup in admin.html / cashier.html / the Super Admin page (.boot-sk). */
.gate > .loading-block { position: fixed; inset: 0; min-height: 0; border-radius: 0; padding: 0 var(--sp-4) var(--sp-8); }
.boot-sk::before { display: none; }
.boot-sk__shell {
  position: absolute; inset: 0; z-index: -2;
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  filter: blur(3px); opacity: 0.95;
}
.boot-sk__shell i { display: block; border-radius: var(--radius-md); background: var(--sk-bar); }
.boot-sk__side { display: flex; flex-direction: column; gap: 14px; padding: 22px 18px; background: var(--sk-side); }
.boot-sk__side i { height: 12px; width: 72%; }
.boot-sk__side i:first-child { height: 26px; width: 58%; margin-bottom: 18px; }
.boot-sk__main { display: flex; flex-direction: column; gap: 20px; padding: 22px clamp(16px, 3vw, 32px); min-width: 0; }
.boot-sk__top { display: flex; justify-content: space-between; align-items: center; }
.boot-sk__top i { height: 18px; width: 30%; }
.boot-sk__top i + i { height: 34px; width: 34px; border-radius: 50%; }
.boot-sk__kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.boot-sk__kpis i { height: 96px; background: var(--sk-card); }
.boot-sk__panel { display: flex; flex-direction: column; gap: 16px; padding: 22px; border-radius: var(--radius-lg); background: var(--sk-card); }
.boot-sk__panel i { height: 11px; }
.boot-sk__panel i:nth-child(1) { width: 26%; height: 15px; }
.boot-sk__panel i:nth-child(2) { width: 92%; }
.boot-sk__panel i:nth-child(3) { width: 84%; }
.boot-sk__panel i:nth-child(4) { width: 88%; }
.boot-sk__panel i:nth-child(5) { width: 70%; }
/* the till: product tiles on the left, the cart on the right */
.boot-sk--till .boot-sk__shell { grid-template-columns: minmax(0, 1fr) clamp(300px, 30vw, 400px); }
.boot-sk__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); grid-auto-rows: 150px; gap: 14px; padding: 76px clamp(16px, 2vw, 24px) 24px; overflow: hidden; }
.boot-sk__grid i { background: var(--sk-card); }
.boot-sk__cart { display: flex; flex-direction: column; gap: 14px; padding: 24px 20px; background: var(--sk-side); }
.boot-sk__cart i { height: 12px; width: 80%; }
.boot-sk__cart i:first-child { height: 20px; width: 46%; margin-bottom: 10px; }
.boot-sk__cart i:last-child { height: 52px; width: 100%; margin-top: auto; border-radius: var(--radius-lg); }
.boot-sk__label {
  padding: 6px 14px; border-radius: 999px;
  background: var(--surface); box-shadow: 0 1px 2px rgba(34, 31, 28, 0.08);
  color: var(--text-secondary); font-weight: var(--fw-medium);
}
@media (max-width: 860px) {
  .boot-sk__shell { grid-template-columns: minmax(0, 1fr); }
  .boot-sk__side, .boot-sk__cart { display: none; }
  .boot-sk__kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .boot-sk--till .boot-sk__shell { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .sk-tile::after { animation: none; transform: none; opacity: 0; }
  .loading-block::after { animation: sk-pulse 2.4s ease-in-out infinite; transform: none; opacity: 0.4; }
  @keyframes sk-pulse { 50% { opacity: 0.9; } }
}

/* --------------------------------------------------------------------------
   Tooltip
   -------------------------------------------------------------------------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 4px 8px;
  background: var(--gray-900);
  color: #fff;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-xs);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast), transform var(--dur-fast);
  z-index: var(--z-tooltip);
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%);
}

/* --------------------------------------------------------------------------
   Avatar
   -------------------------------------------------------------------------- */
.avatar {
  display: grid;
  place-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 26px; height: 26px; font-size: var(--fs-xs); }
.avatar--lg { width: 46px; height: 46px; font-size: var(--fs-lg); }

/* --------------------------------------------------------------------------
   Progress bar
   -------------------------------------------------------------------------- */
.progress {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-inset);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}
.progress--success .progress__bar { background: var(--success-solid); }
.progress--warning .progress__bar { background: var(--warning-solid); }
.progress--danger .progress__bar { background: var(--danger-solid); }

/* --------------------------------------------------------------------------
   Definition / detail lists
   -------------------------------------------------------------------------- */
.detail-list { display: grid; gap: var(--sp-3); }
.detail-list__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
}
.detail-list__row dt { color: var(--text-muted); }
.detail-list__row dd { color: var(--text-primary); font-weight: var(--fw-medium); }

/* --------------------------------------------------------------------------
   Keyboard shortcut hint bar
   -------------------------------------------------------------------------- */
.kbd-hints {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.kbd-hints span { display: inline-flex; align-items: center; gap: 5px; }

/* --------------------------------------------------------------------------
   Language switcher + Bangla typography
   -------------------------------------------------------------------------- */
.lang-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  gap: 2px;
  flex-shrink: 0;
}
.lang-switch button {
  padding: 3px 9px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  white-space: nowrap;
  line-height: 1;
}
.lang-switch button:hover { color: var(--text-primary); }
.lang-switch button[aria-pressed="true"] {
  background: var(--bg-surface);
  color: var(--accent-text);
  box-shadow: var(--shadow-xs);
}

/* ---- Bundled Bangla font: Hind Siliguri (self-hosted, offline-safe) ---- */
@font-face {
  font-family: "Hind Siliguri";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("../assets/fonts/hind-siliguri-bengali-400.woff2") format("woff2");
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: "Hind Siliguri";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("../assets/fonts/hind-siliguri-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Hind Siliguri";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("../assets/fonts/hind-siliguri-bengali-500.woff2") format("woff2");
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: "Hind Siliguri";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("../assets/fonts/hind-siliguri-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Hind Siliguri";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("../assets/fonts/hind-siliguri-bengali-600.woff2") format("woff2");
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: "Hind Siliguri";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("../assets/fonts/hind-siliguri-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Hind Siliguri";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("../assets/fonts/hind-siliguri-bengali-700.woff2") format("woff2");
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: "Hind Siliguri";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("../assets/fonts/hind-siliguri-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

/* When Bangla is active, prefer the Bangla font everywhere. Numbers, currency
   and codes stay on the tabular mono face so they line up and read cleanly. */
.lang-bn,
.lang-bn body,
.lang-bn input,
.lang-bn select,
.lang-bn textarea,
.lang-bn button {
  font-family: "Hind Siliguri", "Noto Sans Bengali", "Kalpurush", "Nikosh",
    "Nirmala UI", "SolaimanLipi", var(--font-sans);
}
.lang-bn .mono,
.lang-bn .pos-amount,
.lang-bn .tabular,
.lang-bn code,
.lang-bn kbd,
.lang-bn .barcode-svg { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* keep Latin digits crisp inside Bangla copy */
.lang-bn { font-feature-settings: "lnum" 1; }

/* ---- subscription guard (components/subscription-guard.js) ---- */
.sub-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: var(--fs-sm, .875rem);
  background: color-mix(in srgb, var(--warn, #A67214) 16%, var(--surface));
  color: var(--text); border-bottom: 1px solid color-mix(in srgb, var(--warn, #A67214) 40%, transparent);
}
.sub-banner--expired, .sub-banner--suspended, .sub-banner--cancelled {
  background: color-mix(in srgb, var(--danger, #9E2B25) 16%, var(--surface));
  border-bottom-color: color-mix(in srgb, var(--danger, #9E2B25) 40%, transparent);
}
.sub-banner__icon { display: inline-flex; flex: none; }
.sub-banner__text { flex: 1; min-width: 0; }
.sub-banner .btn { flex: none; }

.sub-block { display: grid; place-items: center; padding: clamp(24px, 6vw, 64px); min-height: 60vh; }
.sub-block__card {
  max-width: 460px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px); box-shadow: var(--shadow-lg); padding: clamp(24px, 5vw, 40px);
}
.sub-block__icon {
  display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: color-mix(in srgb, var(--danger, #9E2B25) 15%, transparent); color: var(--danger, #9E2B25);
  margin-bottom: 12px;
}
.sub-block__card h1 { font-size: 1.35rem; margin: 0 0 6px; }
.sub-block__card p { color: var(--text-muted); margin: 6px 0; }
.sub-block__due { color: var(--text) !important; }
.sub-block__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0 8px; }
.sub-block__foot { font-size: var(--fs-xs, .78rem); }

/* ------------------------------------------------------------------ */
/* payment sheet - the one centralized merchant payment UI            */
/* ------------------------------------------------------------------ */
.payment-sheet { display: flex; flex-direction: column; gap: 14px; }

.payment-methods { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.payment-method {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 12px 14px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-md, 10px); transition: border-color .12s, background .12s;
}
.payment-method:hover { border-color: var(--brand-300); }
.payment-method.is-selected {
  border-color: var(--brand-500);
  background: color-mix(in srgb, var(--brand-500) 8%, var(--surface));
}
.payment-method__name { font-weight: 700; }
.payment-method__type { font-size: var(--fs-xs, .78rem); color: var(--text-muted); }

.payment-bill {
  border: 1px solid var(--border); border-radius: var(--radius-md, 10px);
  padding: 10px 14px; background: var(--surface-2, var(--surface));
}
.payment-bill__row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: var(--fs-sm, .875rem); }
.payment-bill__row--total { border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 8px; font-size: 1rem; }
.payment-bill__row--total b { font-size: 1.15rem; }

.payment-detail { display: flex; flex-direction: column; gap: 10px; }
.payment-number {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-md, 10px);
  background: color-mix(in srgb, var(--brand-500) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand-500) 25%, transparent);
}
.payment-number__label { display: block; font-size: var(--fs-xs, .78rem); color: var(--text-muted); }
.payment-number__value { display: block; font-size: 1.25rem; font-weight: 800; letter-spacing: .04em; }
.payment-number__name { display: block; font-size: var(--fs-xs, .78rem); color: var(--text-muted); }
/* a Bangla QR account's picture (Super Admin -> Payment Settings) */
.payment-qr { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md, 10px); background: #fff; }
.payment-qr img { width: min(220px, 70vw); height: auto; image-rendering: pixelated; }
.payment-qr span { font-size: var(--fs-xs, .78rem); color: #5c564c; }

.payment-steps { margin: 0; padding-left: 1.35em; display: flex; flex-direction: column; gap: 5px; }
.payment-steps li { font-size: var(--fs-sm, .875rem); line-height: 1.5; }

.payment-form { display: flex; flex-direction: column; gap: 12px; }
.payment-form__err { color: var(--danger); font-size: var(--fs-sm, .875rem); min-height: 1em; }

.payment-success { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.payment-success__icon { font-size: 2.4rem; }
.payment-success h3 { margin: 0; font-size: 1.3rem; }
.payment-success__facts {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-md, 10px); padding: 12px 16px;
}
.payment-success__facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-sm, .875rem); }
.payment-success__actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 6px; }

/* payment-sheet — each method's logo and brand colour (tenders.js brandKey) */
.payment-method { border-top: 3px solid var(--tender, transparent); }
.payment-method .tender-logo, .payment-method > svg { margin-bottom: 6px; }
.payment-method[style*="--tender"].is-selected { border-color: var(--tender); background: color-mix(in srgb, var(--tender) 8%, var(--surface, #fff)); }

/* ── "No Internet" full-screen block ─────────────────────────────────────── */
html.net-guard-lock { overflow: hidden !important; }
html.net-guard-lock body { overflow: hidden !important; pointer-events: none; }
.net-guard {
  position: fixed;
  inset: 0;
  z-index: var(--z-net-guard);
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  pointer-events: auto;
  background: color-mix(in srgb, var(--bg-body, #221F1C) 76%, rgba(0,0,0,.55));
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: net-guard-in 120ms ease-out;
}
@keyframes net-guard-in { from { opacity: 0; } to { opacity: 1; } }
.net-guard__card {
  max-width: 400px;
  width: 100%;
  text-align: center;
  padding: 32px 28px;
  border-radius: var(--radius-lg, 12px);
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-subtle, rgba(0,0,0,.08));
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
}
.net-guard__icon {
  display: inline-grid;
  place-items: center;
  width: 60px; height: 60px;
  margin-bottom: 14px;
  border-radius: 50%;
  color: var(--warning-fg, #7F5710);
  background: color-mix(in srgb, var(--warning-fg, #7F5710) 14%, transparent);
}
.net-guard__card h2 { margin: 0 0 8px; font-size: 1.15rem; }
.net-guard__card p { margin: 0 0 16px; color: var(--text-muted); line-height: 1.6; }
.net-guard__status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: 16px;
}
.net-guard__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--warning-fg, #7F5710);
  animation: net-guard-pulse 1.4s ease-in-out infinite;
}
@keyframes net-guard-pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
/* server not answering: the danger tone, so it is never mistaken for the shop's own Wi-Fi */
.net-guard[data-state="server"] .net-guard__icon {
  color: var(--danger-fg, #7F211C);
  background: color-mix(in srgb, var(--danger-fg, #7F211C) 14%, transparent);
}
.net-guard[data-state="server"] .net-guard__dot { background: var(--danger-fg, #7F211C); }
.net-guard__card p.net-guard__lead { color: var(--text); margin-bottom: 10px; }
.net-guard__card p.net-guard__note { font-size: var(--fs-sm, .875rem); margin-bottom: 14px; }
.net-guard__pending {
  text-align: left;
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid color-mix(in srgb, var(--warning-fg, #7F5710) 35%, transparent);
  border-left-width: 4px;
  background: var(--warning-bg, #F8EFD9);
  color: var(--warning-fg, #7F5710);
  font-size: var(--fs-sm, .875rem);
  line-height: 1.5;
}
.net-guard__pending strong { display: block; margin-bottom: 2px; }
@media (prefers-reduced-motion: reduce) {
  .net-guard, .net-guard__dot { animation: none; }
}

/* ---- install-app pill (see js/components/install-prompt.js) ---- */
.install-pill {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 8px 8px 8px 12px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong, var(--border));
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  animation: install-pill-in 180ms ease-out;
}
@keyframes install-pill-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.install-pill__mark { display: inline-flex; border-radius: 8px; overflow: hidden; }
.install-pill__text { font-size: 13px; color: var(--text); white-space: nowrap; }
.install-pill__x {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}
.install-pill__x:hover { color: var(--text); }
@media (max-width: 420px) {
  .install-pill__text { white-space: normal; }
}

/* --------------------------------------------------------------------------
   Command palette (js/components/command-palette.js)
   -------------------------------------------------------------------------- */
.cmdk-trigger {
  display: flex; align-items: center; gap: var(--sp-2);
  height: 38px; padding: 0 var(--sp-2) 0 var(--sp-3);
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-muted); font-size: var(--fs-sm); text-align: left;
}
.cmdk-trigger:hover { border-color: var(--border-strong); color: var(--text-secondary); }
.cmdk-trigger .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--bg-overlay);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh var(--sp-4) var(--sp-4);
}
.cmdk__box {
  width: min(560px, 100%); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--bg-surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); overflow: hidden;
}
.cmdk__input {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-bottom: 2px solid var(--terracotta); color: var(--text-muted);
}
.cmdk__input input {
  flex: 1; min-width: 0; height: 32px; border: 0; background: none; outline: none;
  font: inherit; font-size: var(--fs-lg); color: var(--text-strong);
}
.cmdk__list { list-style: none; margin: 0; padding: var(--sp-2); overflow-y: auto; }
.cmdk__list li {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md); font-size: var(--fs-md); color: var(--text-primary); cursor: pointer;
}
.cmdk__list li[aria-selected="true"] { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); }
.cmdk__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk__hint { font-size: var(--fs-xs); opacity: 0.7; }
.cmdk__none { color: var(--text-muted); justify-content: center; cursor: default; }

/* Password field: Show/Hide and Caps Lock note */
.pw-field { position: relative; display: block; }
.pw-field .input { width: 100%; padding-right: 58px; }
.pw-field__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  padding: 4px 8px; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-secondary);
}
.pw-field__toggle:hover { background: var(--bg-hover); color: var(--text-strong); }
.pw-field__caps { display: block; margin-top: 4px; font-size: var(--fs-xs); color: var(--warning-fg); }
.pw-field__caps[hidden] { display: none; }

/* Quieter, flatter defaults across every page */
.card { box-shadow: none; }
.btn--primary { box-shadow: none; font-weight: var(--fw-semibold); }
.table thead th { text-transform: none; letter-spacing: 0; font-size: var(--fs-sm); }
.badge { font-weight: 500; border-radius: var(--radius-sm); }
.segmented button[aria-pressed="true"] { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); box-shadow: none; }
.lang-switch button[aria-pressed="true"] { color: var(--text-strong); }

/* Payment method buttons, shared by the till and the admin (collecting বাকি) */
.xr-tenders { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.xr-tender { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.xr-tender svg { flex: none; color: var(--text-muted); }
.xr-tender[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text-strong); font-weight: 600; }
.xr-tender[aria-checked="true"] svg { color: var(--accent-text); }
.xr-tender:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.pay-later__quick { display: flex; flex-wrap: wrap; gap: 6px; }
.pay-later__quick button { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.pay-later__quick button:hover, .pay-later__quick button:focus-visible { border-color: var(--accent-text); color: var(--accent-text); outline: none; }

/* Collect বাকি */
.collect { display: flex; flex-direction: column; gap: var(--sp-3); }
.collect__owed { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px dashed var(--warning-fg); border-radius: var(--radius-md); background: var(--warning-bg); color: var(--warning-fg); font-size: var(--fs-sm); }
.collect__owed b { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.collect__amount { height: 48px; font-size: var(--fs-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.collect__quick { display: flex; gap: 6px; }
.collect__quick button { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.collect__quick button:hover { border-color: var(--accent-text); color: var(--accent-text); }
.collect__after { margin: 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.collect__after.is-bad { color: var(--danger-fg); }

/* --------------------------------------------------------------------------
   Combo picker: search, pick, or add a new entry (combo-pick.js)
   -------------------------------------------------------------------------- */
.cp-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; }
.cp { position: relative; }
.cp-btn { display: flex; align-items: center; text-align: left; cursor: pointer; }
.cp-btn__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-btn__label.is-none { color: var(--text-muted); }
.cp-btn[aria-expanded="true"] { border-color: var(--border-focus); box-shadow: var(--ring-focus); }
.cp-pop {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: max(100%, 300px);
  background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(34, 31, 28, .16));
  overflow: hidden;
}
.cp-pop[hidden] { display: none; }
.cp-search { display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-3); border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); }
.cp-search__in { flex: 1; height: 42px; border: 0; outline: none; background: none; font-size: var(--fs-md); color: var(--text-primary); }
.cp-exists {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  margin: var(--sp-2); padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  background: var(--success-50); border: 1px solid var(--success-500); border-radius: var(--radius-md);
  font-size: var(--fs-sm); color: var(--success-700);
}
.cp-exists[hidden] { display: none; }
.cp-exists__text { display: flex; align-items: center; gap: var(--sp-2); }
.cp-exists__text strong { color: var(--text-strong); }
.cp-tick {
  display: grid; place-content: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--success-600); color: #fff; transition: transform var(--dur-fast);
}
.cp-tick:hover { transform: scale(1.06); }
.cp-tick:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--success-100); }
.cp-list { max-height: 240px; overflow-y: auto; padding: var(--sp-1); margin: 0; list-style: none; }
.cp-opt { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 9px var(--sp-3); border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs-md); }
.cp-opt:hover, .cp-opt.is-active { background: var(--bg-hover); }
.cp-opt[aria-selected="true"] { font-weight: var(--fw-semibold); color: var(--text-strong); }
.cp-opt--none .cp-opt__label { color: var(--text-muted); }
.cp-opt mark { background: var(--warning-100); color: inherit; border-radius: 2px; padding: 0 1px; }
.cp-opt__tick { color: var(--accent); display: grid; }
.cp-empty { padding: var(--sp-3); font-size: var(--fs-sm); color: var(--text-muted); }
.cp-new { border-top: 1px solid var(--border-subtle); padding: var(--sp-1); }
.cp-new[hidden] { display: none; }
.cp-add {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: 10px var(--sp-3); border-radius: var(--radius-sm); text-align: left;
  color: var(--accent-text); font-size: var(--fs-md);
}
.cp-add:hover, .cp-add:focus-visible { background: var(--accent-soft); outline: none; }
.cp-form { display: grid; gap: var(--sp-2); padding: var(--sp-2) var(--sp-2) var(--sp-1); }
.cp-form__row { display: flex; justify-content: flex-end; gap: var(--sp-2); }

/* Payment logos on screen (tenders.js TENDER_BRANDS); receipts stay black and white.
   The tile stays white in dark mode too: the providers' logos are made for white. */
.tender-logo {
  --tl: 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px; flex: none;
  width: calc(var(--tl) * 2.3); height: calc(var(--tl) + 6px); padding: 2px 4px;
  background: #fff; border: 1px solid rgba(0, 0, 0, .1); border-radius: 6px;
}
.tender-logo img { display: block; max-width: 100%; max-height: 100%; min-width: 0; object-fit: contain; }
.tender-logo--upay img, .tender-logo--bangla_qr img { height: 100%; }
.tender-logo--pair { width: auto; }
.tender-logo--pair img { height: 72%; width: auto; }
.tender-logo--pair img + img { height: 82%; }
.tender-inline { display: inline-flex; align-items: center; gap: 6px; }
.tender-inline .tender-logo { border-radius: 4px; padding: 1px 3px; }
.pay-logos { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pay-logos .tender-logo { width: auto; min-width: calc(var(--tl) * 1.6); }
.pay-logos .tender-logo img { height: 100%; width: auto; }
.pay-logos .tender-logo--visa img { height: 70%; }
/* Pick a method with logo buttons (cashier and admin share these) */
.tender-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
.xr-tender { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: var(--fs-sm); cursor: pointer; text-align: left; }
.xr-tender svg { flex: none; color: var(--text-muted); }
.xr-tender[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text-strong); font-weight: 600; }
.xr-tender[aria-checked="true"] svg { color: var(--accent-text); }
.xr-tender:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.pay-split-label { display: inline-flex; align-items: center; gap: 6px; }
.pay-method[style*="--tender"]:hover, .xr-tender[style*="--tender"]:hover { border-color: var(--tender); }
.pay-method[style*="--tender"].is-active {
  border-color: var(--tender);
  background: color-mix(in srgb, var(--tender) 10%, var(--bg-surface));
  box-shadow: 0 0 0 1px var(--tender) inset;
  color: var(--text-strong);
}
.xr-tender[style*="--tender"][aria-checked="true"] {
  border-color: var(--tender);
  background: color-mix(in srgb, var(--tender) 10%, var(--bg-surface));
  color: var(--text-strong);
}

/* Payment requests (QR + wait), Paste SMS and TxID notes: the till and the payment sheet share these */
.pay-request { display: flex; gap: 14px; align-items: center; padding: 10px; border: 1px dashed var(--tender, var(--accent)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--tender, var(--accent)) 5%, var(--bg-surface)); }
.pay-request[hidden] { display: none; }
.pay-request__qr { flex: none; line-height: 0; background: #fff; padding: 4px; border-radius: 6px; }
.pay-request__text { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); }
.pay-request__text .btn { align-self: flex-start; }
.pay-request__sbx { color: var(--warning-fg, #8a5a00); }
.pay-ref__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pay-sms { display: grid; gap: 6px; margin-top: 6px; }
.pay-sms[hidden] { display: none; }
.pay-sms .btn { justify-self: start; }
.pay-ref__note { margin: 6px 0 0; min-height: 1em; font-size: var(--fs-sm); color: var(--text-secondary); }
.pay-ref__note[data-tone="bad"] { color: var(--danger-fg, #b42318); font-weight: 600; }
.pay-ref__note[data-tone="warn"] { color: var(--warning-fg, #8a5a00); font-weight: 600; }
.pay-ref__note[data-tone="good"] { color: var(--success-fg, #1f7a4d); }
.payment-gw { display: grid; gap: 10px; }
.payment-gw p { margin: 0; }
.payment-form[hidden] { display: none; }

/* install steps (js/components/install-prompt.js) */
.install-steps { display: grid; gap: var(--sp-2); padding-left: 1.2em; margin: 0 0 var(--sp-3); line-height: 1.55; }

/* ============================================ Piece scanner (ps-*) ====
 * One scan = one piece = one unit of stock. The scan slot is the one loud
 * thing; scanned pieces stack below it like a till roll, newest on top, each
 * with its running number, its branch and whether the server accepted it. */
.ps { display: grid; gap: var(--sp-2); }
.ps-bar { display: grid; grid-template-columns: minmax(150px, 0.4fr) minmax(0, 1fr); gap: var(--sp-3); align-items: end; }
.ps-bar:has(> .ps-scan:only-child) { grid-template-columns: minmax(0, 1fr); }
.ps-slot {
  position: relative; display: flex; align-items: center; gap: var(--sp-2);
  padding: 4px 4px 4px var(--sp-3);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg-surface); color: var(--text-muted);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.ps-slot:focus-within { border-color: var(--accent); box-shadow: var(--ring-focus); color: var(--accent-text); }
.ps-slot .input {
  flex: 1; min-width: 0; height: 36px; padding: 0; border: 0; background: transparent; box-shadow: none;
  font-family: var(--font-mono); font-size: var(--fs-md); letter-spacing: 0.04em; color: var(--text-strong);
}
.ps-slot .input:focus { outline: none; box-shadow: none; }
.ps-slot .input::placeholder { font-family: var(--font-sans, inherit); letter-spacing: 0; color: var(--text-muted); }
.ps-slot.is-shake { animation: ps-shake 260ms ease; border-color: var(--danger-500); }
@keyframes ps-shake { 25% { translate: -4px 0; } 50% { translate: 4px 0; } 75% { translate: -2px 0; } }
.ps-hint { min-height: 1.3em; font-size: var(--fs-xs); color: var(--text-muted); }
.ps-hint.is-ok { color: var(--success-fg); }
.ps-hint.is-bad { color: var(--danger-fg); }
.ps-hint.is-warn { color: var(--warning-fg); }

.ps-tally { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.ps-tally[hidden], .ps-list[hidden] { display: none; }
.ps-total { font-size: var(--fs-sm); color: var(--text-secondary); margin-right: var(--sp-1); }
.ps-total strong { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; color: var(--text-strong); margin-right: 2px; }
.ps-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-surface-2); font-size: var(--fs-xs); color: var(--text-secondary);
}
.ps-chip b { font-variant-numeric: tabular-nums; color: var(--text-strong); }
.ps-chip.is-on { border-color: var(--accent-soft-border); background: var(--accent-soft); color: var(--accent-text); }
.ps-badcount { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--danger-fg); }

.ps-list {
  list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface);
}
.ps-row {
  display: grid; grid-template-columns: 2.6em minmax(0, 1fr) auto minmax(0, auto) 32px; align-items: center; gap: var(--sp-2);
  padding: 5px var(--sp-2) 5px var(--sp-3); border-bottom: 1px dashed var(--border-subtle); font-size: var(--fs-sm);
}
.ps-row:last-child { border-bottom: 0; }
.ps-row.is-fresh { animation: ps-in 220ms ease-out; }
@keyframes ps-in { from { background: var(--accent-soft); translate: 0 -4px; opacity: 0.4; } }
.ps-n { font-size: var(--fs-2xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ps-code { font-family: var(--font-mono); font-size: var(--fs-sm); letter-spacing: 0.04em; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-br { font-size: var(--fs-xs); color: var(--text-secondary); white-space: nowrap; }
.ps-state { display: inline-flex; align-items: center; gap: 4px; justify-self: end; font-size: var(--fs-xs); color: var(--success-fg); min-width: 0; }
.ps-state span:not(.spinner) { overflow: hidden; text-overflow: ellipsis; }
.ps-state .spinner { width: 12px; height: 12px; border-width: 2px; }
.ps-row.is-bad { background: var(--danger-bg); }
.ps-row.is-bad .ps-state { color: var(--danger-fg); white-space: normal; grid-column: 2 / -2; grid-row: 2; justify-self: start; }
.ps-row.is-bad .js-ps-rm { grid-row: 1; grid-column: -2 / -1; }
.ps-row.is-bad .ps-code { text-decoration: line-through; text-decoration-color: var(--danger-500); }
.ps--compact .ps-list { max-height: 200px; }
@media (max-width: 640px) {
  .ps-bar { grid-template-columns: minmax(0, 1fr); }
  .ps-row { grid-template-columns: 2.2em minmax(0, 1fr) 32px; }
  .ps-row .ps-br { display: none; }
  .ps-row .ps-state { grid-column: 2 / 3; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  .ps-row.is-fresh, .ps-slot.is-shake { animation: none; }
}

/* Piece chips: the pieces of a line sold by the piece, each chosen on its own
   (Exchange / Return, purchase returns) */
.xr-pieces { display: flex; flex-wrap: wrap; gap: 4px; max-width: 420px; }
.xr-piece {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; min-height: 28px;
  border: 1px dashed var(--border-strong); border-radius: 999px; background: var(--bg-surface); color: var(--text-secondary); cursor: pointer;
}
.xr-piece code { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.03em; color: var(--text-strong); }
.xr-piece small { font-size: var(--fs-2xs); color: var(--text-muted); }
.xr-piece:hover:not(:disabled) { border-color: var(--accent-text); }
.xr-piece.is-on { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.xr-piece:disabled { opacity: 0.55; cursor: not-allowed; text-decoration: line-through; }
.xr-piece button { display: grid; place-content: center; width: 18px; height: 18px; border-radius: 50%; color: var(--text-muted); }
.xr-piece button:hover { background: var(--danger-bg); color: var(--danger-fg); }
.pr-scan > td { background: var(--bg-surface-2); padding-top: var(--sp-2); padding-bottom: var(--sp-3); }
/* the barcodes of the pieces sold on a line (sale details, transactions) */
.sn-list { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.sn-list code { font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.03em; padding: 0 6px; border-radius: 999px; background: var(--bg-inset); color: var(--text-secondary); }
/* a number box's example (placeholder 0.00) steps aside the moment it is clicked */
input[type="number"]:focus::placeholder, input[inputmode="decimal"]:focus::placeholder, input[inputmode="numeric"]:focus::placeholder { color: transparent; }
/* a line's warranty or guarantee (cart, sale details, transactions) */
.wr-tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-2xs); font-weight: var(--fw-semibold); color: var(--success-fg); }
.wr-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============================================ Warranty (wb-, wm-, wc-, wp-) ====
 * A sold product's cover, read at a glance when the customer comes back: a pill
 * with the days left (green, amber in the last 30 days, red once ended) and a
 * bar of how much of the cover has gone. */
.wb { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap; }
.wb::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.wb--active { background: var(--success-bg); color: var(--success-fg); }
.wb--ending { background: var(--warning-bg); color: var(--warning-fg); }
.wb--ended { background: var(--danger-bg); color: var(--danger-fg); }
.wm { height: 6px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; }
.wm span { display: block; height: 100%; border-radius: inherit; background: var(--success-500); }
.wm--ending span { background: var(--warning-500); }
.wm--ended span { background: var(--danger-500); }

.wc-list { display: grid; gap: var(--sp-3); }
.wc { display: grid; gap: var(--sp-2); padding: var(--sp-4); border: 1px solid var(--border); border-left: 4px solid var(--success-500); border-radius: var(--radius-md); background: var(--bg-surface); }
.wc--ending { border-left-color: var(--warning-500); }
.wc--ended { border-left-color: var(--danger-500); }
.wc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.wc-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--sp-2); min-width: 0; }
.wc-title strong { font-size: var(--fs-lg); color: var(--text-strong); }
.wc-cover { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-secondary); padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; }
.wc-dates { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--text-secondary); }
.wc-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--sp-2) var(--sp-4); margin: var(--sp-1) 0 0; }
.wc-facts dt { font-size: var(--fs-2xs); color: var(--text-muted); }
.wc-facts dd { margin: 0; font-size: var(--fs-sm); color: var(--text-primary); }
.wc-facts__wide { grid-column: 1 / -1; }
.wc-note { font-size: var(--fs-xs); color: var(--text-muted); }
.wc-warn { font-size: var(--fs-xs); color: var(--danger-fg); }
.wc-claims { display: grid; gap: var(--sp-2); padding-top: var(--sp-2); border-top: 1px dashed var(--border-subtle); justify-items: start; }
.wc-claims__head { display: flex; gap: var(--sp-2); align-items: baseline; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.wc-claims__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); width: 100%; }
.wc-claim { padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); background: var(--bg-surface-2); display: grid; gap: 4px; }
.wc-claim.is-open { background: var(--warning-bg); }
.wc-claim__top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.wc-claim__status { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-strong); }
.wc-claim__problem { margin: 0; font-size: var(--fs-sm); }
.wc-claim__problem code { font-family: var(--font-mono); font-size: var(--fs-2xs); }
.wc-claim__steps { margin: 0; padding-left: var(--sp-4); font-size: var(--fs-xs); }
.wc-claim__move { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(120px, 1fr) auto; gap: var(--sp-2); margin-top: 2px; }
.wc-claim__move .select, .wc-claim__move .input { height: 32px; font-size: var(--fs-sm); }
.wc-form { display: grid; gap: var(--sp-2); width: 100%; max-width: 560px; }
.wc-form[hidden] { display: none; }

.wp { display: grid; gap: var(--sp-3); }
.wp-find {
  display: flex; align-items: center; gap: var(--sp-2); padding: 4px 4px 4px var(--sp-3);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-muted);
}
.wp-find:focus-within { border-color: var(--accent); box-shadow: var(--ring-focus); color: var(--accent-text); }
.wp-find .input { flex: 1; border: 0; box-shadow: none; background: transparent; height: 38px; padding: 0; font-size: var(--fs-md); }
.wp-find .input:focus { outline: none; box-shadow: none; }
.wp-filter { justify-self: start; flex-wrap: wrap; }
.wp-more { display: flex; justify-content: center; }
.wk { display: grid; gap: var(--sp-3); }
.wk .wc-list { max-height: 60vh; overflow-y: auto; padding-right: 2px; }
.xr-wr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; }
.pos-stockstop__wr { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-3); font-size: var(--fs-sm); }
@media (max-width: 640px) {
  .wc-claim__move { grid-template-columns: 1fr; }
  .wc-dates { flex-direction: column; gap: 2px; }
}

/* A box with its picture inside (form field `icon`): the job of the box shows
   before anything is typed. The picture sits on the left, the text after it. */
.ctl-ic { position: relative; }
.ctl-ic__i { position: absolute; left: 12px; top: 50%; translate: 0 -50%; z-index: 1; display: grid; place-content: center; color: var(--text-muted); pointer-events: none; transition: color var(--dur-fast); }
.ctl-ic--top .ctl-ic__i { top: 12px; translate: 0 0; }
.ctl-ic:focus-within .ctl-ic__i { color: var(--accent-text); }
.ctl-ic > .input, .ctl-ic > .select, .ctl-ic > .textarea, .ctl-ic > .input-group, .ctl-ic .cp-btn { padding-left: 38px; }
.input-group__addon--ic { display: inline-flex; align-items: center; gap: 6px; }
.input-group__addon--ic svg { width: 17px; height: 17px; color: var(--text-secondary); }
.input-group:focus-within .input-group__addon--ic svg { color: var(--accent-text); }
.ps-branch .ctl-ic { display: block; }

/* ============================================ Camera scanner (cam-*) ====
 * The camera picture with a frame to hold the barcode in. A scan flashes the
 * frame green; the window says plainly what to do when the camera cannot open. */
.cam { display: grid; gap: var(--sp-3); }
.cam__view { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius-md); overflow: hidden; background: #000; }
.cam__video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam__frame { position: absolute; inset: 22% 10%; border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28); pointer-events: none; transition: border-color 160ms; }
.cam__line { position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--terracotta, #C64F2C); opacity: 0.9; animation: cam-line 1.8s ease-in-out infinite alternate; }
@keyframes cam-line { from { top: 18%; } to { top: 82%; } }
.cam__view.is-hit .cam__frame { border-color: #6ED38A; }
.cam__status { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--sp-2); padding: var(--sp-4); background: rgba(0, 0, 0, 0.72); color: #F1EBE1; text-align: center; font-size: var(--fs-sm); }
.cam__status[hidden] { display: none; }
.cam__status > span:not(.spinner) { opacity: 0.9; }
.cam__problem { display: grid; justify-items: center; gap: 6px; max-width: 34ch; line-height: 1.45; }
.cam__problem b { font-size: var(--fs-md); }
.cam__tools { display: flex; justify-content: center; gap: var(--sp-2); }
.cam__tools .btn.is-on { background: var(--warning-bg); color: var(--warning-fg); }
.cam__hint { margin: 0; text-align: center; font-size: var(--fs-xs); color: var(--text-muted); }
.cam__got { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 160px; overflow-y: auto; }
.cam__got li { display: grid; grid-template-columns: 2em minmax(0, 1fr) 18px; align-items: center; gap: var(--sp-2); padding: 4px var(--sp-2); border-radius: var(--radius-sm); background: var(--bg-surface-2); font-size: var(--fs-sm); color: var(--success-fg); }
.cam__got span { font-size: var(--fs-2xs); color: var(--text-muted); }
.cam__got code { font-family: var(--font-mono); color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; }
.cam-btn { flex: none; }
@media (prefers-reduced-motion: reduce) { .cam__line { animation: none; } }

/* ============================================ Phone link (pl-*) ====
 * The window with the QR code and three steps, and the pill that stays at the
 * bottom of the screen while a phone is the scanner. */
.pl { display: grid; gap: var(--sp-4); }
.pl-qr { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4); }
.pl-qr__code { padding: 10px; background: #fff; border-radius: var(--radius-md); border: 1px solid var(--border); line-height: 0; }
.pl-qr__side { display: grid; gap: var(--sp-2); justify-items: start; }
.pl-qr__time { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.pl-qr__time.is-late { color: var(--danger-fg); }
.pl-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); counter-reset: s; }
.pl-steps li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: var(--sp-3); align-items: start; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-secondary); }
.pl-steps li > svg { box-sizing: content-box; padding: 7px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); }
.pl-steps b { display: block; color: var(--text-strong); }
.pl-safe { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-xs); color: var(--success-fg); }
.pl-on { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-md); background: var(--success-bg); }
.pl-on__ic { color: var(--success-fg); }
.pl-on b { color: var(--text-strong); }
.pl-on p { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.pl-phones { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pl-phones li { display: flex; align-items: center; gap: var(--sp-2); padding: 6px var(--sp-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: var(--fs-sm); }
.pl-phones li span { flex: 1; }
.pl-recent ol { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.pl-recent li { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--bg-surface-2); font-size: var(--fs-xs); color: var(--success-fg); }
.pl-recent code { font-family: var(--font-mono); color: var(--text-strong); }
.pl-more summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-secondary); }
.pl-more[open] { display: grid; gap: var(--sp-2); }
.pl-pill {
  position: fixed; left: 16px; bottom: 48px; z-index: 900; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--bg-ink-panel, #221F1C); color: #F1EBE1;
  box-shadow: 0 6px 18px rgba(34, 31, 28, 0.28); font-size: var(--fs-sm);
}
.pl-pill.is-on svg:first-child { color: #6ED38A; }
.pl-pill__open { color: inherit; font: inherit; padding: 2px 4px; }
.pl-pill__open:hover { text-decoration: underline; }
.pl-pill__x { display: grid; place-content: center; width: 24px; height: 24px; border-radius: 50%; color: #C9BFB1; }
.pl-pill__x:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
@media print { .pl-pill { display: none; } }
.topbar__icon-btn .dot.dot--on { background: #3FA672; }
.phone-on { display: inline-block; width: 8px; height: 8px; margin-left: 2px; border-radius: 50%; background: #3FA672; box-shadow: 0 0 0 3px rgba(63, 166, 114, 0.2); }
.phone-on[hidden] { display: none; }
.ps-slot .ps-tool { flex: none; color: var(--text-muted); }
.ps-slot .ps-tool:hover { color: var(--accent-text); }
/* a camera button inside a box with a picture (product barcode): it sits at the right end */
.ctl-ic .ctl-ic__cam { position: absolute; right: 4px; top: 50%; translate: 0 -50%; z-index: 1; }
.ctl-ic:has(.ctl-ic__cam) > .input { padding-right: 40px; }
.wp-find .cam-btn, .js-inv + .cam-btn { flex: none; }
.xr-cam { margin-top: var(--sp-2); }
.pos-phone-btn { position: relative; }
.pos-phone-btn .phone-on { position: absolute; top: 4px; right: 4px; margin: 0; width: 7px; height: 7px; }

/* ---- App permissions (components/app-permissions.js) ---- */
.perm { display: flex; flex-direction: column; gap: var(--sp-3); }
.perm__list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.perm__row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.perm__ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent-text); }
.perm__txt { display: flex; flex-direction: column; min-width: 0; }
.perm__txt small { font-size: var(--fs-xs); color: var(--text-muted); }
.perm__all { align-self: flex-start; }
.perm__steps { margin: 0; padding-left: 1.2em; color: var(--text-secondary); display: grid; gap: 4px; }
@media (max-width: 520px) { .perm__row { grid-template-columns: auto 1fr; } .perm__row .badge, .perm__row .btn { grid-column: 2; justify-self: start; } }

/* Notifications window: what this device announces as it happens (live-alerts.js) */
.live-prefs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); margin: 0; padding: 0 0 var(--sp-4); border: 0; border-bottom: 1px solid var(--border); }
.live-prefs legend { float: left; margin-right: var(--sp-2); font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-secondary); }
.live-pref { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; font-size: var(--fs-sm); cursor: pointer; }
.live-pref input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Signed-in devices (devices.js) */
.devices__lead { margin: 0 0 var(--sp-4); max-width: 60ch; }
.devices { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.devices__row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.devices__ic { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--bg-inset, var(--gray-100)); color: var(--text-secondary); }
.devices__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.devices__txt b { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: var(--fw-semibold); }
.devices__txt small { color: var(--text-muted); font-size: var(--fs-xs); overflow-wrap: anywhere; }

/* piece scanner: one tab per branch with its count (piece-scanner.js) */
.ps-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.ps-tab { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; cursor: pointer; font: inherit; font-size: var(--fs-sm);
  color: var(--text-secondary); background: var(--bg-surface); border: 1.5px solid var(--border); border-radius: 999px; }
.ps-tab:hover { border-color: var(--border-strong); }
.ps-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ps-tab[aria-selected="true"] { color: var(--bg-surface); background: var(--text-strong); border-color: var(--text-strong); }
.ps-tab b { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--bg-inset); color: var(--text-strong); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; text-align: center; }
.ps-tab[aria-selected="true"] b { background: var(--accent); color: var(--text-on-brand); }
.ps-bar:has(.ps-tabs) { grid-template-columns: minmax(0, 1fr); }


/* ----------------------------------------- two-step sign-in (components/two-step.js) */
.ts-lead { margin: 0 0 12px; font-size: var(--fs-sm); color: var(--text-secondary); line-height: 1.55; }
.ts-err { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--danger-fg); }
.ts-link { display: block; margin: 12px auto 0; padding: 0; border: 0; background: none; font: inherit; font-size: var(--fs-sm); color: var(--accent-text); cursor: pointer; }
.ts-link:hover { text-decoration: underline; }
.ts-code { text-align: center; }
.ts-code__ic { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); }
.ts-code__in {
  font-size: 1.6rem; font-weight: 600; letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums;
  height: 56px; margin-bottom: 12px;
}
.ts-code .btn--block { width: 100%; }
.ts-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 18px; padding: 0; counter-reset: none; }
.ts-steps li { flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-md); background: var(--bg-hover); font-size: var(--fs-xs); color: var(--text-muted); }
.ts-steps li b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--bg-surface); border: 1px solid var(--border-strong); font-size: 11px; flex: none; }
.ts-steps li.is-now { background: var(--accent-soft); color: var(--text-strong); font-weight: 600; }
.ts-steps li.is-now b { background: var(--accent); border-color: var(--accent); color: var(--text-on-brand); }
.ts-steps li.is-done b { background: var(--success-solid); border-color: var(--success-solid); color: #fff; }
.ts-why { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg-hover); color: var(--text-secondary); font-size: var(--fs-sm); line-height: 1.55; }
.ts-why svg { flex: none; margin-top: 2px; color: var(--accent-text); }
.ts-why p { margin: 0; }
.ts-apps { margin-bottom: 14px; }
.ts-apps__links { display: flex; flex-wrap: wrap; gap: 8px; }
.ts-store { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); font-size: var(--fs-sm); font-weight: 600; color: var(--text-strong); text-decoration: none; }
.ts-store:hover { background: var(--bg-hover); }
.ts-form .field { margin-bottom: 12px; }
.ts-scan { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: start; }
.ts-qr { padding: 10px; border-radius: var(--radius-lg); background: #fff; border: 1px solid var(--border); line-height: 0; }
.ts-qr svg { display: block; width: 184px; height: 184px; }
.ts-key { margin: 0 0 14px; font-size: var(--fs-sm); }
.ts-key summary { cursor: pointer; color: var(--accent-text); font-weight: 600; }
.ts-key__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ts-key code { padding: 6px 10px; border-radius: var(--radius-sm, 6px); background: var(--bg-hover); font-size: 0.95rem; letter-spacing: 0.05em; word-break: break-all; }
.ts-done { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--success-bg); color: var(--success-fg); }
.ts-done p { margin: 0; color: var(--text-primary); font-size: var(--fs-sm); }
.ts-done svg { flex: none; margin-top: 1px; }
.ts-backup { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; list-style: none; margin: 0 0 12px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); font-family: var(--font-mono, ui-monospace, monospace); font-size: 1rem; letter-spacing: 0.04em; }
.ts-backup__acts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ts-saved { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: var(--fs-sm); font-weight: 600; }
.ts-manage { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ts-link:focus-visible, .ts-store:focus-visible, .ts-key summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 560px) {
  .ts-scan { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .ts-steps li span { display: none; }
  .ts-steps li { justify-content: center; }
}
