/* Shared components: buttons, form controls, dropdown, cards, badges, tabs,
   stat tiles, tables, empty states. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover {
  background: var(--surface-3);
  border-color: var(--ink-3);
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 14px rgba(76, 141, 255, 0.25);
}
.btn.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.btn.danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.btn.danger-ghost {
  background: transparent;
  color: var(--bad);
  border-color: var(--bad-soft);
}
.btn.danger-ghost:hover {
  background: var(--bad-soft);
}
.btn.sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}
.btn.block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.on {
  color: var(--good);
  border-color: var(--good);
  background: var(--good-soft);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-btn svg {
  width: 17px;
  height: 17px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ---------- Form controls ---------- */
.input,
textarea.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--inset);
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input {
  height: auto;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder {
  color: var(--ink-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.field-hint {
  font-size: 12px;
  color: var(--ink-3);
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.search {
  position: relative;
}
.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink-3);
}
.search .input {
  padding-left: 34px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
}
.switch {
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: transform 0.18s var(--ease), background 0.18s;
}
.switch[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
}
.switch[aria-checked='true']::after {
  transform: translateX(18px);
  background: #fff;
}

/* ---------- Bespoke dropdown (components/dropdown.js) ---------- */
.dd {
  position: relative;
  width: 100%;
  font-size: 13.5px;
}
.dd-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--inset);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.dd-btn:hover {
  border-color: var(--ink-3);
}
.dd.open .dd-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dd-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dd.is-placeholder .dd-label {
  color: var(--ink-3);
}
.dd-chev {
  color: var(--ink-3);
  font-size: 10px;
  transition: transform 0.18s;
}
.dd.open .dd-chev {
  transform: rotate(180deg);
}
.dd.dd-disabled {
  opacity: 0.5;
  pointer-events: none;
}
.dd-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  z-index: 60;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 5px;
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  animation: rise 0.12s var(--ease);
}
.dd-up .dd-panel {
  top: auto;
  bottom: calc(100% + 6px);
}
.dd-opt {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.dd-opt:hover {
  background: var(--surface-3);
}
.dd-opt.active {
  color: var(--accent-2);
  background: var(--accent-soft);
}
.dd-opt.disabled {
  color: var(--ink-3);
  cursor: not-allowed;
}
.dd-opt-main {
  flex: 1;
}
.dd-opt-hint {
  font-size: 11.5px;
  color: var(--ink-3);
}
.dd-opt-tick {
  color: var(--accent);
  opacity: 0;
}
.dd-opt.active .dd-opt-tick {
  opacity: 1;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card-pad {
  padding: 18px 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.card-title {
  font-size: 14.5px;
  font-weight: 650;
}
.card-sub {
  font-size: 12.5px;
  color: var(--ink-3);
}
.card-body {
  padding: 18px 20px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  background: var(--surface-2);
}
.badge.good,
.badge.pass,
.badge.validated {
  color: var(--good);
  border-color: transparent;
  background: var(--good-soft);
}
.badge.bad,
.badge.fail,
.badge.returned {
  color: var(--bad);
  border-color: transparent;
  background: var(--bad-soft);
}
.badge.warn,
.badge.inconclusive,
.badge.testing {
  color: var(--warn);
  border-color: transparent;
  background: var(--warn-soft);
}
.badge.accent,
.badge.new {
  color: var(--accent-2);
  border-color: transparent;
  background: var(--accent-soft);
}
.badge.violet,
.badge.superseded {
  color: var(--violet);
  border-color: transparent;
  background: var(--violet-soft);
}
.badge.dead {
  color: var(--ink-3);
  text-decoration: line-through;
}
/* Parked for revival rounds: out of the regular pools, not dead. */
.badge.reserve {
  color: var(--violet);
  border-style: dashed;
  border-color: var(--violet);
  background: transparent;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------- Tabs & segmented ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}
.tabs a,
.tabs button {
  padding: 10px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  margin-bottom: -1px;
}
.tabs a:hover,
.tabs button:hover {
  color: var(--ink);
}
.tabs .active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--inset);
  border: 1px solid var(--line);
  gap: 2px;
  flex-wrap: wrap;
}
.seg button,
.seg a {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.seg button:hover,
.seg a:hover {
  color: var(--ink);
}
.seg button.active,
.seg a.active {
  background: var(--surface-3);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.seg .count {
  margin-left: 5px;
  color: var(--ink-3);
  font-weight: 500;
}

/* ---------- Stat tiles ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  color: var(--ink);
}
a.stat:hover {
  border-color: var(--accent-line);
  color: var(--ink);
}
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table th.sortable {
  cursor: pointer;
  user-select: none;
}
.table th.sortable:hover,
.table th.sorted {
  color: var(--ink);
}
/* Names a group of columns; the header row below names each one. */
.table th.th-group {
  text-align: center;
  color: var(--ink-2);
  padding: 6px 12px;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table .n {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.table tbody tr.clickable {
  cursor: pointer;
}
.table tbody tr.clickable:hover td {
  background: var(--surface-2);
}
.table .cell-main {
  font-weight: 600;
}
.table .cell-sub {
  font-size: 12px;
  color: var(--ink-3);
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-2);
}
.empty-ico {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty-ico svg {
  width: 22px;
  height: 22px;
}
.empty-title {
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 4px;
}
.empty p {
  max-width: 52ch;
  margin: 0 auto;
  font-size: 13px;
}
