:root {
  color-scheme: light;
  --canvas: #f2f5f3;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --surface-strong: #edf2ef;
  --ink: #17231f;
  --ink-soft: #344a42;
  --muted: #64736d;
  --faint: #8a9691;
  --border: #d8e0dc;
  --border-strong: #bccac3;
  --accent: #14684f;
  --accent-hover: #0e543f;
  --accent-soft: #e8f3ee;
  --nav: #173b32;
  --nav-hover: #214b40;
  --blue: #28658d;
  --blue-soft: #eaf2f7;
  --amber: #a95e0c;
  --amber-soft: #fff3df;
  --red: #b42318;
  --red-soft: #fdefec;
  --shadow-sm: 0 1px 2px rgba(20, 42, 33, 0.06);
  --shadow-md: 0 10px 30px rgba(20, 42, 33, 0.09);
  --sidebar-width: 240px;
  --topbar-height: 64px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-synthesis: none;
  letter-spacing: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
}

body.is-drawer-open {
  overflow: hidden;
}

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

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
}

img {
  max-width: 100%;
}

h1,
h2,
h3,
p,
dl,
dd,
ol {
  margin: 0;
}

h1,
h2,
h3,
strong {
  font-weight: 650;
}

code,
.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

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

:focus-visible {
  outline: 3px solid rgba(40, 101, 141, 0.25);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 9px 13px;
  border-radius: 5px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.icon {
  flex: 0 0 auto;
  pointer-events: none;
}

.icon-flip {
  transform: scaleX(-1);
}

.muted {
  color: var(--muted);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
}

.brand-inverse {
  color: #fff;
}

.brand-inverse .brand-mark {
  background: rgba(255, 255, 255, 0.13);
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 600;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  line-height: 1.2;
  white-space: nowrap;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-primary.is-success {
  border-color: #17764f;
  background: #17764f;
}

.button-primary.is-error {
  border-color: var(--red);
  background: var(--red);
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
}

.button-secondary:hover:not(:disabled) {
  border-color: #91a39b;
  background: var(--surface-muted);
  color: var(--ink);
}

.button-small {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 13px;
}

.button-block {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  padding: 0;
  border-color: var(--border);
  background: var(--surface);
  color: var(--ink-soft);
}

.icon-button:hover:not(.is-disabled) {
  border-color: var(--border-strong);
  background: var(--surface-strong);
  color: var(--ink);
}

.icon-button.is-disabled {
  cursor: default;
  opacity: 0.45;
  pointer-events: none;
}

.icon-button-inverse {
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
}

.icon-button-inverse:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.danger-quiet {
  color: var(--red);
}

.danger-quiet:hover {
  border-color: #e0aaa5;
  background: var(--red-soft);
}

.success-quiet {
  color: var(--accent);
}

.success-quiet:hover {
  border-color: #9bc4b4;
  background: var(--accent-soft);
}

.button-spinner {
  display: none;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.button.is-loading .button-spinner {
  display: block;
}

.button.is-loading .button-icon,
.button.is-loading > .icon {
  display: none;
}

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

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

.field-group label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.label-optional {
  margin-left: 5px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input,
select {
  height: 44px;
  padding: 9px 12px;
}

select {
  padding-right: 34px;
}

textarea {
  min-height: 110px;
  padding: 11px 12px;
  line-height: 1.55;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #929e99;
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #9babaa;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 101, 141, 0.12);
  outline: 0;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.09);
}

.input-prefix {
  display: flex;
  height: 44px;
  overflow: hidden;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input-prefix:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 101, 141, 0.12);
}

.input-prefix > span {
  display: grid;
  width: 42px;
  height: 100%;
  flex: 0 0 42px;
  place-items: center;
  border-right: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--muted);
  font-weight: 650;
}

.input-prefix input {
  height: 42px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.input-prefix input:focus {
  box-shadow: none;
}

.stack-form {
  display: grid;
  gap: 20px;
}

.field-error {
  min-height: 0;
  color: var(--red);
  font-size: 12px;
  line-height: 1.35;
}

.field-error:empty {
  display: none;
}

.form-alert {
  padding: 10px 12px;
  border: 1px solid #e7b5b0;
  border-radius: 6px;
  background: var(--red-soft);
  color: #8d1d15;
  font-size: 13px;
}

.public-page {
  background: var(--canvas);
}

.public-header {
  position: relative;
  z-index: 10;
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.public-header-inner {
  display: flex;
  width: min(1120px, calc(100% - 40px));
  height: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto;
}

.public-nav {
  display: flex;
  height: 100%;
  align-items: center;
  gap: 4px;
}

.public-nav a {
  position: relative;
  display: inline-flex;
  min-width: 76px;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 600;
}

.public-nav a:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.public-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.public-main {
  display: grid;
  min-height: calc(100vh - 64px);
  padding: 52px 20px 64px;
  place-items: start center;
}

.public-tool {
  width: min(920px, 100%);
}

.tool-heading {
  margin-bottom: 22px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
}

.tool-heading h1 {
  font-size: 28px;
  line-height: 1.25;
}

.tool-frame {
  display: grid;
  min-height: 430px;
  overflow: hidden;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.tool-form-pane,
.tool-result-pane {
  min-width: 0;
  padding: 34px;
}

.tool-form-pane {
  border-right: 1px solid var(--border);
}

.tool-form-pane > h2 {
  margin-bottom: 25px;
  font-size: 17px;
  line-height: 1.35;
}

.tool-result-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  background: var(--surface-muted);
}

.result-empty {
  display: grid;
  justify-items: center;
  padding: 32px 10px;
  color: var(--muted);
  text-align: center;
}

.result-empty-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 15px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
}

.result-empty h2 {
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 16px;
}

.result-empty p {
  font-size: 13px;
}

.result-content {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.result-header {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.result-header-main {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.result-header-main > div {
  min-width: 0;
}

.result-symbol {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.result-symbol.is-error {
  background: var(--red-soft);
  color: var(--red);
}

.result-header h2 {
  font-size: 17px;
}

.result-header p {
  max-width: 100%;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-profile {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.result-avatar,
.result-avatar-fallback {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  background: var(--surface-strong);
  object-fit: cover;
}

.result-avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.result-profile-copy {
  min-width: 0;
}

.result-profile-copy strong,
.result-profile-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-profile-copy strong {
  font-size: 15px;
}

.result-profile-copy span {
  color: var(--muted);
  font-size: 13px;
}

.redeem-confirm-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--ink);
}

.redeem-confirm-dialog::backdrop {
  background: rgba(10, 25, 20, 0.56);
}

.redeem-confirm-content {
  padding: 28px;
}

.redeem-confirm-header {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.redeem-confirm-header .eyebrow {
  margin-bottom: 3px;
}

.redeem-confirm-header h2 {
  font-size: 18px;
  line-height: 1.35;
}

.redeem-confirm-header .icon-button {
  margin-top: -2px;
}

.redeem-confirm-content > .form-alert {
  margin-top: 18px;
}

.redeem-confirm-section {
  min-width: 0;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.redeem-confirm-content > .form-alert + .redeem-confirm-section,
.redeem-confirm-header + .redeem-confirm-section {
  margin-top: 20px;
}

.redeem-confirm-section h3 {
  margin-bottom: 12px;
  font-size: 14px;
}

.redeem-confirm-data-list {
  display: grid;
  min-width: 0;
}

.redeem-confirm-data-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  padding: 6px 0;
}

.redeem-confirm-data-row dt {
  color: var(--muted);
  font-size: 12px;
}

.redeem-confirm-data-row dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-weight: 600;
  text-align: right;
}

.redeem-confirm-profile {
  display: grid;
  min-width: 0;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.redeem-confirm-avatar,
.redeem-confirm-avatar-fallback {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-strong);
  object-fit: cover;
}

.redeem-confirm-avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.redeem-confirm-profile-copy {
  min-width: 0;
}

.redeem-confirm-profile-copy strong,
.redeem-confirm-profile-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.redeem-confirm-profile-copy strong {
  font-size: 15px;
}

.redeem-confirm-profile-copy span {
  color: var(--muted);
  font-size: 13px;
}

.redeem-confirm-bio {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-size: 13px;
  white-space: pre-wrap;
}

.redeem-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.result-data-list {
  display: grid;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.result-data-row {
  display: grid;
  min-height: 48px;
  align-items: center;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
}

.result-data-row:last-child {
  border-bottom: 0;
}

.result-data-row dt {
  color: var(--muted);
  font-size: 12px;
}

.result-data-row dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-weight: 600;
  text-align: right;
}

.result-data-row dd.mono {
  font-size: 12px;
}

.result-timeline {
  margin-top: 22px;
}

.result-timeline h3 {
  margin-bottom: 13px;
  font-size: 14px;
}

.mini-timeline {
  position: relative;
  display: grid;
  gap: 0;
  list-style: none;
  padding: 0;
}

.mini-timeline::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 5px;
  width: 1px;
  background: var(--border-strong);
  content: "";
}

.mini-timeline li {
  position: relative;
  display: grid;
  min-height: 42px;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: start;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 13px;
}

.mini-timeline-marker {
  position: relative;
  z-index: 1;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border: 3px solid var(--surface-muted);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.mini-timeline time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.toast-region {
  position: fixed;
  z-index: 1100;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  width: min(360px, calc(100vw - 36px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--ink);
  box-shadow: var(--shadow-md);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.admin-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.admin-sidebar {
  position: fixed;
  z-index: 70;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  background: var(--nav);
  color: rgba(255, 255, 255, 0.82);
}

.sidebar-head {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-close {
  display: none;
}

.admin-nav {
  display: grid;
  gap: 5px;
  padding: 18px 12px;
}

.admin-nav a {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.68);
  font-weight: 600;
}

.admin-nav a:hover {
  background: var(--nav-hover);
  color: #fff;
}

.admin-nav a.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-account {
  display: grid;
  min-height: 68px;
  grid-template-columns: 34px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.account-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.account-name {
  overflow: hidden;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-workspace {
  min-width: 0;
  grid-column: 2;
}

.admin-topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.admin-topbar h1 {
  min-width: 0;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-menu {
  display: none;
}

.topbar-account {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.admin-content {
  width: min(1500px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 28px;
}

.drawer-overlay {
  display: none;
}

.page-stack {
  display: grid;
  gap: 20px;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  display: grid;
  min-height: 44px;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
}

.flash-success,
.flash-message {
  border-color: #afd0c2;
  background: var(--accent-soft);
  color: #10533f;
}

.flash-error,
.flash-danger {
  border-color: #e5b4af;
  background: var(--red-soft);
  color: #8d1d15;
}

.flash-warning {
  border-color: #e5c595;
  background: var(--amber-soft);
  color: #7f480b;
}

.flash-close {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-item {
  display: flex;
  min-width: 0;
  min-height: 112px;
  align-items: center;
  gap: 13px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 7px;
}

.metric-green .metric-icon { background: var(--accent-soft); color: var(--accent); }
.metric-ink .metric-icon { background: #edf0ef; color: var(--ink-soft); }
.metric-amber .metric-icon { background: var(--amber-soft); color: var(--amber); }
.metric-blue .metric-icon { background: var(--blue-soft); color: var(--blue); }

.metric-item > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.metric-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-item strong {
  font-size: 25px;
  line-height: 1.2;
}

.content-section,
.generation-tool,
.editor-form {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.section-heading {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.section-heading.compact {
  min-height: 58px;
}

.section-heading h2 {
  font-size: 16px;
  line-height: 1.35;
}

.section-heading p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.data-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.data-table td {
  color: var(--ink-soft);
  font-size: 13px;
}

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

.data-table tbody tr:hover {
  background: #fbfcfb;
}

.data-table time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.table-primary strong,
.table-primary > span {
  display: block;
}

.table-primary strong {
  color: var(--ink);
}

.table-primary > span {
  max-width: 280px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-link {
  color: var(--accent);
  font-weight: 650;
}

.table-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.user-handle {
  color: var(--ink-soft);
  white-space: nowrap;
}

.cell-actions {
  width: 120px;
  text-align: right !important;
  white-space: nowrap;
}

.cell-actions > * {
  margin-left: 4px;
}

.inline-form {
  display: inline-block;
  margin: 0;
}

.card-code {
  display: inline-block;
  max-width: 280px;
  overflow: hidden;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.status-completed,
.status-badge.status-active,
.status-badge.status-enabled,
.status-badge.status-unused {
  border-color: #aad0bf;
  background: var(--accent-soft);
  color: #126145;
}

.status-badge.status-submitted {
  border-color: #b9cddc;
  background: var(--blue-soft);
  color: #245c80;
}

.status-badge.status-processing,
.status-badge.status-used {
  border-color: #e7ca9d;
  background: var(--amber-soft);
  color: #8d500c;
}

.status-badge.status-exception,
.status-badge.status-disabled {
  border-color: #e2b1ac;
  background: var(--red-soft);
  color: #982219;
}

.empty-state {
  display: grid;
  min-height: 210px;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-state .icon {
  color: var(--border-strong);
}

.pagination {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 11px 15px;
  border-top: 1px solid var(--border);
}

.pagination-label {
  min-width: 86px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-bar {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.filter-bar select {
  width: auto;
  min-width: 136px;
}

.filter-search {
  position: relative;
  min-width: 230px;
}

.filter-search .icon {
  position: absolute;
  z-index: 1;
  top: 13px;
  left: 12px;
  color: var(--muted);
}

.filter-search input {
  padding-left: 39px;
}

.generation-tool {
  overflow: hidden;
}

.generation-tool > summary {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  color: var(--ink-soft);
  font-weight: 650;
  list-style: none;
}

.generation-tool > summary::-webkit-details-marker {
  display: none;
}

.generation-tool > summary:hover {
  background: var(--surface-muted);
}

.summary-chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform 150ms ease;
}

.generation-tool[open] .summary-chevron {
  transform: rotate(90deg);
}

.generation-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 200px) auto;
  align-items: end;
  gap: 16px;
  padding: 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.generation-actions {
  padding-bottom: 1px;
}

.generation-empty,
.generation-report {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.generation-empty,
.generation-report-head {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.generation-report-head > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.generation-report-head strong {
  color: var(--ink-soft);
  font-size: 14px;
}

.generation-report-head span,
.generation-empty > span {
  color: var(--muted);
  font-size: 12px;
}

.generation-codes {
  min-height: 170px;
  background: var(--surface-muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.table-user {
  display: flex;
  min-width: 160px;
  align-items: center;
  gap: 9px;
}

.table-user > img,
.avatar-fallback {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  background: var(--surface-strong);
  object-fit: cover;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.table-user > span:last-child {
  display: grid;
  min-width: 0;
}

.table-user strong,
.table-user small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-user strong {
  max-width: 160px;
  color: var(--ink-soft);
  font-size: 12px;
}

.table-user small {
  max-width: 160px;
  color: var(--muted);
  font-size: 11px;
}

.form-page {
  width: min(720px, 100%);
}

.form-page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.form-page-head h2 {
  font-size: 18px;
}

.form-page-head p {
  color: var(--muted);
  font-size: 12px;
}

.editor-form {
  display: grid;
  gap: 22px;
  padding: 24px;
}

.switch-row {
  display: grid;
  min-height: 66px;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 14px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.switch-row > span:first-child {
  display: grid;
  gap: 2px;
}

.switch-row strong {
  color: var(--ink-soft);
  font-size: 13px;
}

.switch-row small {
  color: var(--muted);
  font-size: 12px;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-control {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #adb9b4;
  transition: background-color 150ms ease;
}

.switch-control::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  content: "";
  transition: transform 150ms ease;
}

.switch-row input:checked + .switch-control {
  background: var(--accent);
}

.switch-row input:checked + .switch-control::after {
  transform: translateX(18px);
}

.switch-row input:focus-visible + .switch-control {
  box-shadow: 0 0 0 3px rgba(40, 101, 141, 0.2);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.detail-page {
  display: grid;
  gap: 18px;
}

.detail-head {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.detail-head-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.detail-head-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.detail-head-main > div {
  min-width: 0;
}

.detail-kicker {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.detail-head h2 {
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  align-items: start;
  gap: 18px;
}

.detail-main,
.detail-side {
  display: grid;
  min-width: 0;
  gap: 18px;
}

.detail-section {
  overflow: hidden;
}

.definition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 6px 18px 16px;
}

.definition-grid > div {
  min-width: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.definition-grid > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.definition-grid dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.definition-grid dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-weight: 600;
}

.exception-note {
  margin: 0 18px 18px;
  padding: 12px 13px;
  border: 1px solid #e3b2ad;
  border-radius: 6px;
  background: var(--red-soft);
  color: #8d1d15;
}

.exception-note strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
}

.exception-note p {
  white-space: pre-wrap;
}

.profile-section,
.detail-side .detail-section {
  padding-bottom: 18px;
}

.profile-summary {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 18px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 50%;
  background: var(--surface-strong);
  object-fit: cover;
}

.profile-avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.profile-summary > div {
  display: grid;
  min-width: 0;
}

.profile-summary strong,
.profile-summary span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-summary strong {
  font-size: 15px;
}

.profile-summary span {
  color: var(--muted);
  font-size: 12px;
}

.profile-bio {
  margin: 0 18px 16px;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
}

.profile-section > .button,
.detail-side .stack-form {
  width: calc(100% - 36px);
  margin-right: 18px;
  margin-left: 18px;
}

.timeline {
  position: relative;
  display: grid;
  list-style: none;
  padding: 18px 20px 22px;
}

.timeline::before {
  position: absolute;
  top: 29px;
  bottom: 33px;
  left: 25px;
  width: 1px;
  background: var(--border-strong);
  content: "";
}

.timeline-item {
  position: relative;
  display: grid;
  min-height: 62px;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
}

.timeline-marker {
  position: relative;
  z-index: 1;
  width: 11px;
  height: 11px;
  margin-top: 5px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 1px var(--muted);
}

.timeline-item.status-completed .timeline-marker { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.timeline-item.status-processing .timeline-marker { background: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.timeline-item.status-exception .timeline-marker { background: var(--red); box-shadow: 0 0 0 1px var(--red); }
.timeline-item.status-submitted .timeline-marker { background: var(--blue); box-shadow: 0 0 0 1px var(--blue); }

.timeline-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.timeline-title strong {
  color: var(--ink-soft);
  font-size: 13px;
}

.timeline-title time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.timeline-content > p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-reason {
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--surface-muted);
  white-space: pre-wrap;
}

.auth-page {
  background: var(--canvas);
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px 20px;
  place-items: center;
}

.auth-panel {
  width: min(400px, 100%);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.auth-brand {
  margin-bottom: 30px;
}

.auth-heading {
  margin-bottom: 22px;
}

.auth-heading h1 {
  font-size: 22px;
}

.auth-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.setup-page {
  overflow: hidden;
  background: var(--canvas);
}

.setup-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.setup-dialog {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--ink);
}

.setup-dialog::backdrop {
  background: rgba(10, 25, 20, 0.56);
}

.setup-dialog-content {
  padding: 30px;
}

.setup-brand {
  margin-bottom: 30px;
}

.setup-dialog .form-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .generation-form {
    grid-template-columns: minmax(180px, 1fr) minmax(120px, 170px) auto;
  }
}

@media (max-width: 900px) {
  :root {
    --topbar-height: 58px;
  }

  .admin-shell {
    display: block;
  }

  .admin-sidebar {
    width: min(280px, calc(100vw - 56px));
    max-width: 280px;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .is-drawer-open .admin-sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 28px rgba(10, 29, 23, 0.2);
  }

  .sidebar-close {
    display: grid;
    border-color: rgba(255, 255, 255, 0.16);
    background: transparent;
    color: #fff;
  }

  .drawer-overlay {
    position: fixed;
    z-index: 60;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(10, 25, 20, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .is-drawer-open .drawer-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .admin-workspace {
    width: 100%;
  }

  .topbar-menu {
    display: grid;
  }

  .admin-topbar {
    padding: 0 18px;
  }

  .admin-content {
    padding: 22px 18px;
  }

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

  .detail-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 720px) {
  .public-header-inner {
    width: calc(100% - 28px);
  }

  .public-main {
    padding: 34px 14px 44px;
  }

  .tool-frame {
    grid-template-columns: minmax(0, 1fr);
  }

  .tool-form-pane {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .tool-result-pane {
    min-height: 300px;
  }

  .page-actions,
  .filter-bar {
    align-items: stretch;
  }

  .page-actions {
    flex-direction: column-reverse;
  }

  .page-actions > .button {
    align-self: flex-end;
  }

  .filter-bar,
  .filter-bar-wrap {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-search {
    min-width: 0;
    grid-column: 1 / -1;
  }

  .filter-bar select {
    width: 100%;
    min-width: 0;
  }

  .filter-bar .button {
    grid-column: 1 / -1;
  }

  .generation-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .generation-actions {
    grid-column: 1;
  }

  .generation-actions .button {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  .data-table {
    display: block;
    min-width: 0;
  }

  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .data-table tbody {
    display: grid;
    gap: 9px;
    padding: 10px;
  }

  .data-table tr {
    display: grid;
    min-width: 0;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
  }

  .data-table td {
    display: flex;
    min-width: 0;
    min-height: 34px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 1px;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }

  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table td::before {
    flex: 0 0 76px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 650;
    text-align: left;
  }

  .data-table td > * {
    min-width: 0;
  }

  .data-table .table-primary > strong,
  .data-table .table-primary > span {
    max-width: min(260px, calc(100vw - 150px));
  }

  .data-table .table-link {
    display: block;
    max-width: min(280px, calc(100vw - 150px));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cell-actions {
    width: auto;
    text-align: right !important;
  }

  .table-user {
    min-width: 0;
    justify-content: flex-end;
    text-align: left;
  }

  .card-code {
    max-width: min(280px, calc(100vw - 150px));
  }

  .pagination {
    justify-content: center;
  }

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

  .definition-grid > div:nth-last-child(2) {
    border-bottom: 1px solid var(--border);
  }

  .detail-side {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  body {
    font-size: 13px;
  }

  .public-header {
    height: 58px;
  }

  .brand {
    font-size: 14px;
  }

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

  .public-nav a {
    min-width: 44px;
    padding: 0 10px;
  }

  .public-nav a span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
  }

  .public-main {
    min-height: calc(100vh - 58px);
    padding-top: 27px;
  }

  .tool-heading {
    margin-bottom: 16px;
  }

  .tool-heading h1 {
    font-size: 23px;
  }

  .tool-form-pane,
  .tool-result-pane {
    padding: 22px 18px;
  }

  .tool-form-pane > h2 {
    margin-bottom: 20px;
    font-size: 16px;
  }

  .stack-form {
    gap: 17px;
  }

  .redeem-confirm-content {
    padding: 22px 18px;
  }

  .redeem-confirm-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .redeem-confirm-actions .button {
    width: 100%;
  }

  .result-header {
    align-items: center;
  }

  .result-data-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .mini-timeline li {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .mini-timeline time {
    grid-column: 2;
    margin-top: -17px;
  }

  .admin-topbar {
    padding: 0 12px;
  }

  .admin-topbar h1 {
    font-size: 16px;
  }

  .topbar-account {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .admin-content {
    padding: 16px 12px 28px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .metric-item {
    min-height: 98px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 13px;
  }

  .metric-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .metric-item strong {
    font-size: 21px;
  }

  .section-heading {
    min-height: 58px;
    padding: 11px 13px;
  }

  .section-heading h2 {
    font-size: 14px;
  }

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

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

  .filter-bar,
  .filter-bar-wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-search,
  .filter-bar .button {
    grid-column: 1;
  }

  .generation-form,
  .editor-form {
    padding: 15px;
  }

  .generation-empty,
  .generation-report {
    padding: 14px 15px;
  }

  .generation-empty,
  .generation-report-head {
    align-items: stretch;
    flex-direction: column;
  }

  .generation-empty .button,
  .generation-report-head .button {
    width: 100%;
  }

  .data-table tbody {
    padding: 8px;
  }

  .data-table td {
    gap: 10px;
  }

  .data-table td::before {
    flex-basis: 68px;
  }

  .data-table .table-primary > strong,
  .data-table .table-primary > span,
  .card-code {
    max-width: calc(100vw - 130px);
  }

  .detail-head {
    align-items: flex-start;
  }

  .detail-head h2 {
    max-width: calc(100vw - 160px);
    font-size: 15px;
  }

  .definition-grid {
    padding-right: 14px;
    padding-left: 14px;
  }

  .profile-summary {
    padding: 15px;
  }

  .profile-bio {
    margin-right: 15px;
    margin-left: 15px;
  }

  .profile-section > .button,
  .detail-side .stack-form {
    width: calc(100% - 30px);
    margin-right: 15px;
    margin-left: 15px;
  }

  .timeline-title {
    display: grid;
    gap: 1px;
  }

  .auth-shell {
    padding: 18px 12px;
  }

  .auth-panel {
    padding: 24px 18px;
  }

  .setup-dialog-content {
    padding: 24px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
