:root {
  --bg0: #0c0f12;
  --bg1: #141a1f;
  --bg2: #1b232b;
  --line: #2a3540;
  --text: #e8eef3;
  --muted: #8b9aab;
  --gold: #d4a35c;
  --gold-dim: #a67c3d;
  --ok: #6fbf8a;
  --err: #e07070;
  --radius: 12px;
  --font: "Instrument Sans", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 500px at 0% 0%, #1a2818 0%, transparent 55%),
    radial-gradient(800px 480px at 100% 10%, #2a2214 0%, transparent 50%),
    var(--bg0);
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.rail {
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg1) 88%, transparent);
  backdrop-filter: blur(8px);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  background: linear-gradient(145deg, var(--gold), var(--gold-dim));
  color: #1a1208;
}
.brand strong { display: block; font-size: 0.95rem; }
.brand small { color: var(--muted); font-size: 0.75rem; }

.nav-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.nav-item.active, .nav-item:hover {
  background: var(--bg2);
  color: var(--text);
}

.rail-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

main { padding: 1.5rem 1.75rem 2.5rem; max-width: 1180px; }

.panel {
  background: color-mix(in srgb, var(--bg1) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
}

.login-panel { max-width: 420px; margin: 8vh auto; }
.login-panel h1 { margin: 0 0 0.35rem; font-size: 1.6rem; letter-spacing: -0.02em; }

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.page-head h1 { margin: 0; font-size: 1.55rem; letter-spacing: -0.02em; }
.lede { margin: 0.35rem 0 0; color: var(--muted); line-height: 1.45; max-width: 42rem; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1rem;
  align-items: start;
}

.tenant-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tenant-card {
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg1);
  color: inherit;
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, transform 0.12s;
}
.tenant-card:hover { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
.tenant-card.active {
  border-color: var(--gold);
  box-shadow: inset 3px 0 0 var(--gold);
}
.tenant-card .name { font-weight: 600; }
.tenant-card .meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; font-family: var(--mono); }

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.editor-head h2 { margin: 0; font-size: 1.15rem; }

.form-grid {
  display: grid;
  gap: 1rem;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0;
  padding: 0.85rem 1rem 1rem;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 1fr 1fr;
}
fieldset legend {
  padding: 0 0.35rem;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.85rem;
}
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
}
label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  grid-column: 1 / -1;
}
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}
textarea { font-family: var(--mono); font-size: 0.78rem; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-color: var(--gold-dim);
}
.hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.editor-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}
button.primary {
  background: linear-gradient(180deg, #e0b56e, var(--gold-dim));
  color: #1a1208;
  font-weight: 600;
}
button.ghost {
  background: var(--bg2);
  border-color: var(--line);
  color: var(--text);
}
button.linkish {
  background: transparent;
  border: 0;
  color: var(--gold);
  padding: 0;
}
button:hover { filter: brightness(1.06); }

.stack { display: grid; gap: 0.75rem; }
.err { color: var(--err); }
.toast {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ok) 18%, var(--bg1));
  border: 1px solid color-mix(in srgb, var(--ok) 40%, var(--line));
  color: var(--ok);
}
.toast.bad {
  background: color-mix(in srgb, var(--err) 16%, var(--bg1));
  border-color: color-mix(in srgb, var(--err) 40%, var(--line));
  color: var(--err);
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .layout { grid-template-columns: 1fr; }
  fieldset { grid-template-columns: 1fr; }
}
