*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  min-height: 100%;
  overflow-x: hidden;
}

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface2: #f2f0eb;
  --border: #e4e1d8;
  --border2: #d0cdc3;
  --text: #1a1917;
  --text2: #5c5a54;
  --text3: #9a9890;
  --accent: #2d6a4f;
  --accent-light: #e8f4ed;
  --accent-text: #1b4332;
  --danger: #c0392b;
  --danger-light: #fdf0ef;
  --danger-text: #7b241c;
  --warn: #b7590a;
  --warn-light: #fef3e8;
  --warn-text: #7c3c06;
  --info: #1a5276;
  --info-light: #eaf1f8;
  --info-text: #1a3a5c;
  --sidebar-w: 220px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --font: 'Be Vietnam Pro', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body.logged-out .sidebar,
body.logged-out .topbar,
body.logged-out .bottom-nav,
body.logged-out .more-drawer,
body.logged-out .more-drawer-overlay,
body.logged-out .sidebar-overlay {
  display: none !important;
}

body.logged-out .main-content {
  margin-left: 0;
  min-height: 100vh;
  padding-bottom: 0 !important;
}

body.logged-out .page-content {
  padding: 0;
}

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  line-height: 1;
}

.login-subtitle {
  font-size: 12.5px;
  color: var(--text3);
  margin-top: 4px;
}

.login-btn {
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.auth-user-name {
  font-size: 12.5px;
  color: var(--text2);
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- LAYOUT ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--text);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 8px;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
}
.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  color: #fff;
  letter-spacing: .3px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: all .15s;
}
.nav-item i { font-size: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }

/* ---- MAIN ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky; top: 0; z-index: 50;
}
.menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--text2);
  padding: 4px;
}
.topbar-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-date { font-size: 12px; color: var(--text3); }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.page-content { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-label { font-size: 12px; color: var(--text3); font-weight: 400; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--text); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text3); }
.stat-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 4px;
}
.stat-icon.green { background: var(--accent-light); color: var(--accent); }
.stat-icon.blue  { background: var(--info-light);   color: var(--info); }
.stat-icon.warn  { background: var(--warn-light);   color: var(--warn); }
.stat-icon.red   { background: var(--danger-light); color: var(--danger); }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; font-weight: 600;
  color: var(--text3); text-transform: uppercase; letter-spacing: .5px;
  padding: 0 12px 10px; border-bottom: 1px solid var(--border);
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px; color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 500;
  padding: 3px 9px; border-radius: 20px;
}
.badge-green { background: var(--accent-light); color: var(--accent-text); }
.badge-red   { background: var(--danger-light); color: var(--danger-text); }
.badge-warn  { background: var(--warn-light);   color: var(--warn-text); }
.badge-blue  { background: var(--info-light);   color: var(--info-text); }
.badge-gray  { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; font-family: var(--font);
  border: 1px solid transparent; cursor: pointer;
  transition: all .15s; line-height: 1;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #235c42; }
.btn-outline { background: var(--surface); color: var(--text2); border-color: var(--border2); }
.btn-outline:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger-light); color: var(--danger-text); border-color: #e8b4af; }
.btn-danger:hover { background: #fae0de; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text2); margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: var(--font); color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
}
.form-control:focus { border-color: var(--accent); }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ---- SEARCH / FILTER BAR ---- */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-wrap i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: var(--text3); pointer-events: none;
}
.search-input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: var(--font); color: var(--text);
  background: var(--surface); outline: none; transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }

/* ---- ATTENDANCE ---- */
.att-row-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.att-row-item:last-child { border-bottom: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--info-light); color: var(--info);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.att-info { flex: 1; min-width: 0; }
.att-name { font-size: 13.5px; font-weight: 500; }
.att-meta { font-size: 11.5px; color: var(--text3); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; align-items: center; }
.dot-chain { display: flex; gap: 3px; align-items: center; }
.dot-s { width: 7px; height: 7px; border-radius: 50%; }
.dot-s.p { background: var(--accent); }
.dot-s.a { background: var(--danger); }
.dot-s.cur { outline: 2px solid var(--border2); outline-offset: 1px; }
.att-toggle { display: flex; gap: 6px; flex-shrink: 0; }
.btn-att {
  font-size: 12px; padding: 5px 11px;
  border-radius: var(--radius-sm); border: 1px solid;
  cursor: pointer; transition: all .15s; font-family: var(--font); font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.btn-att.present.on  { background: var(--accent-light); color: var(--accent-text); border-color: var(--accent); }
.btn-att.present.off { background: var(--surface); color: var(--text3); border-color: var(--border); }
.btn-att.absent.on   { background: var(--danger-light); color: var(--danger-text); border-color: var(--danger); }
.btn-att.absent.off  { background: var(--surface); color: var(--text3); border-color: var(--border); }

.saved-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 14px; font-size: 13px;
}
.saved-banner.ok     { background: var(--accent-light); border: 1px solid #a8d5b5; color: var(--accent-text); }
.saved-banner.editing { background: var(--warn-light);   border: 1px solid #f0b07a; color: var(--warn-text); }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--text); }
.page-desc  { font-size: 12.5px; color: var(--text3); margin-top: 2px; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 200;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text3);
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background .1s;
}
.modal-close:hover { background: var(--surface2); }
.modal-body { padding: 20px; }

/* ---- RECEIPT (Phiếu thu) ---- */
.receipt-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 14px;
}
.receipt-header {
  position: relative;
  background: var(--accent);
  color: #fff;
  padding: 18px 16px 16px;
  text-align: center;
}
.receipt-download-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,.18); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.receipt-download-btn:hover { background: rgba(255,255,255,.28); }
.receipt-download-btn:disabled { opacity: .6; cursor: wait; }
.receipt-download-btn i { font-size: 17px; }
@keyframes spin { to { transform: rotate(360deg); } }
.receipt-header-sub {
  font-size: 11px; letter-spacing: 1.2px; opacity: .85;
}
.receipt-header-title {
  font-size: 22px; font-weight: 600;
  font-family: 'Playfair Display', serif;
  margin-top: 4px; letter-spacing: .5px;
}
.receipt-header-month {
  font-size: 13px; opacity: .9; margin-top: 2px;
}
.receipt-body { padding: 4px 16px; }
.receipt-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.receipt-row:last-child { border-bottom: 0; }
.receipt-label {
  color: var(--text2);
  display: inline-flex; align-items: center; gap: 8px;
}
.receipt-label i { color: var(--accent); font-size: 17px; }
.receipt-value { font-weight: 600; color: var(--text); }
.receipt-dates {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
}
.receipt-dates-label {
  font-size: 11px; letter-spacing: 1.4px;
  color: var(--text3); text-align: center; margin-bottom: 10px;
}
.receipt-dates-chips {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
.receipt-date-chip {
  display: inline-block; padding: 4px 10px;
  background: var(--accent-light); color: var(--accent-text);
  border-radius: 99px; font-size: 12px; font-weight: 500;
}
.receipt-message {
  background: var(--surface2); padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text2);
  line-height: 1.5;
}

/* ---- TOAST ---- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; z-index: 10000;
  opacity: 0; transform: translateY(8px);
  transition: all .2s; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text3);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 13.5px; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 8px 16px; font-size: 13.5px; font-weight: 500; font-family: var(--font);
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text3); cursor: pointer; transition: all .15s; margin-bottom: -1px;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text2); }

/* ---- MOBILE CARD COMPONENTS ---- */
.page-header-mobile {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 10px;
}
.page-header-mobile .page-title { font-size: 18px; font-weight: 600; }
.page-header-mobile .page-desc  { font-size: 12px; color: var(--text3); margin-top: 1px; }

.mobile-filter-bar {
  display: flex; gap: 8px; align-items: center; margin-bottom: 14px;
}
.mobile-filter-bar .search-wrap { min-width: 0; }

.pay-filter-bar {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.pay-filter-bar .form-control { flex: 1; min-width: 90px; }

.m-card { padding: 12px 0; border-bottom: 1px solid var(--border); }
.m-card:last-child { border-bottom: none; }
.m-card-main { display: flex; align-items: center; gap: 10px; }
.m-card-info { flex: 1; min-width: 0; }
.m-card-name { font-size: 14px; font-weight: 600; color: var(--text); }
.m-card-sub  { font-size: 12px; color: var(--text3); margin-top: 2px; }
.m-card-actions { display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }

.pay-m-group { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.pay-m-group-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2); padding: 8px 12px;
  font-size: 12px; font-weight: 600; color: var(--text2); gap: 8px;
}
.pay-m-group-header i { font-size: 14px; vertical-align: -2px; margin-right: 4px; }
.pay-m-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; gap: 10px; border-top: 1px solid var(--border); background: var(--surface);
}
.pay-m-left  { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.pay-m-right { text-align: right; flex-shrink: 0; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.18); }
  .main-content { margin-left: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .menu-btn { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .form-control,
  .search-input,
  .btn-att {
    font-size: 16px;
    max-width: 100%;
  }
  .form-actions {
    flex-wrap: wrap;
  }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .page-content { padding: 16px; }
  .topbar {
    height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    gap: 8px;
  }
  .topbar-title { font-size: 14px; }
  .topbar-date { display: none; }
  .auth-user { gap: 6px; }
  .auth-user-name { display: none; }
  .auth-user .btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }
  .auth-logout-text { display: none; }

  /* Tables on mobile: horizontal scroll with min-width — NOT inside modals */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; }
  /* Tables inside modal should NOT force min-width */
  .modal .table-wrap { overflow-x: auto; }
  .modal table { min-width: unset; width: 100%; }

  /* Cards tighter on mobile */
  .card { padding: 14px; }

  /* Page header stack on mobile */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Attendance toggle: stack vertically */
  .att-row-item { flex-wrap: wrap; gap: 8px; }
  .att-toggle { width: 100%; justify-content: flex-end; }

  /* Attendance card-header: wrap action buttons */
  .att-card-header { flex-wrap: wrap; gap: 8px; }
  .att-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
  .att-card-actions .btn { font-size: 11px; padding: 4px 8px; }

  /* Modal: bottom sheet on mobile */
  .modal-overlay {
    align-items: flex-end;
    justify-content: stretch;
    padding: 0;
    overflow: hidden;
  }
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    animation: slideUp .22s ease;
    max-height: calc(100dvh - env(safe-area-inset-top) - 8px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-body {
    padding: 16px;
    overflow-x: hidden;
  }
  .modal .form-control,
  .modal .search-input {
    min-width: 0;
  }
  .modal .form-actions {
    display: grid;
    grid-template-columns: minmax(72px, .75fr) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    justify-content: stretch;
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
  .modal .form-actions .btn {
    width: 100%;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: none; }
  }

  /* Stat cards font size */
  .stat-value { font-size: 18px; }

  /* Filter bar stack */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select { width: 100% !important; }
  .search-wrap { min-width: unset; }

  /* Toast: above bottom nav */
  .toast {
    bottom: calc(76px + env(safe-area-inset-bottom));
    right: 16px;
    left: 16px;
    text-align: center;
  }

  /* Dashboard bottom 2-col → 1-col */
  .dashboard-bottom { grid-template-columns: 1fr !important; }

  /* Payment stats 3-col: smaller text */
  .pay-stats .stat-value { font-size: 14px !important; }
  .pay-stats .stat-label { font-size: 11px; }
  .pay-stats .stat-card  { padding: 10px 12px; }
  .pay-stats { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }

  .page-header-mobile {
    align-items: flex-start;
  }
  .page-header-mobile > div {
    min-width: 0;
  }
  .page-header-mobile .btn {
    flex-shrink: 0;
  }
  .m-card-main,
  .pay-m-left,
  .pay-m-item {
    min-width: 0;
  }
}

/* ---- SIDEBAR OVERLAY (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ---- BOTTOM NAV ---- */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 110;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text3);
    font-size: 10px;
    font-weight: 500;
    transition: color .15s;
    padding: 6px 0;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-item i { font-size: 22px; line-height: 1; }
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-item.active i {
    background: var(--accent-light);
    border-radius: 12px;
    padding: 2px 14px;
  }
}

/* ---- MORE DRAWER ---- */
.more-drawer {
  display: none;
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom)); left: 0; right: 0;
  z-index: 115;
  transform: translateY(calc(100% + 12px));
  visibility: hidden;
  pointer-events: none;
  transition: transform .22s ease;
}
.more-drawer.open {
  transform: none;
  visibility: visible;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .more-drawer {
    display: block;
  }
}

.more-drawer-inner {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 8px 0 16px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.1);
}

.more-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}
.more-drawer-item i { font-size: 20px; color: var(--accent); }
.more-drawer-item:hover, .more-drawer-item:active { background: var(--surface2); }

.more-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 114;
}
.more-drawer-overlay.show { display: block; }

/* ---- ANIMATIONS ---- */
.page-content > * {
  animation: fadeUp .2s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---- UTILS ---- */
.text-right { text-align: right; }
.text-mono  { font-family: 'Courier New', monospace; }
.fw-500 { font-weight: 500; }
.color-green { color: var(--accent); }
.color-red   { color: var(--danger); }
.color-warn  { color: var(--warn); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---- REPORT ---- */
.report-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 0;
}
.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 768px) {
  .report-filters { grid-template-columns: 1fr 1fr; }
  .report-summary { grid-template-columns: 1fr 1fr; }
  .report-summary .stat-value { font-size: 14px !important; }
  .report-summary .stat-card  { padding: 10px 12px; }
}

/* ---- ATTENDANCE FILTER GRID ---- */
.att-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}
@media (max-width: 768px) {
  .att-filter-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .att-filter-grid .att-load-btn {
    grid-column: 1 / -1;
    justify-content: center;
  }
  /* Attendance card header wraps */
  .att-card-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .att-card-actions {
    display: flex;
    gap: 6px;
    width: 100%;
  }
  .att-card-actions .btn {
    flex: 1;
    justify-content: center;
    font-size: 12px;
    padding: 6px 8px;
  }
}
