@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --panel-soft: #fbfaf5;
  --line: #d7d2c4;
  --line-strong: #b6ae9d;
  --text: #23201b;
  --muted: #615a4f;
  --primary: #1e6a57;
  --primary-strong: #145644;
  --accent: #b4771f;
  --danger: #a53e2f;
  --ok: #1e7a4b;
  --shadow: 0 10px 30px rgba(40, 32, 20, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f0ede4 0%, var(--bg) 35%, #f8f7f2 100%);
  color: var(--text);
  font-family: "Space Grotesk", "Avenir Next", "Trebuchet MS", sans-serif;
  line-height: 1.35;
}

.bg-shape {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(0.4px);
}

.bg-shape-1 {
  top: -120px;
  right: -80px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(30, 106, 87, 0.25), rgba(30, 106, 87, 0));
}

.bg-shape-2 {
  bottom: -160px;
  left: -120px;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  background: radial-gradient(circle at 60% 45%, rgba(180, 119, 31, 0.16), rgba(180, 119, 31, 0));
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 16px 14px 50px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  animation: enter 260ms ease both;
}

.hero {
  background:
    linear-gradient(140deg, rgba(30, 106, 87, 0.06), rgba(255, 255, 255, 0) 60%),
    linear-gradient(320deg, rgba(180, 119, 31, 0.08), rgba(255, 255, 255, 0) 50%),
    var(--panel-soft);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.badge {
  margin: 0;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  border: 1px solid rgba(30, 106, 87, 0.28);
  background: rgba(30, 106, 87, 0.08);
  font-weight: 600;
}

.hero-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(1.28rem, 2.3vw, 1.9rem);
  line-height: 1.15;
}

h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.2;
}

h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.2;
}

.muted {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-points {
  margin: 10px 0 0;
  padding-left: 17px;
  display: grid;
  gap: 3px;
  color: #4b4438;
  font-size: 0.88rem;
}

.section-head {
  margin-bottom: 12px;
}

.tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
  padding: 5px;
  border-radius: 12px;
  background: #efe9da;
}

.tab {
  appearance: none;
  border: none;
  border-radius: 9px;
  padding: 8px 14px;
  background: transparent;
  color: #5b5243;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: #1e6a57;
  box-shadow: 0 2px 6px rgba(35, 32, 27, 0.08);
}

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

label {
  display: block;
  font-size: 0.82rem;
  color: #474034;
}

input,
select,
button {
  width: 100%;
  margin-top: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 10px 11px;
}

input,
select {
  background: #ffffff;
  color: var(--text);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 106, 87, 0.17);
}

button {
  cursor: pointer;
}

.btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
  transition: background-color 140ms ease, transform 140ms ease;
}

.btn:hover {
  background: var(--primary-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.btn.ghost {
  background: #fff;
  color: #3b3328;
  border-color: var(--line-strong);
}

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

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

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--panel-soft);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#wsState {
  color: #5b5243;
}

#wsState[data-state="connected"] {
  color: var(--ok);
}

#wsState[data-state="error"],
#wsState[data-state="closed"] {
  color: var(--danger);
}

.page-nav {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: #efe9da;
  padding: 8px;
}

.page-tab {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 11px;
  margin: 0;
  padding: 9px 10px;
  background: transparent;
  color: #584f40;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.page-tab:hover {
  border-color: rgba(30, 106, 87, 0.22);
  background: rgba(255, 255, 255, 0.65);
}

.page-tab.active {
  background: #fff;
  border-color: rgba(30, 106, 87, 0.35);
  color: var(--primary);
  box-shadow: 0 4px 10px rgba(23, 22, 20, 0.08);
}

.page-view {
  animation: enter 200ms ease both;
}

#viewLogs .subcard-head {
  margin-bottom: 4px;
}

.result-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdfa;
  padding: 12px;
}

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

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 9px;
  min-width: 88px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5e5549;
  background: #f3eee0;
}

.status-chip[data-tone="ok"] {
  color: #105537;
  background: #e4f4eb;
  border-color: #9dc7ae;
}

.status-chip[data-tone="error"] {
  color: #7b251b;
  background: #fae8e5;
  border-color: #d8a59d;
}

.status-chip[data-tone="pending"] {
  color: #664012;
  background: #f9efdc;
  border-color: #d5bb8e;
}

.status-chip[data-tone="idle"] {
  color: #5e5549;
  background: #f3eee0;
  border-color: #d4cab8;
}

.result-meta {
  margin-top: 8px;
}

.result-output {
  margin-top: 8px;
  max-height: 38vh;
}

.ws-stats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.8rem;
  color: #4f463a;
  background: #f7f2e7;
}

.inline-btn {
  width: auto;
  margin-top: 0;
  padding: 8px 11px;
  font-size: 0.83rem;
}

.symbol-picker {
  margin-top: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffcf5;
}

.picker-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.picker-head h4 {
  margin: 0;
  font-size: 0.9rem;
}

.picker-head label {
  min-width: 220px;
}

.picker-filters {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.picker-fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.picker-fieldset legend {
  font-size: 0.78rem;
  padding: 0 5px;
  color: var(--muted);
}

.picker-fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.8rem;
}

.picker-fieldset input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}

.picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.symbols-list {
  margin-top: 9px;
  min-height: 220px;
  width: 100%;
  background: #fff;
}

.symbols-list option {
  padding: 4px 7px;
}

.picker-summary {
  margin-top: 7px;
  margin-bottom: 0;
  font-size: 0.83rem;
}

.grid2 {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr;
}

.grid3 {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr;
}

.actions-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  margin-top: 9px;
}

.admin-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.subcard {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fffdfa;
}

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

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

.list-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 140ms ease;
}

.list-item:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(30, 106, 87, 0.12);
  transform: translateY(-1px);
}

.user-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.user-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.user-policy {
  margin-top: 7px;
  font-size: 0.8rem;
  color: #3f372b;
}

pre {
  margin: 0;
  padding: 11px;
  border-radius: 13px;
  border: 1px solid #11233a;
  background: #0f1926;
  color: #deebf8;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  overflow: auto;
  max-height: 46vh;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  z-index: 9999;
  right: 14px;
  bottom: 14px;
  min-width: 220px;
  max-width: min(92vw, 420px);
  border-radius: 13px;
  padding: 11px 12px;
  color: #fff;
  background: #243344;
  box-shadow: 0 14px 34px rgba(17, 18, 21, 0.32);
  font-size: 0.87rem;
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: #1d6d4a;
}

.toast.error {
  background: #8a3126;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 760px) {
  .page-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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

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

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

@media (max-width: 759px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .picker-head label {
    min-width: 0;
    width: 100%;
  }

  .picker-fieldset {
    grid-template-columns: 1fr;
  }

  .hero-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
}
