:root {
  --navy: #16233e;
  --navy-2: #22345a;
  --navy-3: #2f4b7a;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6eaf0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --mint: #10b981;
  --mint-dark: #059669;
  --mint-light: #d1fae5;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --blue-light: #e0e7ff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.right { text-align: right; }

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

.sidebar {
  width: 248px;
  background: var(--navy);
  color: #cfd8ea;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 20px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--mint), var(--mint-dark));
  color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 15px;
}
.brand-mark.lg { width: 54px; height: 54px; font-size: 20px; border-radius: 14px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: #8ea0c2; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #b9c4dc; font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav a span { width: 18px; text-align: center; opacity: .8; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--mint); color: #04351f; font-weight: 700; }
.nav a.active span { opacity: 1; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.who-name { color: #fff; font-size: 13px; font-weight: 600; }
.who-role { font-size: 11px; color: #8ea0c2; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--mint-light); color: var(--mint-dark);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none;
}
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }

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

/* ---- Page head ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.pill { font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 20px; }
.pill-live { background: var(--mint-light); color: var(--mint-dark); }

/* ---- Cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px;
}
.card-head { margin-bottom: 14px; }

/* ---- Stat grid ---- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--navy); margin: 8px 0 2px; }
.stat-sub { font-size: 12px; color: var(--muted); }

.role-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.role-cell { background: var(--bg); border-radius: 12px; padding: 16px; text-align: center; }
.role-count { font-size: 22px; font-weight: 800; color: var(--navy); }
.role-name { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfe; }
td small { display: block; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.ref { color: var(--muted); }

/* ---- Tags & badges ---- */
.tag { background: var(--blue-light); color: var(--navy-2); font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.badge-active, .badge-completed, .badge-normal { background: var(--mint-light); color: var(--mint-dark); }
.badge-suspended, .badge-failed, .badge-urgent { background: var(--red-light); color: var(--red); }
.badge-pending, .badge-reversed, .badge-high { background: var(--amber-light); color: var(--amber); }
.badge-low { background: #e2e8f0; color: #475569; }

/* ---- Attendance bar ---- */
.bar { position: relative; background: #eef1f7; border-radius: 8px; height: 22px; min-width: 140px; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--mint), var(--mint-dark)); border-radius: 8px; }
.bar-label { position: relative; font-size: 11px; font-weight: 700; color: var(--navy); line-height: 22px; padding-left: 10px; }

/* ---- Forms ---- */
.filters { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 14px; }
.row label { flex: 1; }
label span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(34,52,90,.1); }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.check span { margin: 0; }
.inline { display: inline; }

/* ---- Buttons ---- */
.btn {
  display: inline-block; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit; text-align: center;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-ok { background: var(--mint-light); color: var(--mint-dark); }

/* ---- Split layout ---- */
.split { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }

/* ---- Lists (announcements) ---- */
.list { display: flex; flex-direction: column; }
.list-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.list-body { margin: 6px 0; color: #334155; }
.list-meta { font-size: 12px; }
.pin { font-size: 12px; }

/* ---- Flash ---- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 600; font-size: 13.5px; }
.flash-success { background: var(--mint-light); color: var(--mint-dark); }
.flash-error { background: var(--red-light); color: var(--red); }

/* ---- Login ---- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, var(--navy), #0b1830); }
.login-card { background: #fff; width: 380px; max-width: 92vw; border-radius: 18px; padding: 32px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { margin: 0 auto 12px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-hint { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0 0; }
.login-hint code { background: var(--bg); padding: 2px 6px; border-radius: 5px; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: none; display: flex; gap: 12px; align-items: center; }
  .sidebar-foot .who { margin: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .role-grid { grid-template-columns: repeat(3, 1fr); }
  .split { grid-template-columns: 1fr; }
  .main { padding: 20px; }
}
