:root {
  --navy: #0f172a;
  --sidebar: #111827;
  --sidebar-2: #1e293b;
  --blue: #2563eb;
  --blue-600: #1d4ed8;
  --blue-50: #eff6ff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

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

/* Sidebar */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--blue); color: #fff; font-weight: 800;
  display: grid; place-items: center;
}
.brand small { display: block; color: #94a3b8; font-size: 11px; letter-spacing: .04em; }
.nav-sec {
  font-size: 11px; letter-spacing: .12em; color: #64748b;
  padding: 18px 18px 8px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; margin: 2px 10px; border-radius: 10px;
  color: #cbd5e1; cursor: pointer; font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-ico { width: 18px; text-align: center; opacity: .9; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: var(--blue);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; color: #fff;
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.bell {
  position: relative; width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255,255,255,.15); display: grid; place-items: center; cursor: pointer;
}
.badge {
  position: absolute; top: 4px; right: 4px; background: #ef4444;
  color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 99px;
  display: grid; place-items: center; font-weight: 700;
}
.user-wrap { position: relative; }
.user-menu {
  display: none;
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 200px; background: #fff; color: #0f172a;
  border-radius: 12px; box-shadow: 0 16px 40px rgba(15,23,42,.2);
  overflow: hidden; z-index: 80; border: 1px solid #e2e8f0;
}
.user-wrap.open .user-menu { display: block; }
.user-menu button {
  width: 100%; text-align: left; border: 0; background: #fff;
  padding: 11px 14px; font-size: 13px; font-weight: 600; cursor: pointer; color: #0f172a;
}
.user-menu button:hover { background: #f1f5f9; }
.user-menu .sep { height: 1px; background: #e2e8f0; }
.user-menu .out { color: #dc2626; }
.user-chip { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.15);
  padding: 6px 12px 6px 6px; border-radius: 999px; cursor: pointer; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #fff; color: var(--blue);
  display: grid; place-items: center; font-weight: 800; font-size: 12px;
}
.content { padding: 22px; }

/* Cards / tables */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 600; cursor: pointer;
  font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-sm { padding: 7px 10px; font-size: 12px; }

.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }

.stat, .card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 16px 18px; }
.stat .lbl { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat .val { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--ok); margin-top: 4px; }

.card { padding: 16px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-size: 11px; letter-spacing: .06em; padding: 10px 8px; border-bottom: 1px solid var(--line); }
td { padding: 12px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }

.pill {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.pill-ok { background: #d1fae5; color: #065f46; }
.pill-warn { background: #fef3c7; color: #92400e; }
.pill-off { background: #e2e8f0; color: #475569; }
.pill-info { background: #dbeafe; color: #1e40af; }
.pill-bad { background: #fee2e2; color: #991b1b; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 200px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: #fff;
}

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; width: min(640px, 100%); border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25); overflow: hidden;
}
.modal header { padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal .body { padding: 18px; max-height: 70vh; overflow: auto; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fff;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Login */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(800px 400px at 10% 0%, rgba(37,99,235,.25), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, rgba(124,58,237,.2), transparent 55%),
    #0b1220;
}
.login-card {
  width: min(420px, 92vw); background: #fff; border-radius: 20px; padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.login-card h2 { font-size: 22px; margin: 8px 0 4px; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 12px; background: #f8fafc; padding: 10px; border-radius: 10px; }

.empty { text-align: center; color: var(--muted); padding: 28px; }

.notif-list { display: grid; gap: 8px; }
.notif {
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.notif.unread { background: var(--blue-50); border-color: #bfdbfe; }
.notif time { color: var(--muted); font-size: 11px; }

.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; }

@media (max-width: 980px) {
  .g-4, .g-3 { grid-template-columns: 1fr 1fr; }
  .sidebar { width: 76px; }
  .nav-item span:last-child, .brand div, .nav-sec { display: none; }
  .nav-item { justify-content: center; }
}
@media (max-width: 640px) {
  .g-4, .g-3, .g-2, .row2, .perm-grid { grid-template-columns: 1fr; }
}
