:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #dde1e6;
  --text: #1c2430;
  --text-muted: #626c7a;
  --primary: #1e3a5f;
  --primary-dark: #142a45;
  --accent: #2f7d5c;
  --danger: #b3392c;
  --warning: #b3811e;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 30, 45, 0.08), 0 1px 2px rgba(20, 30, 45, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
  color: var(--primary-dark);
}

.login-card p.subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s ease;
}

button:hover, .btn:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary { background: #eef0f3; color: var(--text); }
.btn-secondary:hover { background: #e1e4e9; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8f2c22; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.error-msg {
  background: #fbeceb;
  color: var(--danger);
  border: 1px solid #f2c9c4;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.ok-msg {
  background: #eaf5ef;
  color: var(--accent);
  border: 1px solid #c8e6d5;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* --- App shell --- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--primary-dark);
  color: #fff;
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar .brand {
  padding: 0 20px 20px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 12px;
}

.sidebar .brand small {
  display: block;
  font-weight: 400;
  color: rgba(255,255,255,0.6);
  font-size: 11.5px;
  margin-top: 2px;
}

.nav-item {
  display: block;
  padding: 11px 20px;
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-size: 13.5px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 600;
}

.main {
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.topbar h2 { margin: 0; font-size: 19px; color: var(--primary-dark); }
.topbar .who { font-size: 13px; color: var(--text-muted); }

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 14.5px;
  color: var(--primary-dark);
}

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

.toolbar input[type="text"], .toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }

tr:hover td { background: #fafbfc; }

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

.badge-ok { background: #eaf5ef; color: var(--accent); }
.badge-off { background: #f5eaea; color: var(--danger); }
.badge-role { background: #eef1f6; color: var(--primary); }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: default;
}

.chip.enabled { border-color: #c8e6d5; background: #eaf5ef; color: var(--accent); }
.chip.disabled { color: var(--text-muted); }

.actions-cell { display: flex; gap: 6px; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 30, 45, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  padding: 26px 28px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal h3 { margin-top: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

.hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px;
  font-size: 13px;
}

code.key {
  background: #f4f5f7;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.hidden { display: none !important; }
