:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #f0f4f3;
  --text: #17211f;
  --muted: #65736f;
  --line: #dce4e1;
  --accent: #0f8f7f;
  --accent-strong: #087064;
  --warn: #b56a12;
  --danger: #b42318;
  --good: #127a45;
  --shadow: 0 18px 50px rgba(18, 31, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #10201d;
  color: #d9fff6;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-footer,
p {
  color: var(--muted);
}

nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  color: #31413d;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 650;
}

.nav-item.active,
.nav-item:hover {
  background: #e9f4f1;
  color: var(--accent-strong);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  line-height: 1.5;
}

.workspace {
  padding: 28px;
  display: grid;
  gap: 18px;
  max-width: 1280px;
  width: 100%;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.topbar p,
.panel-heading p {
  margin-top: 6px;
}

.topbar-actions,
.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary,
.ghost {
  height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.metric,
.panel,
.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.metric {
  border-radius: 8px;
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.metric.good strong {
  color: var(--good);
}

.metric.warn strong {
  color: var(--warn);
}

.panel,
.auth-panel {
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
}

.auth-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.inline-form,
.form-grid {
  display: grid;
  gap: 10px;
}

.inline-form {
  grid-template-columns: minmax(260px, 1fr) auto;
}

.form-grid {
  grid-template-columns: 1fr 1fr auto;
}

input {
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 11px;
  color: var(--text);
  min-width: 0;
}

input:focus {
  outline: 2px solid rgba(15, 143, 127, 0.22);
  border-color: var(--accent);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td strong {
  display: block;
}

td small {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.status.active {
  color: var(--good);
  background: #eaf7f0;
}

.status.cooldown,
.status.exhausted {
  color: var(--warn);
  background: #fff2df;
}

.status.disabled,
.status.missing_secret {
  color: var(--danger);
  background: #fff0ee;
}

.mini-input {
  width: 86px;
}

.table-action {
  color: var(--accent-strong);
  background: transparent;
  font-weight: 800;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
}

.two-col .form-grid {
  grid-template-columns: 1fr;
}

.participant-list,
.token-list {
  display: grid;
  gap: 10px;
}

.participant,
.token-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fbfdfc;
}

.participant-head,
.token-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.participant-head {
  display: grid;
  gap: 10px;
}

.participant-actions {
  display: flex;
  gap: 8px;
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(420px, 100vw);
  background: white;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 48px rgba(18, 31, 28, 0.16);
  padding: 20px;
  transform: translateX(105%);
  transition: transform 180ms ease;
  z-index: 20;
  visibility: hidden;
  pointer-events: none;
}

.drawer:not(.open) {
  display: none;
}

.drawer.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.drawer-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 22px;
  line-height: 1;
}

.drawer-form,
.modal-form {
  display: grid;
  gap: 12px;
}

.drawer-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 750;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-row input {
  height: auto;
}

.full {
  width: 100%;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: min(520px, calc(100vw - 24px));
  padding: 20px;
}

dialog::backdrop {
  background: rgba(9, 21, 18, 0.32);
}

code {
  display: block;
  padding: 12px;
  background: #0f1f1c;
  color: #d9fff6;
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #10201d;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 40;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  nav,
  .metrics-grid,
  .two-col,
  .form-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }
}
