* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fb;
  color: #111827;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: #0f172a;
  color: white;
  padding: 24px 18px;
}
.logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
  display: grid;
  place-items: center;
  font-weight: 800;
}
.side-title {
  margin: 14px 0 28px;
  font-size: 20px;
  font-weight: 700;
}
nav a {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 8px;
  color: #cbd5e1;
}
nav a.active {
  background: #1e293b;
  color: white;
}
nav a.disabled {
  opacity: .45;
}
.logout {
  position: absolute;
  left: 18px;
  bottom: 22px;
  color: #cbd5e1;
  text-decoration: none;
}
.main {
  margin-left: 240px;
  padding: 28px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
h1 {
  margin: 0;
  font-size: 30px;
}
.topbar p {
  margin: 6px 0 0;
  color: #64748b;
}
button {
  border: 0;
  background: #16a34a;
  color: white;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
}
.card span {
  color: #64748b;
  font-size: 14px;
}
.card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}
.panel {
  background: white;
  border-radius: 22px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
  overflow: hidden;
}
.panel-head {
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
}
.panel-head h2 {
  margin: 0;
}
input {
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 280px;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}
th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #eef2f7;
  font-size: 14px;
}
th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}
tr.alert td {
  background: #fff1f2;
}
.status {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 700;
  font-size: 12px;
}
.empty {
  padding: 36px;
  text-align: center;
  color: #16a34a;
  font-size: 20px;
  font-weight: 700;
}
.hidden { display: none; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top left, #dcfce7, transparent 35%), #f8fafc;
}
.login-card {
  width: min(420px, calc(100% - 32px));
  background: white;
  padding: 28px;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .12);
}
.brand {
  font-weight: 800;
  color: #16a34a;
  margin-bottom: 12px;
}
.login-card h1 {
  font-size: 24px;
  margin-bottom: 22px;
}
.login-card label {
  display: block;
  margin: 14px 0 6px;
  color: #475569;
}
.login-card input {
  width: 100%;
  min-width: 0;
}
.login-card button {
  width: 100%;
  margin-top: 20px;
}
.hint {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 0;
}

@media (max-width: 820px) {
  .sidebar {
    position: static;
    width: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
  }
  .side-title, .logout { position: static; margin: 0; white-space: nowrap; }
  nav { display: flex; gap: 8px; }
  nav a { margin-bottom: 0; white-space: nowrap; }
  .main { margin-left: 0; padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  input { min-width: 0; width: 100%; }
  .panel-head { flex-direction: column; align-items: stretch; }
}

.user-box {
  background: #1e293b;
  border-radius: 14px;
  padding: 12px 14px;
  margin: -12px 0 20px;
}
.user-box div {
  font-weight: 700;
  color: white;
}
.user-box small {
  display: block;
  margin-top: 4px;
  color: #94a3b8;
}
nav a.hidden-by-permission {
  display: none;
}

.page { display: none; }
.page.active-page { display: block; }

.user-form {
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 180px auto;
  gap: 12px;
  align-items: end;
}
.user-form label {
  display: none;
}
.user-form select {
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 12px 14px;
  background: white;
}
.small-btn {
  padding: 8px 12px;
  border-radius: 10px;
}
.role-pill, .active-pill, .locked-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.role-pill {
  background: #e0f2fe;
  color: #0369a1;
}
.active-pill {
  background: #dcfce7;
  color: #15803d;
}
.locked-pill {
  background: #fee2e2;
  color: #b91c1c;
}

@media (max-width: 820px) {
  .user-form {
    grid-template-columns: 1fr;
  }
}

.permission-box {
  grid-column: 1 / -1;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px 14px;
}
.permission-title {
  grid-column: 1 / -1;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}
.permission-box label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 14px;
}
.permission-box input {
  min-width: auto;
  width: auto;
}
.custom-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
}
.role-default-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
}
@media (max-width: 820px) {
  .permission-box {
    grid-template-columns: 1fr;
  }
}
