* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f4f5;
  --surface: #fff;
  --text: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #27272a;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 4%);
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background: var(--bg);
  font:
    14px / 1.45 system-ui,
    -apple-system,
    sans-serif;
}

a {
  color: inherit;
}

.shell {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

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

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand strong {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

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

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.tabs a {
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a.is-active {
  background: var(--text);
  color: #fff;
}

.page-head {
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  max-width: 52ch;
}

.hub-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 8px;
}

.hub-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}

.hub-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.hub-card:active {
  transform: scale(0.99);
}

.hub-card .eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hub-card h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.hub-card p {
  margin: 0;
  color: var(--muted);
  flex: 1;
}

.hub-card .cta {
  font-size: 13px;
  font-weight: 600;
}

.connect {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.connect .field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 180px;
  flex: 1;
}

.connect .field.grow {
  flex: 2;
  min-width: 220px;
}

.connect label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.connect input {
  width: 100%;
  max-width: none;
  margin: 0;
}

.status {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.status.is-visible {
  display: block;
}

.status.is-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.status.is-err {
  color: var(--err);
  background: var(--err-bg);
}

.status.is-info {
  color: var(--muted);
  background: #f4f4f5;
}

.panel {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.panel-body {
  padding: 16px;
}

.panel-body.flush {
  padding: 0;
}

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

.toolbar input[type="search"] {
  width: min(280px, 100%);
  max-width: none;
  margin: 0;
}

.muted {
  color: var(--muted);
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: block;
  margin-bottom: 10px;
}

input,
select,
button,
textarea {
  font: inherit;
}

input[type="password"],
input[type="text"],
input[type="email"],
input[type="search"],
input[type="number"],
select {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 4px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--text) 25%, transparent);
  outline-offset: 1px;
}

button {
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  cursor: pointer;
  font-weight: 550;
}

button:hover {
  filter: brightness(1.05);
}

button:active {
  transform: scale(0.98);
}

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

button.danger {
  background: #fff;
  color: var(--err);
  border-color: #fecaca;
}

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

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

.stat {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
}

.stat strong {
  display: block;
  margin-bottom: 2px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: #fafafa;
}

tr:last-child td {
  border-bottom: 0;
}

.cell-title {
  font-weight: 600;
}

.cell-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f4f4f5;
  color: var(--muted);
}

.badge.is-on {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.is-off {
  background: var(--err-bg);
  color: var(--err);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.row-actions input {
  width: 140px;
  max-width: none;
  margin: 0;
  padding: 7px 9px;
}

.plan-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.plan-row select,
.plan-row input {
  width: auto;
  max-width: none;
  margin: 0;
}

.duration-fields {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.duration-fields.is-hidden {
  display: none;
}

.plan-row .duration-input {
  width: 64px;
  padding: 7px 8px;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid label {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.form-grid input {
  max-width: none;
  margin: 0;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.empty strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

code {
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 640px) {
  .shell {
    width: calc(100% - 24px);
  }

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

  .connect button {
    width: 100%;
  }
}

.gate {
  display: flex;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate[hidden],
#workspace[hidden] {
  display: none !important;
}

.gate-card {
  width: min(420px, 100%);
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.gate-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.gate-card .lede {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.gate-card .stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gate-card label {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.gate-card input {
  max-width: none;
  margin: 0;
}

.gate-card .actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.gate-card .actions button {
  width: 100%;
}

.gate-status {
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 13px;
}

.gate-status.is-err {
  color: var(--err);
}

.gate-status.is-ok {
  color: var(--ok);
}

.connected-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
}

.connected-bar code {
  word-break: break-all;
}

