:root {
  color-scheme: light;
  --ink: #142320;
  --muted: #687571;
  --paper: #f4f1e9;
  --surface: #fffdf7;
  --surface-strong: #ffffff;
  --line: #d8d8ce;
  --line-strong: #bdc3b9;
  --jade: #0d6b55;
  --jade-dark: #084c3d;
  --jade-soft: #dcece5;
  --amber: #a86710;
  --amber-soft: #f7e8c9;
  --danger: #a33d37;
  --danger-soft: #f6dfdb;
  --shadow: 0 24px 80px rgba(26, 43, 38, .12);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(20, 35, 32, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 35, 32, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 44px 44px;
}

button, input { font: inherit; }
button { color: inherit; }
button, input[type="checkbox"] { cursor: pointer; }

button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(13, 107, 85, .24);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

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

.app-shell { min-height: 100vh; }

.topbar {
  height: 84px;
  padding: 0 clamp(24px, 5vw, 76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(20, 35, 32, .12);
  background: rgba(244, 241, 233, .86);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  border-radius: 11px 11px 11px 3px;
  font-family: "Songti SC", serif;
  font-size: 21px;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: .08em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .18em; }

.session-panel { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
.session-dot { width: 8px; height: 8px; border-radius: 50%; background: #2da271; box-shadow: 0 0 0 4px rgba(45, 162, 113, .12); }
.text-button { padding: 8px 4px; border: 0; color: var(--ink); background: transparent; font-weight: 650; }
.text-button:hover { color: var(--jade); }

main { padding: clamp(28px, 5vw, 72px) clamp(20px, 5vw, 76px) 76px; }

.login-view {
  min-height: calc(100vh - 230px);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 480px);
  gap: clamp(56px, 9vw, 148px);
  align-items: center;
  max-width: 1240px;
  margin: 0 auto;
}

.login-copy { max-width: 620px; }
.eyebrow, .card-kicker { margin: 0 0 14px; color: var(--jade); font-size: 12px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.login-copy h1 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(54px, 7vw, 94px); font-weight: 600; line-height: .98; letter-spacing: -.055em; }
.login-copy h1 em { color: var(--jade); font-style: normal; }
.login-copy > p:not(.eyebrow) { max-width: 520px; margin: 32px 0 0; color: var(--muted); font-size: 17px; line-height: 1.9; }
.trust-note { margin-top: 42px; display: flex; gap: 14px; align-items: center; max-width: 450px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.trust-line { flex: 0 0 40px; height: 1px; background: var(--jade); }

.login-card {
  display: grid;
  gap: 22px;
  padding: clamp(28px, 4vw, 48px);
  background: rgba(255, 253, 247, .94);
  border: 1px solid var(--line);
  border-radius: 3px 30px 30px 30px;
  box-shadow: var(--shadow);
}

.login-card h2, .dialog-heading h2 { margin: 0; font-family: "Songti SC", serif; font-size: 30px; font-weight: 650; }
label > span { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 750; }
input:not([type="checkbox"]) {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
input:not([type="checkbox"]):focus { border-color: var(--jade); box-shadow: 0 0 0 4px rgba(13, 107, 85, .08); }
input::placeholder { color: #9ba39f; }

.primary-button, .secondary-button {
  min-height: 49px;
  display: inline-flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 750;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.primary-button { color: #fff; background: var(--jade); }
.primary-button:hover { background: var(--jade-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.primary-button.compact { width: auto; min-height: 44px; }
.secondary-button { background: transparent; border-color: var(--line-strong); }
.secondary-button:hover { background: #eeece4; }
.login-footnote { margin: -5px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.form-error { min-height: 20px; margin: -8px 0 0; color: var(--danger); font-size: 13px; }

.dashboard-view { max-width: 1440px; margin: 0 auto; }
.dashboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.dashboard-heading h1 { margin: 0; font-family: "Songti SC", serif; font-size: clamp(38px, 5vw, 62px); font-weight: 600; letter-spacing: -.035em; }
.dashboard-heading > div > p:last-child { margin: 12px 0 0; color: var(--muted); }

.metric-grid { margin-top: 38px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-card { min-height: 155px; padding: 23px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-card.accent { color: white; background: var(--ink); border-color: var(--ink); border-radius: 3px var(--radius) var(--radius) var(--radius); }
.metric-card > span { color: var(--muted); font-size: 13px; font-weight: 750; }
.metric-card.accent > span, .metric-card.accent small { color: #b7c9c3; }
.metric-card strong { margin-top: 12px; font-family: "Songti SC", serif; font-size: 42px; font-weight: 600; line-height: 1; }
.metric-card small { margin-top: auto; color: var(--muted); }

.registry-card { margin-top: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 44px rgba(26, 43, 38, .06); }
.registry-toolbar { min-height: 94px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.registry-toolbar h2 { margin: 0; font-size: 18px; }
.registry-toolbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.search-field { width: min(290px, 40vw); position: relative; }
.search-field > span:not(.sr-only) { position: absolute; left: 14px; top: 13px; color: var(--muted); font-size: 19px; }
.search-field input { height: 44px; padding-left: 42px; background: #f7f5ee; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 17px 22px; text-align: left; border-bottom: 1px solid #e8e6de; white-space: nowrap; }
th { color: var(--muted); background: #faf8f2; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #f9f7f0; }
tbody tr:last-child td { border-bottom: 0; }
.account-cell { display: flex; gap: 12px; align-items: center; }
.account-avatar { width: 36px; height: 36px; display: grid; place-items: center; color: var(--jade); background: var(--jade-soft); border-radius: 10px; font-weight: 800; }
.account-cell strong, .account-cell small { display: block; }
.account-cell small { margin-top: 2px; color: var(--muted); }
.status-badge { display: inline-flex; gap: 7px; align-items: center; padding: 6px 9px; border-radius: 999px; color: var(--jade-dark); background: var(--jade-soft); font-size: 12px; font-weight: 750; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.pending { color: var(--amber); background: var(--amber-soft); }
.status-badge.expired, .status-badge.disabled { color: var(--danger); background: var(--danger-soft); }
.edit-button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: transparent; font-weight: 700; }
.edit-button:hover { color: var(--jade); border-color: var(--jade); }
.empty-state { padding: 70px 24px; text-align: center; }
.empty-state > span { font-size: 36px; color: var(--jade); }
.empty-state h3 { margin: 12px 0 4px; }
.empty-state p { margin: 0; color: var(--muted); }

.account-dialog {
  width: min(620px, calc(100vw - 28px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.account-dialog::backdrop { background: rgba(10, 25, 21, .58); backdrop-filter: blur(5px); }
.account-dialog form { padding: 30px; display: grid; gap: 20px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: #efede6; font-size: 24px; line-height: 1; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label small { display: block; margin-top: 7px; color: var(--muted); line-height: 1.4; }
.switch-row { padding: 14px 15px; display: flex; align-items: center; gap: 14px; background: #f4f2eb; border: 1px solid var(--line); border-radius: 12px; }
.switch-row > span:first-child { flex: 1; margin: 0; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 14px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 42px; height: 24px; position: relative; flex: 0 0 auto; margin: 0; background: #a7aaa5; border-radius: 999px; transition: background .16s ease; }
.switch::after { content: ""; width: 18px; height: 18px; position: absolute; top: 3px; left: 3px; background: #fff; border-radius: 50%; transition: transform .16s ease; box-shadow: 0 2px 5px rgba(0,0,0,.18); }
.switch-row input:checked + .switch { background: var(--jade); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 3px solid rgba(13, 107, 85, .24); outline-offset: 2px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 48px)); padding: 15px 18px; color: white; background: var(--ink); border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; z-index: 10; }

@media (max-width: 920px) {
  .login-view { grid-template-columns: 1fr; gap: 44px; }
  .login-copy { padding-top: 24px; }
  .login-copy h1 { font-size: clamp(50px, 13vw, 76px); }
  .login-card { max-width: 560px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .topbar { height: 70px; padding: 0 18px; }
  .brand-mark { width: 38px; height: 38px; }
  .session-panel #current-account, .session-dot { display: none; }
  main { padding: 28px 14px 54px; }
  .login-view { min-height: auto; }
  .login-copy > p:not(.eyebrow), .trust-note { margin-top: 22px; }
  .login-card { padding: 25px 20px; border-radius: 3px 22px 22px 22px; }
  .dashboard-heading { align-items: start; flex-direction: column; }
  .dashboard-heading .primary-button { width: 100%; }
  .metric-grid { margin-top: 26px; grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 133px; padding: 17px; }
  .metric-card strong { font-size: 34px; }
  .registry-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .field-grid { grid-template-columns: 1fr; }
  .account-dialog form { padding: 23px 18px; }
}

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