.app-bg {
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.03), rgba(2, 6, 23, 0.01));
}

.app-bg.role-pending .admin-topbar-right,
.app-bg.role-pending .admin-tabs,
.app-bg.role-pending #inAppBanner,
.app-bg.role-pending .admin-content {
  display: none;
}

.app-bg.role-pending .admin-shell::after {
  content: 'กำลังโหลดสิทธิ์การใช้งาน...';
  display: block;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: rgba(15, 23, 42, 0.72);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.04);
}

.admin-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
}

.admin-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #22c55e);
}

.admin-title {
  font-size: 18px;
  font-weight: 800;
}

.admin-subtitle {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.7);
}

.admin-topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  position: relative;
}

/* Mobile hamburger button */
.admin-topbar .icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: none;
  font-size: 18px;
  line-height: 1;
}

.admin-actions {
  display: flex;
  gap: 8px;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.admin-tabs .tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: 14px;
  padding: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.04);
}

.admin-tabs .tab.active {
  border-color: rgba(37, 99, 235, 0.4);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.12), rgba(34, 197, 94, 0.06));
}

.admin-content {
  display: block;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

@media (min-width: 980px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  /* Keep header compact on mobile */
  .admin-topbar {
    padding: 12px;
  }

  .admin-title {
    font-size: 16px;
  }

  /* Show hamburger on the RIGHT */
  .admin-topbar .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Actions become a dropdown menu */
  .admin-actions {
    display: none;
    position: absolute;
    top: calc(44px + 8px);
    right: 0;
    width: min(280px, 90vw);
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #fff;
    border: 1px solid rgba(2, 6, 23, 0.12);
    border-radius: 16px;
    box-shadow: 0 14px 34px rgba(2, 6, 23, 0.14);
    z-index: 20;
  }

  .admin-actions.open {
    display: flex;
  }
}

.card {
  background: #fff;
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(2, 6, 23, 0.10);
  background: rgba(2, 6, 23, 0.03);
  font-size: 12px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.8);
  cursor: pointer;
}

.inline-check input {
  width: 14px;
  height: 14px;
}

.card-header h2 {
  margin: 0;
  font-size: 16px;
}

.hint {
  font-size: 12px;
  color: rgba(15, 23, 42, 0.7);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(2, 6, 23, 0.04);
  border: 1px solid rgba(2, 6, 23, 0.06);
}

.table-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(2, 6, 23, 0.06);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.table th,
.table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid rgba(2, 6, 23, 0.06);
  vertical-align: top;
}

.table thead th {
  position: sticky;
  top: 0;
  background:
    linear-gradient(180deg, rgba(239, 246, 255, 0.98), rgba(236, 253, 245, 0.96));
  z-index: 1;
  font-size: 12px;
  text-transform: none;
  font-weight: 700;
  color: rgba(30, 41, 59, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

#pendingTable thead th,
#approvedTable thead th {
  text-align: left;
}

/* เพิ่มความอ่านง่าย: แถวสลับสี + hover */
.table tbody tr:nth-child(even) td {
  background: rgba(248, 250, 252, 0.9);
}

.table tbody tr:hover td {
  background: rgba(219, 234, 254, 0.35);
}

#bedsTable tbody tr.beds-row-empty td {
  background: linear-gradient(180deg, rgba(254, 226, 226, 0.86), rgba(255, 241, 242, 0.96));
}

#bedsTable tbody tr.beds-row-empty td:first-child {
  box-shadow: inset 4px 0 0 rgba(239, 68, 68, 0.42);
}

#bedsTable tbody tr.beds-row-empty:hover td {
  background: linear-gradient(180deg, rgba(254, 205, 211, 0.9), rgba(255, 228, 230, 0.98));
}

#bedsTable tbody tr.beds-row-empty td:nth-child(5) {
  color: #b91c1c;
  font-weight: 800;
}

#pendingTable tbody tr.fast-track-row td,
#approvedTable tbody tr.fast-track-row td {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.22), rgba(239, 68, 68, 0.09));
}

/* Pending: ประเภท | คนไข้ | ผู้จอง | วอร์ดที่เลือก | เวลาจอง | อนุมัติ | Fast track | จัดการ */
#pendingTable {
  min-width: 1020px;
}

/* Approved: ประเภท | คนไข้ | ผู้จอง | ลงวอร์ด | เวลาจอง | เวลาอนุมัติ | Fast track | จัดการ */
#approvedTable {
  min-width: 1040px;
}

#pendingTable th:nth-child(1),
#pendingTable td:nth-child(1),
#approvedTable th:nth-child(1),
#approvedTable td:nth-child(1) {
  width: 48px;
  min-width: 48px;
}

#pendingTable td:nth-child(1),
#approvedTable td:nth-child(1) {
  text-align: center;
}

#pendingTable th:nth-child(2),
#pendingTable td:nth-child(2),
#approvedTable th:nth-child(2),
#approvedTable td:nth-child(2) {
  min-width: 220px;
}

#pendingTable th:nth-child(3),
#pendingTable td:nth-child(3),
#approvedTable th:nth-child(3),
#approvedTable td:nth-child(3) {
  min-width: 102px;
}

#pendingTable th:nth-child(4),
#pendingTable td:nth-child(4) {
  width: 24%;
  min-width: 210px;
  line-height: 1.45;
}

#approvedTable th:nth-child(4),
#approvedTable td:nth-child(4) {
  width: 27%;
  min-width: 230px;
  line-height: 1.45;
}

#pendingTable td:nth-child(4),
#approvedTable td:nth-child(4) {
  overflow-wrap: anywhere;
}

#pendingTable th:nth-child(5),
#pendingTable td:nth-child(5),
#approvedTable th:nth-child(5),
#approvedTable td:nth-child(5),
#approvedTable th:nth-child(6),
#approvedTable td:nth-child(6) {
  width: 98px;
  min-width: 98px;
  white-space: nowrap;
}

#pendingTable td:nth-child(5),
#approvedTable td:nth-child(5),
#approvedTable td:nth-child(6) {
  font-size: 11px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

#pendingTable th:nth-child(6),
#pendingTable td:nth-child(6) {
  min-width: 106px;
}

#pendingTable td:nth-child(6) {
  text-align: center;
}

#pendingTable th:nth-child(7),
#pendingTable td:nth-child(7) {
  min-width: 168px;
}

#pendingTable td:nth-child(7) select {
  width: 100%;
  min-width: 132px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(2, 6, 23, 0.16);
  background: #fff;
}

#pendingTable td:nth-child(7) .btn {
  min-width: 84px;
  font-size: 11px;
  padding: 7px 10px;
}

#approvedTable th:nth-child(7),
#approvedTable td:nth-child(7) {
  min-width: 106px;
}

#approvedTable td:nth-child(7) {
  text-align: center;
}

#pendingTable th:nth-child(8),
#pendingTable td:nth-child(8) {
  min-width: 82px;
}

#approvedTable th:nth-child(8),
#approvedTable td:nth-child(8) {
  min-width: 92px;
}

#approvedTable td:nth-child(8) {
  text-align: center;
}

.approved-actions {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.approved-actions > .btn {
  min-width: 0;
}

.approved-actions > .btn:first-child {
  width: 100%;
  max-width: 124px;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.25;
}

.approved-actions > .btn.btn-danger {
  min-width: 44px;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 11px;
}

.approved-actions-edit {
  display: grid;
  gap: 6px;
  width: 100%;
}

.approved-actions-edit select,
.approved-actions-edit .btn {
  width: 100%;
}

.approved-actions-edit .btn {
  font-size: 11px;
  padding: 7px 10px;
}

.time-col {
  font-variant-numeric: tabular-nums;
}

.fasttrack-col {
  text-align: center;
}

#pendingTable td:nth-child(2) .cell-title,
#pendingTable td:nth-child(3) .cell-title,
#approvedTable td:nth-child(2) .cell-title,
#approvedTable td:nth-child(3) .cell-title {
  font-size: 11px;
  font-weight: 600;
}

#pendingTable td:nth-child(3) .cell-meta,
#approvedTable td:nth-child(3) .cell-meta {
  font-size: 11px;
  margin-top: 1px;
}

#pendingTable td:nth-child(4) .ward-line,
#approvedTable td:nth-child(4) .cell-title {
  font-size: 11px;
  font-weight: 600;
}

#approvedTable td:nth-child(4) .cell-meta {
  font-size: 11px;
}

@media (max-width: 960px) {
  #pendingTable {
    min-width: 940px;
  }

  #approvedTable {
    min-width: 970px;
  }

  #pendingTable th:nth-child(1),
  #pendingTable td:nth-child(1),
  #approvedTable th:nth-child(1),
  #approvedTable td:nth-child(1) {
    min-width: 46px;
  }

  #pendingTable th:nth-child(2),
  #pendingTable td:nth-child(2),
  #approvedTable th:nth-child(2),
  #approvedTable td:nth-child(2) {
    min-width: 200px;
  }

  #pendingTable th:nth-child(3),
  #pendingTable td:nth-child(3),
  #approvedTable th:nth-child(3),
  #approvedTable td:nth-child(3) {
    min-width: 96px;
    font-size: 11px;
  }

  #pendingTable th:nth-child(4),
  #pendingTable td:nth-child(4) {
    min-width: 196px;
    font-size: 11px;
  }

  #approvedTable th:nth-child(4),
  #approvedTable td:nth-child(4) {
    min-width: 214px;
    font-size: 11px;
  }

  #pendingTable th:nth-child(5),
  #pendingTable td:nth-child(5),
  #approvedTable th:nth-child(5),
  #approvedTable td:nth-child(5),
  #approvedTable th:nth-child(6),
  #approvedTable td:nth-child(6) {
    min-width: 88px;
    font-size: 10.5px;
  }

  #pendingTable th:nth-child(6),
  #pendingTable td:nth-child(6) {
    min-width: 96px;
  }

  #pendingTable th:nth-child(7),
  #pendingTable td:nth-child(7) {
    min-width: 156px;
  }

  #pendingTable td:nth-child(7) select {
    min-width: 120px;
  }

  #approvedTable th:nth-child(7),
  #approvedTable td:nth-child(7) {
    min-width: 96px;
  }

  #pendingTable th:nth-child(8),
  #pendingTable td:nth-child(8),
  #approvedTable th:nth-child(8),
  #approvedTable td:nth-child(8) {
    min-width: 80px;
  }

  #pendingTable td:nth-child(7) .btn {
    font-size: 10px;
    padding: 6px 9px;
  }

  .approved-actions > .btn:first-child {
    max-width: 112px;
    min-height: 38px;
    padding: 7px 10px;
    font-size: 10px;
  }

  .approved-actions > .btn.btn-danger {
    min-width: 40px;
    min-height: 32px;
    padding: 6px 10px;
    font-size: 10px;
  }

  .approved-actions-edit .btn {
    font-size: 10px;
    padding: 6px 9px;
  }
}

@media (max-width: 640px) {
  #pendingTable {
    min-width: 790px;
  }

  #approvedTable {
    min-width: 820px;
  }

  #pendingTable th:nth-child(1),
  #pendingTable td:nth-child(1),
  #approvedTable th:nth-child(1),
  #approvedTable td:nth-child(1) {
    min-width: 42px;
  }

  #pendingTable th:nth-child(2),
  #pendingTable td:nth-child(2),
  #approvedTable th:nth-child(2),
  #approvedTable td:nth-child(2) {
    min-width: 168px;
  }

  #pendingTable th:nth-child(3),
  #pendingTable td:nth-child(3),
  #approvedTable th:nth-child(3),
  #approvedTable td:nth-child(3) {
    min-width: 84px;
    font-size: 10.5px;
  }

  #pendingTable th:nth-child(4),
  #pendingTable td:nth-child(4) {
    min-width: 156px;
    font-size: 10.5px;
    line-height: 1.35;
  }

  #approvedTable th:nth-child(4),
  #approvedTable td:nth-child(4) {
    min-width: 172px;
    font-size: 10.5px;
    line-height: 1.35;
  }

  #pendingTable th:nth-child(5),
  #pendingTable td:nth-child(5),
  #approvedTable th:nth-child(5),
  #approvedTable td:nth-child(5),
  #approvedTable th:nth-child(6),
  #approvedTable td:nth-child(6) {
    min-width: 78px;
    font-size: 10px;
    white-space: normal;
  }

  #pendingTable th:nth-child(6),
  #pendingTable td:nth-child(6) {
    min-width: 90px;
  }

  #pendingTable th:nth-child(7),
  #pendingTable td:nth-child(7) {
    min-width: 128px;
  }

  #pendingTable td:nth-child(7) select {
    min-width: 108px;
  }

  #approvedTable th:nth-child(7),
  #approvedTable td:nth-child(7) {
    min-width: 90px;
  }

  #pendingTable th:nth-child(8),
  #pendingTable td:nth-child(8),
  #approvedTable th:nth-child(8),
  #approvedTable td:nth-child(8) {
    min-width: 70px;
  }

  #pendingTable td:nth-child(7) .btn {
    font-size: 9px;
    padding: 5px 8px;
  }

  .approved-actions {
    gap: 6px;
  }

  .approved-actions > .btn:first-child {
    max-width: 100px;
    min-height: 36px;
    padding: 7px 8px;
    font-size: 9px;
  }

  .approved-actions > .btn.btn-danger {
    min-width: 38px;
    min-height: 30px;
    padding: 5px 9px;
    font-size: 9px;
  }

  .approved-actions-edit .btn {
    font-size: 9px;
    padding: 5px 8px;
  }
}

.cell-title {
  font-weight: 700;
  color: #0f172a;
}

.cell-meta {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.7);
}

.approve-mode-hint {
  font-size: 11px;
  color: rgba(15, 23, 42, 0.68);
  line-height: 1.35;
}

.approve-mode-hint.outside {
  color: #b45309;
  font-weight: 700;
}

.ward-tag-outside {
  color: #b45309;
  font-weight: 700;
}

.ward-lines {
  line-height: 1.45;
}

.ward-line + .ward-line {
  margin-top: 4px;
}

.fasttrack-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  white-space: nowrap;
}

.fasttrack-badge[data-ft="fast_track"] {
  border-color: #dc2626;
  background: #fef2f2;
  color: #7f1d1d;
}

.color-col {
  width: 48px;
  min-width: 48px;
}

.type-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #cbd5f5;
  background: #fff;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.08);
  display: grid;
  place-items: center;
  margin: 0 auto;
}

.type-badge-text {
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  color: #0f172a;
}

.type-badge[data-kind="red"] {
  background: #ef4444;
  border-color: #f87171;
}

.type-badge[data-kind="orange"] {
  background: #fb923c;
  border-color: #fdba74;
}

.type-badge[data-kind="yellow"] {
  background: #facc15;
  border-color: #fde047;
}

.type-badge[data-kind="green"] {
  background: #22c55e;
  border-color: #4ade80;
}

.type-badge[data-kind="none"] {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.type-badge[data-kind="red"] .type-badge-text,
.type-badge[data-kind="orange"] .type-badge-text,
.type-badge[data-kind="yellow"] .type-badge-text,
.type-badge[data-kind="green"] .type-badge-text {
  color: #fff;
}

@media (max-width: 720px) {
  .color-col { width: 42px; min-width: 42px; }
  .type-badge { width: 24px; height: 24px; border-width: 2px; }
  .type-badge-text { font-size: 9px; }
}

.btn {
  appearance: none;
  border: 1px solid rgba(2, 6, 23, 0.12);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  padding: 10px 14px;
  border-radius: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 4px 10px rgba(15, 23, 42, 0.06);
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.admin-shell a.btn,
.admin-shell a.btn:visited,
.admin-shell a.btn:hover,
.admin-shell a.btn:active {
  text-decoration: none;
  color: #000;
}

.btn:hover:not(:disabled) {
  border-color: rgba(2, 6, 23, 0.2);
  background: linear-gradient(180deg, #ffffff, #f1f5f9);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 8px 18px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 4px 10px rgba(15, 23, 42, 0.06);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2), 0 8px 18px rgba(15, 23, 42, 0.1);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  border-color: rgba(37, 99, 235, 0.4);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(34, 197, 94, 0.12));
}

.btn-primary:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.55);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.26), rgba(34, 197, 94, 0.18));
}

/* Make button text readable on light gradient backgrounds (requested: black text) */
.admin-shell .btn,
.admin-shell .btn-primary,
.admin-shell .btn-secondary,
.admin-shell .btn-danger {
  color: #000;
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.4);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.14), rgba(239, 68, 68, 0.05));
}

.btn-danger:hover:not(:disabled) {
  border-color: rgba(239, 68, 68, 0.55);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.08));
}

#reportMenuBtn {
  border-color: rgba(191, 229, 207, 0.95);
  background: linear-gradient(180deg, rgba(191, 229, 207, 0.52), rgba(191, 229, 207, 0.2));
}

#reportMenuBtn:hover:not(:disabled) {
  border-color: rgba(167, 215, 186, 0.95);
  background: linear-gradient(180deg, rgba(191, 229, 207, 0.62), rgba(191, 229, 207, 0.3));
}

#bookingPageBtn {
  border-color: rgba(186, 230, 253, 0.95);
  background: linear-gradient(180deg, rgba(186, 230, 253, 0.52), rgba(209, 250, 229, 0.22));
}

#bookingPageBtn:hover:not(:disabled) {
  border-color: rgba(125, 211, 252, 0.95);
  background: linear-gradient(180deg, rgba(186, 230, 253, 0.62), rgba(209, 250, 229, 0.32));
}

#exportApprovedBtn {
  border-color: rgba(191, 229, 207, 0.95);
  background: linear-gradient(180deg, rgba(191, 229, 207, 0.52), rgba(191, 229, 207, 0.2));
}

#exportApprovedBtn:hover:not(:disabled) {
  border-color: rgba(167, 215, 186, 0.95);
  background: linear-gradient(180deg, rgba(191, 229, 207, 0.62), rgba(191, 229, 207, 0.3));
}

.admin-actions .btn {
  font-size: 13px;
  white-space: nowrap;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.admin-msg {
  font-size: 13px;
  color: rgba(15, 23, 42, 0.85);
}

.form-grid {
  display: grid;
  gap: 10px;
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.report-stats-overview {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.report-stats-range {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
}

.report-top-wards {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.report-top-ward-card {
  border: 1px solid rgba(147, 197, 253, 0.55);
  border-radius: 14px;
  padding: 10px;
  background:
    radial-gradient(120px 60px at 100% 0%, rgba(255, 255, 255, 0.42), transparent 64%),
    linear-gradient(180deg, rgba(219, 234, 254, 0.84), rgba(239, 246, 255, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
  text-align: center;
}

.report-top-ward-rank {
  font-size: 12px;
  font-weight: 800;
  color: #1e40af;
}

.report-top-ward-name {
  margin-top: 4px;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.25;
}

.report-top-ward-count {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  color: #1d4ed8;
}

.report-stat {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--report-stat-border, rgba(2, 6, 23, 0.08));
  border-radius: 12px;
  padding: 10px;
  background: var(--report-stat-bg, #fff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  text-align: center;
}

.report-stat::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(140px 72px at 100% 0%, rgba(255, 255, 255, 0.48), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.report-stat-label {
  font-size: 12px;
  color: var(--report-stat-label, rgba(15, 23, 42, 0.68));
  text-align: center;
}

.report-stat-value {
  position: relative;
  margin-top: 6px;
  font-size: 20px;
  font-weight: 800;
  color: var(--report-stat-value, #0f172a);
  text-align: center;
}

.report-stat-approved {
  --report-stat-bg: #e8f6ef;
  --report-stat-border: #bfe5cf;
  --report-stat-label: #2f7a4e;
  --report-stat-value: #13653a;
}

.report-stat-pending {
  --report-stat-bg: #f3ecfe;
  --report-stat-border: #d9c9f7;
  --report-stat-label: #7b4db8;
  --report-stat-value: #5b2e95;
}

.report-stat-total {
  --report-stat-bg: #e9effd;
  --report-stat-border: #c8d6fa;
  --report-stat-label: #3f63b8;
  --report-stat-value: #23418f;
}

.report-stat-fasttrack {
  --report-stat-bg: #feeee5;
  --report-stat-border: #f5d0bd;
  --report-stat-label: #b86a3d;
  --report-stat-value: #9a3f1a;
}

.report-stat-cancelled {
  --report-stat-bg: #fdecef;
  --report-stat-border: #f9c7d0;
  --report-stat-label: #b53a56;
  --report-stat-value: #8a1f3b;
}

.report-stat-nonfasttrack {
  --report-stat-bg: #e9f5f2;
  --report-stat-border: #c2e2da;
  --report-stat-label: #2d7f75;
  --report-stat-value: #0f6a5d;
}

.report-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.report-date-field {
  margin: 0;
}

.report-toolbar-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  grid-column: 1 / -1;
  flex-wrap: wrap;
}

.report-chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  color: rgba(15, 23, 42, 0.72);
  font-size: 12px;
}

.report-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.report-legend-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.report-legend-item .dot.approved {
  background: #16a34a;
}

.report-legend-item .dot.pending {
  background: #f59e0b;
}

.report-legend-item .dot.cancelled {
  background: #ec4899;
}

.report-chart {
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.report-chart-empty {
  color: rgba(15, 23, 42, 0.7);
  font-size: 13px;
}

.report-chart-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}

.report-chart-bars {
  min-height: 240px;
  min-width: 720px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.report-chart-col {
  flex: 1 1 0;
  min-width: 20px;
  display: grid;
  justify-items: center;
  gap: 4px;
}

.report-chart-stack {
  width: 100%;
  max-width: 24px;
  height: 180px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}

.report-bar {
  width: 100%;
}

.report-bar.approved {
  background: linear-gradient(180deg, #22c55e, #15803d);
}

.report-bar.pending {
  background: linear-gradient(180deg, #fbbf24, #d97706);
}

.report-bar.cancelled {
  background: linear-gradient(180deg, #f472b6, #be185d);
}

.report-bar-zero {
  width: 100%;
  height: 2px;
  background: rgba(100, 116, 139, 0.55);
}

.report-chart-date {
  font-size: 11px;
  color: rgba(15, 23, 42, 0.74);
}

.report-chart-total {
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
}

.report-ward-ranking {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.report-ward-item {
  display: grid;
  gap: 4px;
}

.report-ward-header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.report-ward-rank {
  font-size: 14px;
  font-weight: 700;
  color: #94a3b8;
  line-height: 1;
}

.report-ward-title-wrap {
  min-width: 0;
}

.report-ward-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.report-ward-id {
  margin-top: 2px;
  font-size: 10px;
  color: rgba(15, 23, 42, 0.66);
}

.report-ward-count {
  min-width: 28px;
  text-align: right;
  font-size: 20px;
  font-weight: 800;
  color: #1d4ed8;
  line-height: 1;
}

.report-ward-bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.report-ward-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
}

.report-ward-empty {
  color: rgba(15, 23, 42, 0.72);
  font-size: 13px;
}

@media (max-width: 980px) {
  .report-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-ward-rank {
    font-size: 13px;
  }

  .report-ward-title {
    font-size: 12px;
  }

  .report-ward-count {
    font-size: 18px;
  }

  .report-top-wards {
    grid-template-columns: 1fr;
  }

  .report-top-ward-name {
    min-height: 30px;
  }
}

@media (max-width: 640px) {
  .report-toolbar {
    grid-template-columns: 1fr;
  }

  .report-stats {
    grid-template-columns: 1fr;
  }

  .report-stats-range {
    grid-template-columns: 1fr;
  }

  .report-chart-bars {
    min-width: 620px;
  }

  .report-ward-header {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .report-ward-rank {
    font-size: 12px;
  }

  .report-ward-title {
    font-size: 12px;
  }

  .report-ward-count {
    font-size: 18px;
  }
}

.field span {
  display: block;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.75);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(2, 6, 23, 0.12);
  background: #fff;
}

.admin-login-card {
  width: min(420px, 100%);
  margin: 64px auto;
  background: #fff;
  border: 1px solid rgba(2, 6, 23, 0.08);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 14px 40px rgba(2, 6, 23, 0.10);
}

.admin-login-header h1 {
  margin: 10px 0 6px;
  font-size: 20px;
}

.admin-login-header p {
  margin: 0 0 10px;
  color: rgba(15, 23, 42, 0.75);
  font-size: 13px;
}

.admin-login-form {
  display: grid;
  gap: 10px;
}

/* -----------------------------
   In-page notify banner + badge
------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: linear-gradient(180deg, #fca5a5, #f87171);
  color: #fff;
  margin-left: 8px;
}

.admin-tabs .badge {
  margin-left: 2px;
}

.badge.pulse {
  animation: bedqPulse 1s ease-out 2;
}

@keyframes bedqPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.banner {
  width: min(1100px, 96vw);
  margin: 12px auto 0;
  background: #fff;
  border: 1px solid rgba(2, 6, 23, 0.10);
  border-radius: 18px;
  padding: 12px 12px;
  box-shadow: 0 14px 40px rgba(2, 6, 23, 0.10);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.banner-left {
  display: grid;
  gap: 2px;
}

.banner-title {
  font-weight: 800;
  color: #0f172a;
}

.banner-body {
  font-size: 13px;
  color: rgba(15, 23, 42, 0.85);
  white-space: pre-line;
}

.banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .banner {
    flex-direction: column;
    align-items: stretch;
  }
  .banner-actions {
    justify-content: flex-end;
  }
}

/* Responsive topbar actions: collapse into a hamburger on mobile */
@media (max-width: 760px) {
  .admin-topbar {
    align-items: center;
  }

  .admin-topbar-right {
    gap: 10px;
  }

  .admin-topbar .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .admin-actions {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(320px, 84vw);
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #fff;
    border: 1px solid rgba(2, 6, 23, 0.10);
    border-radius: 16px;
    box-shadow: 0 14px 40px rgba(2, 6, 23, 0.10);
    z-index: 30;
  }

  .admin-actions.open {
    display: flex;
  }

  .admin-actions .btn,
  .admin-actions a.btn {
    width: 100%;
    min-height: 52px;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 17px;
    font-weight: 800;
    justify-content: center;
  }
}

/* Ensure [hidden] works even if .banner sets display */
.banner[hidden]{display:none !important;}

/* Mobile notify guide modal */
body.modal-open {
  overflow: hidden;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.modal-layer[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(2, 6, 23, 0.52);
  cursor: pointer;
}

.mobile-notify-card {
  position: relative;
  z-index: 1;
  width: min(700px, 100%);
  max-height: calc(100vh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(2, 6, 23, 0.12);
  border-radius: 18px;
  box-shadow: 0 20px 44px rgba(2, 6, 23, 0.24);
  padding: 16px;
}

.mobile-notify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(2, 6, 23, 0.08);
}

.mobile-notify-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  color: #0f172a;
}

.mobile-notify-steps {
  margin: 12px 0 0;
  padding-left: 22px;
  color: #0f172a;
}

.mobile-notify-steps li {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.5;
}

.mobile-notify-steps a {
  color: #1d4ed8;
  font-weight: 700;
}

.mobile-notify-qr-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.mobile-notify-qr {
  width: min(420px, 100%);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(2, 6, 23, 0.1);
}

.mobile-notify-preview {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed rgba(2, 6, 23, 0.18);
}

.mobile-notify-preview h3 {
  margin: 0;
  font-size: 16px;
  color: #334155;
}

.mobile-notify-example {
  display: block;
  width: min(720px, 100%);
  margin: 10px auto 0;
  border-radius: 14px;
  border: 1px solid rgba(2, 6, 23, 0.1);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.12);
}

@media (max-width: 640px) {
  .modal-layer {
    place-items: start center;
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .mobile-notify-card {
    border-radius: 14px;
    padding: 12px;
    max-height: calc(100vh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .mobile-notify-head h2 {
    font-size: 18px;
  }

  .mobile-notify-steps li {
    font-size: 14px;
    margin-top: 8px;
  }

  .mobile-notify-preview h3 {
    font-size: 15px;
  }

  .mobile-notify-example {
    border-radius: 12px;
  }
}

/* In-page toast */
.toast-host {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  width: min(360px, calc(100vw - 20px));
  display: grid;
  gap: 10px;
  z-index: 120;
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(2, 6, 23, 0.12);
  border-left-width: 4px;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.14);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.app-toast.closing {
  opacity: 0;
  transform: translateY(-6px);
}

.app-toast-message {
  flex: 1;
  font-size: 14px;
  line-height: 1.45;
}

.app-toast-close {
  border: 0;
  background: transparent;
  color: rgba(15, 23, 42, 0.6);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 1px 2px;
}

.app-toast-close:hover {
  color: rgba(15, 23, 42, 0.95);
}

.app-toast-info {
  border-left-color: #2563eb;
}

.app-toast-success {
  border-left-color: #16a34a;
}

.app-toast-error {
  border-left-color: #dc2626;
}

@media (max-width: 640px) {
  .toast-host {
    left: 8px;
    right: 8px;
    width: auto;
    top: max(8px, env(safe-area-inset-top));
  }
}
