:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #657386;
  --line: #d9e0e8;
  --accent: #0d7a66;
  --dev: #9a5b00;
  --dev-bg: #fff6df;
  --dev-line: #f0c66a;
  --danger: #b42318;
  --focus: #1f6feb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(13, 122, 102, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(31, 111, 235, 0.08), transparent 42%),
    var(--bg);
}

.gate-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-panel {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(24, 33, 47, 0.12);
}

.brand {
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 8px;
}

.gate-marker {
  width: fit-content;
  margin: 0 0 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.gate-copy,
.gate-note {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 20px;
  background: #eef2f5;
  border-radius: 8px;
  padding: 4px;
}

.tab,
button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

.tab {
  background: transparent;
  color: var(--muted);
}

.tab.is-active {
  background: #ffffff;
  color: var(--text);
}

.gate-form {
  display: none;
  gap: 14px;
}

.gate-form.is-active {
  display: grid;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

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

button[type="submit"],
.space-list button {
  min-height: 44px;
  background: var(--accent);
  color: #ffffff;
}

.state-message {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--muted);
}

.test-code-panel {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--dev-line);
  border-radius: 8px;
  background: var(--dev-bg);
  color: var(--dev);
  font-size: 14px;
  line-height: 1.45;
}

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

.gate-shell[data-state="loading"] .state-message::before {
  content: "Подождите...";
}

.gate-shell[data-state="error"] .state-message,
.gate-shell[data-state="no-access"] .state-message {
  color: var(--danger);
}

.gate-shell[data-state="read-only"] .state-message {
  color: var(--dev);
}

.space-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

@media (max-width: 440px) {
  .gate-shell {
    padding: 0;
    place-items: stretch;
  }

  .gate-panel {
    width: 100%;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    padding: 24px 18px;
    box-shadow: none;
  }

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

  .tab {
    min-height: 46px;
    padding: 0 6px;
    font-size: 13px;
  }

  h1 {
    font-size: 24px;
  }
}
