/* ==========================================================================
   components.css — the reusable interface vocabulary
   ========================================================================== */

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn svg { flex: 0 0 auto; width: 15px; height: 15px; }

/* Two stops of one colour plus an inset highlight: the control reads as a
   surface lit from above rather than a flat rectangle of brand colour. */
.btn--primary {
  background: linear-gradient(180deg, var(--color-primary-lit) 0%, var(--color-primary) 100%);
  color: #fff;
  box-shadow: var(--edge-light), 0 1px 2px rgba(25, 22, 18, 0.16);
}
.btn--primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
}
.btn--primary:active:not(:disabled) {
  background: var(--color-primary-press);
  box-shadow: inset 0 1px 3px rgba(25, 22, 18, 0.25);
}

.btn--secondary {
  background: linear-gradient(180deg, #FFFFFF 0%, #FCFAF8 100%);
  border-color: var(--color-border-strong);
  color: var(--color-text);
  box-shadow: 0 1px 1.5px rgba(25, 22, 18, 0.045);
}
.btn--secondary:hover:not(:disabled) {
  background: linear-gradient(180deg, #FFFFFF 0%, #F5F1EC 100%);
  border-color: #CFC7BB;
}
.btn--secondary:active:not(:disabled) { background: var(--color-surface-muted); box-shadow: none; }

.btn--ghost { background: transparent; color: var(--color-text-muted); }
.btn--ghost:hover:not(:disabled) { background: var(--color-surface-muted); color: var(--color-text); }

.btn--danger {
  background: linear-gradient(180deg, #CB4B3B 0%, var(--color-danger) 100%);
  color: #fff;
  box-shadow: var(--edge-light), 0 1px 2px rgba(25, 22, 18, 0.16);
}
.btn--danger:hover:not(:disabled) { background: linear-gradient(180deg, var(--color-danger) 0%, #A33023 100%); }

.btn--sm { height: 26px; padding: 0 var(--space-2); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn--sm svg { width: 13px; height: 13px; }
.btn--lg { height: 38px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn--block { width: 100%; }

/* Icon-only button. Always carries an aria-label. */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  position: relative;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--color-surface-muted); color: var(--color-text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn--sm { width: 26px; height: 26px; }
.icon-btn--sm svg { width: 15px; height: 15px; }

.icon-btn__badge {
  position: absolute;
  top: 3px; right: 3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--color-surface);
}

/* Segmented control — for view switches (Month/Week/List, Units/Volume). */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  gap: 2px;
}

.segmented button {
  height: 26px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segmented button:hover { color: var(--color-text); }
.segmented button.is-active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.card__title { font-size: var(--text-md); font-weight: 600; letter-spacing: -0.012em; }
.card__body { padding: var(--space-5); }
.card__body--flush { padding: 0; }
.card__foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================
   KPI strip — a run of figures, not three equal marketing cards
   ========================================================================== */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.kpi {
  padding: var(--space-4) var(--space-4) var(--space-4);
  border-right: 1px solid var(--color-border);
  display: block;
  width: 100%;
  text-align: left;
  transition: background-color var(--dur-fast) var(--ease);
  position: relative;
}
.kpi:last-child { border-right: 0; }
.kpi:hover { background: var(--color-surface-muted); }
.kpi:hover .kpi__label { color: var(--color-primary); }

.kpi__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  transition: color var(--dur-fast) var(--ease);
}

.kpi__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-top: 7px;
  color: var(--color-text);
}

/* Figure and its twelve-week shape share a baseline: the number is the fact,
   the sparkline is the direction, and neither competes for the eye. */
.kpi__row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); }
.kpi__spark { flex: 0 0 auto; padding-bottom: 3px; opacity: 0.9; }
.kpi__spark .spark { display: block; width: 72px; height: 22px; }
.kpi:hover .kpi__spark { opacity: 1; }

.kpi__foot { display: flex; align-items: center; gap: var(--space-1); margin-top: var(--space-1); font-size: var(--text-xs); color: var(--color-text-muted); }

.kpi--alert .kpi__value { color: var(--color-primary); }

.delta { display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono); font-weight: 600; font-size: var(--text-xs); }
.delta--up { color: var(--color-success); }
.delta--down { color: var(--color-danger); }
.delta--flat { color: var(--color-text-faint); }
.delta svg { width: 11px; height: 11px; }

/* ==========================================================================
   Badges / chips
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 19px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  background: var(--color-neutral-wash);
  color: var(--color-neutral);
}

.badge svg { width: 11px; height: 11px; }
.badge--success { background: var(--color-success-wash); color: var(--color-success); }
.badge--warning { background: var(--color-warning-wash); color: var(--color-warning); }
.badge--danger  { background: var(--color-danger-wash);  color: var(--color-danger); }
.badge--info    { background: var(--color-info-wash);    color: var(--color-info); }
.badge--primary { background: var(--color-primary-wash); color: var(--color-primary-hover); }
.badge--neutral { background: var(--color-neutral-wash); color: var(--color-neutral); }

/* A dot prefix so state is never carried by colour alone at a glance. */
.badge__dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

.badge--lg { height: 24px; padding: 0 10px; font-size: var(--text-sm); }

/* Channel chips */
.chan {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: var(--color-surface-muted);
  color: var(--color-text-faint);
  border: 1px solid var(--color-border);
}
.chan[data-state="verified"] { background: var(--color-success-wash); color: var(--color-success); border-color: transparent; }
.chan[data-state="review"]   { background: var(--color-warning-wash); color: var(--color-warning); border-color: transparent; }
.chan[data-state="found"]    { background: var(--color-info-wash);    color: var(--color-info);    border-color: transparent; }
.chan[data-state="rejected"] { background: var(--color-danger-wash);  color: var(--color-danger);  border-color: transparent; }
.chan[data-state="missing"]  { background: transparent; color: var(--color-text-faint); border-style: dashed; }

.chan-group { display: inline-flex; gap: 3px; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.field:last-child { margin-bottom: 0; }

.field__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.field__label .req { color: var(--color-danger); margin-left: 2px; }

.field__hint { font-size: var(--text-xs); color: var(--color-text-faint); }
.field__error { font-size: var(--text-xs); color: var(--color-danger); font-weight: 500; display: none; }
.field.has-error .field__error { display: block; }
.field.has-error .input, .field.has-error .select, .field.has-error textarea.input { border-color: var(--color-danger); }

.input,
.select,
textarea.input {
  width: 100%;
  height: 32px;
  padding: 0 var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  font-size: var(--text-base);
  color: var(--color-text);
  /* A whisper of inset shadow reads as a recess rather than a drawn box. */
  box-shadow: inset 0 1px 2px rgba(25, 22, 18, 0.035);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

textarea.input { height: auto; min-height: 78px; padding: var(--space-2) var(--space-3); line-height: 1.55; }

.input::placeholder { color: var(--color-text-faint); }

.input:hover, .select:hover { border-color: var(--color-text-faint); }

.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-wash), inset 0 1px 2px rgba(25, 22, 18, 0.02);
  outline: none;
}

.select {
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236B635A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  cursor: pointer;
}

.input--sm, .select--sm { height: 28px; font-size: var(--text-sm); }

/* Search input with a leading icon */
.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search svg {
  position: absolute;
  left: 9px;
  width: 15px; height: 15px;
  color: var(--color-text-faint);
  pointer-events: none;
}
.search .input { padding-left: 30px; }

/* Checkbox + switch */
.checkbox {
  appearance: none;
  width: 15px; height: 15px;
  border: 1.5px solid var(--color-border-strong);
  border-radius: 4px;
  background: var(--color-surface);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.checkbox:hover { border-color: var(--color-primary); }
.checkbox:checked, .checkbox:indeterminate { background: var(--color-primary); border-color: var(--color-primary); }
.checkbox:checked::after {
  content: "";
  width: 9px; height: 9px;
  background: #fff;
  clip-path: polygon(14% 47%, 0 61%, 39% 100%, 100% 22%, 85% 8%, 37% 70%);
}
.checkbox:indeterminate::after { content: ""; width: 8px; height: 2px; background: #fff; border-radius: 1px; }

.switch {
  appearance: none;
  width: 34px; height: 19px;
  border-radius: var(--radius-full);
  background: var(--color-border-strong);
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background-color var(--dur) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease);
}
.switch:checked { background: var(--color-primary); }
.switch:checked::after { transform: translateX(15px); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row__label { font-size: var(--text-base); font-weight: 500; }
.switch-row__hint { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 1px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }
.form-grid .field--full { grid-column: 1 / -1; }

.form-section-title {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.form-section-title:not(:first-child) { margin-top: var(--space-3); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #F6F2ED 0%, var(--color-surface-muted) 100%);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 9px var(--space-3);
  border-bottom: 1px solid var(--color-border-strong);
  white-space: nowrap;
}

.table th.num, .table td.num { text-align: right; }

.table tbody td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  height: var(--row-h);
  vertical-align: middle;
}

.table tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: #FBF8F4; }
.table tbody tr.is-selected { background: var(--color-primary-wash); box-shadow: inset 3px 0 0 var(--color-primary); }
.table tbody tr.is-selected:hover { background: rgba(226, 105, 28, 0.12); }
.table tbody tr:last-child td { border-bottom: 0; }

.table--clickable tbody tr { cursor: pointer; }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}
.th-sort:hover { color: var(--color-text); }
.th-sort svg { width: 12px; height: 12px; opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.th-sort:hover svg { opacity: 0.5; }
.th-sort.is-sorted { color: var(--color-primary); }
.th-sort.is-sorted svg { opacity: 1; }

.col-check { width: 34px; }
.col-actions { width: 1%; white-space: nowrap; }

/* The primary cell: name over a mono identifier. */
.cell-primary { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.cell-primary__name { font-weight: 600; color: var(--color-text); }
.cell-primary__sub { font-size: var(--text-xs); color: var(--color-text-faint); font-family: var(--font-mono); }
.cell-primary__sub.nowrap { white-space: nowrap; }

.row-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.table tbody tr:hover .row-actions,
.table tbody tr:focus-within .row-actions { opacity: 1; }

/* Table toolbar + pagination */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-3);
  flex-wrap: wrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.page-numbers { display: flex; align-items: center; gap: 2px; }
.page-num {
  min-width: 27px; height: 27px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}
.page-num:hover { background: var(--color-surface-muted); color: var(--color-text); }
.page-num.is-active { background: var(--color-primary); color: #fff; }
.page-num:disabled { opacity: 0.35; }

/* Bulk action bar, appears when rows are selected. */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-sidebar);
  color: var(--color-on-dark);
  border-radius: var(--radius);
  margin: 0 var(--space-4) var(--space-3);
  flex-wrap: wrap;
}
.bulk-bar__count { font-family: var(--font-mono); font-weight: 600; font-size: var(--text-base); }
.bulk-bar .btn--secondary { background: #322D28; border-color: #443E37; color: var(--color-on-dark); }
.bulk-bar .btn--secondary:hover { background: #3D3730; }

/* ==========================================================================
   Empty + loading states
   ========================================================================== */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-12) var(--space-6);
  gap: var(--space-2);
}
.empty__icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--color-surface-muted);
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}
.empty__icon svg { width: 19px; height: 19px; }
.empty__title { font-size: var(--text-md); font-weight: 600; }
.empty__text { font-size: var(--text-base); color: var(--color-text-muted); max-width: 44ch; }
.empty__actions { margin-top: var(--space-3); display: flex; gap: var(--space-2); }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--color-text); }
.tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab__count {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
}
.tab.is-active .tab__count { background: var(--color-primary-wash); color: var(--color-primary-hover); }

/* Pill filter row (Conversations, Activity). */
.pills { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.pill {
  height: 27px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--dur-fast) var(--ease);
}
.pill:hover { border-color: var(--color-text-faint); color: var(--color-text); }
.pill.is-active { background: var(--color-sidebar); border-color: var(--color-sidebar); color: #fff; }
.pill__count { font-family: var(--font-mono); font-size: 10px; opacity: 0.7; }

/* ==========================================================================
   Dropdown menus
   ========================================================================== */

.dropdown { position: relative; display: inline-block; }

.menu {
  position: absolute;
  z-index: var(--z-dropdown);
  min-width: 190px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  top: calc(100% + 5px);
  right: 0;
  animation: menu-in var(--dur-fast) var(--ease);
}

@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: background-color var(--dur-fast) var(--ease);
}
.menu__item:hover { background: var(--color-surface-muted); }
.menu__item svg { width: 15px; height: 15px; color: var(--color-text-muted); flex: 0 0 auto; }
.menu__item--danger { color: var(--color-danger); }
.menu__item--danger svg { color: var(--color-danger); }
.menu__item--danger:hover { background: var(--color-danger-wash); }
.menu__sep { height: 1px; background: var(--color-border); margin: var(--space-1) 0; }
.menu__label {
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}
.menu__item .check { margin-left: auto; color: var(--color-primary); }

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(26, 24, 21, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  overflow-y: auto;
  animation: fade-in var(--dur) var(--ease);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  margin: auto;
  animation: modal-in var(--dur) var(--ease);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--space-12));
}

@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }

.modal--wide { max-width: 720px; }
.modal--xwide { max-width: 940px; }
.modal--narrow { max-width: 400px; }

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex: 0 0 auto;
}
.modal__title { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.02em; }
.modal__sub { font-size: var(--text-base); color: var(--color-text-muted); margin-top: 2px; }
.modal__body { padding: var(--space-5); overflow-y: auto; flex: 1 1 auto; }
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex: 0 0 auto;
}
.modal__foot--split { justify-content: space-between; }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--color-sidebar);
  color: var(--color-on-dark);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease);
  border-left: 3px solid var(--color-neutral);
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

.toast--success { border-left-color: #3FBE86; }
.toast--warning { border-left-color: #E0A82E; }
.toast--error   { border-left-color: #E06A5B; }
.toast--info    { border-left-color: var(--color-primary); }

.toast__icon { flex: 0 0 auto; margin-top: 1px; }
.toast__icon svg { width: 16px; height: 16px; }
.toast--success .toast__icon { color: #3FBE86; }
.toast--warning .toast__icon { color: #E0A82E; }
.toast--error   .toast__icon { color: #E06A5B; }
.toast--info    .toast__icon { color: #F0894A; }

.toast__body { flex: 1 1 auto; min-width: 0; }
.toast__msg { font-size: var(--text-base); font-weight: 500; }
.toast__detail { font-size: var(--text-sm); color: var(--color-on-dark-muted); margin-top: 2px; }
.toast__close { color: var(--color-on-dark-muted); flex: 0 0 auto; }
.toast__close:hover { color: #fff; }
.toast__close svg { width: 14px; height: 14px; }

/* ==========================================================================
   Avatars
   ========================================================================== */

.avatar {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  background: var(--color-neutral);
  user-select: none;
  /* An inner edge stops flat colour tiles reading as placeholders. */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 0 0 1px rgba(25, 22, 18, 0.06);
}
.avatar--sm { width: 22px; height: 22px; font-size: 9px; border-radius: var(--radius-sm); }
.avatar--lg { width: 46px; height: 46px; font-size: var(--text-lg); border-radius: var(--radius-lg); }
.avatar--xl { width: 60px; height: 60px; font-size: var(--text-2xl); border-radius: var(--radius-lg); }

/* ==========================================================================
   Progress
   ========================================================================== */

.progress {
  height: 5px;
  background: var(--color-surface-sunken);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--dur) var(--ease);
}
.progress__fill--success { background: var(--color-success); }
.progress__fill--warning { background: var(--color-warning); }

.progress-row { display: grid; grid-template-columns: 1fr 46px; gap: var(--space-3); align-items: center; }
.progress-row__label { font-size: var(--text-sm); color: var(--color-text-muted); }
.progress-row__value { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 600; text-align: right; }

/* ==========================================================================
   Definition list — used across detail panes
   ========================================================================== */

.dl { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-base); }
.dl dt { color: var(--color-text-muted); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.stat-row { display: flex; gap: var(--space-6); flex-wrap: wrap; }
.stat { min-width: 0; }
.stat__label { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-faint); }
.stat__value { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.stat__sub { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ==========================================================================
   Command palette
   Sits higher on the screen than a modal: it is a jump, not a task.
   ========================================================================== */

.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(25, 22, 18, 0.38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh var(--space-4) var(--space-4);
  animation: fade-in var(--dur-fast) var(--ease);
}

.palette {
  width: 100%;
  max-width: 560px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 62vh;
  overflow: hidden;
  animation: palette-in var(--dur) var(--ease);
}

@keyframes palette-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.palette__search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex: 0 0 auto;
}
.palette__search > svg { width: 17px; height: 17px; color: var(--color-text-faint); flex: 0 0 auto; }

.palette__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--color-text);
  outline: none;
}
.palette__input::placeholder { color: var(--color-text-faint); font-weight: 400; }

.palette__list { overflow-y: auto; flex: 1 1 auto; padding: var(--space-1); }

.palette__item { gap: var(--space-3); }
.palette__item.is-active { background: var(--color-primary-wash); }
.palette__item.is-active .search-result__name { color: var(--color-primary-hover); }

.palette__icon {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
}
.palette__icon svg { width: 14px; height: 14px; }
.palette__item.is-active .palette__icon { background: var(--color-primary); color: #fff; }

.palette__hint { flex: 0 0 auto; color: var(--color-text-faint); opacity: 0; }
.palette__hint svg { width: 14px; height: 14px; }
.palette__item.is-active .palette__hint { opacity: 1; color: var(--color-primary); }

.palette__foot {
  flex: 0 0 auto;
  display: flex;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.palette__foot span { display: inline-flex; align-items: center; gap: 4px; }

kbd,
.palette__kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  box-shadow: 0 1px 0 var(--color-border-strong);
  color: var(--color-text-muted);
}
.palette__kbd { background: var(--color-surface-muted); }

/* Inline toast action. Used for Undo, where reading and acting are one step. */
.toast__action {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #F0894A;
  padding: 3px 9px;
  margin-left: -9px;
  border-radius: var(--radius-sm);
  transition: background-color var(--dur-fast) var(--ease);
}
.toast__action:hover { background: rgba(240, 137, 74, 0.14); }

/* Sticky table headers lift once rows scroll beneath them. */
.table thead th::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -5px;
  height: 4px;
  background: linear-gradient(180deg, rgba(25, 22, 18, 0.055), transparent);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  pointer-events: none;
}
.table-wrap.is-scrolled thead th::after { opacity: 1; }
.table thead th { position: sticky; }

/* Menu that opens upward — used by the sidebar user card, which sits at the
   bottom of the panel and has no room below it. */
.menu--up {
  top: auto;
  bottom: calc(100% + 6px);
  left: 0;
  right: auto;
  min-width: 216px;
  animation: menu-up-in var(--dur-fast) var(--ease);
}
@keyframes menu-up-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.sidebar__footer .dropdown { display: block; }

/* The caret is the affordance that says "this opens something". */
.user-card { justify-content: flex-start; }
.user-card__caret {
  margin-left: auto;
  display: grid;
  place-items: center;
  color: var(--color-on-dark-muted);
  transition: transform var(--dur) var(--ease);
}
.user-card__caret svg { width: 14px; height: 14px; }
.user-card[aria-expanded="true"] .user-card__caret { transform: rotate(180deg); }

/* Header avatar button gains a caret for the same reason. */
.header__account { display: inline-flex; align-items: center; gap: 3px; }
.header__account svg { width: 13px; height: 13px; color: var(--color-text-faint); }
