:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1a2a43;
  background: #f4f7fc;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  display: flex;
  min-height: 100vh;
}
a {
  color: #245cce;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ==================== SIDEBAR & MENU ==================== */
.sidebar {
  width: 228px;
  flex: none;
  background: #142b51;
  color: white;
  padding: 24px 14px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  font-weight: 800;
  font-size: 19px;
  padding: 4px 8px 22px;
}
.logo {
  display: inline-grid;
  place-items: center;
  background: white;
  color: #245cce;
  border-radius: 10px;
  width: 30px;
  height: 30px;
  margin-right: 7px;
}
.side-caption {
  color: #97b5e1;
  letter-spacing: 1px;
  font-size: 10px;
  margin: 4px 12px 20px;
}

/* Structuring Nav Container */
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Link Cấp 1 (Đơn lẻ) */
.sidebar nav > a {
  display: block;
  color: #ccdcf5;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.sidebar nav > a:hover,
.sidebar nav > a.active {
  background: #294a78;
  color: white;
  text-decoration: none;
}

/* Nhóm Menu Cấp 2 */
.nav-group {
  margin-top: 6px;
  margin-bottom: 4px;
}

/* Tiêu đề nhóm - Thu gọn tinh tế */
.nav-label {
  display: block;
  color: #7292c2;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 6px 12px 4px;
}

/* Khối Submenu con - Căn lùi vạch chỉ */
.submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 14px;
  padding-left: 8px;
  border-left: 2px solid #233e68;
}

.submenu a {
  display: block;
  color: #a3c2ee;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.submenu a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.submenu a.active {
  background: #245cce;
  color: #ffffff;
  font-weight: 600;
}

.side-foot {
  position: absolute;
  bottom: 18px;
  left: 18px;
  right: 18px;
  background: #294363;
  padding: 14px;
  border-radius: 12px;
  color: #cbdcf4;
  font-size: 11px;
  line-height: 1.7;
}

/* ==================== MAIN CONTENT & UI ==================== */
main {
  min-width: 0;
  flex: 1;
}
.topbar {
  background: white;
  border-bottom: 1px solid #e2e9f5;
  padding: 18px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar small {
  color: #7290be;
  font-size: 10px;
  letter-spacing: 0.9px;
  font-weight: 800;
}
.topbar h1 {
  font-size: 19px;
  margin: 3px 0 0;
}
.demo-pill {
  background: #ebf8f1;
  color: #1b8160;
  border-radius: 20px;
  padding: 8px 13px;
  font-size: 11px;
  font-weight: 700;
}
.content {
  max-width: 1450px;
  margin: auto;
  padding: 24px 30px;
}
.intro {
  color: #617189;
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.6;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat,
.card {
  background: white;
  border: 1px solid #dce6f6;
  border-radius: 14px;
  box-shadow: 0 3px 9px #1d416008;
}
.stat {
  padding: 19px 20px;
}
.stat small {
  display: block;
  color: #73839c;
  font-size: 12px;
}
.stat strong {
  display: block;
  font-size: 29px;
  margin-top: 5px;
  color: #234f9e;
}
.stat.alert strong {
  color: #d06b22;
}
.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 18px;
}
.card {
  padding: 18px;
  margin-bottom: 18px;
  min-width: 0;
}
.card h2 {
  font-size: 16px;
  margin: 0 0 14px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.card-head a {
  font-size: 12px;
}
.table-wrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
th {
  text-align: left;
  background: #f6f9ff;
  color: #657790;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.35px;
  padding: 12px 10px;
}
td {
  border-top: 1px solid #e7edf8;
  padding: 12px 10px;
  vertical-align: middle;
}
td strong {
  display: block;
}
td small {
  display: block;
  color: #8290a3;
  margin-top: 4px;
}
td:last-child {
  white-space: nowrap;
}
.badge {
  display: inline-block;
  background: #e8f5ee;
  color: #17845a;
  border-radius: 16px;
  padding: 5px 8px;
  font-weight: 700;
  font-size: 10px;
}
.badge.warn {
  background: #fff2e2;
  color: #ad6821;
}
.activity {
  border-top: 1px solid #e8edf6;
  padding: 11px 1px;
}
.activity strong {
  font-size: 12px;
}
.activity small {
  display: block;
  color: #8692a4;
  font-size: 10px;
  margin-top: 3px;
}
.activity p {
  font-size: 12px;
  margin: 6px 0 0;
  color: #465671;
}
.filters,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.filters {
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  margin-bottom: 16px;
}
.form-grid .wide {
  grid-column: 1/-1;
}
label {
  display: grid;
  gap: 6px;
  color: #50617b;
  font-size: 12px;
  font-weight: 700;
}
input,
select,
textarea {
  font: inherit;
  color: #1a2a43;
  border: 1px solid #d3e0f2;
  border-radius: 9px;
  background: white;
  padding: 10px 11px;
  width: 100%;
  font-size: 13px;
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #b7cffa;
  border-color: #4277d9;
}
.check {
  display: flex;
  gap: 10px;
  align-items: center;
}
.check input {
  width: auto;
}
button,
.button {
  display: inline-block;
  border: 1px solid #2965d7;
  border-radius: 9px;
  background: #2965d7;
  color: white;
  font: inherit;
  font-weight: 700;
  font-size: 12px;
  padding: 10px 13px;
  cursor: pointer;
  text-align: center;
  width: max-content;
}
button:hover,
.button:hover {
  background: #174bb6;
  color: white;
  text-decoration: none;
}
.ghost,
.button.ghost {
  background: white;
  color: #2965d7;
  border-color: #cadaf6;
}
.ghost:hover,
.button.ghost:hover {
  background: #edf4ff;
  color: #174bb6;
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 5px;
}
.notice {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
}
.notice.success {
  background: #eaf8f0;
  color: #147652;
}
.notice.error {
  background: #fff0ed;
  color: #bd4940;
}
.muted {
  color: #76859b;
  font-size: 12px;
  line-height: 1.6;
}
.empty {
  color: #8895aa;
  text-align: center;
  padding: 25px 8px;
  font-size: 13px;
}
.empty.large {
  padding: 75px 20px;
}
.message {
  border: 1px solid #e2eaf6;
  border-radius: 11px;
  padding: 12px 15px;
  margin: 12px 0;
  max-width: 85%;
}
.message.outgoing {
  background: #eaf4ff;
  margin-left: auto;
}
.message strong {
  font-size: 12px;
  margin-right: 8px;
}
.message small {
  color: #8692a4;
  margin-left: 8px;
  font-size: 10px;
}
.message p {
  font-size: 13px;
  line-height: 1.5;
  margin: 9px 0 2px;
  overflow-wrap: anywhere;
}
.qr {
  text-align: center;
  margin: 20px auto;
}
.qr img {
  display: block;
  width: min(100%, 270px);
  margin: auto;
  border: 1px solid #dce6f6;
  padding: 10px;
  border-radius: 10px;
}
.qr-placeholder {
  border: 2px dashed #dce6f6;
  border-radius: 12px;
  padding: 75px 12px;
  text-align: center;
  color: #91a0b4;
  font-size: 12px;
  margin-top: 22px;
}
footer {
  font-size: 11px;
  color: #8b99a9;
  padding: 24px 0;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
  .sidebar {
    width: 195px;
  }
  .grid-two {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 650px) {
  body {
    display: block;
  }
  .sidebar {
    position: static;
    width: auto;
    height: auto;
    min-height: 0;
    padding: 10px;
  }
  .brand {
    padding: 5px;
  }
  .side-caption,
  .side-foot {
    display: none;
  }
  .sidebar nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
  }
  .sidebar nav > a,
  .submenu a {
    white-space: nowrap;
    padding: 8px 12px;
  }
  .nav-group {
    margin: 0;
  }
  .nav-label {
    display: none; /* Ẩn bớt tiêu đề nhóm trên mobile */
  }
  .submenu {
    flex-direction: row;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
  }
  .topbar {
    padding: 14px;
  }
  .content {
    padding: 15px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}