:root {
  color-scheme: light;
  --bg: oklch(97.8% 0.004 158);
  --surface: oklch(100% 0 0);
  --surface-subtle: oklch(96.4% 0.006 158);
  --surface-strong: oklch(93.2% 0.01 158);
  --sidebar: oklch(95.4% 0.009 158);
  --ink: oklch(24% 0.022 158);
  --ink-soft: oklch(42% 0.018 158);
  --muted: oklch(50% 0.014 158);
  --border: oklch(88.5% 0.011 158);
  --border-strong: oklch(78% 0.018 158);
  --accent: oklch(44% 0.105 157);
  --accent-hover: oklch(38% 0.105 157);
  --accent-soft: oklch(93.5% 0.035 157);
  --accent-ink: oklch(34% 0.09 157);
  --success: oklch(43% 0.11 151);
  --success-soft: oklch(94% 0.035 151);
  --warning: oklch(52% 0.125 76);
  --warning-soft: oklch(95% 0.04 76);
  --danger: oklch(49% 0.17 28);
  --danger-hover: oklch(43% 0.17 28);
  --danger-soft: oklch(95% 0.035 28);
  --info: oklch(46% 0.105 242);
  --info-soft: oklch(95% 0.025 242);
  --focus: oklch(61% 0.14 157);
  --sidebar-width: 236px;
  --topbar-height: 60px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --z-sidebar: 30;
  --z-topbar: 20;
  --z-dialog: 50;
  --z-toast: 60;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

button,
select {
  cursor: pointer;
}

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

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

h1,
h2,
h3,
p {
  margin-block-start: 0;
}

h1,
h2,
h3 {
  line-height: 1.3;
  text-wrap: balance;
}

input::placeholder,
textarea::placeholder {
  color: oklch(49% 0.012 158);
  opacity: 1;
}

input[type="search"]::-webkit-search-cancel-button {
  opacity: 0.55;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: calc(var(--z-toast) + 1);
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--surface);
  transform: translateY(-160%);
  transition: transform 180ms ease-out;
}

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

/* Login */

.auth-view {
  display: grid;
  grid-template-columns: minmax(420px, 0.88fr) minmax(440px, 1.12fr);
  min-height: 100vh;
  background: var(--surface);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  width: min(100%, 520px);
  min-height: 100vh;
  padding: 44px clamp(36px, 6vw, 80px);
  border-inline-end: 1px solid var(--border);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-lockup > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-lockup strong {
  font-size: 15px;
  font-weight: 720;
  letter-spacing: -0.01em;
}

.brand-lockup small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.brand-symbol {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: var(--surface);
  font-size: 17px;
  font-weight: 750;
}

.auth-copy {
  margin-top: auto;
  padding-top: 72px;
}

.auth-copy h1 {
  margin-bottom: 10px;
  font-size: 27px;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.auth-copy p {
  max-width: 38ch;
  margin-bottom: 30px;
  color: var(--ink-soft);
}

.auth-footnote {
  margin: auto 0 0;
  padding-top: 36px;
  color: var(--muted);
  font-size: 12px;
}

.auth-context {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: clamp(56px, 10vw, 140px);
  background: oklch(26% 0.04 158);
  color: oklch(97% 0.005 158);
}

.auth-context > div:first-child {
  max-width: 500px;
}

.context-index {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  margin-bottom: 24px;
  border: 1px solid oklch(72% 0.025 158 / 0.5);
  border-radius: var(--radius-sm);
  color: oklch(82% 0.035 158);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.auth-context h2 {
  max-width: 13ch;
  margin-bottom: 16px;
  font-size: 36px;
  font-weight: 690;
  letter-spacing: -0.035em;
}

.auth-context p {
  max-width: 44ch;
  color: oklch(83% 0.015 158);
  font-size: 15px;
  line-height: 1.75;
  text-wrap: pretty;
}

.security-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 500px;
  margin-top: 80px;
  padding-top: 20px;
  border-top: 1px solid oklch(56% 0.025 158 / 0.55);
}

.security-note strong {
  font-size: 13px;
}

.security-note span {
  color: oklch(77% 0.015 158);
  font-size: 12px;
}

.preview-only {
  display: none;
}

body.is-preview .preview-only {
  display: inline-flex;
}

/* App frame */

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

.sidebar {
  position: fixed;
  z-index: var(--z-sidebar);
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-inline-end: 1px solid var(--border);
  background: var(--sidebar);
}

.sidebar-brand {
  height: var(--topbar-height);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}

.primary-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 10px 20px;
}

.nav-group-label {
  margin: 16px 9px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 640;
}

.nav-group-label:first-child {
  margin-top: 2px;
}

.primary-nav a {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 560;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}

.primary-nav a:hover {
  background: oklch(92% 0.014 158);
  color: var(--ink);
}

.primary-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 680;
}

.nav-mark {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 5px;
  background: oklch(90.5% 0.012 158);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.primary-nav a[aria-current="page"] .nav-mark {
  background: var(--accent);
  color: var(--surface);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 66px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.signed-in-user {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  gap: 9px;
}

.signed-in-user > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

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

.signed-in-user strong {
  font-size: 12px;
  font-weight: 670;
}

.signed-in-user small {
  color: var(--muted);
  font-size: 10px;
}

.user-avatar {
  display: inline-grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: oklch(87% 0.035 158);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 750;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  z-index: var(--z-topbar);
  top: 0;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: oklch(100% 0 0 / 0.96);
}

.menu-button {
  display: none;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
}

.menu-button:hover {
  background: var(--surface-subtle);
}

.menu-button span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: currentColor;
}

.global-search {
  position: relative;
  width: min(520px, 52vw);
}

.global-search input {
  width: 100%;
  height: 36px;
  padding: 0 58px 0 35px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: 12px;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}

.global-search input:hover {
  border-color: var(--border-strong);
}

.global-search input:focus {
  border-color: var(--focus);
  background: var(--surface);
  outline: 2px solid oklch(61% 0.14 157 / 0.2);
  outline-offset: 0;
}

.search-glyph {
  position: absolute;
  z-index: 1;
  top: 10px;
  left: 12px;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}

.search-glyph::after {
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 5px;
  height: 1.5px;
  background: var(--muted);
  content: "";
  transform: rotate(45deg);
  transform-origin: left center;
}

.global-search kbd {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.connection-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.connection-status.is-online > span {
  background: var(--success);
}

.connection-status.is-offline > span {
  background: var(--danger);
}

.main-content {
  width: min(100%, 1480px);
  min-height: calc(100vh - var(--topbar-height));
  padding: 28px 30px 52px;
}

.sidebar-scrim {
  display: none;
}

/* Shared page structure */

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

.page-heading h1 {
  margin-bottom: 6px;
  font-size: 23px;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.page-heading p {
  max-width: 66ch;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 13px;
  text-wrap: pretty;
}

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

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

.section-heading h2,
.section-heading h3 {
  margin-bottom: 0;
  font-size: 14px;
  font-weight: 680;
}

.section-heading p,
.section-heading span {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel + .panel {
  margin-top: 18px;
}

.panel-body {
  padding: 18px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 18px;
  align-items: start;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.page-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 11px;
}

.page-notice strong {
  color: var(--ink);
  white-space: nowrap;
}

.page-notice.is-success {
  border-color: oklch(83% 0.055 151);
  background: var(--success-soft);
  color: var(--success);
}

.mono,
.data-id,
.operation-id {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

.data-id {
  color: var(--ink-soft);
}

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, opacity 150ms ease-out;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.52;
}

.button-primary {
  background: var(--accent);
  color: var(--surface);
}

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

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

.button-secondary:hover:not(:disabled) {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.button-quiet {
  min-height: 30px;
  padding: 5px 8px;
  border-color: transparent;
  background: transparent;
  color: var(--accent-ink);
}

.button-quiet:hover:not(:disabled) {
  background: var(--accent-soft);
}

.button-danger {
  background: var(--danger);
  color: var(--surface);
}

.button-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.button-block {
  width: 100%;
}

.button.is-loading {
  pointer-events: none;
}

.button.is-loading::before {
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  content: "";
  animation: spin 700ms linear infinite;
}

.icon-button {
  min-width: 34px;
  height: 32px;
  padding: 0 7px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

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

.status-badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 680;
  white-space: nowrap;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.7;
}

.status-success,
.status-active,
.status-completed,
.status-online {
  background: var(--success-soft);
  color: var(--success);
}

.status-warning,
.status-pending,
.status-partial {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-error,
.status-failed,
.status-disabled,
.status-offline {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-info,
.status-running,
.status-scheduled {
  background: var(--info-soft);
  color: var(--info);
}

.tag {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 10px;
  white-space: nowrap;
}

/* Dashboard */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-item {
  min-width: 0;
  padding: 16px 18px;
}

.stat-item + .stat-item {
  border-inline-start: 1px solid var(--border);
}

.stat-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.stat-value {
  display: block;
  overflow: hidden;
  font-size: 22px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
}

.stat-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.attention-list,
.timeline,
.service-list,
.detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.attention-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
}

.attention-item + .attention-item {
  border-top: 1px solid var(--border);
}

.attention-symbol {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
}

.attention-symbol.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.attention-symbol.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.attention-item strong,
.attention-item span {
  display: block;
}

.attention-item strong {
  font-size: 12px;
  font-weight: 650;
}

.attention-item span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.service-list li {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
}

.service-list li + li {
  border-top: 1px solid var(--border);
}

.service-name {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.service-name strong {
  font-size: 12px;
  font-weight: 620;
}

.service-name span {
  color: var(--muted);
  font-size: 10px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}

.quick-action {
  display: flex;
  min-height: 64px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  text-align: start;
}

.quick-action:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quick-action strong {
  font-size: 12px;
}

.quick-action span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

/* Tables */

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

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

.data-table th {
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 10px;
  font-weight: 670;
}

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

.data-table tbody tr:hover td {
  background: oklch(98% 0.004 158);
}

.data-table .cell-wrap {
  max-width: 310px;
  white-space: normal;
}

.data-table .cell-primary {
  display: block;
  color: var(--ink);
  font-weight: 620;
}

.data-table .cell-secondary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.table-empty {
  padding: 36px 20px !important;
  color: var(--muted);
  text-align: center !important;
  white-space: normal;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 8px 13px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
}

/* Forms */

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

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

.field {
  min-width: 0;
}

.field-span-2 {
  grid-column: span 2;
}

.field-span-3 {
  grid-column: span 3;
}

.field label,
.field legend {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.field legend {
  padding: 0;
}

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

.label-row > span {
  color: var(--muted);
  font-size: 10px;
}

.field input,
.field select,
.field textarea,
.filter-bar input,
.filter-bar select {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12px;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.filter-bar input:hover,
.filter-bar select:hover {
  border-color: var(--muted);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--focus);
  outline: 2px solid oklch(61% 0.14 157 / 0.18);
  outline-offset: 0;
}

.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea,
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-message {
  min-height: 0;
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 10px;
}

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

.field-help {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
}

.radio-option {
  position: relative;
  flex: 1 1 150px;
}

.radio-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.radio-option span {
  display: flex;
  min-height: 48px;
  flex-direction: column;
  justify-content: center;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 11px;
  font-weight: 640;
}

.radio-option small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 450;
}

.radio-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.radio-option input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  min-height: 0;
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--accent);
}

.checkbox-row label {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
}

.form-section {
  padding: 18px;
}

.form-section + .form-section {
  border-top: 1px solid var(--border);
}

.form-section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.form-section-title h3 {
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 680;
}

.form-section-title p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 10px;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  border-radius: 0 0 var(--radius) var(--radius);
}

.form-footer .form-feedback {
  flex: 1 1 auto;
}

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

.form-feedback {
  min-height: 18px;
  color: var(--muted);
  font-size: 11px;
}

.form-feedback.is-error {
  color: var(--danger);
}

.form-feedback.is-success {
  color: var(--success);
}

.form-feedback.is-loading {
  color: var(--info);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(140px, 0.7fr)) auto;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.filter-bar label {
  min-width: 0;
}

.filter-bar .button {
  align-self: stretch;
}

.input-action {
  display: flex;
  align-items: stretch;
  gap: 7px;
}

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

/* Structured rewards and reviews */

.reward-builder {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.reward-builder-header {
  display: grid;
  grid-template-columns: 0.65fr 1.4fr 0.6fr 32px;
  gap: 8px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.reward-row {
  display: grid;
  grid-template-columns: 0.65fr 1.4fr 0.6fr 32px;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
}

.reward-row + .reward-row {
  border-top: 1px solid var(--border);
}

.reward-row select,
.reward-row input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 11px;
}

.reward-row .remove-reward {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}

.reward-row .remove-reward:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.reward-builder-footer {
  padding: 8px 9px;
  border-top: 1px solid var(--border);
}

.review-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 18px);
}

.review-empty,
.empty-state {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-symbol {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink-soft);
  font-weight: 720;
}

.review-empty strong,
.empty-state strong {
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-size: 12px;
}

.review-empty p,
.empty-state p {
  max-width: 38ch;
  margin-bottom: 0;
  font-size: 10px;
  text-wrap: pretty;
}

.review-summary {
  padding: 4px 0;
}

.review-summary dl {
  margin: 0;
}

.review-summary dl > div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 14px;
}

.review-summary dl > div + div {
  border-top: 1px solid var(--border);
}

.review-summary dt {
  color: var(--muted);
  font-size: 10px;
}

.review-summary dd {
  margin: 0;
  font-size: 11px;
  font-weight: 560;
  overflow-wrap: anywhere;
}

.reward-summary-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-warning {
  margin: 12px 14px;
  padding: 10px 11px;
  border: 1px solid oklch(83% 0.075 76);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: oklch(38% 0.09 76);
  font-size: 10px;
}

.review-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

/* Players and query details */

.search-hero {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.search-hero form {
  display: flex;
  gap: 8px;
}

.search-hero .field {
  flex: 1 1 auto;
}

.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.player-detail {
  position: sticky;
  top: calc(var(--topbar-height) + 18px);
}

.identity-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.identity-avatar {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 750;
}

.identity-block h2 {
  margin-bottom: 2px;
  font-size: 15px;
  font-weight: 700;
}

.identity-block p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 10px;
}

.detail-list li {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 14px;
}

.detail-list li + li {
  border-top: 1px solid var(--border);
}

.detail-list span {
  color: var(--muted);
  font-size: 10px;
}

.detail-list strong {
  min-width: 0;
  font-size: 11px;
  font-weight: 570;
  overflow-wrap: anywhere;
}

.detail-section-title {
  margin: 0;
  padding: 13px 14px 7px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 680;
}

.summary-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0 14px 14px;
}

.summary-values div {
  padding: 8px 9px;
  background: var(--surface-subtle);
}

.summary-values div:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.summary-values div:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

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

.summary-values strong {
  margin-top: 2px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.query-selector {
  display: grid;
  grid-template-columns: minmax(210px, 0.7fr) minmax(260px, 1.3fr) auto;
  gap: 10px;
  align-items: end;
}

.query-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 12px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  color: var(--ink-soft);
  font-size: 10px;
}

.query-note strong {
  color: var(--accent-ink);
}

/* Operations */

.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
  padding: 11px 13px;
  border: 1px solid oklch(84% 0.05 242);
  border-radius: var(--radius);
  background: var(--info-soft);
  color: oklch(36% 0.07 242);
  font-size: 11px;
}

.notice-bar strong {
  white-space: nowrap;
}

.notice-bar p {
  margin: 0;
}

.environment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 13px 15px;
}

.environment-row + .environment-row {
  border-top: 1px solid var(--border);
}

.environment-info {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(180px, 1fr) minmax(100px, 0.5fr);
  gap: 16px;
  align-items: center;
}

.environment-info > span,
.environment-info > strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.environment-info strong {
  font-size: 12px;
  font-weight: 640;
}

.environment-info span {
  color: var(--muted);
  font-size: 10px;
}

.task-catalog {
  display: flex;
  flex-direction: column;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 0.45fr) auto;
  gap: 18px;
  align-items: center;
  padding: 13px 15px;
}

.task-row + .task-row {
  border-top: 1px solid var(--border);
}

.task-row strong,
.task-row span {
  display: block;
}

.task-row strong {
  font-size: 12px;
  font-weight: 640;
}

.task-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.task-owner {
  color: var(--ink-soft) !important;
}

/* Loading, errors, dialog and toast */

.page-loading {
  padding-top: 4px;
}

.skeleton {
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.skeleton::after {
  display: block;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, transparent, oklch(100% 0 0 / 0.75), transparent);
  content: "";
  animation: shimmer 1.25s ease-in-out infinite;
}

.skeleton-title {
  width: 160px;
  height: 25px;
  margin-bottom: 10px;
}

.skeleton-line {
  width: min(420px, 70%);
  height: 12px;
  margin-bottom: 30px;
}

.skeleton-block {
  width: 100%;
  height: 230px;
}

.error-state {
  display: flex;
  min-height: 340px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

.error-state .error-symbol {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 750;
}

.error-state h2 {
  margin-bottom: 6px;
  font-size: 16px;
}

.error-state p {
  max-width: 50ch;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 11px;
}

.confirm-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 24px oklch(20% 0.02 158 / 0.22);
}

.confirm-dialog::backdrop {
  background: oklch(18% 0.025 158 / 0.54);
}

.confirm-dialog form {
  padding: 20px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.dialog-symbol {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 780;
}

.dialog-heading h2 {
  margin-bottom: 4px;
  font-size: 16px;
}

.dialog-heading p {
  margin-bottom: 16px;
  color: var(--ink-soft);
  font-size: 11px;
  text-wrap: pretty;
}

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

.toast-region {
  position: fixed;
  z-index: var(--z-toast);
  right: 18px;
  bottom: 18px;
  display: flex;
  width: min(380px, calc(100vw - 36px));
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
  padding: 12px 13px;
  border-radius: var(--radius);
  background: oklch(25% 0.025 158);
  color: var(--surface);
  box-shadow: 0 5px 12px oklch(20% 0.02 158 / 0.22);
  pointer-events: auto;
  animation: toast-in 180ms ease-out both;
}

.toast-symbol {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: oklch(100% 0 0 / 0.14);
  font-size: 10px;
  font-weight: 750;
}

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  font-size: 11px;
}

.toast span {
  margin-top: 1px;
  color: oklch(86% 0.012 158);
  font-size: 10px;
}

.toast button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: oklch(84% 0.01 158);
}

.toast button:hover {
  background: oklch(100% 0 0 / 0.1);
  color: var(--surface);
}

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

@keyframes shimmer {
  from { transform: translateX(-120%); }
  to { transform: translateX(260%); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */

@media (max-width: 1120px) {
  .content-grid,
  .player-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .review-panel,
  .player-detail {
    position: static;
  }

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

  .stat-item:nth-child(3) {
    border-inline-start: 0;
  }

  .stat-item:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

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

  .form-grid-3 .field-span-3 {
    grid-column: span 2;
  }
}

@media (max-width: 860px) {
  .auth-view {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-panel {
    width: 100%;
    min-height: 100vh;
    border-inline-end: 0;
  }

  .auth-context {
    display: none;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    z-index: calc(var(--z-sidebar) - 1);
    inset: 0;
    display: block;
    border: 0;
    background: oklch(18% 0.02 158 / 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease-out;
  }

  body.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .workspace {
    margin-left: 0;
  }

  .menu-button {
    display: flex;
  }

  .topbar {
    padding: 0 14px;
  }

  .global-search {
    width: min(440px, 60vw);
  }

  .topbar-action {
    display: none;
  }

  .main-content {
    padding: 24px 20px 44px;
  }

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

@media (max-width: 660px) {
  .auth-panel {
    padding: 28px 22px;
  }

  .auth-copy {
    padding-top: 52px;
  }

  .topbar {
    gap: 8px;
  }

  .global-search {
    width: auto;
    flex: 1 1 auto;
  }

  .global-search input {
    padding-right: 10px;
  }

  .global-search kbd,
  .connection-status {
    display: none;
  }

  .main-content {
    padding: 20px 14px 40px;
  }

  .page-heading {
    flex-direction: column;
    gap: 14px;
  }

  .page-heading h1 {
    font-size: 21px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .button {
    flex: 1 1 auto;
  }

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

  .stat-item + .stat-item,
  .stat-item:nth-child(3) {
    border-top: 1px solid var(--border);
    border-inline-start: 0;
  }

  .stat-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 16px;
    align-items: center;
    padding: 12px 14px;
  }

  .stat-label {
    grid-row: span 2;
    margin: 0;
  }

  .stat-value {
    font-size: 18px;
    text-align: end;
  }

  .stat-note {
    text-align: end;
  }

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

  .field-span-2,
  .field-span-3,
  .form-grid-3 .field-span-3 {
    grid-column: span 1;
  }

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

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions {
    width: 100%;
  }

  .form-actions .button {
    flex: 1 1 auto;
  }

  .reward-builder-header {
    display: none;
  }

  .reward-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 68px 30px;
    padding: 9px;
  }

  .attention-item {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .attention-item .button {
    grid-column: 2;
    justify-self: start;
  }

  .search-hero form {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .environment-info > span:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .task-owner {
    display: none !important;
  }

  .notice-bar {
    flex-direction: column;
    gap: 2px;
  }

  .review-summary dl > div,
  .detail-list li {
    grid-template-columns: 92px minmax(0, 1fr);
  }
}

@media (max-width: 420px) {
  .reward-row {
    grid-template-columns: minmax(0, 1fr) 62px 30px;
  }

  .reward-row [data-reward-kind] {
    grid-column: 1 / -1;
  }

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

  .summary-values {
    grid-template-columns: minmax(0, 1fr);
    gap: 1px;
  }

  .summary-values div:first-child,
  .summary-values div:last-child {
    border-radius: 0;
  }
}

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