:root {
  color-scheme: light;
  --ui-background: #f7f8fa;
  --ui-surface: #ffffff;
  --ui-surface-muted: #f2f4f7;
  --ui-border: #e4e7ec;
  --ui-border-strong: #d0d5dd;
  --ui-text: #101828;
  --ui-text-muted: #667085;
  --ui-primary: #155eef;
  --ui-primary-hover: #004eeb;
  --ui-primary-soft: #eef4ff;
  --ui-success: #039855;
  --ui-success-soft: #ecfdf3;
  --ui-warning: #dc6803;
  --ui-warning-soft: #fff8ed;
  --ui-danger: #d92d20;
  --ui-danger-soft: #fef3f2;
  --ui-focus: #84adff;
  --ui-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --ui-shadow-md: 0 8px 24px rgba(16, 24, 40, 0.12);
  --ui-sidebar-width: 248px;
}

html {
  background: var(--ui-background);
  color: var(--ui-text);
}

body,
button,
input,
select,
textarea {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
}

body {
  background: var(--ui-background);
  color: var(--ui-text);
}

a {
  color: var(--ui-primary);
}

::selection {
  background: var(--ui-primary-soft);
  color: var(--ui-text);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ui-focus) 55%, transparent);
  outline-offset: 2px;
}

.ui-icon,
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.125em;
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 2000;
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--ui-primary);
  color: #fff;
  text-decoration: none;
  transform: translateY(-160%);
}

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

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex: 0 0 var(--ui-sidebar-width);
  flex-direction: column;
  width: var(--ui-sidebar-width);
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--ui-border);
  background: var(--ui-surface);
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 16px;
  border-bottom: 1px solid var(--ui-border);
}

.app-sidebar-brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.app-sidebar-brand p {
  margin: 3px 0 0;
  color: var(--ui-text-muted);
  font-size: 11px;
}

.app-brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--ui-primary);
  color: #fff;
  box-shadow: var(--ui-shadow-sm);
}

.app-brand-mark .icon {
  width: 20px;
  height: 20px;
}

.app-status-card {
  display: grid;
  gap: 8px;
  margin: 14px 4px 2px;
  padding: 10px 11px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface-muted);
}

.app-status-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-status-card span {
  color: var(--ui-text-muted);
  font-size: 11px;
}

.app-status-card b {
  font-size: 12px;
}

.app-nav {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.app-nav-section {
  display: grid;
  gap: 4px;
}

.app-nav-label {
  margin: 0 9px 3px;
  color: #98a2b3;
  font-size: 10px;
  font-weight: 800;
}

.app-nav-link,
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.app-nav-link:hover,
.mobile-more-menu .mobile-nav-link:hover {
  background: var(--ui-surface-muted);
  color: var(--ui-text);
}

.app-nav-link.active,
.mobile-nav-link.active {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
  font-weight: 750;
}

.app-nav-link .icon,
.mobile-nav-link .icon {
  width: 17px;
  height: 17px;
}

.app-sidebar-footer {
  margin-top: auto;
  padding: 13px 7px 2px;
  border-top: 1px solid var(--ui-border);
  color: var(--ui-text-muted);
  font-size: 11px;
}

.app-sidebar-footer p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 7px;
}

.app-sidebar-footer .scan-summary {
  display: block;
  line-height: 1.55;
}

.app-content {
  flex: 1;
  min-width: 0;
  max-width: calc(100vw - var(--ui-sidebar-width));
  padding: 24px;
}

.app-content-inner {
  width: min(100%, 1480px);
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 17px;
}

.page-header h1 {
  margin: 2px 0 0;
  font-size: 25px;
  line-height: 1.25;
}

.page-kicker {
  margin: 0;
  color: var(--ui-primary);
  font-size: 11px;
  font-weight: 800;
}

.page-header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.page-header-meta > span {
  padding: 6px 9px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: var(--ui-surface);
  color: var(--ui-text-muted);
  font-size: 11px;
}

.page-header-meta b {
  margin-left: 4px;
  color: var(--ui-text);
}

.page-header-meta b.ok {
  color: var(--ui-success);
}

.page-header-meta b.warn {
  color: var(--ui-warning);
}

.affiliate-hero {
  position: relative;
  min-height: 190px;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
}

.affiliate-hero::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 58%;
  background: rgba(255, 255, 255, 0.94);
  content: "";
}

.affiliate-hero-art {
  position: absolute;
  top: 50%;
  right: 0;
  width: 68%;
  height: 150%;
  object-fit: contain;
  object-position: right center;
  transform: translateY(-50%);
}

.affiliate-hero-content {
  position: relative;
  z-index: 2;
  width: min(650px, 62%);
  padding: 27px 28px;
}

.affiliate-hero h1 {
  margin: 4px 0 8px;
  font-size: 30px;
  line-height: 1.18;
}

.affiliate-hero-content > p:not(.page-kicker) {
  max-width: 590px;
  margin: 0;
  color: #475467;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.hero-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.affiliate-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
}

.affiliate-summary > div {
  min-width: 0;
  padding: 12px 15px;
  border-right: 1px solid var(--ui-border);
}

.affiliate-summary > div:last-child {
  border-right: 0;
}

.affiliate-summary span,
.affiliate-summary strong {
  display: block;
}

.affiliate-summary span {
  margin-bottom: 4px;
  color: var(--ui-text-muted);
  font-size: 11px;
}

.affiliate-summary strong {
  overflow: hidden;
  color: var(--ui-text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.affiliate-summary strong.ok {
  color: var(--ui-success);
}

.affiliate-summary strong.warn {
  color: var(--ui-warning);
}

.rule-summary {
  margin-bottom: 18px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
}

.rule-summary summary {
  padding: 11px 14px;
  cursor: pointer;
  color: var(--ui-text);
  font-weight: 750;
}

.rule-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--ui-border);
}

.rule-summary-grid > div {
  padding: 11px 14px 13px;
  border-right: 1px solid var(--ui-border);
}

.rule-summary-grid > div:last-child {
  border-right: 0;
}

.rule-summary-grid b,
.rule-summary-grid span {
  display: block;
}

.rule-summary-grid b {
  margin-bottom: 3px;
  font-size: 12px;
}

.rule-summary-grid span {
  color: var(--ui-text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.poster-workspace-tabs,
.poster-mobile-actions {
  display: none;
}

.poster-panel {
  min-width: 0;
}

.lookup-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
}

.lookup-toolbar-copy {
  display: flex;
  align-items: center;
  min-width: 190px;
  gap: 10px;
}

.lookup-toolbar-copy b,
.lookup-toolbar-copy span {
  display: block;
}

.lookup-toolbar-copy b {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lookup-toolbar-copy span:not(.lookup-toolbar-icon) {
  margin-top: 2px;
  color: var(--ui-text-muted);
  font-size: 11px;
}

.lookup-toolbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 7px;
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
}

.lookup-toolbar .searchbar {
  display: grid;
  grid-template-columns: minmax(190px, 310px) auto auto;
  flex: 1;
  justify-content: end;
}

.lookup-toolbar button,
.lookup-hero button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
}

.metric-strip > div {
  min-width: 0;
  padding: 14px 15px;
  border-right: 1px solid var(--ui-border);
}

.metric-strip > div:last-child {
  border-right: 0;
}

.metric-strip span,
.metric-strip b,
.metric-strip small {
  display: block;
}

.metric-strip span {
  color: var(--ui-text-muted);
  font-size: 11px;
}

.metric-strip b {
  margin: 5px 0 3px;
  overflow: hidden;
  color: var(--ui-text);
  font-size: 21px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-strip small {
  overflow: hidden;
  color: var(--ui-text-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settlement-journey {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface-muted);
}

.journey-step {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 12px 15px;
  color: var(--ui-text-muted);
}

.journey-step:not(:last-child)::after {
  position: absolute;
  top: 50%;
  right: -5px;
  z-index: 2;
  width: 10px;
  height: 10px;
  border-top: 1px solid var(--ui-border-strong);
  border-right: 1px solid var(--ui-border-strong);
  background: var(--ui-surface-muted);
  content: "";
  transform: translateY(-50%) rotate(45deg);
}

.journey-step > b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 50%;
  background: var(--ui-surface);
  color: var(--ui-text-muted);
  font-size: 12px;
}

.journey-step span,
.journey-step strong,
.journey-step small {
  display: block;
  min-width: 0;
}

.journey-step strong {
  color: var(--ui-text);
  font-size: 12px;
}

.journey-step small {
  margin-top: 2px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journey-step.active {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
}

.journey-step.active::after {
  background: var(--ui-primary-soft);
}

.journey-step.active > b {
  border-color: var(--ui-primary);
  background: var(--ui-primary);
  color: #fff;
}

.lookup-overview {
  margin-bottom: 12px;
  padding: 14px 15px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
}

.lookup-overview h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.lookup-results {
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
}

.data-tab-list {
  display: flex;
  gap: 2px;
  padding: 7px 8px 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface-muted);
}

.data-tab-list button {
  display: inline-flex;
  align-items: center;
  min-height: 39px;
  gap: 7px;
  padding: 7px 11px 9px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--ui-text-muted);
}

.data-tab-list button span {
  min-width: 21px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #e4e7ec;
  color: #475467;
  font-size: 10px;
  text-align: center;
}

.data-tab-list button.active {
  border-bottom-color: var(--ui-primary);
  background: var(--ui-surface);
  color: var(--ui-primary);
}

.data-tab-list button.active span {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
}

.data-tab-panel[hidden] {
  display: none;
}

.responsive-table {
  overflow-x: auto;
}

.responsive-table table {
  margin: 0;
}

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

.admin-guardrail {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #b7e4d0;
  border-radius: 8px;
  background: var(--ui-success-soft);
  color: #05603a;
}

.admin-guardrail > .icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin-top: 1px;
}

.admin-guardrail b,
.admin-guardrail span {
  display: block;
}

.admin-guardrail b {
  font-size: 13px;
}

.admin-guardrail span {
  margin-top: 2px;
  color: #087a55;
  font-size: 11px;
  line-height: 1.5;
}

.admin-workbench,
.record-table-shell,
.ranking-table-shell,
.audit-table-shell {
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-sm);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--ui-border);
}

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading h2 {
  font-size: 16px;
}

.panel-heading p {
  margin-top: 3px;
  color: var(--ui-text-muted);
  font-size: 11px;
}

.panel-heading form {
  margin: 0 !important;
}

.admin-groups {
  padding: 5px 12px 12px;
  background: var(--ui-surface-muted);
}

.admin-groups .group-card {
  margin: 8px 0 0;
  box-shadow: var(--ui-shadow-sm);
}

.admin-groups .group-card summary {
  background: var(--ui-surface);
}

.panel-empty {
  padding: 32px 14px;
  color: var(--ui-text-muted);
  text-align: center;
}

.record-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 7px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
}

.record-filters {
  display: flex;
  min-width: 0;
  gap: 3px;
  overflow-x: auto;
}

.record-filters a {
  padding: 7px 11px;
  border-radius: 6px;
  color: var(--ui-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.record-filters a.active {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
}

.record-result-count {
  margin: 0 8px 0 0;
  color: var(--ui-text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.record-result-count b {
  color: var(--ui-text);
}

.record-revoke-form {
  display: grid;
  min-width: 180px;
  gap: 6px;
}

.record-revoke-form input,
.record-revoke-form button {
  min-height: 34px;
}

.confirm-dialog-danger .confirm-dialog-icon {
  color: var(--ui-danger);
}

.confirm-dialog-danger .confirm-dialog-actions .danger {
  background: var(--ui-danger);
}

@media (min-width: 901px) and (max-width: 1200px) {
  .app-content .invite-studio {
    grid-template-columns: minmax(250px, 0.82fr) minmax(320px, 1.18fr);
  }

  .app-content .invite-studio > [data-workspace-panel="templates"] {
    grid-column: 1 / -1;
  }

  .app-content .invite-studio .template-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    max-height: 280px;
  }
}

.login-panel {
  width: min(460px, 100%);
  margin: 48px auto;
  padding: 24px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-md);
}

.login-panel-heading {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 20px;
}

.login-panel-heading h2,
.login-panel-heading p {
  margin: 0;
}

.login-panel-heading h2 {
  margin: 3px 0 5px;
  font-size: 21px;
}

.login-panel-heading p:not(.page-kicker) {
  color: var(--ui-text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.login-panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
}

.login-panel form {
  display: grid;
  gap: 9px;
}

.login-panel form label {
  margin: 0;
  font-weight: 700;
}

.login-panel form button {
  min-height: 40px;
  margin-top: 4px;
}

.login-security-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--ui-border);
  color: var(--ui-text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.login-security-note .icon {
  flex: 0 0 auto;
  color: var(--ui-success);
}

.ranking-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 16px 18px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
}

.ranking-header h2,
.ranking-header p {
  margin: 0;
}

.ranking-header h2 {
  margin: 3px 0 4px;
  font-size: 22px;
}

.ranking-header p:not(.page-kicker) {
  color: var(--ui-text-muted);
  font-size: 12px;
}

.segmented-tabs {
  display: inline-flex;
  flex-direction: row;
  gap: 3px;
  margin-top: 0;
  padding: 3px;
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  background: var(--ui-surface-muted);
}

.segmented-tabs a {
  min-width: 54px;
  padding: 7px 10px;
  border-radius: 5px;
  color: var(--ui-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.segmented-tabs a.active {
  background: var(--ui-surface);
  color: var(--ui-primary);
  box-shadow: var(--ui-shadow-sm);
}

.ranking-position {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
  font-weight: 800;
}

.settings-form {
  display: grid;
  width: min(920px, 100%);
  gap: 12px;
}

.settings-section {
  display: grid;
  grid-template-columns: minmax(190px, 0.72fr) minmax(280px, 1.28fr);
  gap: 28px;
  padding: 18px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
}

.settings-section-copy h2,
.settings-section-copy p {
  margin: 0;
}

.settings-section-copy h2 {
  font-size: 16px;
}

.settings-section-copy p {
  margin-top: 5px;
  color: var(--ui-text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.setting-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: 0;
}

.setting-toggle > span:first-child b,
.setting-toggle > span:first-child small {
  display: block;
}

.setting-toggle > span:first-child small {
  margin-top: 3px;
  color: var(--ui-text-muted);
  font-size: 11px;
  font-weight: 400;
}

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

.toggle-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #d0d5dd;
  transition: background 150ms ease;
}

.toggle-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--ui-shadow-sm);
  transition: transform 150ms ease;
}

.setting-toggle input:checked + .toggle-track {
  background: var(--ui-primary);
}

.setting-toggle input:checked + .toggle-track span {
  transform: translateX(18px);
}

.setting-toggle input:focus-visible + .toggle-track {
  outline: 3px solid color-mix(in srgb, var(--ui-focus) 55%, transparent);
  outline-offset: 2px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(180px, 1fr);
  align-items: center;
  gap: 10px 14px;
}

.settings-grid label {
  margin: 0;
  font-weight: 700;
}

.settings-grid label span {
  display: block;
  margin-top: 2px;
  color: var(--ui-text-muted);
  font-size: 10px;
  font-weight: 400;
}

.scan-status-row span,
.scan-status-row small {
  display: flex;
  align-items: center;
  gap: 7px;
}

.scan-status-row span {
  color: var(--ui-success);
}

.scan-status-row small {
  margin-top: 7px;
  color: var(--ui-text-muted);
  line-height: 1.5;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.settings-actions button {
  min-width: 130px;
}

.audit-filters {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(220px, 1.4fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-surface);
}

.audit-filters label {
  margin: 0;
  color: var(--ui-text-muted);
  font-size: 10px;
  font-weight: 700;
}

.audit-filters select,
.audit-filters input {
  margin-top: 4px;
}

.audit-filter-actions {
  display: flex;
  gap: 7px;
}

.audit-filter-actions .btn,
.audit-filter-actions button {
  min-height: 38px;
}

.audit-table-shell code {
  overflow-wrap: anywhere;
  white-space: normal;
}

.empty-state {
  padding: 22px 12px;
  color: var(--ui-text-muted);
  font-size: 12px;
  text-align: center;
}

.embed-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.mobile-nav,
.mobile-more-menu {
  display: none;
}

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  color: var(--ui-text);
  box-shadow: var(--ui-shadow-md);
}

.confirm-dialog::backdrop {
  background: rgba(16, 24, 40, 0.42);
}

.confirm-dialog h2 {
  margin: 10px 0 4px;
  font-size: 19px;
}

.confirm-dialog p {
  margin: 0;
  color: var(--ui-text-muted);
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .app-sidebar {
    position: static;
    width: auto;
    height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--ui-border);
  }

  .app-sidebar-brand {
    padding: 0;
    border-bottom: 0;
  }

  .app-status-card,
  .app-nav,
  .app-sidebar-footer {
    display: none;
  }

  .app-content {
    max-width: none;
    padding: 16px 16px 88px;
  }

  .page-header {
    align-items: center;
    margin-bottom: 13px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .page-header-meta > span {
    padding: 5px 7px;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 68px;
    padding: 5px 10px max(5px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--ui-border);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -8px 22px rgba(16, 24, 40, 0.08);
    backdrop-filter: blur(12px);
  }

  .mobile-nav .mobile-nav-link {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 56px;
    padding: 5px 2px;
    color: var(--ui-text-muted);
    font-size: 10px;
  }

  .mobile-nav .mobile-nav-link.active {
    background: transparent;
    color: var(--ui-primary);
  }

  .mobile-more-menu {
    position: fixed;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    z-index: 55;
    width: min(300px, calc(100vw - 24px));
    padding: 9px;
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-md);
  }

  .mobile-more-menu:not([hidden]) {
    display: grid;
    gap: 3px;
  }

  .mobile-more-menu .mobile-nav-link {
    width: 100%;
  }

  .mobile-more-title {
    margin: 3px 9px 5px;
    color: var(--ui-text-muted);
    font-size: 11px;
    font-weight: 800;
  }

  .toast-host {
    top: auto;
    right: 12px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
  }

  .affiliate-hero {
    min-height: 232px;
  }

  .affiliate-hero::after {
    width: 100%;
    background: rgba(255, 255, 255, 0.87);
  }

  .affiliate-hero-art {
    right: -90px;
    width: 125%;
    height: 132%;
    opacity: 0.42;
  }

  .affiliate-hero-content {
    width: 100%;
    padding: 21px 18px;
  }

  .affiliate-hero h1 {
    max-width: 330px;
    font-size: 26px;
  }

  .affiliate-hero-content > p:not(.page-kicker) {
    max-width: 335px;
    font-size: 12px;
  }

  .hero-actions {
    margin-top: 15px;
  }

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

  .affiliate-summary > div:nth-child(2) {
    border-right: 0;
  }

  .affiliate-summary > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--ui-border);
  }

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

  .rule-summary-grid > div:nth-child(2) {
    border-right: 0;
  }

  .rule-summary-grid > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--ui-border);
  }

  .poster-workspace-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    margin-bottom: 10px;
    padding: 3px;
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    background: var(--ui-surface-muted);
  }

  .poster-workspace-tabs button {
    min-height: 36px;
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ui-text-muted);
  }

  .poster-workspace-tabs button.active {
    background: var(--ui-surface);
    color: var(--ui-primary);
    box-shadow: var(--ui-shadow-sm);
  }

  .poster-panel:not(.is-active) {
    display: none !important;
  }

  .poster-panel.is-active.poster-preview {
    display: flex !important;
  }

  .poster-panel.is-active:not(.poster-preview) {
    display: block !important;
  }

  .poster-panel .template-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: 350px;
  }

  .poster-mobile-actions {
    position: fixed;
    right: 12px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    left: 12px;
    z-index: 46;
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: var(--ui-shadow-md);
    backdrop-filter: blur(12px);
  }

  body:has(.poster-mobile-actions) .app-content {
    padding-bottom: 158px;
  }

  .lookup-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .lookup-toolbar .searchbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    width: 100%;
  }

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

  .metric-strip > div:nth-child(2) {
    border-right: 0;
  }

  .metric-strip > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--ui-border);
  }

  .admin-tab-list {
    padding-right: 8px;
  }

  .record-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .record-result-count {
    margin: 0 8px 3px;
  }

  .ranking-header {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented-tabs {
    align-self: flex-start;
  }

  .settings-section {
    grid-template-columns: 1fr;
    gap: 16px;
  }

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

  .audit-search,
  .audit-filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .lookup-toolbar .searchbar {
    grid-template-columns: 1fr 1fr;
  }

  .lookup-toolbar .searchbar input {
    grid-column: 1 / -1;
  }

  .lookup-toolbar .searchbar button,
  .lookup-toolbar .searchbar .btn {
    text-align: center;
  }

  .settlement-journey {
    grid-template-columns: 1fr;
  }

  .journey-step:not(:last-child) {
    border-bottom: 1px solid var(--ui-border);
  }

  .journey-step:not(:last-child)::after {
    display: none;
  }

  .responsive-table {
    padding: 10px;
    background: var(--ui-surface-muted);
  }

  .responsive-table table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

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

  .responsive-table tbody {
    display: grid;
    gap: 9px;
  }

  .responsive-table tr {
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: 7px;
    background: var(--ui-surface);
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    min-height: 38px;
    padding: 9px 11px;
    text-align: right;
  }

  .responsive-table td::before {
    color: var(--ui-text-muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-align: left;
  }

  .responsive-table td[data-empty-row] {
    display: block;
    padding: 24px 12px;
    color: var(--ui-text-muted);
    text-align: center;
  }

  .responsive-table td[data-empty-row]::before {
    display: none;
  }

  .responsive-table td .action-form,
  .responsive-table td form.inline,
  .responsive-table td .record-revoke-form {
    width: 100%;
    min-width: 0;
  }

  .responsive-table td[data-label="操作"] {
    align-items: start;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-heading form,
  .panel-heading button {
    width: 100%;
  }

  .admin-groups {
    padding: 2px 8px 9px;
  }

  .admin-tab-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
  }

  .admin-tab-list button {
    justify-content: center;
    min-width: 0;
    gap: 3px;
    padding-inline: 3px;
    font-size: 10px;
  }

  .admin-tab-list button span {
    min-width: 17px;
    padding-inline: 4px;
  }

  .group-card summary {
    gap: 7px;
  }

  .login-panel {
    margin: 18px auto;
    padding: 19px 17px;
  }

  .ranking-header {
    padding: 14px;
  }

  .segmented-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .segmented-tabs a {
    min-width: 0;
    padding-inline: 5px;
  }

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

  .settings-grid input + label {
    margin-top: 6px;
  }

  .audit-filters {
    grid-template-columns: 1fr;
  }

  .audit-search,
  .audit-filter-actions {
    grid-column: auto;
  }

  .audit-filter-actions .btn,
  .audit-filter-actions button {
    flex: 1;
    text-align: center;
  }
}

.toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: grid;
  width: min(360px, calc(100vw - 32px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--ui-border);
  border-left: 4px solid var(--ui-primary);
  border-radius: 8px;
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow-md);
  font-size: 14px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.toast-info {
  border-left-color: var(--ui-primary);
  background: color-mix(in srgb, var(--ui-primary-soft) 42%, var(--ui-surface));
}

.toast-success {
  border-left-color: var(--ui-success);
  background: color-mix(in srgb, var(--ui-success-soft) 52%, var(--ui-surface));
}

.toast-warning {
  border-left-color: var(--ui-warning);
  background: color-mix(in srgb, var(--ui-warning-soft) 54%, var(--ui-surface));
}

.toast-danger {
  border-left-color: var(--ui-danger);
  background: color-mix(in srgb, var(--ui-danger-soft) 56%, var(--ui-surface));
}

.ui-busy,
[aria-busy="true"] {
  cursor: wait;
}

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

.ui-busy-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.ui-busy-label::before {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: ui-spin 700ms linear infinite;
}

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

@media (max-width: 900px) {
  .toast-host {
    top: auto;
    bottom: calc(80px + env(safe-area-inset-bottom));
  }

  body:has(.poster-mobile-actions) .toast-host {
    top: auto;
    bottom: calc(154px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }

  .ui-busy-label::before {
    animation: none;
  }
}
