:root {
  --primary: #1E2022;
  --primary-light: #2B2D30;
  --accent: #C4A97E;
  --accent-hover: #B89A6A;
  --accent-light: rgba(196, 169, 126, 0.12);
  --success: #8BA888;
  --danger: #C87A7A;
  --warning: #D4A86A;
  --info: #7AA8C8;
  --sidebar-width: 250px;
  --header-height: 60px;
  --bg-light: #F7F5F2;
  --text-dark: #2C2C2C;
  --text-muted: #9A958E;
  --border-light: rgba(0,0,0,0.06);
  --card-radius: 14px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Layout ─── */
.wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  color: rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.sidebar-header {
  padding: 28px 20px 22px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #fff;
}

.sidebar-header small {
  opacity: 0.4;
  font-size: 0.7rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.sidebar .nav {
  flex: 1;
  padding: 16px 10px;
  list-style: none;
  margin: 0;
}

.sidebar .nav-item { margin: 2px 0; }

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  transition: all 0.25s ease;
  font-size: 0.88rem;
  border-radius: 10px;
  font-weight: 450;
}

.sidebar .nav-link:hover {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.06);
}

.sidebar .nav-link.active {
  color: #fff;
  background: var(--accent);
  font-weight: 500;
}

.sidebar .nav-link i { width: 20px; text-align: center; font-size: 1rem; opacity: 0.7; }
.sidebar .nav-link.active i { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.8rem;
}

.sidebar-footer .user-info { opacity: 0.5; }
.sidebar-footer a { color: rgba(255,255,255,0.35); text-decoration: none; transition: opacity 0.2s; }
.sidebar-footer a:hover { opacity: 0.7; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.top-header {
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 99;
}

.toggle-sidebar {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 8px;
  margin-right: 12px;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dark);
  letter-spacing: 0.3px;
}
.page-title small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.content-body { padding: 28px; }

/* ─── Cards ─── */
.card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
  border: none;
  margin-bottom: 20px;
  transition: box-shadow 0.25s ease;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-light);
  padding: 18px 22px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-dark);
  letter-spacing: 0.2px;
}

.card-body { padding: 22px; }

.card-search .card-body {
  padding: 10px 16px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  padding: 24px;
  border-radius: var(--card-radius);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-card .icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: rgba(255,255,255,0.18);
}

.stat-card .info { flex: 1; }
.stat-card .info .number {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}
.stat-card .info .label { opacity: 0.75; font-size: 0.82rem; font-weight: 450; }

.bg-primary-card { background: linear-gradient(135deg, #3D3F45, #2B2D30); }
.bg-success-card { background: linear-gradient(135deg, #8BA888, #6F8D6C); }
.bg-warning-card { background: linear-gradient(135deg, #D4A86A, #C49350); }
.bg-danger-card { background: linear-gradient(135deg, #C87A7A, #B56161); }
.bg-info-card { background: linear-gradient(135deg, #7AA8C8, #5D8FAD); }

/* ─── Bed Map ─── */
.floor-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.room-card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.room-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.room-header {
  padding: 12px 14px;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
  background: #FAF9F7;
  color: #1A1A2E;
}

.room-header .room-type {
  font-weight: 500;
  font-size: 0.72rem;
  color: #444;
}

.room-body { padding: 12px 14px; }

.beds-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bed-item {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1.5px solid transparent;
  box-sizing: border-box;
  flex: 1;
  min-width: 40px;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.bed-item.vacant {
  background: #F2F6F0;
  color: #5A7D58;
  border-color: #D5E3D2;
}

.bed-item.occupied {
  background: #F8EEEE;
  color: #A05858;
  border-color: #E8D0D0;
}

.bed-item:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(0,0,0,0.1);
}

.bed-item .bed-label { font-weight: 700; }
.bed-item .bed-status { font-size: 0.6rem; display: block; opacity: 0.65; }
.bed-item .bed-school-short { font-size: 0.88rem; display: block; word-break: break-all; opacity: 0.9; font-weight: 600; }

/* ─── Tables ─── */
.table-container { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th {
  background: #FAF9F7;
  padding: 13px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid #EAE8E4;
  white-space: nowrap;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.table td {
  padding: 11px 16px;
  border-bottom: 1px solid #F0EFEC;
  vertical-align: middle;
}

.table tr:hover { background: #FAF9F7; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.badge-success { background: #EAF0E8; color: #4A7A48; }
.badge-danger { background: #F4E8E8; color: #8A4A4A; }
.badge-warning { background: #F5EDE0; color: #B88A3A; }
.badge-info { background: #E4EDF4; color: #4A7A9A; }

/* ─── Forms ─── */
.form-control, .form-select {
  border-radius: 10px;
  border: 1.5px solid #E5E3E0;
  padding: 10px 14px;
  font-size: 0.88rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-dark);
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  outline: none;
}

.form-label { font-weight: 500; font-size: 0.84rem; margin-bottom: 6px; color: var(--text-dark); }

.search-box {
  display: flex;
  max-width: 500px;
}

.search-box input {
  border-radius: 10px 0 0 10px;
  border-right: none;
}

.search-box button.btn {
  border-radius: 0 10px 10px 0;
  padding: 10px 14px;
  flex-shrink: 0;
}

/* ─── Pagination ─── */
.pagination {
  display: flex;
  gap: 0;
  justify-content: center;
  align-items: center;
  list-style: none;
  border: 1px solid #D5D3D0;
  border-radius: 6px;
  background: #fff;
  width: fit-content;
  margin: 0 auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  height: 26px;
  text-decoration: none;
  font-size: 0.75rem;
  color: var(--text-dark);
  background: #fff;
  border-right: 1px solid #D5D3D0;
  transition: all 0.15s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 1px 2px rgba(0,0,0,0.03);
}

.pagination a:last-child,
.pagination span:last-child {
  border-right: none;
}

.pagination a:hover {
  background: linear-gradient(to bottom, #f8f7f5, #f0efec);
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 1px 3px rgba(0,0,0,0.06);
}

.pagination a.active {
  background: linear-gradient(to bottom, var(--accent), #B89A6A);
  color: #fff;
  border-color: #B89A6A;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 1px 3px rgba(0,0,0,0.1);
}
.pagination a.active span { background: transparent; color: #fff; }

/* ─── Alert / Flash ─── */
.alert {
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: #EAF0E8; color: #4A7A48; border: 1px solid #D5E3D2; }
.alert-danger { background: #F4E8E8; color: #8A4A4A; border: 1px solid #E8D0D0; }
.alert-info { background: #E4EDF4; color: #4A7A9A; border: 1px solid #CDDDE8; }
.alert-warning { background: #F5EDE0; color: #B88A3A; border: 1px solid #EADCC8; }

/* ─── Login ─── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #E8E4DE 0%, #D5CFC6 50%, #C4BDB2 100%);
}

.login-box {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 20px;
  padding: 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}

.login-box h2 {
  text-align: center;
  margin-bottom: 4px;
  color: var(--text-dark);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.5px;
}

.login-box p {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 0.82rem;
}

.login-box .form-control {
  padding: 13px 16px;
  margin-bottom: 16px;
  border-radius: 12px;
}

.login-box .btn {
  width: 100%;
  padding: 13px;
  font-size: 0.95rem;
  border-radius: 12px;
}

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-box h4 { margin-top: 0; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .toggle-sidebar { display: block; }
  .main-content { margin-left: 0; }
  .content-body { padding: 16px; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .floor-map { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 480px) {
  .floor-map { grid-template-columns: 1fr; }
  .stat-card .info .number { font-size: 1.25rem; }
  .login-box { padding: 24px; }
  .search-box { flex-direction: column; }
}

/* ─── Progress Bar ─── */
.progress {
  height: 6px;
  border-radius: 3px;
  background: #F0EFEC;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-bar.bg-success { background: var(--success); }
.progress-bar.bg-danger { background: var(--danger); }
.progress-bar.bg-warning { background: var(--warning); }

/* ─── Misc ─── */
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.me-2 { margin-right: 8px; }
.ms-2 { margin-left: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.w-100 { width: 100%; }
.float-right { float: right; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .form-grid-2 { grid-template-columns: 1fr; }
}

.floor-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.floor-tabs .tab-btn {
  padding: 10px 24px;
  border-radius: 10px;
  border: 1.5px solid #E5E3E0;
  background: #fff;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text-dark);
}

.floor-tabs .tab-btn:hover { border-color: var(--accent); color: var(--accent); }
.floor-tabs .tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.chart-grid .card {
  display: flex;
  flex-direction: column;
}

.chart-grid .card .card-body {
  flex: 1;
}

.chart-wrap {
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 260px;
}

.chart-wrap canvas {
  max-width: 220px;
  max-height: 220px;
}

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