:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #ffffff;
  --background: #ffffff;
  --subtle: #f9fafb;
  --surface: #ffffff;
  --surface-muted: #f6f7f9;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --muted-strong: #4b5563;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --ring: rgb(37 99 235 / 18%);
  --success: #047857;
  --success-bg: #ecfdf5;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

button:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

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

button:focus-visible,
input:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px var(--ring);
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder {
  color: #9ca3af;
}

input:hover {
  border-color: #9ca3af;
}

a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 650;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: 0;
}

code,
time {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
}

code {
  color: #1f2937;
  white-space: nowrap;
}

time {
  color: var(--muted-strong);
  white-space: nowrap;
}

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

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

.empty-value {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.admin-shell {
  width: min(1240px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 48px 0;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.admin-header p {
  max-width: 620px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

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

.toolbar-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px;
  margin-bottom: 16px;
}

.toolbar-panel .muted,
.section-heading .muted {
  margin-top: 4px;
  font-size: 13px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(520px, 100%);
}

.form-row input {
  min-width: 260px;
}

.form-row button {
  flex: 0 0 auto;
}

.records-panel {
  overflow: hidden;
  box-shadow: 0 16px 40px rgb(17 24 39 / 4%);
}

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

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

table {
  width: 100%;
  min-width: 1268px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th:nth-child(1),
td:nth-child(1) {
  width: 230px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 94px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 300px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 170px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 150px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 150px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 160px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 104px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  padding: 10px 12px;
  background: var(--subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

td {
  padding: 12px;
  color: var(--text);
}

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

tbody tr:hover {
  background: #fcfcfd;
}

th:last-child,
.action-cell {
  position: sticky;
  right: 0;
  z-index: 1;
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: -10px 0 18px rgb(17 24 39 / 5%);
}

th:last-child {
  z-index: 2;
  background: var(--subtle);
}

tbody tr:hover .action-cell {
  background: #fcfcfd;
}

.label-cell {
  min-width: 230px;
  font-weight: 550;
}

.token-cell {
  min-width: 210px;
}

.error-cell {
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
}

.value-with-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.value-with-action code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ghost-button {
  min-height: 28px;
  border-color: var(--border-strong);
  padding: 0 9px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
}

.ghost-button:hover {
  border-color: #9ca3af;
  background: var(--surface-muted);
  color: var(--text);
}

.copy-button {
  flex: 0 0 auto;
}

.inline-edit-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-edit-form input {
  min-width: 0;
  min-height: 32px;
  font-size: 13px;
}

.inline-edit-form input[readonly] {
  border-color: transparent;
  background: transparent;
  padding-left: 0;
  color: var(--text);
  cursor: default;
}

.inline-edit-form input[readonly]:hover,
.inline-edit-form input[readonly]:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.inline-edit-form button,
.delete-form button {
  flex: 0 0 auto;
}

.note-edit-button,
.note-save-button {
  min-width: 44px;
}

.action-cell {
  text-align: center;
}

.delete-form {
  display: flex;
  justify-content: center;
}

.danger-button {
  min-height: 28px;
  border-color: #fecaca;
  padding: 0 9px;
  background: #fff7f7;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

.danger-button:hover {
  border-color: #fca5a5;
  background: #fee2e2;
  color: #991b1b;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-muted);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.status-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.status-connected {
  border-color: #bbf7d0;
  background: var(--success-bg);
  color: var(--success);
}

.status-pending,
.status-refreshing {
  border-color: #fde68a;
  background: var(--warning-bg);
  color: var(--warning);
}

.status-expired,
.status-error {
  border-color: #fecaca;
  background: var(--danger-bg);
  color: var(--danger);
}

.status-unknown {
  color: var(--muted-strong);
}

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 24px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 48%, #f6f7f9 100%);
}

.auth-card {
  width: min(560px, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgb(17 24 39 / 8%);
}

.auth-card-connected {
  border-color: #a7f3d0;
  box-shadow: 0 24px 64px rgb(4 120 87 / 11%);
}

.auth-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.auth-card h1 {
  font-size: 30px;
  line-height: 1.15;
}

.service-kicker {
  margin-bottom: 12px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.service-card .auth-notice {
  margin-top: 24px;
}

.auth-status {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 11px;
  font-size: 13px;
}

.context-label {
  margin-top: 18px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 14px 16px;
  background: #f8fafc;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.auth-notice {
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}

.auth-notice-pending {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.auth-notice-success {
  border-color: #bbf7d0;
  background: var(--success-bg);
}

.notice-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
}

.auth-notice-pending .notice-title {
  color: var(--primary-hover);
}

.auth-notice-success .notice-title {
  color: var(--success);
}

.lede {
  margin-top: 6px;
  color: var(--muted-strong);
  font-size: 15px;
  line-height: 1.6;
}

.auth-card form {
  margin-top: 24px;
}

.auth-card button {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  font-size: 16px;
}

.auth-card .secondary-action {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.auth-card .secondary-action:hover {
  border-color: #d97706;
  background: #fef3c7;
  color: #78350f;
}

.status-line {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.status-line span {
  color: var(--text);
  font-weight: 600;
}

.result-card p {
  margin-top: 14px;
  color: var(--muted-strong);
}

.success {
  border-color: #bbf7d0;
  box-shadow: 0 18px 44px rgb(4 120 87 / 8%);
}

.failure {
  border-color: #fecaca;
  box-shadow: 0 18px 44px rgb(185 28 28 / 8%);
}

@media (max-width: 760px) {
  .admin-shell {
    width: min(100%, calc(100vw - 28px));
    padding: 28px 0;
  }

  h1 {
    font-size: 24px;
  }

  .admin-header,
  .toolbar-panel,
  .section-heading {
    display: block;
  }

  .toolbar-panel {
    padding: 16px;
  }

  .form-row {
    display: grid;
    width: 100%;
    margin-top: 16px;
  }

  .form-row input {
    min-width: 0;
  }

  .form-row button {
    width: 100%;
  }

  .section-heading {
    padding: 16px;
  }

  .auth-card {
    padding: 24px;
  }

  .auth-card-header {
    display: block;
  }

  .auth-card h1 {
    font-size: 26px;
  }

  .auth-status {
    margin-top: 14px;
  }

  .context-label {
    padding: 12px 14px;
    font-size: 16px;
  }
}
