/* Shared UI primitives — toast, modal, spinner, form helpers, status text */

.tt-toast {
  position: fixed;
  top: 2rem;
  left: 50%;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: min(90vw, 36rem);
  padding: 0.875rem 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--tt-toast-border);
  background: var(--tt-toast);
  box-shadow: 0 25px 50px -12px rgb(15 23 42 / 0.25);
  transform: translateX(-50%);
}

.tt-toast__icon {
  padding: 0.5rem;
  border-radius: 0.75rem;
  flex-shrink: 0;
}

.tt-toast__icon--error {
  background: color-mix(in srgb, var(--tt-error) 20%, transparent);
  color: var(--tt-error);
}

.tt-toast__icon--success {
  background: color-mix(in srgb, var(--tt-accent) 20%, transparent);
  color: var(--tt-accent);
}

.tt-toast__message {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--tt-heading);
}

.tt-toast__dismiss {
  flex-shrink: 0;
  padding: 0.25rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--tt-cell);
  cursor: pointer;
  transition: color 0.15s ease;
}

.tt-toast__dismiss:hover {
  color: var(--tt-heading);
}

.tt-session-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 100vh;
  background: var(--tt-login-bg);
  color: var(--tt-cell);
}

.tt-session-loader__label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tt-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 4px solid var(--tt-accent);
  border-top-color: transparent;
  border-radius: 9999px;
  animation: tt-spin 0.8s linear infinite;
}

.tt-spinner--muted {
  border-color: var(--tt-cell);
  border-top-color: transparent;
}

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

.tt-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--tt-heading) 55%, transparent);
  backdrop-filter: blur(2px);
}

.tt-modal-panel {
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.tt-modal-panel--wide {
  max-width: min(56rem, calc(100vw - 2rem));
}

.tt-modal-panel--form {
  display: flex;
  flex-direction: column;
  max-height: min(92vh, 52rem);
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--tt-border);
  border-radius: 1rem;
  background: var(--tt-card);
  box-shadow: 0 1.5rem 3rem color-mix(in srgb, var(--tt-heading) 18%, transparent);
}

.tt-modal-panel--form.tt-modal-panel--wide {
  max-height: min(94vh, 58rem);
}

.tt-modal-panel--form .tt-modal-panel__head--sticky {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--tt-border);
}

.tt-modal-panel--form .tt-modal-panel__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.25rem 1.5rem 1.5rem;
}

.tt-modal-panel--form .tt-modal-panel__actions--sticky {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-top: 0;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--tt-border);
  background: var(--tt-card);
}

.tt-modal-form-section + .tt-modal-form-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--tt-border);
}

.tt-modal-form-section__title {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--tt-heading);
}

.tt-modal-form-section__desc {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--tt-cell);
}

.tt-modal-panel--archive {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 52rem);
  overflow: hidden;
  padding: 0;
}

.tt-modal-panel--archive .tt-modal-panel__head--sticky {
  flex-shrink: 0;
  padding: 1.25rem 1.5rem 0;
}

.tt-modal-panel--archive .tt-modal-panel__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.tt-modal-panel--archive .tt-modal-panel__actions--sticky {
  flex-shrink: 0;
  margin-top: 0;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--tt-border);
  background: var(--tt-card);
}

.tt-archive-edit-blocks .tt-rpt-card--compact .tt-rpt-card-header {
  padding: 0.75rem 1rem;
}

.tt-archive-edit-blocks .tt-rpt-table-wrap {
  overflow-x: auto;
}

.tt-modal-panel__head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.tt-modal-panel__body {
  min-width: 0;
  flex: 1 1 auto;
}

.tt-modal-panel__title {
  margin: 0;
  font-size: var(--tt-text-lg);
  font-weight: 700;
  color: var(--tt-heading);
}

.tt-modal-panel__desc {
  margin: 0.5rem 0 0;
  font-size: var(--tt-text-sm);
  line-height: 1.45;
  color: var(--tt-cell);
}

.tt-modal-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.tt-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--tt-accent) 12%, var(--tt-card));
  color: var(--tt-accent);
}

.tt-icon-badge--md {
  width: 2.5rem;
  height: 2.5rem;
}

.tt-icon-badge--lg {
  width: 2.75rem;
  height: 2.75rem;
}

.tt-field-label {
  font-size: var(--tt-text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tt-cell);
}

.tt-field-label--block {
  display: block;
  margin-bottom: 0.5rem;
}

.tt-checkbox {
  border-radius: 0.25rem;
  border-color: var(--tt-border);
  accent-color: var(--tt-accent);
}

.tt-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tt-accent) 35%, transparent);
}

.tt-checkbox--delete {
  accent-color: var(--tt-danger);
}

.tt-checkbox--delete:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tt-danger) 35%, transparent);
}

.tt-checkbox--enabled {
  accent-color: var(--tt-success);
}

.tt-checkbox--enabled:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tt-success) 35%, transparent);
}

.tt-text-warning {
  color: var(--tt-warning);
}

.tt-text-error {
  color: var(--tt-error);
}

.tt-text-success {
  color: var(--tt-success);
}

.tt-btn-success {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-sizing: border-box;
  min-height: var(--tt-control-h, 2.5rem);
  height: var(--tt-control-h, 2.5rem);
  padding: 0 1rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  color: #ffffff;
  background: var(--tt-success);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--tt-success) 20%, transparent);
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.tt-btn-success:hover:not(:disabled) {
  background: var(--tt-success-hover);
}

.tt-btn-success:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tt-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.tt-switch__track {
  width: 2.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  border: 1px solid var(--tt-border);
  background: var(--tt-elevated);
  transition: background-color 0.15s ease;
}

.tt-switch__input:checked + .tt-switch__track {
  background: var(--tt-accent);
}

.tt-switch__thumb {
  position: absolute;
  left: 0.25rem;
  top: 0.25rem;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.12);
  transition: transform 0.15s ease;
}

.tt-switch__input:checked ~ .tt-switch__thumb {
  transform: translateX(1rem);
}

.tt-switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tt-report-order-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tt-report-order-list > li + li {
  margin-top: 0.375rem;
}

.tt-recipient-list {
  max-height: 10rem;
  overflow-y: auto;
}

.tt-recipient-list > li + li {
  margin-top: 0.5rem;
}

.tt-recipient-list__label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.tt-modal-panel--compose {
  max-width: 36rem;
}

.tt-compose-sheet {
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius-md, 0.5rem);
  overflow: hidden;
  background: var(--tt-elevated);
}

.tt-compose-row {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  align-items: start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--tt-border);
  min-height: 2.5rem;
}

.tt-compose-row:last-child {
  border-bottom: 0;
}

.tt-compose-row--subject {
  align-items: center;
}

.tt-compose-row__label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tt-cell);
  padding-top: 0.35rem;
  line-height: 1.2;
}

.tt-compose-row--subject .tt-compose-row__label {
  padding-top: 0;
}

.tt-compose-row__field {
  min-width: 0;
}

.tt-compose-row__input {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 0.875rem;
  color: var(--tt-heading);
  padding: 0.25rem 0;
  outline: none;
}

.tt-compose-row__input:focus {
  outline: none;
}

.tt-compose-row__chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.75rem;
}

.tt-compose-row__empty {
  font-size: 0.8125rem;
  color: var(--tt-cell);
  opacity: 0.7;
}

.tt-compose-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  padding: 0.125rem 0.375rem 0.125rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tt-accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--tt-accent) 28%, transparent);
  font-size: 0.8125rem;
  line-height: 1.3;
}

.tt-compose-chip__name {
  color: var(--tt-heading);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tt-compose-chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.125rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--tt-cell);
  cursor: pointer;
  line-height: 0;
}

.tt-compose-chip__remove:hover:not(:disabled) {
  background: color-mix(in srgb, var(--tt-heading) 10%, transparent);
  color: var(--tt-heading);
}

.tt-compose-add {
  position: relative;
}

.tt-compose-add__btn {
  border: 0;
  background: transparent;
  color: var(--tt-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.25rem 0.375rem;
  cursor: pointer;
  border-radius: 0.25rem;
}

.tt-compose-add__btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--tt-accent) 10%, transparent);
}

.tt-compose-add__menu {
  position: absolute;
  left: 0;
  top: calc(100% + 0.25rem);
  z-index: 20;
  min-width: 14rem;
  max-width: min(20rem, 70vw);
  max-height: 10rem;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius-md, 0.5rem);
  background: var(--tt-elevated);
  box-shadow: var(--tt-shadow);
  overflow-y: auto;
}

.tt-compose-add__option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.tt-compose-add__option:hover {
  background: color-mix(in srgb, var(--tt-accent) 8%, transparent);
}

.tt-compose-add__name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tt-heading);
}

.tt-compose-add__email {
  font-size: 0.75rem;
  color: var(--tt-cell);
}

.tt-compose-attach {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem 0.625rem 3.75rem;
  border-top: 1px solid var(--tt-border);
  font-size: 0.8125rem;
  color: var(--tt-cell);
}

.tt-compose-attach__name {
  font-weight: 500;
  color: var(--tt-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tt-appearance-popover {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 50;
  width: min(100vw - 2rem, 22rem);
  max-height: min(70dvh, 32rem);
  margin-top: 0.5rem;
  overflow-y: auto;
  padding: 1rem;
  box-shadow: var(--tt-shadow);
}

.tt-location-marker {
  background: transparent;
  border: 0;
}

.tt-location-marker__pin {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 38px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.28));
}

.tt-location-marker__pin::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--marker-color, #004aad);
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.tt-location-marker__pin--preview {
  width: 36px;
  height: 44px;
}

.tt-location-marker__glyph {
  position: relative;
  z-index: 1;
  font-size: 14px;
  line-height: 1;
  transform: translateY(-3px);
}

.tt-location-marker-custom {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.28));
}

.tt-marker-picker-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius-md, 0.5rem);
  background: var(--tt-elevated);
  font-size: 1.25rem;
  cursor: pointer;
}

.tt-marker-picker-btn:hover {
  border-color: color-mix(in srgb, var(--tt-accent) 40%, var(--tt-border));
}

.tt-marker-picker-btn--active {
  border-color: var(--tt-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tt-accent) 20%, transparent);
}

.tt-photo-card {
  overflow: hidden;
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius-md, 0.5rem);
  background: var(--tt-elevated);
}

.tt-photo-card__image {
  display: block;
  width: 100%;
  height: 7rem;
  object-fit: cover;
}

.tt-photo-card__meta {
  padding: 0.625rem;
}

.tt-photo-card__type {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tt-cell);
}

.tt-photo-card__caption {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--tt-heading);
}

.tt-photo-card__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tt-accent) 12%, transparent);
  color: var(--tt-accent-muted-fg, var(--tt-accent));
  font-size: 0.75rem;
  font-weight: 600;
}

.tt-btn-secondary--sm {
  min-height: var(--tt-control-h, 2.5rem);
  height: var(--tt-control-h, 2.5rem);
  padding: 0 0.75rem;
  font-size: 0.875rem;
}

.tt-address-lookup-dropdown {
  position: fixed;
  z-index: 2000;
  max-height: 12rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  border: 1px solid var(--tt-border);
  border-radius: var(--tt-radius-md, 0.5rem);
  background-color: var(--tt-card);
  color: var(--tt-heading);
  box-shadow: var(--tt-shadow);
}

.tt-address-lookup-dropdown__option {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--tt-heading);
  font-size: 0.875rem;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.tt-address-lookup-dropdown__option:hover,
.tt-address-lookup-dropdown__option--active {
  background: var(--tt-elevated-hover);
}
