:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f9;
  color: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f4f6f9;
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.title {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.subtitle {
  color: #64748b;
  font-size: 13px;
  margin-top: 6px;
}

.nav-link {
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.panel {
  background: #ffffff;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.06);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd7e3;
  border-radius: 6px;
  padding: 11px 12px;
  color: #111827;
  background: #ffffff;
  font: inherit;
}

textarea {
  min-height: 180px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

button {
  border: 0;
  border-radius: 6px;
  background: #111827;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 11px 14px;
}

button.secondary {
  background: #e8edf5;
  color: #172033;
}

button.danger {
  background: #b42318;
}

.result {
  margin-top: 14px;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
  min-height: 86px;
}

.code {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 4px;
}

.meta {
  color: #64748b;
  font-size: 13px;
  margin-top: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-item {
  background: #ffffff;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  padding: 14px 16px;
}

.summary-item span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  color: #111827;
  font-size: 20px;
}

.admin-import {
  margin-bottom: 18px;
}

.form-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin: 18px 0;
}

.compact-panel {
  margin: 18px 0;
  padding: 14px;
}

.toolbar .search {
  flex: 1;
}

.filter-field {
  width: 170px;
}

.filter-field.small {
  width: 110px;
}

.table-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.table-head h2 {
  margin: 0;
  color: #111827;
  font-size: 16px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.account-cards {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 1060px;
}

th,
td {
  border-bottom: 1px solid #e5eaf1;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #475569;
  font-size: 12px;
  white-space: nowrap;
}

.sort-link {
  color: inherit;
  font-weight: 800;
  text-decoration: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.badge.success {
  background: #dcfce7;
  color: #166534;
}

.badge.muted {
  background: #eef2f7;
  color: #475569;
}

.card-key {
  display: inline-block;
  max-width: 220px;
  overflow-wrap: anywhere;
  color: #111827;
  font-size: 12px;
}

.email-cell {
  color: #172033;
  font-weight: 700;
  white-space: nowrap;
}

.remark-input {
  min-width: 150px;
  padding: 8px 9px;
  font-size: 13px;
}

.error-cell {
  max-width: 220px;
  color: #b42318;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions button {
  padding: 8px 10px;
  font-size: 12px;
}

.account-card {
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.account-card + .account-card,
.empty-card {
  margin-top: 12px;
}

.account-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.account-card-email {
  min-width: 0;
  color: #111827;
  font-size: 15px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.mobile-fields {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.mobile-fields div {
  border-top: 1px solid #e5eaf1;
  padding-top: 10px;
  min-width: 0;
}

.mobile-fields span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.mobile-fields strong,
.mobile-fields em {
  display: block;
  color: #172033;
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.mobile-fields em {
  color: #64748b;
  font-size: 12px;
  margin-top: 4px;
}

.mobile-error strong {
  color: #b42318;
}

.mobile-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.mobile-actions button {
  min-height: 40px;
  width: 100%;
}

.empty-card {
  border: 1px dashed #cfd7e3;
  border-radius: 8px;
  color: #64748b;
  padding: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
  color: #166534;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.14);
  font-size: 14px;
  font-weight: 800;
  max-width: min(420px, calc(100vw - 32px));
  opacity: 0;
  padding: 12px 14px;
  transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.user-shell {
  min-height: 100vh;
  width: min(720px, calc(100vw - 32px));
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 32px 0;
}

.user-panel {
  background: #ffffff;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 44px rgba(17, 24, 39, 0.08);
}

.user-header {
  margin-bottom: 24px;
}

.eyebrow {
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.user-header h1 {
  margin: 8px 0 0;
  color: #111827;
  font-size: 30px;
  letter-spacing: 0;
}

.user-header p {
  max-width: 560px;
  margin: 10px 0 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.7;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 12px;
}

.access-key-input {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
}

.user-result {
  margin-top: 18px;
  min-height: 144px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.user-result.is-idle {
  background: #f8fafc;
}

.user-result.is-loading {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.user-result.is-success {
  background: #f7fdf9;
  border-color: #bbf7d0;
}

.user-result.is-error {
  background: #fff7f7;
  border-color: #fecaca;
}

.result-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.result-message {
  margin-top: 12px;
  color: #172033;
  font-size: 15px;
  line-height: 1.7;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.detail-grid div {
  border-top: 1px solid #e5eaf1;
  padding-top: 10px;
  min-width: 0;
}

.detail-grid span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  color: #172033;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.copy-code-btn {
  width: 100%;
  margin-top: 12px;
}

.user-footnote {
  color: #64748b;
  font-size: 12px;
  line-height: 1.6;
  margin-top: 16px;
  text-align: center;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding: 16px 0 28px;
  }

  .grid,
  .toolbar {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }

  .title {
    font-size: 22px;
  }

  .subtitle {
    line-height: 1.5;
  }

  .nav-link {
    align-items: center;
    background: #e8edf5;
    border-radius: 6px;
    color: #172033;
    display: inline-flex;
    min-height: 38px;
    padding: 0 12px;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .summary-item {
    padding: 10px;
  }

  .summary-item span {
    font-size: 11px;
  }

  .summary-item strong {
    font-size: 16px;
    overflow-wrap: anywhere;
  }

  .panel {
    padding: 14px;
  }

  textarea {
    min-height: 130px;
  }

  button,
  input,
  textarea,
  select {
    min-height: 42px;
  }

  .form-footer,
  .table-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-footer {
    gap: 8px;
  }

  .form-footer button,
  .toolbar button {
    width: 100%;
  }

  .compact-panel,
  .toolbar {
    margin: 12px 0;
  }

  .filter-field,
  .filter-field.small {
    width: 100%;
  }

  .table-wrap {
    display: none;
  }

  .account-cards {
    display: block;
  }

  .remark-input {
    min-width: 0;
  }

  .card-key {
    max-width: 100%;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
  }

  .user-panel {
    padding: 22px;
  }

  .user-header h1 {
    font-size: 26px;
  }

  .user-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
