/* Manage Tips modal (Quick Sale). Namespaced `.mt-*` so it never picks up the legacy
   `#quickSaleTip .tip-*` rules in payment.css. Colours are tokens on `.mt`; Dark overrides
   them in pos-theme.css, so this file stays Light-only. */

#quickSaleTip .modal-dialog:has(.mt) {
  max-width: 960px;
  width: calc(100vw - 2rem);
}

#quickSaleTip .modal-content:has(.mt) {
  background: transparent;
  border-radius: 20px;
  overflow: hidden;
}

#quickSaleTip .modal-body:has(.mt) {
  padding: 0;
  min-height: 0;
  background: transparent;
}

.mt {
  --mt-bg: #ffffff;
  --mt-panel: #f6f8f5;
  --mt-seg: #eef1ef;
  --mt-seg-2: #e7ebe8;
  --mt-line: #e4e8e5;
  --mt-line-2: #d6ddd8;
  --mt-hover-line: #9fb0a6;
  --mt-text: #0f1a14;
  --mt-muted: #5a6660;
  --mt-faint: #9aa6a0;
  --mt-accent: var(--pos-primary, #1f7a3a);
  --mt-accent-ink: #ffffff;
  --mt-accent-soft: var(--pos-primary-soft, #e8f3ec);
  --mt-accent-text: var(--pos-primary-text, #165c2b);
  --mt-total-bg: #13201a;
  --mt-total-ink: #ffffff;
  --mt-total-muted: #a7b6ad;
  --mt-key: #ffffff;
  --mt-key-edge: #e2e7e4;
  --mt-danger: #b42318;
  --mt-danger-soft: #fcedeb;
  --mt-danger-edge: #f2d4d0;
  --mt-warn: #8a3d0b;
  --mt-warn-soft: #fdf0e4;
  --mt-ok: #165c2b;
  --mt-ok-soft: #e8f3ec;
  --mt-foot: #f8faf9;
  --mt-disabled-bg: #e4e8e5;
  --mt-disabled-ink: #66716b;
  --mt-shadow: 0 24px 64px rgba(15, 26, 20, 0.16);

  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(640px, 94dvh);
  background: var(--mt-bg);
  color: var(--mt-text);
  border-radius: 20px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.mt *,
.mt *::before,
.mt *::after {
  box-sizing: border-box;
}

:where(.mt) button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mt button:disabled {
  cursor: not-allowed;
}

.mt button:focus-visible,
.mt input:focus-visible {
  outline: 2px solid var(--mt-accent);
  outline-offset: 2px;
}

/* ---- tech tones: avatar tint + allocation bar ---- */
.mt-tone-0 { --tone: #1f7a3a; --tone-bg: #e8f3ec; }
.mt-tone-1 { --tone: #1e5bb8; --tone-bg: #e7eef9; }
.mt-tone-2 { --tone: #b4500f; --tone-bg: #fbede2; }
.mt-tone-3 { --tone: #6b3fa0; --tone-bg: #f0eaf8; }
.mt-tone-4 { --tone: #0e7490; --tone-bg: #e3f2f6; }
.mt-tone-5 { --tone: #b4235a; --tone-bg: #fbe8f0; }

/* ---- header / footer ---- */
.mt-head {
  flex: none;
  height: 60px;
  padding: 0 16px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--mt-line);
}

.mt-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.mt-title-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mt-accent-soft);
  color: var(--mt-accent-text);
}

.mt-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--mt-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mt-close:hover {
  background: var(--mt-seg);
}

.mt-foot {
  flex: none;
  min-height: 68px;
  padding: 10px 16px 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--mt-line);
  background: var(--mt-foot);
}

.mt-foot-note {
  font-size: 13px;
  color: var(--mt-muted);
}

.mt-foot-actions {
  display: flex;
  gap: 10px;
}

.mt-btn {
  height: 46px;
  white-space: nowrap;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid var(--mt-line-2);
  background: var(--mt-bg);
  font-size: 15px;
  font-weight: 600;
}

.mt-btn--primary {
  min-width: 200px;
  border: 0;
  background: var(--mt-accent);
  color: var(--mt-accent-ink);
  font-weight: 700;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--mt-accent) 25%, transparent);
}

.mt-btn--primary:disabled {
  background: var(--mt-disabled-bg);
  color: var(--mt-disabled-ink);
  box-shadow: none;
}

/* ---- body ---- */
.mt-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 368px;
  gap: 20px;
  padding: 16px 16px 16px 24px;
}

.mt-left {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* credit + other = total */
.mt-strip {
  flex: none;
  min-height: 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr) 20px minmax(0, 1.1fr);
  align-items: stretch;
  padding: 4px;
  border: 1px solid var(--mt-line);
  border-radius: 12px;
}

.mt-op {
  align-self: center;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--mt-faint);
}

.mt-cell {
  min-width: 0;
  padding: 6px 10px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
}

.mt-cell-label {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--mt-muted);
  white-space: nowrap;
}

.mt-cell-value {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

button.mt-cell {
  width: 100%;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  background: var(--mt-panel);
  border: 1px dashed var(--mt-line-2);
}

button.mt-cell:hover {
  border-color: var(--mt-hover-line);
}

button.mt-cell.is-on {
  background: var(--mt-bg);
  border: 1px solid var(--mt-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mt-accent) 14%, transparent);
}

.mt-cell-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--mt-muted);
}

.mt-cell--total {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--mt-total-bg);
  color: var(--mt-total-ink);
}

.mt-cell--total .mt-cell-label {
  color: var(--mt-total-muted);
}

.mt-cell--total .mt-cell-value {
  font-size: 21px;
  letter-spacing: -0.02em;
}

/* split method */
.mt-seg {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: var(--mt-seg);
}

.mt-seg-btn {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.mt-seg-btn b {
  font-size: 14px;
  font-weight: 600;
}

.mt-seg-btn small {
  font-size: 11px;
  font-weight: 500;
  color: var(--mt-muted);
}

.mt-seg-btn.is-on {
  background: var(--mt-bg);
  box-shadow: 0 1px 3px rgba(15, 26, 20, 0.14);
  outline: 2px solid var(--mt-accent);
  outline-offset: -2px;
}

.mt-seg-btn:disabled {
  opacity: 0.55;
}

/* allocation status */
.mt-status {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mt-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--mt-muted);
}

.mt-status-row strong {
  color: var(--mt-text);
}

.mt-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--mt-seg);
  color: var(--mt-muted);
}

.mt-badge.is-ok { background: var(--mt-ok-soft); color: var(--mt-ok); }
.mt-badge.is-left { background: var(--mt-warn-soft); color: var(--mt-warn); }
.mt-badge.is-over { background: var(--mt-danger-soft); color: var(--mt-danger); }

.mt-bar {
  height: 6px;
  display: flex;
  gap: 2px;
  border-radius: 999px;
  background: var(--mt-seg);
  overflow: hidden;
}

.mt-bar span {
  height: 100%;
  background: var(--tone);
}

/* staff: as many columns as fit, scrolls when there are many techs */
.mt-staff {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 2px;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  grid-auto-rows: minmax(60px, auto);
  gap: 8px;
  align-content: start;
  overflow-y: auto;
}

.mt-staff.is-single {
  grid-template-columns: minmax(0, 1fr);
}

.mt-staff-item {
  min-width: 0;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--mt-line);
  border-radius: 12px;
  background: var(--mt-bg);
  box-shadow: 0 1px 2px rgba(15, 26, 20, 0.04);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.mt-staff-item:hover {
  border-color: #c5cec8;
}

.mt-staff-item.is-active {
  border-color: var(--mt-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mt-accent) 14%, transparent);
}

.mt-avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--tone-bg);
  color: var(--tone);
}

.mt-staff-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.mt-staff-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-staff-sub {
  font-size: 11px;
  color: var(--mt-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-staff-amount {
  min-width: 76px;
  padding: 6px 0;
  text-align: right;
  font-size: 16px;
  font-weight: 700;
}

.mt.is-custom .mt-staff-amount {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--mt-seg);
  border: 1px solid var(--mt-line);
}

.mt-staff-item.is-active .mt-staff-amount {
  background: var(--mt-bg);
  border-color: var(--mt-accent);
}

/* editor */
.mt-right {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--mt-line);
  border-radius: 14px;
  background: var(--mt-panel);
}

.mt-display {
  flex: none;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--mt-line);
  border-radius: 10px;
  background: var(--mt-bg);
}

.mt-display.has-error {
  border-color: var(--mt-danger);
}

.mt-display-top,
.mt-display-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mt-display-bottom {
  align-items: flex-end;
}

.mt-eyebrow {
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mt-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-clear {
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--mt-danger);
}

.mt-display-sub {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--mt-muted);
}

.mt-fill {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--mt-accent);
  background: var(--mt-accent-soft);
  color: var(--mt-accent-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.mt-fill[hidden] {
  display: none;
}

.mt-value {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  min-width: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.mt-value-sym {
  color: var(--mt-muted);
}

.mt-value input {
  width: 6ch;
  field-sizing: content;
  min-width: 1ch;
  max-width: 9ch;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: right;
  caret-color: transparent;
}

.mt-value input:focus-visible {
  outline: none;
}

.mt-value input::placeholder {
  color: var(--mt-faint);
  opacity: 1;
}

.mt-hint {
  min-height: 16px;
  font-size: 12px;
  color: var(--mt-muted);
}

.mt-display.has-error .mt-hint {
  color: var(--mt-danger);
}

.mt-presets {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mt-presets-items {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
}

.mt-unit[hidden] {
  display: none;
}

.mt-unit {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: var(--mt-seg-2);
}

.mt-unit button {
  height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--mt-muted);
  font-size: 14px;
  font-weight: 700;
}

.mt-unit button.is-on {
  background: var(--mt-bg);
  color: var(--mt-text);
  box-shadow: 0 1px 2px rgba(15, 26, 20, 0.12);
}

.mt-preset {
  height: 40px;
  padding: 0 2px;
  border-radius: 9px;
  border: 1px solid var(--mt-line-2);
  background: var(--mt-bg);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}

.mt-preset:hover {
  border-color: var(--mt-hover-line);
}

.mt-preset.is-on {
  background: var(--mt-accent);
  border-color: var(--mt-accent);
  color: var(--mt-accent-ink);
}

.mt-preset-sub {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.8;
}

.mt-keys {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(44px, 1fr));
  gap: 6px;
}

.mt-key {
  border: 0;
  border-radius: 10px;
  background: var(--mt-key);
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -2px 0 var(--mt-key-edge), 0 0 0 1px var(--mt-line);
  transition: transform 0.06s, filter 0.12s;
}

.mt-key:hover:not(:disabled) {
  filter: brightness(0.97);
}

.mt-key:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 0 0 1px var(--mt-line);
}

.mt-key--back {
  background: var(--mt-danger-soft);
  color: var(--mt-danger);
  box-shadow: inset 0 -2px 0 var(--mt-danger-edge);
}

.mt-right.is-disabled .mt-presets,
.mt-right.is-disabled .mt-keys {
  opacity: 0.5;
  pointer-events: none;
}

/* saved confirmation */
.mt-saved {
  position: absolute;
  inset: 60px 0 0 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--mt-bg);
  overflow-y: auto;
}

.mt-saved[hidden] {
  display: none;
}

.mt-saved-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mt-saved-check {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mt-accent-soft);
  color: var(--mt-accent-text);
}

.mt-saved-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.mt-saved-head span {
  font-size: 13px;
  color: var(--mt-muted);
}

.mt-saved-rows {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
}

.mt-saved-row {
  min-height: 56px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--mt-line);
  border-radius: 12px;
}

.mt-saved-row .mt-staff-name {
  flex: 1;
}

.mt-saved-pct {
  font-size: 12px;
  color: var(--mt-muted);
}

.mt-saved-amt {
  min-width: 64px;
  text-align: right;
  font-size: 16px;
  font-weight: 700;
}

.mt-saved-foot {
  width: min(560px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 14px;
  color: var(--mt-muted);
}

.mt-saved-foot strong {
  font-size: 18px;
  color: var(--mt-text);
}

/* ---- tablet / phone: one column, body scrolls, footer stays put ---- */
@media (max-width: 900px) {
  #quickSaleTip .modal-dialog:has(.mt) {
    margin: 0.5rem auto;
  }

  .mt {
    max-height: 96dvh;
  }

  .mt-body {
    display: block;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px;
  }

  .mt-left {
    min-height: auto;
    margin-bottom: 12px;
  }

  .mt-staff {
    overflow: visible;
  }

  .mt-keys {
    grid-template-rows: repeat(4, 52px);
  }
}

@media (max-width: 640px) {
  .mt-head {
    padding-left: 16px;
  }

  .mt-strip {
    grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr) 14px minmax(0, 1.1fr);
  }

  .mt-cell {
    padding: 6px 6px;
  }

  .mt-cell-value {
    font-size: 15px;
  }

  .mt-cell-pct {
    display: none;
  }

  .mt-cell--total {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    padding: 4px 8px;
  }

  .mt-cell--total .mt-cell-value {
    font-size: 17px;
  }

  .mt-foot {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .mt-foot-note {
    text-align: center;
  }

  .mt-foot-actions .mt-btn {
    flex: 1;
    min-width: 0;
    padding: 0 12px;
  }

  .mt-saved {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mt *,
  .mt *::before,
  .mt *::after {
    transition: none !important;
  }
}
