:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #637083;
  --line: #dfe4ea;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 14px 38px rgba(24, 32, 42, .08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

button:hover { background: var(--accent-dark); }

button.ghost {
  color: var(--ink);
  background: #edf1f5;
}

input, select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

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

.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .14), transparent 45%),
    linear-gradient(315deg, rgba(37, 99, 235, .10), transparent 45%),
    var(--bg);
}

.login-panel {
  width: min(430px, 100%);
  padding: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 24px;
  font-size: 32px;
}

.join-panel {
  width: min(760px, 100%);
}

.join-command {
  display: block;
  margin: 18px 0 14px;
  padding: 14px;
  overflow-wrap: anywhere;
  border-radius: 7px;
  background: #eef2f6;
  color: #223044;
}

.small-note {
  margin: 14px 0 0;
  font-size: 13px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 22px;
  background: #111827;
  color: #fff;
}

.sidebar h1 {
  font-size: 25px;
  margin-bottom: 0;
}

.sidebar nav {
  display: grid;
  gap: 6px;
  margin-top: 26px;
}

.sidebar a {
  padding: 11px 12px;
  border-radius: 7px;
  color: #d7dde7;
  text-decoration: none;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, .09);
  color: #fff;
}

.workspace {
  width: min(1380px, 100%);
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h2 {
  margin-bottom: 0;
  font-size: 28px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar .eyebrow { color: #5eead4; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(24, 32, 42, .05);
}

.stats-grid article {
  padding: 20px;
}

.stats-grid span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.inline-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.key-form select { min-width: 130px; }

.check {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--muted);
  white-space: nowrap;
}

.check input {
  min-height: auto;
  width: 16px;
  height: 16px;
}

.table-wrap { overflow-x: auto; }

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

th, td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td code,
.new-key code {
  display: inline-block;
  max-width: 100%;
  padding: 7px 9px;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: #eef2f6;
  color: #223044;
}

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

.row-actions button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: #edf1f5;
}

.row-actions button.danger {
  color: #fff;
  background: var(--danger);
}

.new-key {
  display: grid;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #f3fbfa;
}

.command-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.error {
  min-height: 20px;
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 7px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .sidebar nav {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }
  .workspace { padding: 18px; }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .inline-form,
  .command-row {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .inline-form input,
  .inline-form select,
  .inline-form button {
    width: 100%;
  }
}
