:root {
  --bg: #0f1412;
  --bg-elev: #171d1a;
  --panel: #1c2420;
  --line: #2a3530;
  --text: #e8efe9;
  --muted: #8fa399;
  --accent: #3ecf8e;
  --accent-dim: #1f6b4a;
  --warn: #e4b45a;
  --danger: #e07070;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(900px 420px at 10% -10%, #1a3a2c 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #1e2a24 0%, transparent 50%),
    var(--bg);
  color: var(--text);
}

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

.rail {
  border-right: 1px solid var(--line);
  background: rgba(15, 20, 18, 0.9);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #1a7a52);
}
.brand strong { display: block; font-size: 1rem; }
.brand small { color: var(--muted); }

nav { display: flex; flex-direction: column; gap: 0.35rem; }
.nav-btn {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.nav-btn:hover { background: var(--bg-elev); color: var(--text); }
.nav-btn.active {
  background: var(--accent-dim);
  color: var(--text);
}

.rail-foot {
  margin-top: auto;
  display: grid;
  gap: 0.45rem;
}
.rail-foot label { font-size: 0.75rem; color: var(--muted); }
input, textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 0.82rem; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 1px solid var(--accent); }

main { padding: 1.5rem 1.75rem 2.5rem; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}
.top h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.top p { margin: 0.25rem 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

.btn {
  border: 0;
  background: var(--accent);
  color: #062417;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #5a2a2a;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.8rem;
  color: var(--muted);
}
.pill.ok { color: #9be7bf; border-color: #1d4a35; }
.pill.warn { color: #f0d9a0; border-color: #4a3d1d; }
.mono { font-family: var(--mono); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
}
.stat span { display: block; color: var(--muted); font-size: 0.8rem; }
.stat strong { font-size: 1.55rem; letter-spacing: -0.03em; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.15rem;
}
.panel h2 { margin: 0 0 0.85rem; font-size: 0.95rem; font-weight: 600; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}
.panel-head h2 { margin: 0; }
.muted { color: var(--muted); }

.bars { display: grid; gap: 0.55rem; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr auto;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.85rem;
}
.bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.bars.horizontal .bar-row {
  grid-template-columns: 72px 1fr auto;
}

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 500; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge.ok, .badge.active { background: #1d4a35; color: #9be7bf; }
.badge.error, .badge.revoked, .badge.disabled { background: #4a2323; color: #f0b0b0; }
.badge.suspended { background: #4a3d1d; color: #f0d9a0; }
.badge.builtin { background: #1a3340; color: #9bc7e7; }

.form-grid {
  display: grid;
  gap: 0.75rem;
  max-width: 520px;
}
.form-grid.two {
  max-width: none;
  grid-template-columns: 1fr 1fr;
}
.form-grid label, .tool-form > label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.tool-form { display: grid; gap: 0.85rem; max-width: 900px; }
.row { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }

.params-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.params-head h3 { margin: 0; font-size: 0.9rem; }
.params-list { display: grid; gap: 0.65rem; }
.param-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  background: var(--bg);
  display: grid;
  gap: 0.55rem;
}
.param-card .param-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr auto;
  gap: 0.5rem;
  align-items: end;
}
.param-card .param-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: end;
}
.param-card label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.check-label {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  flex-direction: row !important;
  padding-bottom: 0.55rem;
}
.check-label input { width: auto; }

.code-block {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.hidden { display: none !important; }

.linkish {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
}
.hint a { color: var(--accent); }
.hint code {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text);
}

.share-box {
  margin-top: 0.75rem;
  display: grid;
  gap: 1rem;
}
.share-banner {
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid rgba(62, 207, 142, 0.35);
  color: var(--text);
  font-size: 0.92rem;
}
.share-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: var(--bg-elev);
}
.share-block.highlight {
  border-color: rgba(62, 207, 142, 0.45);
  background: rgba(62, 207, 142, 0.06);
}
.share-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.share-value {
  display: block;
  word-break: break-all;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--accent);
  user-select: all;
}
.share-details {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  background: var(--bg-elev);
}
.share-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
}
.share-details[open] summary {
  margin-bottom: 0.25rem;
  color: var(--text);
}
.muted.small { font-size: 0.78rem; margin: 0.45rem 0 0; }
.code-block.nested {
  margin: 0 0 0.75rem;
  max-height: 200px;
  overflow: auto;
}

.steps {
  margin: 0.5rem 0 1rem;
  padding-left: 1.2rem;
  color: var(--text);
  line-height: 1.65;
}
.steps li { margin-bottom: 0.35rem; }
.steps code {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
}

.dialog-form {
  min-width: min(440px, 86vw);
}
.dialog-form h3 { margin: 0 0 0.35rem; }
.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}
.share-dialog { display: grid; gap: 0.85rem; }

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 1.15rem 1.2rem;
  width: min(520px, 94vw);
}
dialog::backdrop { background: rgba(0,0,0,0.55); }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .param-card .param-row,
  .param-card .param-row-2,
  .form-grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .stat-grid, .split { grid-template-columns: 1fr; }
}
