:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #5b667a;
  --line: #dbe1ec;
  --accent: #1f5eff;
  --accent-ink: #ffffff;
  --ok: #177245;
  --ok-bg: #e8f6ee;
  --bad: #a32222;
  --bad-bg: #fdeaea;
  --radius: 12px;
  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141c;
    --panel: #171d28;
    --ink: #e8edf6;
    --muted: #a3aec2;
    --line: #2a3342;
    --accent: #7aa2ff;
    --accent-ink: #0b1020;
    --ok: #7fe0a8;
    --ok-bg: #15301f;
    --bad: #ff9c9c;
    --bad-bg: #361919;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--accent); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--panel);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }

.app-root { max-width: 1080px; margin: 0 auto; padding: 1.25rem; }
.boot { padding: 2rem; text-align: center; color: var(--muted); }

.shell { display: flex; flex-direction: column; gap: 1rem; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.brand { display: flex; flex-direction: column; gap: 0.15rem; }
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: 0.01em; }
.brand .sub { color: var(--muted); font-size: 0.85rem; }

.session { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.identity { display: flex; flex-direction: column; font-size: 0.85rem; }
.identity strong { font-weight: 600; }
.identity span { color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.panel > h2 { margin: 0 0 0.25rem; font-size: 1rem; }
.panel > .hint { margin: 0 0 1rem; color: var(--muted); font-size: 0.88rem; }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.panel-head h2 { margin: 0; font-size: 1rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; }
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.card h3 { margin: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.card .value { font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.card .detail { font-size: 0.82rem; color: var(--muted); overflow-wrap: anywhere; }
.card[data-phase="ok"] { background: var(--ok-bg); border-color: var(--ok); }
.card[data-phase="ok"] .value { color: var(--ok); }
.card[data-phase="error"] { background: var(--bad-bg); border-color: var(--bad); }
.card[data-phase="error"] .value { color: var(--bad); }
.card[data-phase="loading"], .card[data-phase="idle"] { opacity: 0.75; }

button, select {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.45rem 0.8rem;
}
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button:disabled { opacity: 0.6; cursor: progress; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
select.tenant { min-width: 12rem; }

.alert {
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border: 1px solid var(--bad);
  background: var(--bad-bg);
  color: var(--bad);
}
.alert[data-kind="info"] { border-color: var(--line); background: var(--bg); color: var(--ink); }
.alert code { font-size: 0.82rem; }

.members-header { font-weight: 600; margin-bottom: 0.75rem; }
.state { color: var(--muted); }
.state-error { color: var(--bad); }
table.members { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.members th, table.members td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); }
table.members th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.total { display: inline-block; margin-top: 0.5rem; color: var(--muted); font-size: 0.85rem; }

.contract-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.contract-meta div { border-left: 3px solid var(--line); padding-left: 0.7rem; }
.contract-meta dt { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.contract-meta dd { margin: 0.1rem 0 0; font-size: 0.88rem; overflow-wrap: anywhere; }
details.operations { border-top: 1px solid var(--line); padding-top: 0.75rem; }
details.operations summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.operation-list { max-height: 21rem; overflow: auto; margin: 0.75rem 0 0; padding: 0; list-style: none; font-size: 0.82rem; }
.operation-list li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--line); }
.operation-list .method { font-weight: 700; color: var(--muted); }
.operation-list code { overflow-wrap: anywhere; }

.footer { color: var(--muted); font-size: 0.78rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.25rem 0.25rem 1rem; }
.fatal { max-width: 44rem; margin: 3rem auto; }
.fatal h1 { font-size: 1.25rem; }
