/* =====================================================
   BARUCH FLOWS
   Task-oriented UI for recording things: sales, purchases,
   returns, transfers, bulk edits. Built on design-system.css tokens.
   Mobile-first: sticky action bar, bottom sheets, big tap targets.
   ===================================================== */

:root {
  /* Mode colours: sales lean on the brand purple, purchases on teal */
  --mode-sale: var(--primary);
  --mode-sale-soft: var(--primary-50);
  --mode-buy: hsl(180, 70%, 32%);
  --mode-buy-soft: hsl(180, 60%, 94%);
  --mode-neutral: hsl(220, 60%, 45%);
  --mode-neutral-soft: hsl(220, 60%, 95%);
  --mode: var(--mode-sale);
  --mode-soft: var(--mode-sale-soft);
  --flow-bar-height: 76px;
  --bottom-nav-height: 64px;
}

/* -----------------------------------------------------
   Flow shell
   ----------------------------------------------------- */
.flow {
  max-width: 880px;
  margin: 0 auto;
  padding-bottom: calc(var(--flow-bar-height) + var(--space-6));
  animation: fadeIn 250ms ease-out;
}

.flow--buy {
  --mode: var(--mode-buy);
  --mode-soft: var(--mode-buy-soft);
}

.flow--neutral {
  --mode: var(--mode-neutral);
  --mode-soft: var(--mode-neutral-soft);
}

.flow__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.flow__back {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.flow__back:hover {
  background: var(--surface-hover);
}

.flow__back:active {
  transform: scale(0.94);
}

.flow__titles {
  min-width: 0;
  flex: 1;
}

.flow__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mode);
}

.flow__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: var(--line-tight);
}

.flow__subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-top: 2px;
}

/* -----------------------------------------------------
   Stepper
   ----------------------------------------------------- */
.stepper {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  scrollbar-width: none;
}

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

.stepper__step {
  flex: 1;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: default;
  font-family: inherit;
}

.stepper__step::before {
  content: '';
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--border-light);
  transition: background var(--transition-base);
}

.stepper__step--done {
  color: var(--text-secondary);
  cursor: pointer;
}

.stepper__step--done::before {
  background: color-mix(in srgb, var(--mode) 45%, transparent);
}

.stepper__step--active {
  color: var(--mode);
  font-weight: var(--font-semibold);
}

.stepper__step--active::before {
  background: var(--mode);
}

/* -----------------------------------------------------
   Panels & sections
   ----------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.panel--flush {
  padding: 0;
  overflow: hidden;
}

.panel__title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.panel__hint {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.field-row .form-group {
  margin-bottom: 0;
}

/* -----------------------------------------------------
   Search
   ----------------------------------------------------- */
.search-field {
  position: relative;
  margin-bottom: var(--space-3);
}

.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-4) 0 44px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-field input:focus {
  outline: none;
  border-color: var(--mode, var(--primary));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode, var(--primary)) 18%, transparent);
}

/* -----------------------------------------------------
   Product picker
   ----------------------------------------------------- */
.pick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-2);
}

.pick-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-height: 64px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-light);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: border-color var(--transition-fast), background var(--transition-fast),
    transform var(--transition-fast), box-shadow var(--transition-fast);
}

.pick-item:hover {
  border-color: color-mix(in srgb, var(--mode, var(--primary)) 40%, var(--border));
  box-shadow: var(--shadow-sm);
}

.pick-item:active {
  transform: scale(0.98);
}

.pick-item[aria-pressed='true'] {
  border-color: var(--mode, var(--primary));
  background: var(--mode-soft, var(--primary-50));
}

.pick-item:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.pick-item__avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--mode-soft, var(--primary-50));
  color: var(--mode, var(--primary));
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.pick-item[aria-pressed='true'] .pick-item__avatar {
  background: var(--mode, var(--primary));
  color: var(--text-inverse);
}

.pick-item__body {
  min-width: 0;
  flex: 1;
}

.pick-item__name {
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick-item__meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: 2px;
}

.pick-item__meta .low {
  color: var(--warning-dark);
  font-weight: var(--font-semibold);
}

.pick-item__meta .out {
  color: var(--error);
  font-weight: var(--font-semibold);
}

/* -----------------------------------------------------
   Cart lines
   ----------------------------------------------------- */
.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
  animation: fadeIn 200ms ease-out;
}

.cart-line:last-child {
  border-bottom: none;
}

.cart-line__name {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.cart-line__sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.cart-line__remove {
  align-self: start;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cart-line__remove:hover {
  background: var(--error-light);
  color: var(--error);
}

.cart-line__controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(140px, auto) 1fr auto;
  gap: var(--space-3);
  align-items: end;
}

.cart-line__total {
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  color: var(--text-primary);
  text-align: right;
  white-space: nowrap;
  padding-bottom: 10px;
}

.cart-line__warn {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  color: var(--warning-dark);
  background: var(--warning-light);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
}

.mini-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* -----------------------------------------------------
   Quantity stepper
   ----------------------------------------------------- */
.qty-stepper {
  display: inline-flex;
  align-items: stretch;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface);
}

.qty-stepper button {
  width: 44px;
  border: none;
  background: var(--surface-subtle);
  color: var(--mode, var(--primary));
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast);
}

.qty-stepper button:hover {
  background: var(--mode-soft, var(--primary-50));
}

.qty-stepper input {
  width: 64px;
  border: none;
  text-align: center;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
  -moz-appearance: textfield;
}

.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-stepper input:focus {
  outline: none;
}

.money-input {
  position: relative;
}

.money-input input {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
}

.money-input input:focus {
  outline: none;
  border-color: var(--mode, var(--primary));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode, var(--primary)) 18%, transparent);
}

/* -----------------------------------------------------
   Segmented control
   ----------------------------------------------------- */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-active);
  border-radius: var(--radius-lg);
}

.segmented button {
  flex: 1;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--mode, var(--primary));
  font-weight: var(--font-semibold);
  box-shadow: var(--shadow-sm);
}

/* -----------------------------------------------------
   Hero amount
   ----------------------------------------------------- */
.amount-hero {
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  background: linear-gradient(135deg, var(--mode) 0%, color-mix(in srgb, var(--mode) 70%, black) 100%);
  color: var(--text-inverse);
  margin-bottom: var(--space-4);
  position: relative;
  overflow: hidden;
}

.amount-hero::after {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.amount-hero__label {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.amount-hero__value {
  font-size: var(--text-4xl);
  font-weight: var(--font-extrabold);
  line-height: 1.1;
  margin-top: var(--space-1);
  font-variant-numeric: tabular-nums;
}

.amount-hero__sub {
  font-size: var(--text-sm);
  opacity: 0.9;
  margin-top: var(--space-2);
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* -----------------------------------------------------
   Key-value summary
   ----------------------------------------------------- */
.kv {
  display: flex;
  flex-direction: column;
}

.kv__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px dashed var(--border-light);
  font-size: var(--text-sm);
}

.kv__row:last-child {
  border-bottom: none;
}

.kv__key {
  color: var(--text-secondary);
}

.kv__val {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kv__row--total .kv__key,
.kv__row--total .kv__val {
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.kv__row--debt .kv__val {
  color: var(--warning-dark);
}

/* -----------------------------------------------------
   Pickable chip (client, branch)
   ----------------------------------------------------- */
.picker-button {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.picker-button:hover {
  border-color: var(--mode, var(--primary));
}

.picker-button--error {
  border-color: var(--error);
  background: var(--error-light);
}

.picker-button__icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--mode-soft, var(--primary-50));
  color: var(--mode, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
}

.picker-button__text {
  flex: 1;
  min-width: 0;
}

.picker-button__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.picker-button__value {
  font-weight: var(--font-semibold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-button__value--empty {
  color: var(--text-muted);
  font-weight: var(--font-normal);
}

/* -----------------------------------------------------
   Sticky action bar
   ----------------------------------------------------- */
.flow-bar {
  position: fixed;
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.06);
  animation: slideInUp 250ms ease-out;
}

.flow-bar__inner {
  max-width: 880px;
  margin: 0 auto;
  min-height: var(--flow-bar-height);
  padding: var(--space-3) var(--space-8);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.flow-bar__summary {
  flex: 1;
  min-width: 0;
}

.flow-bar__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.flow-bar__value {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow-bar .btn {
  min-height: 48px;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
  border-radius: var(--radius-full);
}

.flow-bar .btn-mode {
  background: var(--mode);
  border-color: var(--mode);
  color: var(--text-inverse);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--mode) 35%, transparent);
}

.flow-bar .btn-mode:hover:not(:disabled) {
  background: color-mix(in srgb, var(--mode) 85%, black);
}

.flow-bar .btn-mode:disabled {
  opacity: 0.55;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-mode {
  background: var(--mode, var(--primary));
  border-color: var(--mode, var(--primary));
  color: var(--text-inverse);
}

/* Hide the FAB while a flow is on screen */
body:has(.flow-bar) .fab,
body:has(.flow-bar) .fab__menu {
  display: none !important;
}

@media (max-width: 768px) {
  .flow-bar {
    left: 0;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0));
  }

  .flow-bar__inner {
    padding: var(--space-3) var(--space-4);
  }

  .flow {
    padding-bottom: calc(var(--flow-bar-height) + var(--space-4));
  }

  .flow__title {
    font-size: var(--text-xl);
  }

  .panel {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
  }

  .cart-line {
    padding: var(--space-4);
  }

  .cart-line__controls {
    grid-template-columns: auto 1fr;
  }

  .cart-line__total {
    grid-column: 1 / -1;
    text-align: left;
    padding-bottom: 0;
  }

  .amount-hero__value {
    font-size: var(--text-3xl);
  }

  .pick-list {
    grid-template-columns: 1fr;
  }
}

/* -----------------------------------------------------
   Bottom sheet / dialog
   ----------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 180ms ease-out;
}

.sheet-backdrop--closing {
  animation: fadeOut 180ms ease-in forwards;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  animation: scaleIn 200ms ease-out;
  overflow: hidden;
}

.sheet--wide {
  max-width: 720px;
}

.sheet__grab {
  display: none;
}

.sheet__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-3);
}

.sheet__titles {
  flex: 1;
  min-width: 0;
}

.sheet__title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.sheet__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.sheet__close {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--surface-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sheet__body {
  padding: 0 var(--space-5) var(--space-5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet__footer {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  padding: var(--space-3) var(--space-5) var(--space-5);
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}

.sheet__footer .btn {
  min-height: 44px;
}

@media (max-width: 640px) {
  .sheet-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .sheet,
  .sheet--wide {
    max-width: none;
    max-height: 92vh;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    animation: slideInUp 260ms cubic-bezier(0.2, 0.9, 0.3, 1);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .sheet__grab {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: var(--radius-full);
    background: var(--border);
    margin: var(--space-2) auto 0;
  }

  .sheet__footer {
    flex-direction: column-reverse;
  }

  .sheet__footer .btn {
    width: 100%;
  }
}

/* Selectable list inside sheets (clients, branches, accounts) */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 calc(var(--space-2) * -1);
}

.choice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-lg);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
  width: 100%;
}

.choice:hover {
  background: var(--surface-hover);
}

.choice[aria-selected='true'] {
  background: var(--mode-soft, var(--primary-50));
}

.choice__icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--surface-active);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
}

.choice[aria-selected='true'] .choice__icon {
  background: var(--mode, var(--primary));
  color: var(--text-inverse);
}

.choice__text {
  flex: 1;
  min-width: 0;
}

.choice__label {
  font-weight: var(--font-medium);
}

.choice__desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* -----------------------------------------------------
   Empty, info and success states
   ----------------------------------------------------- */
.flow-empty {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--text-secondary);
}

.flow-empty__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-3);
  border-radius: var(--radius-full);
  background: var(--mode-soft, var(--primary-50));
  color: var(--mode, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-empty__title {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.callout {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  background: var(--info-light);
  color: var(--info-dark);
  margin-bottom: var(--space-4);
}

.callout--warn {
  background: var(--warning-light);
  color: var(--warning-dark);
}

.callout--error {
  background: var(--error-light);
  color: var(--error-dark);
}

.callout--success {
  background: var(--success-light);
  color: var(--success-dark);
}

.callout svg {
  flex: none;
  margin-top: 2px;
}

.success-state {
  text-align: center;
  padding: var(--space-10) var(--space-4) var(--space-6);
}

.success-state__check {
  width: 88px;
  height: 88px;
  margin: 0 auto var(--space-5);
  border-radius: 50%;
  background: var(--success-light);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: popIn 450ms cubic-bezier(0.2, 1.4, 0.4, 1);
}

.success-state__check svg {
  stroke: var(--success);
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: drawCheck 450ms 250ms ease-out forwards;
}

.success-state__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.success-state__text {
  color: var(--text-secondary);
  margin: var(--space-2) auto var(--space-6);
  max-width: 420px;
}

.success-state__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

@keyframes popIn {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes drawCheck {
  to {
    stroke-dashoffset: 0;
  }
}

/* -----------------------------------------------------
   Action tiles (menu of things you can do)
   ----------------------------------------------------- */
.action-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}

.action-tile {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.action-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-100);
}

.action-tile__icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-50);
  color: var(--primary);
}

.action-tile__icon--buy {
  background: var(--mode-buy-soft);
  color: var(--mode-buy);
}

.action-tile__icon--warn {
  background: var(--warning-light);
  color: var(--warning-dark);
}

.action-tile__icon--info {
  background: var(--info-light);
  color: var(--info-dark);
}

.action-tile__title {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.action-tile__desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

/* -----------------------------------------------------
   Editable grid (bulk edits, multi-add)
   ----------------------------------------------------- */
.edit-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.edit-grid th {
  position: sticky;
  top: 0;
  background: var(--surface-subtle);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-light);
  z-index: 1;
}

.edit-grid td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.edit-grid tr:last-child td {
  border-bottom: none;
}

.edit-grid input,
.edit-grid select {
  width: 100%;
  min-width: 90px;
  height: 40px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.edit-grid input:focus,
.edit-grid select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.edit-grid tr.is-dirty td {
  background: var(--primary-50);
}

.edit-grid tr.is-invalid td {
  background: var(--error-light);
}

.edit-grid__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.edit-grid-wrap {
  overflow-x: auto;
  max-height: 65vh;
}

/* Responsive: grid rows become cards on phones */
@media (max-width: 640px) {
  .edit-grid--cards thead {
    display: none;
  }

  .edit-grid--cards,
  .edit-grid--cards tbody,
  .edit-grid--cards tr,
  .edit-grid--cards td {
    display: block;
    width: 100%;
  }

  .edit-grid--cards tr {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-light);
  }

  .edit-grid--cards td {
    border: none;
    padding: var(--space-1) 0;
  }

  .edit-grid--cards td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-bottom: 2px;
  }

  .edit-grid-wrap {
    max-height: none;
  }
}

/* Small pill for status */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  background: var(--surface-active);
  color: var(--text-secondary);
}

.pill--sale {
  background: var(--mode-sale-soft);
  color: var(--mode-sale);
}

.pill--buy {
  background: var(--mode-buy-soft);
  color: var(--mode-buy);
}

.pill--warn {
  background: var(--warning-light);
  color: var(--warning-dark);
}

.pill--error {
  background: var(--error-light);
  color: var(--error-dark);
}

.pill--success {
  background: var(--success-light);
  color: var(--success-dark);
}

.picker-button__label,
.picker-button__value,
.choice__label,
.choice__desc,
.pick-item__name,
.pick-item__meta {
  display: block;
}

.pick-item__meta {
  display: flex;
}

.edit-grid input[data-key='name'],
.edit-grid input[data-k='name'] {
  min-width: 200px;
}

@media (max-width: 640px) {
  .edit-grid input[data-key='name'],
  .edit-grid input[data-k='name'] {
    min-width: 0;
  }
}


/* -----------------------------------------------------
   Staff list (settings/staff.js)
   ----------------------------------------------------- */
.staff-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.staff-item--disabled {
  opacity: 0.6;
}

.staff-item__avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-50);
  color: var(--primary);
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.staff-item__info {
  flex: 1;
  min-width: 0;
}

.staff-item__name {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.staff-item__details {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-item__badge {
  display: inline-flex;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--font-semibold);
  background: var(--surface-active);
  color: var(--text-secondary);
}

.staff-item__badge--owner {
  background: var(--primary-50);
  color: var(--primary);
}

.staff-item__badge--full-access {
  background: var(--info-light);
  color: var(--info-dark);
}

.staff-item__badge--disabled {
  background: var(--error-light);
  color: var(--error-dark);
}

.sheet .section-list__items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet .section-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}

.sheet .section-list__item:hover {
  background: var(--surface-hover);
}
