:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.976 0.004 255);
  --panel: oklch(0.997 0 0);
  --ink: oklch(0.2 0.024 255);
  --muted: oklch(0.42 0.026 255);
  --line: oklch(0.885 0.017 255);
  --soft-line: oklch(0.93 0.01 255);
  --primary: oklch(0.47 0.16 27);
  --primary-hover: oklch(0.41 0.16 27);
  --primary-soft: oklch(0.95 0.026 27);
  --danger: oklch(0.52 0.18 27);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px oklch(0.2 0.024 255 / 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  transition: background-color 180ms ease, border-color 180ms ease, opacity 180ms ease;
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid oklch(0.76 0.12 165 / 0.45);
  outline-offset: 2px;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}

textarea {
  min-height: 116px;
  resize: vertical;
}

textarea::placeholder {
  color: oklch(0.48 0.018 255);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.16;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.shell,
.login-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
}

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

.login-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.login-message.error {
  color: var(--danger);
  font-weight: 700;
}

.topbar,
.top-actions,
.claim-actions,
.panel-head,
.progress-copy,
.credential-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  align-items: flex-start;
  margin-bottom: 18px;
}

.top-actions,
.claim-actions {
  align-items: center;
  justify-content: flex-end;
}

.mobile-actionbar,
.drawer-head,
.panel-close,
.panel-backdrop {
  display: none;
}

.topbar > div,
.panel-head > div {
  min-width: 0;
}

.progress-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
}

.progress-panel {
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.progress-copy {
  align-items: baseline;
}

.progress-copy span {
  color: var(--muted);
  font-weight: 700;
}

.progress-copy strong {
  color: var(--primary);
  font-size: 24px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--primary-soft);
  margin: 12px 0 16px;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 220ms ease;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.stat-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.stat-grid span {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.stat-grid small {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.workspace.single {
  grid-template-columns: minmax(0, 760px);
}

.panel {
  padding: 18px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head.simple {
  align-items: flex-start;
}

.primary-button,
.submit-button {
  color: white;
  background: var(--primary);
}

.primary-button:hover,
.submit-button:hover {
  background: var(--primary-hover);
}

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

.danger-button:hover {
  background: oklch(0.46 0.17 27);
}

.secondary-button {
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
}

.claim-actions {
  flex-wrap: wrap;
}

.secondary-button:hover {
  background: var(--primary-soft);
  border-color: oklch(0.78 0.04 27);
}

.credential-box {
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  margin-bottom: 16px;
}

.empty-state,
.empty-cell {
  color: var(--muted);
  text-align: center;
}

.empty-state {
  display: grid;
  min-height: 90px;
  place-items: center;
}

.credential-row {
  padding: 11px 0;
  border-bottom: 1px solid var(--soft-line);
}

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

.credential-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.credential-row code {
  min-width: 0;
  max-width: 100%;
  color: var(--ink);
  font-size: 14px;
}

.copy-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
}

.copy-button:hover {
  background: var(--primary-soft);
}

.sso-form {
  display: grid;
  gap: 10px;
}

.sso-form label {
  font-weight: 800;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--bg);
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  background: var(--surface);
}

tr:last-child td {
  border-bottom: 0;
}

.toast-area {
  position: fixed;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 10;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 820px) {
  body.panel-open {
    overflow: hidden;
  }

  .shell,
  .login-shell {
    width: min(100% - 20px, 1180px);
    padding: 16px 0 calc(84px + env(safe-area-inset-bottom));
  }

  .topbar,
  .top-actions,
  .claim-actions,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

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

  .stat-grid {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .stat-grid div {
    flex: 0 0 112px;
    scroll-snap-align: start;
  }

  .panel,
  .progress-panel {
    padding: 14px;
  }

  .primary-button,
  .secondary-button,
  .danger-button,
  .submit-button {
    width: 100%;
  }

  h1 {
    font-size: 23px;
  }

  p {
    font-size: 14px;
  }

  textarea {
    min-height: 132px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 16px, 1180px);
  }

  .progress-copy {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .mobile-actionbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--soft-line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
  }

  .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }

  .panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink);
  }

  .panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    background: oklch(0.2 0.024 255 / 0.42);
  }

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

  .drawer-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(86vw, 360px);
    margin: 0;
    overflow-y: auto;
    border-radius: 0 var(--radius) var(--radius) 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .drawer-panel.open {
    transform: translateX(0);
  }

  .modal-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 40;
    max-height: min(76vh, 640px);
    overflow-y: auto;
    margin: 0;
    transform: translateY(calc(100% + 24px));
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .modal-panel.open {
    transform: translateY(0);
  }

  .modal-panel:not(.open),
  .drawer-panel:not(.open) {
    pointer-events: none;
  }

  .stat-grid {
    gap: 8px;
  }

  .stat-grid div {
    padding: 10px;
  }

  .credential-box {
    padding: 12px;
  }

  .credential-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding: 10px 0;
  }

  .credential-row code {
    width: 100%;
  }

  .copy-button {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--soft-line);
    border-radius: var(--radius-sm);
    background: var(--bg);
    overflow: hidden;
  }

  tr + tr {
    margin-top: 10px;
  }

  td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--soft-line);
    padding: 10px 12px;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 800;
  }

  td.empty-cell {
    display: block;
    border: 1px solid var(--soft-line);
    border-radius: var(--radius-sm);
    padding: 18px;
  }

  td.empty-cell::before {
    content: "";
  }

  .toast-area {
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
  }
}

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