/* Butter Toast Design System: components.
   Every value here is a token reference. No hex, no raw px for colour or spacing.
   Marketing and application surfaces are marked where their rules differ. */

/* ---------- base ---------- */
.bt-app { background: var(--bt-bg-page); color: var(--bt-text-primary);
  font-family: var(--bt-font-text); font-size: var(--bt-type-body-size);
  line-height: var(--bt-type-body-lh); }
.bt-h1, .bt-h2, .bt-h3, .bt-h4 { font-family: var(--bt-font-display); font-weight: 400;
  letter-spacing: -0.02em; margin: 0; }
.bt-h1 { font-size: var(--bt-type-h1-size); line-height: var(--bt-type-h1-lh); }
.bt-h2 { font-size: var(--bt-type-h2-size); line-height: var(--bt-type-h2-lh); }
.bt-h3 { font-size: var(--bt-type-h3-size); line-height: var(--bt-type-h3-lh); }
.bt-h4 { font-size: var(--bt-type-h4-size); line-height: var(--bt-type-h4-lh); }
.bt-label { font-size: var(--bt-type-label-size); line-height: var(--bt-type-label-lh);
  font-weight: var(--bt-type-label-weight); letter-spacing: var(--bt-type-label-track);
  text-transform: uppercase; color: var(--bt-text-muted); }
.bt-muted { color: var(--bt-text-muted); }
.bt-measure { max-width: var(--bt-measure); }

/* focus: two tone so it survives any fill underneath */
.bt-focusable:focus-visible, .bt-btn:focus-visible, .bt-input:focus-visible,
.bt-tab:focus-visible, .bt-chip:focus-visible, .bt-navlink:focus-visible {
  outline: 2px solid var(--bt-focus-ring); outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--bt-focus-ring-contrast); }

/* ---------- buttons ---------- */
.bt-btn { display: inline-flex; align-items: center; justify-content: center;
  gap: var(--bt-space-200); height: var(--bt-touch-target); padding: 0 var(--bt-space-500);
  font-family: var(--bt-font-text); font-size: var(--bt-type-body-sm-size); font-weight: 600;
  border: 2px solid transparent; border-radius: var(--bt-corner-pill); cursor: pointer;
  transition: background var(--bt-duration-short) var(--bt-ease-standard),
              color var(--bt-duration-short) var(--bt-ease-standard); }
.bt-btn--solid { background: var(--bt-accent-solid); color: var(--bt-accent-on);
  border-color: var(--bt-accent-solid); }
.bt-btn--solid:hover { background: var(--bt-accent-hover); border-color: var(--bt-accent-hover); }
.bt-btn--solid:active { background: var(--bt-accent-pressed); border-color: var(--bt-accent-pressed); }
.bt-btn--ghost { background: transparent; color: var(--bt-text-primary);
  border-color: var(--bt-border-control); }
.bt-btn--ghost:hover { background: var(--bt-bg-surface-sunken); }
.bt-btn--quiet { background: transparent; color: var(--bt-accent-text); border-color: transparent;
  padding: 0 var(--bt-space-300); }
.bt-btn--quiet:hover { background: var(--bt-accent-subtle); }
.bt-btn--danger { background: var(--bt-bg-fill-danger); color: var(--bt-text-on-fill);
  border-color: var(--bt-bg-fill-danger); }
.bt-btn--sm { height: 36px; font-size: var(--bt-type-caption-size); padding: 0 var(--bt-space-400); }
.bt-btn[disabled], .bt-btn[aria-disabled="true"] { opacity: var(--bt-state-disabled-content);
  cursor: not-allowed; pointer-events: none; }
/* MARKETING RULE: one solid button per view.
   APPLICATION RULE: one solid per container, so a table row or a modal may each have one. */

/* ---------- fields ---------- */
.bt-field { display: flex; flex-direction: column; gap: var(--bt-space-150);
  margin-bottom: var(--bt-space-400); }
.bt-field > label { font-size: var(--bt-type-body-sm-size); font-weight: 600;
  color: var(--bt-text-primary); }
.bt-input, .bt-select, .bt-textarea { width: 100%; min-height: var(--bt-touch-target);
  padding: 0 var(--bt-space-300); font-family: var(--bt-font-text);
  font-size: var(--bt-type-body-size); color: var(--bt-text-primary);
  background: var(--bt-bg-surface-raised); border: 1px solid var(--bt-border-control);
  border-radius: var(--bt-corner-none); }
.bt-textarea { padding: var(--bt-space-300); min-height: 96px; resize: vertical;
  line-height: var(--bt-type-body-lh); }
.bt-input::placeholder { color: var(--bt-text-muted); }
.bt-field--error .bt-input, .bt-field--error .bt-select, .bt-field--error .bt-textarea {
  border-color: var(--bt-bg-fill-danger); border-width: 2px; }
.bt-field__help { font-size: var(--bt-type-caption-size); color: var(--bt-text-muted); }
.bt-field__error { font-size: var(--bt-type-caption-size); color: var(--bt-text-danger);
  font-weight: 600; }
/* RULE: the label is always above the field. A placeholder is never a label. */

.bt-check { display: flex; align-items: flex-start; gap: var(--bt-space-300);
  min-height: var(--bt-touch-target); cursor: pointer; }
.bt-check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--bt-accent-solid);
  flex: none; }
.bt-switch { position: relative; width: 44px; height: 26px; flex: none;
  background: var(--bt-bg-fill-neutral); border-radius: var(--bt-corner-pill);
  transition: background var(--bt-duration-short) var(--bt-ease-standard); cursor: pointer; }
.bt-switch[aria-checked="true"] { background: var(--bt-accent-solid); }
.bt-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: var(--bt-bg-surface-raised); border-radius: var(--bt-corner-pill);
  transition: transform var(--bt-duration-short) var(--bt-ease-standard); }
.bt-switch[aria-checked="true"]::after { transform: translateX(18px); }

/* ---------- cards ---------- */
.bt-card { background: var(--bt-bg-surface); border: 1px solid var(--bt-border-subtle);
  border-radius: var(--bt-corner-none); padding: var(--bt-space-400); }
.bt-card--link { cursor: pointer; transition: border-color var(--bt-duration-short) var(--bt-ease-standard); }
.bt-card--link:hover { border-color: var(--bt-accent); }
/* RULE: the whole card is the target, not just its title. No shadow, ever. */

/* ---------- table ---------- */
.bt-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--bt-border-subtle); background: var(--bt-bg-surface-data); }
.bt-table { width: 100%; border-collapse: collapse; font-size: var(--bt-type-data-size);
  line-height: var(--bt-type-data-lh); }
.bt-table th { text-align: left; padding: var(--bt-space-300); white-space: nowrap;
  font-size: var(--bt-type-label-size); letter-spacing: var(--bt-type-label-track);
  text-transform: uppercase; color: var(--bt-text-muted); font-weight: 700;
  background: var(--bt-bg-surface); border-bottom: 1px solid var(--bt-border-container);
  position: sticky; top: 0; z-index: 1; }
.bt-table td { padding: var(--bt-space-300); border-bottom: 1px solid var(--bt-border-subtle);
  vertical-align: top; }
.bt-table tbody tr:hover { background: var(--bt-bg-surface); }
.bt-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.bt-table--compact td, .bt-table--compact th { padding: var(--bt-space-200) var(--bt-space-300); }
/* MOBILE: below 600px a table becomes stacked cards. Horizontal scroll is the fallback,
   never the plan. */
@media (max-width: 599px) {
  .bt-table--stack thead { display: none; }
  .bt-table--stack tr { display: block; border-bottom: 1px solid var(--bt-border-container);
    padding: var(--bt-space-300) 0; }
  .bt-table--stack td { display: flex; justify-content: space-between; gap: var(--bt-space-400);
    border: 0; padding: var(--bt-space-150) var(--bt-space-300); }
  .bt-table--stack td::before { content: attr(data-label); color: var(--bt-text-muted);
    font-size: var(--bt-type-caption-size); font-weight: 600; flex: none; }
}

/* ---------- badges and chips ---------- */
.bt-badge { display: inline-flex; align-items: center; gap: var(--bt-space-150);
  padding: 2px var(--bt-space-300); font-size: var(--bt-type-caption-size); font-weight: 600;
  border-radius: var(--bt-corner-pill); }
.bt-badge--neutral { background: var(--bt-bg-fill-neutral); color: var(--bt-text-primary); }
.bt-badge--success { background: var(--bt-bg-fill-success-subtle); color: var(--bt-text-success); }
.bt-badge--warning { background: var(--bt-bg-fill-warning-subtle); color: var(--bt-text-warning); }
.bt-badge--danger  { background: var(--bt-bg-fill-danger-subtle);  color: var(--bt-text-danger); }
.bt-badge--info    { background: var(--bt-bg-fill-info-subtle);    color: var(--bt-text-link); }
/* RULE: colour never carries meaning alone. Every badge has a word in it. */
.bt-chip { display: inline-flex; align-items: center; gap: var(--bt-space-200); height: 34px;
  padding: 0 var(--bt-space-300); font-size: var(--bt-type-body-sm-size);
  background: var(--bt-bg-surface); color: var(--bt-text-primary);
  border: 1px solid var(--bt-border-control); border-radius: var(--bt-corner-pill); cursor: pointer; }
.bt-chip[aria-pressed="true"] { background: var(--bt-accent-solid); color: var(--bt-accent-on);
  border-color: var(--bt-accent-solid); }

/* ---------- banner and toast ---------- */
.bt-banner { display: flex; gap: var(--bt-space-300); padding: var(--bt-space-400);
  border-left: 4px solid var(--bt-accent); background: var(--bt-bg-surface);
  font-size: var(--bt-type-body-sm-size); }
.bt-banner--danger  { border-left-color: var(--bt-bg-fill-danger);  background: var(--bt-bg-fill-danger-subtle); }
.bt-banner--warning { border-left-color: var(--bt-bg-fill-warning); background: var(--bt-bg-fill-warning-subtle); }
.bt-banner--success { border-left-color: var(--bt-bg-fill-success); background: var(--bt-bg-fill-success-subtle); }
.bt-toast { display: flex; align-items: center; gap: var(--bt-space-300);
  padding: var(--bt-space-300) var(--bt-space-400); background: var(--bt-bg-inverse);
  color: var(--bt-bg-page); font-size: var(--bt-type-body-sm-size); max-width: 420px; }
.bt-toastwrap { position: fixed; left: var(--bt-space-400); right: var(--bt-space-400);
  bottom: calc(var(--bt-space-400) + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: flex; flex-direction: column; gap: var(--bt-space-200); align-items: center; }
@media (min-width: 600px) { .bt-toastwrap { left: auto; align-items: flex-end; } }

/* ---------- tabs ---------- */
.bt-tabs { display: flex; gap: var(--bt-space-500); border-bottom: 1px solid var(--bt-border-subtle);
  overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bt-tab { flex: none; height: var(--bt-touch-target); padding: 0 var(--bt-space-100);
  background: none; border: 0; border-bottom: 3px solid transparent; cursor: pointer;
  font-family: var(--bt-font-text); font-size: var(--bt-type-body-sm-size); font-weight: 600;
  color: var(--bt-text-muted); white-space: nowrap; }
.bt-tab[aria-selected="true"] { color: var(--bt-text-primary); border-bottom-color: var(--bt-accent); }

/* ---------- navigation ---------- */
.bt-topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--bt-space-400);
  padding: var(--bt-space-300) var(--bt-space-400); background: var(--bt-bg-surface);
  border-bottom: 1px solid var(--bt-border-subtle); }
.bt-brandmark { font-family: var(--bt-font-display); font-size: 19px;
  letter-spacing: var(--bt-tracking-lockup); color: var(--bt-text-primary); }
.bt-sidenav { display: flex; flex-direction: column; gap: var(--bt-space-050);
  padding: var(--bt-space-300); background: var(--bt-bg-surface); }
.bt-navlink { display: flex; align-items: center; gap: var(--bt-space-300);
  min-height: var(--bt-touch-target); padding: 0 var(--bt-space-300);
  color: var(--bt-text-secondary); text-decoration: none;
  font-size: var(--bt-type-body-sm-size); font-weight: 600; }
.bt-navlink:hover { background: var(--bt-bg-surface-sunken); }
.bt-navlink[aria-current="page"] { background: var(--bt-accent-subtle); color: var(--bt-accent-text);
  box-shadow: inset 3px 0 0 0 var(--bt-accent); }
/* MOBILE: the side nav becomes a bottom bar under 600px. Thumb reach beats hamburger. */
.bt-bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex;
  background: var(--bt-bg-surface); border-top: 1px solid var(--bt-border-subtle);
  padding-bottom: env(safe-area-inset-bottom, 0px); }
.bt-bottombar .bt-navlink { flex: 1; flex-direction: column; gap: 2px; justify-content: center;
  min-height: 56px; font-size: var(--bt-type-label-size); box-shadow: none; }

/* ---------- modal ---------- */
.bt-scrim { position: fixed; inset: 0; z-index: 70; background: var(--bt-bg-inverse);
  opacity: 0.55; }
.bt-modal { position: fixed; z-index: 71; left: 0; right: 0; bottom: 0; max-height: 88vh;
  overflow: auto; background: var(--bt-bg-surface-raised);
  border-top: 1px solid var(--bt-border-container); padding: var(--bt-space-500);
  padding-bottom: calc(var(--bt-space-500) + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 600px) {
  .bt-modal { left: 50%; right: auto; top: 50%; bottom: auto; transform: translate(-50%, -50%);
    width: min(560px, calc(100vw - var(--bt-space-800))); border: 1px solid var(--bt-border-container); }
}
/* MOBILE: a modal is a bottom sheet. Centred dialogs fight the keyboard on a phone. */
.bt-modal__actions { display: flex; gap: var(--bt-space-300); justify-content: flex-end;
  margin-top: var(--bt-space-600); flex-wrap: wrap; }

/* ---------- empty, loading, error states ---------- */
.bt-empty { text-align: center; padding: var(--bt-space-2000) var(--bt-space-400);
  color: var(--bt-text-secondary); }
.bt-empty h3 { font-family: var(--bt-font-display); font-size: var(--bt-type-h4-size);
  color: var(--bt-text-primary); margin: 0 0 var(--bt-space-200); }
.bt-skel { background: var(--bt-bg-fill-neutral); height: 14px;
  animation: bt-pulse 1.4s var(--bt-ease-standard) infinite; }
.bt-skel--line { margin-bottom: var(--bt-space-200); }
@keyframes bt-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .bt-skel { animation: none; }
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ---------- pagination ---------- */
.bt-pager { display: flex; align-items: center; gap: var(--bt-space-200); flex-wrap: wrap;
  padding: var(--bt-space-400) 0; }
.bt-pager__page { min-width: var(--bt-touch-target); height: var(--bt-touch-target);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: transparent; border: 1px solid var(--bt-border-subtle);
  color: var(--bt-text-secondary); font-size: var(--bt-type-body-sm-size); }
.bt-pager__page[aria-current="true"] { background: var(--bt-accent-solid);
  color: var(--bt-accent-on); border-color: var(--bt-accent-solid); }

/* ---------- search and filter bar ---------- */
.bt-filterbar { display: flex; gap: var(--bt-space-300); flex-wrap: wrap; align-items: center;
  padding: var(--bt-space-400) 0; }
.bt-search { flex: 1 1 220px; min-width: 0; }

/* ---------- upload ---------- */
.bt-drop { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--bt-space-300); padding: var(--bt-space-1200) var(--bt-space-400); text-align: center;
  background: var(--bt-bg-surface-sunken); border: 2px dashed var(--bt-border-control);
  color: var(--bt-text-secondary); }
.bt-drop--over { border-color: var(--bt-accent); background: var(--bt-accent-subtle); }
.bt-progress { width: 100%; height: 6px; background: var(--bt-bg-fill-neutral); }
.bt-progress__bar { height: 100%; background: var(--bt-accent-solid);
  transition: width var(--bt-duration-medium) var(--bt-ease-standard); }

/* ---------- layout helpers ---------- */
.bt-wrap { max-width: var(--bt-max-body); margin: 0 auto; padding: 0 var(--bt-space-400); }
@media (min-width: 600px)  { .bt-wrap { padding: 0 var(--bt-space-600); } }
@media (min-width: 1024px) { .bt-wrap { padding: 0 var(--bt-space-800); } }
.bt-stack > * + * { margin-top: var(--bt-space-400); }
.bt-row { display: flex; gap: var(--bt-space-300); align-items: center; flex-wrap: wrap; }
.bt-grid { display: grid; gap: var(--bt-space-400);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.bt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; }
