:root {
  --blue: #0b4ea2;
  --blue2: #1769c2;
  --pale: #eaf3ff;
  --ink: #172b4d;
  --muted: #68778d;
  --bg: #f3f6fb;
  --line: #e3eaf3;
  --green: #16845b;
  --amber: #a96800;
  --red: #c23434;
  --white: #fff;
  --shadow: 0 8px 24px rgba(25, 55, 100, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Topbar */
.topbar {
  background: linear-gradient(120deg, #083c82, #1769c2);
  color: #fff;
  padding: 16px max(18px, calc((100vw - 1200px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.brand-text {
  min-width: 0;
  overflow: hidden;
}

.logo {
  width: 44px;
  height: 44px;
  border: 1px solid #ffffff70;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: #ffffff18;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 19px;
  margin: 0;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand p {
  margin: 2px 0 0;
  color: #dbeaff;
  font-size: 11px;
  letter-spacing: 0.6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-header-add {
  background: #fff;
  color: var(--blue);
  border-color: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.btn-header-add:hover {
  background: #f0f6ff;
}

.btn-header-logout {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

.btn-header-logout:hover {
  background: rgba(255, 255, 255, 0.28);
}

.btn-header-login {
  background: #fff;
  color: var(--blue);
}

.date-pill {
  background: #ffffff18;
  border: 1px solid #ffffff40;
  padding: 8px 14px;
  border-radius: 30px;
  font-size: 12px;
}

/* Layout */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 18px 90px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
}

/* Sidebar */
.sidebar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  height: max-content;
  position: sticky;
  top: 14px;
  box-shadow: var(--shadow);
}

.navbtn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  color: #53647b;
  text-align: left;
  margin: 3px 0;
  font-weight: 600;
  transition: all 0.15s ease;
}

.navbtn .ico {
  font-size: 19px;
  width: 23px;
  text-align: center;
}

.navbtn:hover {
  background: #f4f7fb;
  color: var(--blue);
}

.navbtn.active {
  background: var(--pale);
  color: var(--blue);
}

.nav-group-account {
  margin-top: 2px;
}

.nav-dropdown-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
}

.nav-dropdown-toggle .caret {
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.nav-dropdown-toggle.open .caret {
  transform: rotate(180deg);
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 3px;
  padding-left: 24px;
  margin-top: 3px;
}

.nav-submenu.open {
  display: flex;
}

.nav-sub-btn {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.nav-sub-btn .ico {
  font-size: 16px;
  width: 20px;
}

.side-note {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding: 14px 8px 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Main Content */
.main {
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 2px 0 18px;
}

.page-head h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.3px;
}

.page-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

/* Actions & Buttons */
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.scope-group {
  display: inline-flex;
  gap: 3px;
  background: #e8f0fe;
  padding: 3px;
  border-radius: 10px;
  align-items: center;
  flex-shrink: 0;
}

.scope-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
  color: #4a5c76;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.scope-btn:hover {
  color: var(--blue);
}

.scope-btn.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 6px rgba(11, 78, 162, 0.25);
}

.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  border: 1px solid #d4deeb;
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn.danger {
  background: #fff;
  border-color: #f7c5c5;
  color: #c23434;
}

.btn.danger:hover {
  background: #fff0f0;
}

.btn:hover {
  filter: brightness(0.97);
}

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

/* Stats Cards */
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.stat-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-icon {
  width: 31px;
  height: 31px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--pale);
  font-size: 16px;
}

.stat strong {
  display: block;
  font-size: 29px;
  margin-top: 10px;
  letter-spacing: -0.8px;
}

.stat small {
  color: var(--muted);
  font-size: 11px;
}

/* Panels */
.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(270px, 0.85fr);
  gap: 16px;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.panel h3 {
  margin: 0;
  font-size: 16px;
}

.subtle {
  color: var(--muted);
  font-size: 12px;
}

/* Report List */
.report-list {
  display: flex;
  flex-direction: column;
}

.report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid #edf1f7;
  align-items: center;
}

.report-row:first-child {
  border-top: 0;
}

.report-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.report-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 30px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  background: #eef2f7;
  color: #5a6a80;
}

.badge.green {
  background: #e5f7ef;
  color: var(--green);
}

.badge.amber {
  background: #fff3d8;
  color: var(--amber);
}

.badge.red {
  background: #ffebeb;
  color: var(--red);
}

.badge.blue {
  background: #e8f1ff;
  color: var(--blue);
}

/* Progress */
.progress-wrap {
  margin-top: 12px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.progress {
  height: 8px;
  background: #edf1f7;
  border-radius: 99px;
  overflow: hidden;
}

.progress span {
  height: 100%;
  display: block;
  background: var(--blue2);
  border-radius: 99px;
}

/* Quick Actions */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.quick {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 13px;
  text-align: left;
  display: block;
  width: 100%;
  cursor: pointer;
  transition: all 0.15s;
}

.quick:hover {
  background: #f7fafe;
  border-color: #cbdcf5;
}

.quick b {
  display: block;
  margin-top: 8px;
}

.quick span {
  font-size: 20px;
}

.quick small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

/* Filters & Inputs */
.filters {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  color: #53647b;
}

.input, select, textarea {
  width: 100%;
  border: 1px solid #d7e0ec;
  background: #fff;
  border-radius: 9px;
  padding: 10px 11px;
  color: var(--ink);
  outline: none;
}

.input:focus, select:focus, textarea:focus {
  border-color: #6ca5e8;
  box-shadow: 0 0 0 3px #e5f0ff;
}

.filters .field {
  flex: 1;
  min-width: 150px;
}

/* Table */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 780px;
  background: #fff;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f7;
  font-size: 13px;
  vertical-align: middle;
}

th {
  background: #f7f9fc;
  color: #61718a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td strong {
  font-size: 13px;
}

td .subtle {
  margin-top: 3px;
}

.table-actions {
  display: flex;
  gap: 6px;
}

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

.empty b {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.notice {
  border: 1px solid #f0d69b;
  background: #fff8e8;
  color: #78500b;
  padding: 12px 14px;
  border-radius: 11px;
  font-size: 12px;
  margin-bottom: 15px;
}

.hidden {
  display: none !important;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #0c1c32a8;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 17px;
  width: min(650px, 100%);
  max-height: 92vh;
  overflow: auto;
  box-shadow: 0 20px 60px #07172d45;
}

.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.field.full {
  grid-column: 1 / -1;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.icon-btn {
  border: 0;
  background: transparent;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
}

/* Toast Messages */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 90vw;
}

.toast {
  background: #132b4b;
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Staff Cards */
.staff-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.staff-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 16px;
  background: #fff;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--pale);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-weight: 800;
  margin-bottom: 12px;
  font-size: 14px;
}

.staff-card h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.staff-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.staff-card .btn {
  margin-top: 14px;
}

/* Calendar */
.calendar-list {
  display: grid;
  gap: 9px;
}

.calendar-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.calendar-date {
  background: var(--pale);
  color: var(--blue);
  border-radius: 9px;
  padding: 8px 4px;
  text-align: center;
  font-weight: 800;
}

.calendar-date small {
  display: block;
  font-size: 10px;
}

.footer-note {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 14px;
}

.kpi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kpi-box {
  background: #f7f9fc;
  border-radius: 11px;
  padding: 13px;
}

.kpi-box span {
  color: var(--muted);
  font-size: 12px;
}

.kpi-box strong {
  display: block;
  font-size: 22px;
  margin-top: 4px;
}

.mobile-nav {
  display: none;
}

/* Responsive */
@media (max-width: 950px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px 14px 90px;
  }
  .sidebar {
    display: none;
  }
  .topbar {
    padding: 16px;
  }
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-around;
    padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
    z-index: 40;
  }
  .mobile-nav a {
    color: #6c7a90;
    font-size: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
    flex: 1;
    padding: 4px 0;
    text-align: center;
  }
  .mobile-nav a span {
    font-size: 19px;
  }
  .mobile-nav a.active {
    color: var(--blue);
    font-weight: 800;
  }
  .top-actions .date-pill {
    display: none;
  }
}

@media (max-width: 540px) {
  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }
  .brand {
    gap: 8px;
  }
  .logo {
    width: 36px;
    height: 36px;
    font-size: 18px;
    border-radius: 9px;
  }
  .brand h1 {
    font-size: 14px;
    letter-spacing: 0.1px;
  }
  .brand p {
    font-size: 9px;
  }
  .top-actions {
    gap: 6px;
  }
  .btn-header-add {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 8px;
  }
  .btn-header-add .add-text {
    display: none;
  }
  .btn-header-add::after {
    content: "Báo cáo";
    font-size: 11px;
    margin-left: 2px;
  }
  .btn-header-logout {
    padding: 6px 9px;
    font-size: 12px;
    border-radius: 8px;
  }
  .btn-header-logout .logout-text {
    display: none;
  }
  .btn-header-logout .logout-icon {
    font-size: 14px;
  }
  .page-head {
    flex-direction: column;
    gap: 12px;
  }
  .page-head h2 {
    font-size: 21px;
  }
  .actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .scope-group {
    width: 100%;
    display: flex;
    box-sizing: border-box;
  }
  .scope-btn {
    flex: 1;
    padding: 8px 6px;
    font-size: 12px;
    text-align: center;
    justify-content: center;
  }
  .action-buttons {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .action-buttons .btn {
    flex: 1;
    padding: 10px 8px;
    font-size: 13px;
    text-align: center;
    justify-content: center;
    white-space: nowrap;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .stat {
    padding: 12px;
  }
  .stat strong {
    font-size: 25px;
  }
  .stat-top {
    font-size: 11px;
  }
  .stat:last-child {
    grid-column: 1 / -1;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .field.full {
    grid-column: auto;
  }
  .staff-cards {
    grid-template-columns: 1fr;
  }
  .report-row {
    grid-template-columns: 1fr;
  }
  .report-row .badge {
    justify-self: start;
  }
  .calendar-item {
    grid-template-columns: 54px 1fr;
  }
  .calendar-item > .badge {
    grid-column: 2;
  }
  .panel {
    padding: 14px;
  }
  .quick-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 360px) {
  .btn-header-add::after {
    display: none;
  }
  .brand h1 {
    font-size: 13px;
  }
  .brand p {
    font-size: 8.5px;
  }
}
