:root {
  color-scheme: light;
  --page: #eef3f8;
  --surface: #ffffff;
  --surface-muted: #f6f8fb;
  --border: #d6dee8;
  --text: #1d2939;
  --muted: #5d6b7c;
  --primary: #155eef;
  --primary-dark: #004eeb;
  --success: #067647;
  --success-dark: #05603a;
  --warning: #b54708;
  --warning-dark: #93370d;
  --danger: #b42318;
  --danger-dark: #912018;
  --neutral: #475467;
  --neutral-dark: #344054;
  --focus: #84adff;
  --shadow: 0 14px 36px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  padding: 24px;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #dbeafe 0, transparent 32rem),
    var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
canvas {
  max-width: 100%;
}

.container {
  max-width: 1380px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin: 4px 0 22px;
}

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

h1 {
  margin-bottom: 0;
  color: #102a56;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  color: #183153;
  font-size: 1.25rem;
  line-height: 1.25;
}

h3 {
  margin-bottom: 10px;
  color: #243b5a;
  font-size: 1rem;
}

.eyebrow,
.step-label {
  margin-bottom: 4px;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-summary {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
}

.section {
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid rgba(214, 222, 232, 0.9);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-section {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.section-heading > p {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.compact-heading {
  margin-bottom: 16px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  color: #344054;
  font-size: 0.88rem;
  font-weight: 700;
}

.field small {
  color: var(--muted);
  font-size: 0.78rem;
}

.field-wide {
  min-width: 280px;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #b8c4d2;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font-size: 0.92rem;
}

input::placeholder {
  color: #8996a8;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input:focus,
select:focus {
  border-color: var(--primary);
}

select:disabled {
  color: #475467;
  background: #f2f4f7;
  opacity: 1;
}

.button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 750;
  transition: background-color 120ms ease, border-color 120ms ease,
    transform 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.btn-primary {
  color: #ffffff;
  background: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-success {
  color: #ffffff;
  background: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: var(--success-dark);
}

.btn-warning {
  color: #ffffff;
  background: var(--warning);
}

.btn-warning:hover:not(:disabled) {
  background: var(--warning-dark);
}

.btn-danger {
  color: #ffffff;
  background: var(--danger);
}

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

.btn-secondary {
  color: #ffffff;
  background: var(--neutral);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--neutral-dark);
}

.status,
.notice {
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 0.9rem;
}

.status {
  margin-bottom: 0;
  box-shadow: var(--shadow);
}

.status-info,
.notice-info {
  border-color: #84caff;
  color: #1849a9;
  background: #eff8ff;
}

.status-success {
  border-color: #75e0a7;
  color: #05603a;
  background: #ecfdf3;
}

.status-warning,
.notice-warning {
  border-color: #fec84b;
  color: #93370d;
  background: #fffaeb;
}

.status-error {
  border-color: #fda29b;
  color: #912018;
  background: #fef3f2;
}

.notice {
  margin-top: 18px;
}

.identity-grid,
.session-identity {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 20px 0 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--border);
}

.identity-grid > div,
.session-identity > div {
  min-width: 0;
  padding: 13px 14px;
  background: var(--surface-muted);
}

.identity-grid dt,
.session-identity dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.identity-grid dd,
.session-identity dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #263b57;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 650;
}

.session-identity {
  grid-template-columns: 2fr 2fr 1fr;
  margin: 0 0 16px;
}

.profile-selector {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid #fec84b;
  border-radius: 10px;
  background: #fffcf5;
}

.profile-selector > p {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-candidates {
  display: grid;
  gap: 10px;
}

.profile-option {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  overflow-wrap: anywhere;
  border-color: #b8c4d2;
  color: var(--text);
  background: #ffffff;
  text-align: left;
}

.profile-option span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
}

.profile-option:hover:not(:disabled) {
  border-color: var(--primary);
  background: #f5f8ff;
}

.profile-option.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px #d1e0ff;
  background: #eff4ff;
}

.recovery-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.recovery-select {
  min-width: 320px;
  flex: 1 1 440px;
}

.recovery-actions {
  flex: 2 1 620px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stat-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-muted);
}

.stat-label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.stat-value {
  overflow-wrap: anywhere;
  color: #243b5a;
  font-size: 1.25rem;
  font-weight: 750;
}

.state-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
}

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

.chart-container {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.chart-container h3 {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.82rem;
}

canvas {
  display: block;
  width: 100%;
  height: 200px;
  border: 1px solid #e4e7ec;
  border-radius: 7px;
  background: #ffffff;
}

.log {
  min-height: 90px;
  max-height: 320px;
  padding: 14px;
  overflow-y: auto;
  border-radius: 9px;
  color: #a6f4c5;
  background: #101828;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.77rem;
  line-height: 1.45;
}

.log-entry {
  overflow-wrap: anywhere;
  margin-bottom: 5px;
}

.log-timestamp {
  color: #84caff;
}

.log-warn {
  color: #fec84b;
}

.log-error {
  color: #fda29b;
}

.hidden {
  display: none;
}

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

@media (max-width: 900px) {
  .page-header,
  .section-heading,
  .recovery-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .session-identity {
    grid-template-columns: 1fr;
  }

  .recovery-select,
  .recovery-actions {
    flex-basis: auto;
  }
}

@media (max-width: 700px) {
  body {
    padding: 12px;
  }

  .section {
    padding: 18px;
    border-radius: 11px;
  }

  .field-grid,
  .charts,
  .identity-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .field-wide,
  .recovery-select {
    min-width: 0;
  }
}
