:root {
  color-scheme: dark;
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e232b;
  --border: #2a3038;
  --text: #e7eaee;
  --muted: #94a0ad;
  --accent: #5b8cff;
  --danger: #ff5b6a;
  --ok: #3fcf8e;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
}

.card h1 {
  font-size: 20px;
  margin: 0 0 20px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}

input, textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}

textarea { resize: vertical; min-height: 100px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 16px;
}

/* ---- App shell ---- */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .brand {
  font-weight: 700;
  padding: 0 8px 16px;
  font-size: 16px;
}

.sidebar button.nav-item {
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 500;
  border-radius: 8px;
}

.sidebar button.nav-item.active,
.sidebar button.nav-item:hover {
  background: var(--panel-2);
  color: var(--text);
}

.sidebar .spacer { flex: 1; }

.main {
  padding: 24px 32px;
  overflow-y: auto;
}

.main h2 {
  margin-top: 0;
}

.view { display: none; }
.view.active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

th { color: var(--muted); font-weight: 600; background: var(--panel-2); }

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

tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-2); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.ok { background: rgba(63, 207, 142, 0.15); color: var(--ok); }
.badge.danger { background: rgba(255, 91, 106, 0.15); color: var(--danger); }
.badge.muted { background: rgba(148, 160, 173, 0.15); color: var(--muted); }

.stat-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  min-width: 140px;
}

.stat .value { font-size: 24px; font-weight: 700; }
.stat .label { font-size: 12px; color: var(--muted); }

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal .close-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.settings-note {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.entity-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.entity-card .eid { font-size: 11px; color: var(--muted); margin-bottom: 6px; word-break: break-all; }
.entity-card .estate { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.entity-card .eactions { display: flex; gap: 8px; }
.entity-card .eactions button { flex: 1; font-size: 12px; padding: 6px; }
