:root {
  --bg: #f5f5f7;
  --surface: #fff;
  --surface-soft: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --accent: #0071e3;
  --accent-strong: #005bb5;
  --good: #1d7f42;
  --good-bg: #e9f7ef;
  --warn: #9a6200;
  --warn-bg: #fff4d8;
  --bad: #d70015;
  --bad-bg: #fff0f2;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body.future-admin-page {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  min-height: 38px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 650;
}

a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  padding: 0 14px;
  font-size: 14px;
  font-weight: 650;
}

button:hover,
a:hover {
  border-color: rgba(0, 113, 227, 0.32);
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.16);
  transform: translateY(-1px);
}

button:active,
a:active {
  transform: translateY(0);
}

button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

button.danger {
  border-color: #ffccd3;
  background: var(--bad-bg);
  color: var(--bad);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  box-shadow: none;
  transform: none;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

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

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.admin-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.admin-header {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(210, 210, 215, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.admin-title {
  display: grid;
  gap: 4px;
}

.admin-title p,
.gate-copy p,
.admin-bar span {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.admin-title h1,
.gate-copy h2,
.panel-title h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.08;
  font-weight: 720;
}

.admin-title span,
.gate-copy span,
.panel-title span,
.metric small,
.monitor-item small,
.provider-card p,
#adminMode {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.admin-gate {
  width: min(760px, 100%);
  margin: 24px auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
  align-items: end;
  padding: 24px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.gate-copy {
  display: grid;
  gap: 8px;
}

.admin-gate form {
  display: grid;
  gap: 12px;
}

.admin-gate label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

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

#adminMode {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 2px;
}

.admin-workspace {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.demo-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(154, 98, 0, 0.24);
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
}

.demo-banner strong {
  color: var(--warn);
}

.demo-banner span {
  color: #6d4d00;
}

.ops-overview {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(0, 1.6fr);
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfbfd);
  box-shadow: var(--shadow-soft);
}

.ops-hero {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 150px;
}

.ops-hero span,
.ops-chip span,
.audit-check strong,
.provider-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.ops-hero strong {
  max-width: 560px;
  color: var(--text);
  font-size: 28px;
  line-height: 1.12;
  font-weight: 760;
}

.ops-hero p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.ops-snapshot,
.audit-checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ops-chip,
.audit-check {
  min-width: 0;
  display: grid;
  align-content: space-between;
  gap: 8px;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.ops-chip strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.ops-chip small,
.audit-check small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

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

.audit-check {
  min-height: 82px;
  background: var(--surface);
}

.audit-check span {
  justify-self: start;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
}

.audit-check.is-ok span {
  background: var(--good-bg);
  color: var(--good);
}

.audit-check.is-bad span {
  background: var(--bad-bg);
  color: var(--bad);
}

.admin-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.admin-bar div {
  display: grid;
  gap: 3px;
}

#adminStatus {
  color: var(--text);
  font-size: 15px;
}

.admin-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.admin-bar-actions span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

.metric,
.monitor-item {
  min-height: 108px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.metric span,
.monitor-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metric strong,
.monitor-item strong {
  color: var(--text);
  font-size: 30px;
  line-height: 1;
  font-weight: 720;
}

.monitor-item strong {
  font-size: 22px;
}

.monitor-item.is-p0 {
  border-color: #ffccd3;
  background: var(--bad-bg);
}

.monitor-item.is-p0 strong {
  color: var(--bad);
}

.admin-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

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

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-title > div {
  display: grid;
  gap: 5px;
}

.panel-title h2 {
  font-size: 19px;
}

.admin-danger-zone {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-danger-zone form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px;
  gap: 10px;
}

.security-actions {
  display: grid;
  grid-template-columns: 170px 170px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.security-actions form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 140px;
  gap: 10px;
}

.security-report {
  min-height: 70px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #111827;
  color: #d1fae5;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.session-repair-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(130px, 0.7fr)) minmax(160px, 1fr) 120px 110px;
  gap: 10px;
  align-items: center;
}

#sessionDetailForm {
  grid-template-columns: minmax(0, 1fr) 120px;
}

.inline-check {
  min-height: 42px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.inline-check input {
  width: auto;
  min-height: 0;
}

.session-detail {
  min-height: 120px;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.detail-card {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.detail-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
}

.detail-card strong {
  color: var(--text);
  font-size: 16px;
}

.timeline-list,
.answer-list {
  display: grid;
  gap: 8px;
}

.timeline-item,
.answer-item {
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.timeline-item strong,
.answer-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.timeline-item small,
.answer-item small {
  color: var(--muted);
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.provider-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.provider-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.provider-head > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.provider-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.provider-card form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.provider-secret-field {
  display: grid;
  gap: 7px;
}

.provider-secret-field span {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.provider-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

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

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

td {
  color: var(--text);
}

tbody tr:hover {
  background: #f9f9fb;
}

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

td code {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
}

.status-pill {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 7px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.status-good {
  background: var(--good-bg);
  color: var(--good);
}

.status-warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.status-neutral {
  background: #f1f1f4;
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.preview-panel iframe {
  width: 100%;
  height: min(72svh, 700px);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

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

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

@media (max-width: 920px) {
  .metrics-grid,
  .provider-grid,
  .monitor-grid,
  .ops-snapshot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-gate,
  .ops-overview {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .admin-shell {
    width: min(100% - 24px, 1280px);
    padding-top: 12px;
  }

  .admin-header,
  .admin-bar,
  .panel-title {
    display: grid;
  }

  .admin-header {
    position: static;
  }

  .metrics-grid,
  .provider-grid,
  .monitor-grid,
  .ops-snapshot,
  .audit-checklist,
  .admin-danger-zone,
  .admin-danger-zone form,
  .security-actions,
  .security-actions form,
  .auth-grid,
  .session-repair-form,
  #sessionDetailForm,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 700px;
  }
}
