/* Component library — used by both the sign-in page and the dashboard. */

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  --btn-hover: var(--surface-hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--r);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 550;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.08s var(--ease), box-shadow 0.15s;
  user-select: none;
  text-decoration: none;
}
.btn:hover:not(:disabled) {
  background: var(--btn-hover);
  text-decoration: none;
}
.btn:active:not(:disabled) {
  transform: translateY(0.5px) scale(0.99);
}
.btn:disabled {
  opacity: 0.5;
}
.btn.primary {
  /* light mode's accent is already dark/saturated enough for --on-accent to clear 4.5:1 unmixed (verified: 4.83:1);
     dark mode's accent is much brighter, so it needs real darkening to stay legible - a single mix % can't serve
     both (darkening light mode's already-dark accent drags it toward --on-accent's own luminance and *loses*
     contrast), so bg/border/hover are tuned per theme, each checked against a real rendered screenshot */
  --btn-bg: light-dark(var(--accent), color-mix(in oklab, var(--accent) 90%, black));
  --btn-fg: var(--on-accent);
  --btn-border: light-dark(color-mix(in oklab, var(--accent) 90%, black), color-mix(in oklab, var(--accent) 78%, black));
  --btn-hover: light-dark(color-mix(in oklab, var(--accent) 98%, black), color-mix(in oklab, var(--accent) 84%, black));
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.18) inset, var(--shadow-xs);
}
.btn.danger {
  --btn-bg: var(--danger-soft);
  --btn-fg: var(--danger);
  --btn-border: color-mix(in oklab, var(--danger) 30%, transparent);
  --btn-hover: color-mix(in oklab, var(--danger) 20%, transparent);
  box-shadow: none;
}
.btn.danger.solid {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
  --btn-border: color-mix(in oklab, var(--danger) 80%, black);
  --btn-hover: color-mix(in oklab, var(--danger) 88%, black);
}
.btn.ghost {
  --btn-bg: transparent;
  --btn-border: transparent;
  box-shadow: none;
}
.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: var(--r-sm);
}
.btn.lg {
  height: 42px;
  padding: 0 18px;
  font-size: 14px;
  border-radius: 11px;
}
.btn.block {
  width: 100%;
}
.btn.icon-only {
  width: 34px;
  padding: 0;
}
.btn.icon-only.sm {
  width: 28px;
}
.btn .spinner {
  width: 14px;
  height: 14px;
}
.btn[data-busy="true"] {
  pointer-events: none;
  opacity: 0.85;
}

/* ---------- form controls ---------- */
.field {
  display: grid;
  gap: 6px;
}
.field > label,
.label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
}
.field .hint {
  font-size: 12px;
  color: var(--text-3);
}
.field .error-text {
  font-size: 12px;
  color: var(--danger);
}
.input,
.select,
.textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--r);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
}
.textarea {
  height: auto;
  min-height: 84px;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.5;
}
.select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8a96' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: color-mix(in oklab, var(--border-strong) 60%, var(--text-3));
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
}
.input.sm,
.select.sm {
  height: 30px;
  font-size: 12.5px;
}
.input.code-input {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.35em;
  text-align: center;
  height: 52px;
  padding-left: 0.35em;
}
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group > .icon {
  position: absolute;
  left: 11px;
  color: var(--text-3);
  pointer-events: none;
}
.input-group > .input {
  padding-left: 34px;
}
.input-group > .trail {
  position: absolute;
  right: 4px;
  display: flex;
  gap: 2px;
  align-items: center;
}
.input-group.has-trail > .input {
  padding-right: 40px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13.5px;
}
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
input[type="radio"] {
  border-radius: 50%;
}
input[type="checkbox"]:checked,
input[type="checkbox"]:indeterminate,
input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: translateY(-1px) rotate(-45deg);
}
input[type="checkbox"]:indeterminate::after {
  content: "";
  width: 8px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}
input[type="radio"]:checked::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}
input:focus-visible {
  box-shadow: var(--ring);
}

.switch {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
}
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--border-strong);
  transition: background 0.15s;
  pointer-events: none;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease);
}
.switch input:checked + span {
  background: var(--accent);
}
.switch input:checked + span::after {
  transform: translateX(14px);
}
.switch input:focus-visible + span {
  box-shadow: var(--ring);
}

/* segmented control */
.segmented {
  display: inline-flex;
  max-width: 100%;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  /* a status/filter segmented control (e.g. All/Unused/Active/Expired/Revoked) can have more items than a phone
     screen is wide - scroll it horizontally instead of letting it force the whole toolbar to overflow */
  overflow-x: auto;
  min-width: 0;
}
.segmented button {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  border-radius: 7px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented button:hover {
  color: var(--text);
}
.segmented button[aria-pressed="true"],
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.segmented .count {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.segmented.block {
  display: flex;
}
.segmented.block button {
  flex: 1;
  justify-content: center;
}

/* ---------- badges & chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--text-2);
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.success,
.badge-active {
  background: var(--success-soft);
  color: var(--success);
}
.badge.warning,
.badge-expired {
  background: var(--warning-soft);
  color: var(--warning);
}
.badge.danger,
.badge-revoked {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge.info,
.badge-unused {
  background: var(--info-soft);
  color: var(--info);
}
.badge.accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.badge.outline {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.badge.sm {
  height: 19px;
  font-size: 11px;
  padding: 0 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s;
}
.chip:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: color-mix(in oklab, var(--accent) 40%, transparent);
  color: var(--accent-strong);
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface-2);
  color: var(--text-2);
  font: 600 11px/1 var(--font);
}

/* ---------- cards & panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}
.card-head .sub {
  color: var(--text-3);
  font-size: 12.5px;
  margin-top: 2px;
}
.card-body {
  padding: 16px 18px 18px;
}
.card-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 0;
}

/* ---------- alerts ---------- */
.alert {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r);
  font-size: 13px;
  background: var(--info-soft);
  color: var(--text);
  border: 1px solid color-mix(in oklab, var(--info) 30%, transparent);
}
.alert > .icon {
  margin-top: 2px;
  color: var(--info);
}
.alert.success {
  background: var(--success-soft);
  border-color: color-mix(in oklab, var(--success) 30%, transparent);
}
.alert.success > .icon {
  color: var(--success);
}
.alert.warning {
  background: var(--warning-soft);
  border-color: color-mix(in oklab, var(--warning) 32%, transparent);
}
.alert.warning > .icon {
  color: var(--warning);
}
.alert.danger {
  background: var(--danger-soft);
  border-color: color-mix(in oklab, var(--danger) 32%, transparent);
}
.alert.danger > .icon {
  color: var(--danger);
}
.alert .alert-title {
  font-weight: 600;
}
.alert p {
  color: var(--text-2);
}

/* ---------- tables ---------- */
.table-wrap {
  overflow: auto;
  border-radius: inherit;
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.table th:first-child {
  border-top-left-radius: calc(var(--r-lg) - 1px);
}
.table th:last-child {
  border-top-right-radius: calc(var(--r-lg) - 1px);
}
.table th button.sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.table th button.sort:hover {
  color: var(--text);
}
.table th button.sort .icon {
  width: 13px;
  height: 13px;
  opacity: 0.55;
}
.table th[aria-sort="ascending"] button.sort,
.table th[aria-sort="descending"] button.sort {
  color: var(--text);
}
.table th[aria-sort] button.sort .icon {
  opacity: 1;
  color: var(--accent-strong);
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.table {
  min-width: 860px;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table tbody tr {
  transition: background 0.1s;
}
.table tbody tr:hover {
  background: var(--surface-hover);
}
.table tbody tr.clickable {
  cursor: pointer;
}
.table tbody tr[aria-selected="true"] {
  background: var(--accent-softer);
}
.table .col-check {
  width: 42px;
  padding-right: 0;
}
.table .col-actions {
  width: 52px;
  text-align: right;
}
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
[data-density="compact"] .table td {
  padding-top: 6px;
  padding-bottom: 6px;
}
[data-density="compact"] .table th {
  padding-top: 7px;
  padding-bottom: 7px;
}

.cell-stack {
  display: grid;
  line-height: 1.35;
}
.cell-stack .sub {
  font-size: 12px;
  color: var(--text-3);
}
.key-code {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
}
.copy-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  border: 0;
  background: transparent;
  color: var(--text-3);
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.icon-btn.copied {
  color: var(--success);
}
.reveal-on-hover .icon-btn.reveal {
  opacity: 0;
}
tr:hover .reveal-on-hover .icon-btn.reveal,
.reveal-on-hover:hover .icon-btn.reveal,
.reveal-on-hover .icon-btn.reveal:focus-visible {
  opacity: 1;
}

/* pagination bar */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
}
.pager .pager-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ---------- progress ---------- */
.progress {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s var(--ease);
}
.progress.success > i {
  background: var(--success);
}
.progress.warning > i {
  background: var(--warning);
}
.progress.danger > i {
  background: var(--danger);
}
.stackbar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px;
}
.stackbar > i {
  display: block;
  min-width: 3px;
  transition: flex-grow 0.4s var(--ease);
}

/* ---------- dialog / drawer ---------- */
dialog {
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: visible;
}
dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s var(--ease);
}
.modal {
  width: min(calc(100vw - 32px), var(--modal-w, 520px));
  max-height: min(calc(100dvh - 48px), 820px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.2s var(--ease);
  overflow: hidden;
}
.modal.sm {
  --modal-w: 420px;
}
.modal.lg {
  --modal-w: 720px;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 0;
}
.modal-head h2 {
  font-size: 17px;
  letter-spacing: -0.02em;
}
.modal-head p {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13px;
}
.modal-body {
  padding: 18px 22px;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.modal-body > *,
.drawer-body > * {
  min-width: 0;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
dialog.drawer-dialog {
  margin: 0 0 0 auto;
  height: 100dvh;
  max-height: none;
}
.drawer {
  width: min(100vw, var(--drawer-w, 560px));
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: slide-in 0.26s var(--ease);
}
.drawer-head {
  padding: 18px 22px 0;
  display: grid;
  gap: 12px;
}
.drawer-head .row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 18px 22px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-content: start;
}
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 0 -22px;
  padding: 0 22px;
}
.tabs button {
  position: relative;
  padding: 10px 12px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-weight: 550;
  font-size: 13.5px;
  display: inline-flex;
  gap: 7px;
  align-items: center;
}
.tabs button:hover {
  color: var(--text);
}
.tabs button[aria-selected="true"] {
  color: var(--text);
}
.tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}
@keyframes slide-in {
  from {
    transform: translateX(28px);
    opacity: 0;
  }
}
dialog.closing::backdrop {
  animation: fade-in 0.15s reverse forwards;
}
dialog.closing .modal {
  animation: pop-in 0.15s reverse forwards;
}
dialog.closing .drawer {
  animation: slide-in 0.18s reverse forwards;
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: start;
  padding: 12px 12px 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.28s var(--ease);
}
.toast.leaving {
  animation: toast-out 0.2s var(--ease) forwards;
}
.toast > .icon {
  margin-top: 1px;
}
.toast.success > .icon {
  color: var(--success);
}
.toast.error > .icon {
  color: var(--danger);
}
.toast.warning > .icon {
  color: var(--warning);
}
.toast.info > .icon {
  color: var(--info);
}
.toast .t-title {
  font-weight: 600;
  font-size: 13.5px;
}
.toast .t-msg {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 1px;
  overflow-wrap: anywhere;
}
.toast .t-action {
  margin-top: 8px;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ---------- popover menu & tooltip ---------- */
.menu {
  position: fixed;
  z-index: 1500;
  min-width: 200px;
  max-width: 320px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: menu-in 0.14s var(--ease);
  transform-origin: top;
}
.menu[data-side="top"] {
  transform-origin: bottom;
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(-3px);
  }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  text-align: left;
  font-size: 13.5px;
  color: var(--text);
}
.menu-item .icon {
  color: var(--text-3);
}
.menu-item:hover:not(:disabled),
.menu-item:focus-visible,
.menu-item[data-active="true"] {
  background: var(--surface-3);
  outline: none;
  box-shadow: none;
}
.menu-item.danger,
.menu-item.danger .icon {
  color: var(--danger);
}
.menu-item:disabled {
  opacity: 0.45;
}
.menu-item .kbds {
  margin-left: auto;
  display: flex;
  gap: 3px;
}
.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 5px -5px;
}
.menu-label {
  padding: 6px 10px 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tooltip {
  position: fixed;
  z-index: 3000;
  max-width: 280px;
  padding: 6px 9px;
  border-radius: 7px;
  background: light-dark(#18181b, #f4f4f6);
  color: light-dark(#f4f4f6, #18181b);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  animation: fade-in 0.12s;
  overflow-wrap: anywhere;
}

/* ---------- skeleton, empty, spinner ---------- */
.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}
.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-2);
}
.empty .empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-bottom: 6px;
}
.empty h3 {
  font-size: 15px;
  color: var(--text);
}
.empty p {
  max-width: 380px;
  font-size: 13.5px;
}
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in oklab, currentColor 25%, transparent);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ---------- password strength meter ---------- */
.meter {
  display: grid;
  gap: 8px;
}
.meter-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.meter-bars i {
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
  transition: background 0.2s;
}
.meter[data-score="0"] .meter-bars i:nth-child(-n + 1),
.meter[data-score="1"] .meter-bars i:nth-child(-n + 1) {
  background: var(--danger);
}
.meter[data-score="2"] .meter-bars i:nth-child(-n + 2) {
  background: var(--warning);
}
.meter[data-score="3"] .meter-bars i:nth-child(-n + 3) {
  background: color-mix(in oklab, var(--success) 70%, var(--warning));
}
.meter[data-score="4"] .meter-bars i {
  background: var(--success);
}
.meter-text {
  font-size: 12.5px;
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.meter ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-2);
}
.meter li {
  display: flex;
  gap: 7px;
  align-items: flex-start;
}
.meter li .icon {
  margin-top: 2px;
}
.meter li.bad .icon {
  color: var(--danger);
}
.meter li.ok .icon {
  color: var(--success);
}

/* ---------- code / secret display ---------- */
.codeblock {
  position: relative;
  border-radius: var(--r);
  background: light-dark(#0f0f13, #0b0b0e);
  color: #e8e8ee;
  border: 1px solid var(--border);
  font: 12.5px/1.6 var(--mono);
}
.codeblock pre {
  margin: 0;
  padding: 14px 44px 14px 16px;
  overflow: auto;
  white-space: pre;
}
.codeblock .copy {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #a1a1ab;
}
.codeblock .copy:hover {
  background: rgb(255 255 255 / 0.1);
  color: #fff;
}
.recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
}
.recovery-grid code {
  font-size: 14px;
  letter-spacing: 0.06em;
  padding: 6px 8px;
  text-align: center;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  user-select: all;
}
.secret-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.secret-box code {
  font-size: 13px;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
  user-select: all;
}
.qr {
  width: 176px;
  height: 176px;
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  image-rendering: pixelated;
}

/* ---------- timeline ---------- */
.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 12px;
  padding: 10px 0;
  align-items: start;
}
.timeline li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 14.5px;
  top: 40px;
  bottom: -6px;
  width: 1px;
  background: var(--border);
}
.timeline .tl-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--neutral-soft);
  color: var(--text-2);
}
.timeline .tl-icon.success {
  background: var(--success-soft);
  color: var(--success);
}
.timeline .tl-icon.danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.timeline .tl-icon.warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.timeline .tl-icon.info {
  background: var(--info-soft);
  color: var(--info);
}
.timeline .tl-icon.accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.timeline .tl-title {
  font-weight: 550;
  font-size: 13.5px;
}
.timeline .tl-sub {
  color: var(--text-3);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.timeline .tl-time {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
  padding-top: 2px;
}

/* ---------- avatar ---------- */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 55%, #ff5fa2));
  color: #fff;
  font-weight: 650;
  font-size: 12px;
  letter-spacing: 0.02em;
  overflow: hidden;
}
/* a real picture (uploaded, or from Google/Discord) fills the circle instead of the initials */
.avatar > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- misc helpers ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row.wrap {
  flex-wrap: wrap;
}
.row.between {
  justify-content: space-between;
}
.stack {
  display: grid;
  /* explicit minmax(0, 1fr), not the implicit single auto column grid defaults to: an auto column sizes to its
     widest child's max-content, so one wide grandchild (e.g. a usage row that doesn't wrap) could force every
     card in the stack wider than the viewport instead of shrinking to fit it */
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.grow {
  flex: 1;
  min-width: 0;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px 16px;
  font-size: 13.5px;
}
.kv dt {
  color: var(--text-3);
}
.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
