:root {
  --bg: #f6f7f9; --panel: #fff; --line: #e3e6ea; --text: #1b1f24; --muted: #667085;
  --accent: #d9480f; --accent-ink: #fff; --danger: #c92a2a; --ok: #2b8a3e;
  --radius: 10px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --panel: #171b21; --line: #2a3139; --text: #e6e9ed; --muted: #98a2b3; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; }
.hidden { display: none !important; }
a { color: var(--accent); }
code { font-size: .9em; background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; }
.brand span { color: var(--accent); font-weight: 500; margin-left: 6px; }
.who { color: var(--muted); font-size: 14px; display: flex; gap: 12px; align-items: center; }

.center { flex: 1; display: grid; place-items: center; padding: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; max-width: 420px; }
.card h1 { margin-top: 0; font-size: 22px; }
.card p { color: var(--muted); }

.layout { flex: 1; display: grid; grid-template-columns: 320px 1fr; min-height: 0; }
.side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.side-head input { flex: 1; }
.list { list-style: none; margin: 0; padding: 6px; overflow: auto; }
.list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.list li:hover { background: var(--bg); }
.list li.active { background: var(--accent); color: var(--accent-ink); }
.list li.active .muted { color: var(--accent-ink); opacity: .85; }
.list .t-name { font-weight: 600; }
.list .t-id { font-size: 12px; }
.list .counts { font-size: 12px; white-space: nowrap; text-align: right; }
.muted { color: var(--muted); }

.main { padding: 24px 28px; overflow: auto; }
.empty { color: var(--muted); padding: 60px; text-align: center; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.head h1 { margin: 0 0 4px; font-size: 24px; }
.head h1 input { font: inherit; font-weight: 700; border: 1px solid transparent; background: transparent; color: inherit; padding: 2px 6px; margin-left: -6px; border-radius: 6px; min-width: 300px; }
.head h1 input:hover, .head h1 input:focus { border-color: var(--line); background: var(--panel); outline: none; }
.actions { display: flex; gap: 8px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 12px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .pill { font-size: 12px; }

button { font: inherit; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 12px; cursor: pointer; }
button:hover { filter: brightness(.97); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ghost { background: transparent; }
button.sm { padding: 4px 9px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); width: 100%; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 22px 24px; width: 460px; max-width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
dialog label { display: block; margin: 10px 0; font-size: 14px; }
dialog label small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
dialog label input:not([type=checkbox]):not([type=radio]) { margin-top: 4px; }
dialog label.check { display: flex; gap: 8px; align-items: center; }
dialog label.check input { width: auto; margin: 0; }
dialog fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin: 12px 0; }
dialog legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 18px 0 0; }
.err { color: var(--danger); font-size: 13px; min-height: 1em; margin-top: 6px; }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 6px; min-height: 1em; }
.footprint { columns: 2; font-size: 13px; color: var(--muted); padding-left: 18px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .main { padding: 16px; }
  .footprint { columns: 1; }
}

/* Sidebar view switch (Tenants / Users) */
.side-tabs { display: flex; border-bottom: 1px solid var(--line); }
.side-tabs .tab { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px; cursor: pointer; color: var(--muted); font-weight: 600; }
.side-tabs .tab.active { color: inherit; border-bottom-color: var(--accent, #2563eb); }
