:root{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif}
body{margin:0;background:#0b1020;color:#e8ecff}
a{color:#cdd6ff;text-decoration:none}
.topbar{position:sticky;top:0;background:#0f1630;border-bottom:1px solid #24305f;display:flex;align-items:center;justify-content:space-between;padding:12px 16px;gap:12px}
.brand{font-weight:700}
.nav{display:flex;flex-wrap:wrap;gap:10px}
.nav a{padding:6px 10px;border-radius:10px;background:#121c3c}
.nav a:hover{background:#1a2a5b}
.container{max-width:1200px;margin:0 auto;padding:18px}
.footer{opacity:.7;padding:16px;text-align:center}
h1{margin:6px 0 14px 0}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:14px}
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(360px,1fr));gap:14px}
.card{background:#0f1630;border:1px solid #24305f;border-radius:16px;padding:14px;box-shadow:0 6px 18px rgba(0,0,0,.25)}
.btn{display:inline-block;background:#2b4cff;color:white;border:none;border-radius:12px;padding:10px 12px;font-weight:600;cursor:pointer}
.btn:hover{filter:brightness(1.05)}
.btn.secondary{background:#1b2a5b}
.btn.small{padding:6px 10px;border-radius:10px}
.form{display:flex;flex-direction:column;gap:10px}
.form input,.form select{padding:10px;border-radius:12px;border:1px solid #26356b;background:#0b1020;color:#e8ecff}
.row{display:flex;flex-wrap:wrap;gap:10px}
.row > label{flex:1;min-width:240px}
.table{width:100%;border-collapse:collapse;margin-top:10px}
.table th,.table td{border-bottom:1px solid #24305f;padding:10px;text-align:left;vertical-align:top}
.table tr.warn{background:rgba(255,165,0,.10)}
.actions{display:flex;gap:10px;align-items:center;justify-content:flex-end;margin:6px 0}
.inline{display:flex;gap:8px;align-items:center}
.muted{opacity:.75}
.success{background:rgba(0,255,140,.12);border:1px solid rgba(0,255,140,.25);padding:10px;border-radius:12px;margin-bottom:10px}
.error{background:rgba(255,80,80,.12);border:1px solid rgba(255,80,80,.25);padding:10px;border-radius:12px}
.mt{margin-top:12px}
/* ================== ADVANCED MOBILE MENU ================== */

.menu-toggle {
  display: none;
  width: 32px;
  height: 24px;
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
}

.menu-toggle span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 3px;
  background: #333;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.menu-toggle span:nth-child(1) { top: 0; }
.menu-toggle span:nth-child(2) { top: 10px; }
.menu-toggle span:nth-child(3) { top: 20px; }

/* X icon */
.menu-toggle.open span:nth-child(1) {
  transform: rotate(45deg);
  top: 10px;
}
.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}
.menu-toggle.open span:nth-child(3) {
  transform: rotate(-45deg);
  top: 10px;
}

/* Desktop */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Mobile */
@media (max-width: 768px) {

  .menu-toggle {
    display: block;
  }

  .nav {
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: #fff;
    flex-direction: column;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border-bottom: 1px solid #eee;
    z-index: 999;
  }

  .nav.open {
    max-height: 80vh;
  }

  .nav a {
    padding: 12px 16px;
    border-bottom: 1px solid #f2f2f2;
  }

  body.menu-open {
    overflow: hidden;
  }
}

/* ================== MENU LEVEL 3 ================== */

/* Sticky header */
.topbar {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1000;
}

/* Overlay */
.menu-overlay {
  display: none;
}

@media (max-width: 768px) {

  .menu-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    z-index: 998;
  }

  .menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .nav {
    z-index: 999;
  }

  /* Active link */
  .nav a.active {
    background: #f2f4f7;
    font-weight: 600;
  }
}
/* ================== MENU COLOR FIX ================== */

/* Header */
.topbar {
  background: #0f172a;
  color: #e5e7eb;
}

/* Brand */
.topbar .brand {
  color: #f8fafc;
  font-weight: 600;
}

/* Menu link */
.nav a {
  color: #e5e7eb;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}

/* Hover */
.nav a:hover {
  background: #1e293b;
}

/* Active */
.nav a.active {
  background: #2563eb;
  color: #fff;
}

/* Hamburger icon */
.menu-toggle span {
  background: #e5e7eb;
}

/* Mobile menu panel */
@media (max-width: 768px) {

  .nav {
    background: #0f172a;
  }

  .nav a {
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .menu-overlay {
    background: rgba(0,0,0,0.45);
  }
}

/* ===== RESPONSIVE TABLE - STACK MODE ===== */
@media (max-width: 768px) {

  .table thead {
    display: none;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    background: #0f1630;
    border: 1px solid #24305f;
    border-radius: 14px;
    padding: 10px;
    margin-bottom: 12px;
  }

  .table td {
    border: none;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }

  .table td::before {
    content: attr(data-label);
    font-weight: 600;
    opacity: .75;
  }
}

.table td.actions {
  justify-content: flex-end;
}
@media (max-width:768px){
  .btn.small {
    padding: 6px 8px;
    font-size: 13px;
  }
}
/* ===== ROLES PAGE RESPONSIVE ===== */

/* Desktop mặc định giữ 2 cột */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

/* Mobile: xếp dọc */
@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px 12px;
}

@media (max-width: 768px) {
  .perm-grid {
    grid-template-columns: 1fr;
  }
}

.perm-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.perm-item:hover {
  background: rgba(255,255,255,0.04);
}

.perm-item input[type="checkbox"] {
  margin-top: 3px;
  transform: scale(1.1);
}

.perm-group {
  margin-bottom: 12px;
}

.perm-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .perm-group-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
