:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --ink: #202124;
  --muted: #7b7f83;
  --line: #eceeef;
  --line-strong: #dcdfe3;
  --brand: #18a058;
  --brand-hover: #0c7a43;
  --brand-soft: #e6f6ee;
  --blue: #2080f0;
  --blue-soft: #e8f3ff;
  --danger: #b43b42;
  --danger-soft: #fae9ea;
  --warning: #a96416;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
  --radius: 4px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.topbar {
  min-height: 70px;
  padding: 0 20px;
  background: var(--surface);
}

.topbar-inner {
  width: min(1080px, 100%);
  min-height: 70px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  object-fit: contain;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
  line-height: 1.25;
}

.section-heading p,
.results-toolbar p,
.modal-header p,
.empty-state p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  min-height: 34px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius);
  color: #42464a;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.nav-link svg {
  width: 15px;
  height: 15px;
}

.nav-link:hover,
.nav-link.active {
  color: var(--brand);
  background: #f3faf6;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  margin-left: 5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa6a2;
  box-shadow: 0 0 0 3px #edf0ef;
}

.connection[data-state="online"] {
  color: var(--brand);
}

.connection[data-state="online"] .status-dot {
  background: #1a936f;
  box-shadow: 0 0 0 3px #dcefe8;
}

.connection[data-state="error"] {
  color: var(--danger);
}

.connection[data-state="error"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.control-band {
  margin: 18px 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.control-inner {
  width: 100%;
  margin: 0 auto;
  padding: 22px 20px;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.page-intro {
  margin: 28px 20px 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.page-intro h2 {
  font-size: 21px;
}

.page-intro p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.service-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.results-section {
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 24px;
}

.section-heading,
.results-toolbar,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h2,
.results-toolbar h2,
.modal-header h2 {
  font-size: 18px;
  line-height: 1.3;
}

.create-form {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(100px, 0.42fr) minmax(180px, 0.9fr) auto;
  gap: 12px;
  align-items: end;
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field > span,
.field-label-row > label {
  color: #44514d;
  font-size: 12px;
  font-weight: 700;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.random-prefix-button {
  min-height: 22px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.random-prefix-button:hover {
  background: var(--brand-soft);
}

.random-prefix-button svg {
  width: 14px;
  height: 14px;
}

input,
select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  padding: 0 11px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 85, 0.12);
}

.button,
.icon-button,
.password-toggle,
.mini-button {
  border: 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button {
  min-height: 40px;
  gap: 8px;
  padding: 0 15px;
  font-size: 13px;
  font-weight: 750;
}

.button svg,
.icon-button svg,
.password-toggle svg,
.mini-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.button.primary {
  background: var(--brand);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.button.secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: #34423e;
}

.button.secondary:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.mini-button:hover:not(:disabled) {
  background: #edf2f0;
}

.create-button {
  min-width: 126px;
}

.progress-wrap {
  margin-top: 18px;
}

.progress-meta {
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #e7ecea;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: var(--brand);
  transition: width 0.2s ease;
}

.results-section {
  padding-top: 26px;
}

.results-toolbar {
  margin-bottom: 14px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.password-toggle {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: #43514d;
}

.danger-ghost {
  color: var(--danger);
}

.danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
}

.is-spinning svg,
.button svg[data-lucide="loader-circle"] {
  animation: spin 0.8s linear infinite;
}

.toggle-control {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  color: #44514d;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.toggle-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle {
  width: 34px;
  height: 19px;
  position: relative;
  border-radius: 10px;
  background: #abb5b1;
  transition: background 0.16s;
}

.toggle::after {
  content: "";
  width: 15px;
  height: 15px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s;
}

.toggle-control input:checked + .toggle {
  background: var(--brand);
}

.toggle-control input:checked + .toggle::after {
  transform: translateX(15px);
}

.toggle-control input:focus-visible + .toggle {
  box-shadow: 0 0 0 3px rgba(23, 107, 85, 0.16);
}

.table-shell {
  position: relative;
  min-height: 310px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  table-layout: fixed;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 42px;
  border-bottom: 1px solid var(--line-strong);
  background: #fafafa;
  color: #56635f;
  text-align: left;
  font-size: 12px;
  font-weight: 750;
}

th,
td {
  padding: 10px 12px;
  vertical-align: middle;
}

td {
  height: 68px;
  border-bottom: 1px solid var(--line);
  color: #283632;
  font-size: 13px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f9fbfa;
}

.col-index {
  width: 48px;
  text-align: center;
}

.col-address {
  width: 225px;
}

.col-password {
  width: 170px;
}

.col-api {
  width: 150px;
}

.col-content {
  width: auto;
}

.col-actions {
  width: 92px;
  text-align: right;
}

.mono,
.address-text,
.password-text,
.code-pill {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.address-cell,
.password-cell,
.api-cell,
.row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.address-text,
.password-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.address-text {
  font-weight: 700;
}

.password-text.masked {
  letter-spacing: 1px;
}

.mini-button {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  background: transparent;
  color: #5f6d68;
}

.credential-button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.credential-button:hover:not(:disabled) {
  background: var(--brand-soft);
}

.api-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.api-link:hover {
  text-decoration: underline;
}

.api-link svg {
  width: 15px;
  height: 15px;
}

.mail-content {
  min-width: 0;
}

.mail-primary,
.mail-secondary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #25332f;
  font-weight: 650;
}

.mail-secondary {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.code-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 23px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
}

.code-pill {
  background: var(--brand-soft);
  color: var(--brand);
}

.status-pill.waiting {
  background: #eef1f0;
  color: #687570;
}

.status-pill.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.row-actions {
  justify-content: flex-end;
}

.empty-state {
  min-height: 308px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  color: #92a09b;
}

.empty-state h3 {
  font-size: 15px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 31, 27, 0.46);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(440px, 100%);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-header {
  align-items: flex-start;
  margin-bottom: 20px;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  border: 0;
  background: transparent;
}

.form-error {
  margin-top: 10px;
  color: var(--danger);
  font-size: 12px;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

.toast-region {
  position: fixed;
  z-index: 40;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 11px 13px;
  color: #2f3d39;
  font-size: 13px;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin-top: 1px;
}

.sr-only {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.site-footer {
  width: min(1080px, calc(100% - 40px));
  margin: 22px auto 0;
  padding: 20px 0 34px;
  display: flex;
  justify-content: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.site-footer a {
  color: #5f6468;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--brand);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 820px) {
  .create-form {
    grid-template-columns: 1fr 110px;
  }

  .field-domain {
    grid-column: 1 / 2;
  }

  .create-button {
    grid-column: 2 / 3;
  }

  .results-toolbar {
    align-items: flex-end;
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 64px;
    padding: 0 14px;
  }

  .topbar-inner {
    min-height: 64px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .connection span:last-child {
    display: none;
  }

  .site-nav {
    gap: 1px;
  }

  .nav-link {
    width: 34px;
    min-height: 34px;
    justify-content: center;
    padding: 0;
  }

  .nav-link span,
  .reader-link,
  .version-link {
    display: none;
  }

  .connection {
    margin-left: 4px;
  }

  .page-intro {
    margin: 20px 14px 0;
    align-items: flex-start;
  }

  .page-intro h2 {
    font-size: 19px;
  }

  .service-chip {
    display: none;
  }

  .control-band {
    margin: 14px 14px 0;
  }

  .control-inner {
    padding: 18px 14px;
  }

  .results-section {
    padding: 23px 14px 19px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .section-heading .button span {
    display: none;
  }

  .section-heading .button {
    width: 40px;
    padding: 0;
  }

  .create-form {
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 10px;
  }

  .field-domain,
  .create-button {
    grid-column: 1 / -1;
  }

  .results-toolbar {
    display: block;
  }

  .toolbar-actions {
    margin-top: 12px;
    justify-content: flex-end;
  }

  .toggle-control {
    margin-right: auto;
    padding-left: 0;
  }

  .table-shell {
    min-height: 350px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
