/* Reusable pieces: buttons, panels, badges, tables, fields, dialog, toast. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: var(--t-md);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out), background-color 150ms ease, border-color 150ms ease;
}
.button:active { transform: scale(0.97); }
.button.primary { background: var(--cobalt); border-color: var(--cobalt); color: var(--cobalt-ink); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.subtle-danger { color: var(--danger); }
.button.block { width: 100%; min-height: 40px; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out), color 150ms ease, background-color 150ms ease;
}
.icon-button:active { transform: scale(0.94); }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  padding: 20px;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head.padded { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--line); align-items: center; }
.panel-meta { color: var(--muted); font-size: var(--t-sm); }
.panel-title { margin-bottom: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  vertical-align: middle;
  letter-spacing: 0;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active { color: var(--signal); background: var(--signal-soft); }
.badge-scheduled, .badge-maxed { color: var(--amber); background: var(--amber-soft); }
.badge-expired { color: var(--muted); background: var(--surface-2); }
.badge-dead { color: var(--danger); background: var(--danger-soft); }
.badge-failing { color: var(--amber); background: var(--amber-soft); }

.tag { display: inline-block; margin: 0 4px 4px 0; padding: 1px 8px; border-radius: var(--r-control); background: var(--surface-2); border: 1px solid var(--line); font-size: var(--t-sm); }

.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 600;
  text-align: left;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color 120ms ease; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: var(--t-sm); }
.cell-action { width: 1%; text-align: right; }
.code-link { color: var(--cobalt); text-decoration: none; }

.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 550;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--r-control);
  transition: transform var(--dur-press) var(--ease-out), color 150ms ease;
}
.button.copy { color: var(--ink); padding: 0 14px; border: 1px solid var(--line-strong); background: var(--surface); }
.copy:active { transform: scale(0.96); }
.copy-label { display: inline-block; min-width: 4.2em; text-align: left; transition: filter var(--dur-ui) ease, opacity var(--dur-ui) ease; }
.copy-label.is-swapping { filter: blur(2px); opacity: 0.4; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field-label { font-weight: 600; font-size: var(--t-sm); }
.optional { margin-left: 4px; color: var(--faint); font-weight: 400; }
.field-hint { color: var(--muted); font-size: var(--t-sm); }
.field-error { color: var(--danger); font-size: var(--t-sm); font-weight: 550; }
.prefixed { display: flex; }
.prefix { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--r-control) 0 0 var(--r-control); background: var(--surface-2); color: var(--muted); }
.prefixed input { border-radius: 0 var(--r-control) var(--r-control) 0; }

.alert, .notice { padding: 11px 14px; border-radius: var(--r-control); margin-bottom: 16px; font-size: var(--t-md); }
.alert { color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.notice { color: var(--ink); background: var(--cobalt-soft); border: 1px solid color-mix(in srgb, var(--cobalt) 25%, transparent); }

.state { padding: 56px 24px; text-align: center; display: grid; justify-items: center; gap: 10px; }
.state p { max-width: 44ch; color: var(--muted); }
.state .button { margin-top: 6px; }
.empty-inline { padding: 18px 0 4px; color: var(--muted); }

.dialog {
  width: min(420px, calc(100% - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.dialog h2 { margin-bottom: 8px; }
.dialog p { color: var(--muted); }
.dialog::backdrop { background: var(--overlay); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 24px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--canvas);
  font-weight: 550;
  box-shadow: var(--shadow-pop);
  translate: -50% 0;
}
