:root {
  --bg:       #0d1117;
  --bg2:      #161b22;
  --bg3:      #21262d;
  --border:   #30363d;
  --text:     #e6edf3;
  --text-dim: #8b949e;
  --gold:     #FFD700;
  --gold-dim: #b39800;
  --success:  #3fb950;
  --error:    #f85149;
  --info:     #58a6ff;
  --radius:   8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Screens ─────────────────────────────────────────── */
.screen { width: 100%; min-height: 100vh; }
.hidden { display: none !important; }

/* ── Login ───────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1a1f2e 0%, var(--bg) 70%);
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 28px;
}
.logo-m { color: var(--gold); font-size: 28px; }
.logo-sub { font-size: 12px; color: var(--text-dim); font-weight: 400; letter-spacing: 2px; text-transform: uppercase; }

/* ── Panel layout ────────────────────────────────────── */
#panel-screen {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 20px 16px 12px;
  font-size: 18px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.nav-links {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  transition: background .15s, color .15s;
  font-size: 14px;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover, .nav-link.active {
  background: var(--bg3);
  color: var(--gold);
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.main-content {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

/* ── Section ─────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-header h1 {
  font-size: 22px;
  font-weight: 700;
}
.content-section { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Rank Cards ──────────────────────────────────────── */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rank-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.rank-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.15);
}
.rank-info { flex: 1; }
.rank-name { font-weight: 600; font-size: 15px; }
.rank-meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.rank-perms-preview {
  font-size: 11px;
  color: var(--info);
  margin-top: 4px;
  font-family: monospace;
}
.rank-actions { display: flex; gap: 8px; }

/* ── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg3); }
.uuid-cell { color: var(--text-dim); font-size: 11px; font-family: monospace; }
.rank-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border);
}

/* ── Pagination ──────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  justify-content: center;
}
.page-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
}
.page-btn:hover, .page-btn.active { background: var(--gold); color: #000; border-color: var(--gold); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--gold); color: #0d1117; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger  { background: var(--error); color: #fff; }
.btn-sm      { padding: 5px 10px; font-size: 12px; }
.w-full      { width: 100%; }

/* ── Forms ───────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--text-dim); }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--gold); }
select option { background: var(--bg3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.color-row { display: flex; gap: 8px; align-items: center; }
input[type="color"] { width: 42px; height: 36px; padding: 2px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); cursor: pointer; flex-shrink: 0; }
.search-bar input { width: 280px; }
.error-msg { color: var(--error); font-size: 12px; padding: 8px 0; }

/* ── Modals ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ── Permissions list ────────────────────────────────── */
.perm-add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.perm-add-row input { flex: 1; }
.perm-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.perm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-family: monospace;
  font-size: 13px;
}
.perm-item.inherited { opacity: .6; }
.perm-inherited-label { font-size: 10px; color: var(--text-dim); margin-left: 6px; font-family: sans-serif; }
