:root {
  --bg: #f4f7fb;
  --wallpaper: radial-gradient(circle at top left, rgba(148, 163, 184, 0.16), transparent 22%), linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0f172a;
  --primary-soft: #e2e8f0;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --warn-bg: #fef3c7;
  --warn-text: #a16207;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --disabled-bg: #e2e8f0;
  --disabled-text: #475569;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.74) 0%, rgba(238, 242, 247, 0.84) 100%),
    var(--wallpaper);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

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

.hero-card,
.stats-card,
.filter-card,
.table-card,
.dialog-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(226, 232, 240, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border-radius: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.08;
}

.hero-copy p:last-child {
  margin: 14px 0 0;
  color: var(--muted);
  max-width: 720px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: flex-end;
  gap: 12px;
  min-width: 240px;
}

.switcher {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.switch-btn {
  border-radius: 14px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.switch-btn.active {
  background: var(--primary);
  color: #fff;
}

.import-label {
  display: inline-flex;
}

.import-label .ghost-btn {
  display: inline-flex;
  align-items: center;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn,
.toggle-visibility {
  border-radius: 18px;
  padding: 12px 16px;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.ghost-btn,
.icon-btn,
.toggle-visibility {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-btn {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.12);
}

.compact-btn {
  padding: 9px 12px;
  border-radius: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.stats-card {
  border-radius: 24px;
  padding: 22px 24px;
}

.stats-card span {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
}

.stats-card strong {
  display: block;
  margin-top: 12px;
  font-size: 2.2rem;
  line-height: 1;
}

.filter-card,
.table-card {
  margin-top: 18px;
  border-radius: 28px;
}

.filter-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
}

.search-box input,
.filter-actions select,
.dialog-form input,
.dialog-form select,
.dialog-form textarea,
.table-secret-field input,
.account-cell input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
}

.search-box input:focus,
.filter-actions select:focus,
.dialog-form input:focus,
.dialog-form select:focus,
.dialog-form textarea:focus {
  outline: 2px solid rgba(15, 23, 42, 0.08);
  border-color: #94a3b8;
}

.filter-actions {
  width: 200px;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-actions select {
  width: 148px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
}

.selected-count {
  color: var(--muted);
  font-size: 0.92rem;
}

.section-head {
  padding: 22px 24px 10px;
}

.section-head h2,
.dialog-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.section-head p,
.dialog-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1000px;
  border-collapse: collapse;
}

thead {
  background: var(--surface-soft);
}

th,
td {
  padding: 16px;
  border-top: 1px solid #f1f5f9;
  text-align: left;
  vertical-align: middle;
  font-size: 0.95rem;
}

th {
  color: var(--muted);
  font-weight: 600;
  border-top: 0;
}

tbody tr:hover {
  background: rgba(248, 250, 252, 0.9);
}

.checkbox-col {
  width: 56px;
  text-align: center;
}

.checkbox-col input {
  width: 18px;
  height: 18px;
}

.actions-col {
  text-align: right;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.account-cell {
  display: grid;
  gap: 6px;
}

.account-cell input,
.table-secret-field input {
  min-width: 180px;
}

.notes-text {
  display: inline-block;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.secret-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.toggle-visibility {
  white-space: nowrap;
}

input[data-copyable="true"],
input[data-field="email"],
input[data-field="password"],
input[data-field="secret"] {
  cursor: copy;
}

.copied {
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

select[data-field="status"] {
  min-width: 104px;
  border-radius: 999px;
  padding: 10px 14px;
  border: 0;
  font-weight: 700;
  text-align: center;
  appearance: none;
}

select[data-field="status"][data-status="使用中"],
select[data-field="status"][data-status="未使用"] {
  background: var(--success-bg);
  color: var(--success-text);
}

select[data-field="status"][data-status="异常"] {
  background: var(--danger-bg);
  color: var(--danger-text);
}

select[data-field="status"][data-status="停用"],
select[data-field="status"][data-status="已失效"] {
  background: var(--disabled-bg);
  color: var(--disabled-text);
}

select[data-field="status"][data-status="已使用"] {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 30;
}

.dialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.hidden {
  display: none;
}

.dialog-card {
  width: min(760px, 100%);
  border-radius: 28px;
  padding: 24px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

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

.dialog-form label {
  display: grid;
  gap: 8px;
}

.dialog-form .full {
  grid-column: 1 / -1;
}

.dialog-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.empty-cell {
  padding: 56px 16px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 60;
  max-width: min(320px, calc(100vw - 32px));
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.96);
  color: #fff;
  padding: 14px 18px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@media (max-width: 900px) {
  .hero-card,
  .filter-card {
    display: grid;
  }

  .hero-actions,
  .filter-actions {
    width: 100%;
  }

  .hero-actions button,
  .hero-actions .import-label,
  .filter-actions select {
    width: 100%;
  }

  .bulk-actions {
    width: 100%;
  }

  .bulk-actions > * {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 20px, 1280px);
    padding-top: 14px;
  }

  .hero-card,
  .stats-card,
  .filter-card,
  .table-card,
  .dialog-card {
    border-radius: 22px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .row-actions {
    flex-direction: column;
  }
}
