/* ============================================================
   app.css — Shared Design System
   Student Check-in System | Modern Responsive UI
   Compatible: PC, Tablet, Smartphone, Flutter WebView
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

/* ===== CSS VARIABLES — โทนสีกรมท่า (Navy Blue) - ขาว ===== */
:root {
  /* กรมท่า (Thai Navy Blue) palette */
  --primary:        #1B3A6B;   /* กรมท่าเข้ม */
  --primary-hover:  #142D55;   /* กรมท่าเข้มมาก */
  --primary-mid:    #1E4D8C;   /* กรมท่ากลาง */
  --primary-light:  #2563B8;   /* กรมท่าอ่อน */
  --primary-50:     #EBF0F9;
  --primary-100:    #C7D6EE;
  --success:        #10B981;
  --success-hover:  #059669;
  --success-50:     #ECFDF5;
  --danger:         #EF4444;
  --danger-hover:   #DC2626;
  --danger-50:      #FEF2F2;
  --warning:        #F59E0B;
  --warning-50:     #FFFBEB;
  --info:           #2563EB;
  --info-50:        #EFF6FF;
  --white:          #FFFFFF;
  --gray-50:        #F7F9FC;
  --gray-100:       #EEF2F7;
  --gray-200:       #DDE4EE;
  --gray-300:       #C0CEDF;
  --gray-400:       #8EA4BF;
  --gray-500:       #607A96;
  --gray-600:       #425B77;
  --gray-700:       #2D4060;
  --gray-800:       #1A2D4A;
  --gray-900:       #0D1B30;

  --sidebar-bg:          #0F2347;   /* กรมท่าเข้มมาก สำหรับ sidebar */
  --sidebar-text:        #8FAAC8;
  --sidebar-text-active: #FFFFFF;
  --sidebar-active-bg:   rgba(255,255,255,0.12);
  --sidebar-border:      rgba(255,255,255,0.08);
  --sidebar-width:       240px;

  --topbar-h:    60px;
  --bottomnav-h: 65px;

  --radius-xs:  4px;
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 2px 6px rgba(0,0,0,0.07);
  --shadow:     0 4px 14px rgba(0,0,0,0.09);
  --shadow-lg:  0 10px 28px rgba(0,0,0,0.11);
  --shadow-xl:  0 20px 48px rgba(0,0,0,0.14);

  --transition: 0.18s ease;
  --transition-slow: 0.3s ease;
}

/* ===== BASE ===== */
body {
  font-family: 'Sarabun', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--gray-700);
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
}

/* ===== NAVY PATTERN BACKGROUNDS ===== */
/* ลวดลายเทคโนโลยี/เช็คชื่อ สำหรับหน้า login, checkin, setup */
.bg-navy-pattern {
  background-color: #0F2347;
  background-image:
    /* Grid เทคโนโลยี */
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    /* จุดแสง */
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(37,99,184,0.35) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 70%, rgba(27,58,107,0.4) 0%, transparent 55%);
  background-size: 40px 40px, 40px 40px, 100% 100%, 100% 100%;
}

/* Pattern สำหรับ admin content area */
.bg-admin {
  background-color: var(--gray-100);
  background-image: radial-gradient(var(--primary-100) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Pattern header สำหรับ public pages */
.bg-header-pattern {
  background-color: #0F2347;
  background-image:
    linear-gradient(135deg, #0F2347 0%, #1B3A6B 50%, #1E4D8C 100%);
  position: relative;
}
.bg-header-pattern::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(255,255,255,0.05) 0%, transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.04) 0%, transparent 35%);
  pointer-events: none;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ================================================================
   ADMIN LAYOUT  (sidebar + content)
   ================================================================ */

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

/* ------ SIDEBAR ------ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: transform var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 22px 18px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-brand-text h3 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand-text p {
  font-size: 11px;
  color: var(--sidebar-text);
  margin-top: 2px;
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gray-500);
  padding: 10px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 600;
  border-left: 3px solid var(--primary);
  padding-left: 9px;
}
.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.nav-logout {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: #FDA4AF;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-logout:hover { background: rgba(239,68,68,0.12); color: #FCA5A5; }
.nav-logout .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

/* ------ SIDEBAR OVERLAY (mobile) ------ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 250;
  backdrop-filter: blur(3px);
}
.sidebar-overlay.open { display: block; }

/* ------ PAGE WRAPPER ------ */
.page-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------ ADMIN TOPBAR (desktop) ------ */
.app-topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}

/* ------ MOBILE TOPBAR (hidden on desktop) ------ */
.mobile-topbar {
  display: none;
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  color: #fff;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.mobile-topbar-brand {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.hamburger {
  width: 40px; height: 40px;
  border: none;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}
.hamburger:hover { background: rgba(255,255,255,0.18); }
.hamburger span {
  display: block;
  width: 20px; height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all var(--transition);
}

/* ------ PAGE CONTENT ------ */
.page-content {
  padding: 26px 28px;
  flex: 1;
}

/* ------ BOTTOM NAV (mobile admin, hidden on desktop) ------ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  z-index: 100;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}

.bottom-nav-list {
  display: flex;
  height: 100%;
  list-style: none;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 600;
  transition: color var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 6px 4px;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item .bn-icon { font-size: 22px; line-height: 1; }

/* ================================================================
   PAGE HEADER
   ================================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
}
.page-header-sub {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
}
.card-body { padding: 22px; }

/* ================================================================
   STAT CARDS
   ================================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 20px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
  position: relative;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 0 2px 2px 0;
}
.stat-card.blue::before  { background: var(--info); }
.stat-card.green::before { background: var(--success); }
.stat-card.red::before   { background: var(--danger); }
.stat-card.total::before { background: var(--primary); }
.stat-card.present::before { background: var(--success); }
.stat-card.absent::before  { background: var(--danger); }

.stat-icon {
  width: 50px; height: 50px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-card.blue .stat-icon,
.stat-card.total .stat-icon  { background: var(--primary-50); }
.stat-card.green .stat-icon,
.stat-card.present .stat-icon { background: var(--success-50); }
.stat-card.red .stat-icon,
.stat-card.absent .stat-icon  { background: var(--danger-50); }

.stat-body { flex: 1; min-width: 0; }
.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gray-400);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--gray-800);
}
.stat-card.blue .stat-value,
.stat-card.total .stat-value  { color: var(--primary); }
.stat-card.green .stat-value,
.stat-card.present .stat-value { color: var(--success); }
.stat-card.red .stat-value,
.stat-card.absent .stat-value  { color: var(--danger); }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  min-height: 44px;
  user-select: none;
}
.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(79,70,229,0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79,70,229,0.35);
}
.btn-success {
  background: var(--success);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}
.btn-success:hover {
  background: var(--success-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16,185,129,0.35);
}
.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { background: var(--danger-hover); transform: translateY(-1px); }
.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline-primary:hover { background: var(--primary-50); }
.btn-lg { padding: 14px 34px; font-size: 16px; border-radius: var(--radius-lg); min-height: 52px; }
.btn-sm { padding: 7px 14px; font-size: 13px; min-height: 36px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* ================================================================
   FORM ELEMENTS
   ================================================================ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-700);
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  min-height: 44px;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.form-control::placeholder { color: var(--gray-300); }
select.form-control { cursor: pointer; }

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 140px; }

/* ================================================================
   TABLES
   ================================================================ */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-head-bar {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--gray-200);
}
.table-head-bar.primary-bg { background: linear-gradient(135deg, #0F2347, #1B3A6B); color: #fff; }
.table-head-bar.warning-bg { background: linear-gradient(135deg, #F59E0B, #D97706); color: #fff; }
.table-head-bar.success-bg { background: linear-gradient(135deg, #10B981, #059669); color: #fff; }
.table-head-bar.dark-bg { background: linear-gradient(135deg, #0F2347, #1B3A6B); color: #fff; }
.table-head-title {
  font-size: 15px;
  font-weight: 700;
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 380px;
}
.data-table thead th {
  padding: 12px 14px;
  background: var(--gray-50);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  border-bottom: 1.5px solid var(--gray-200);
  text-align: center;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 13px 14px;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  text-align: center;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tfoot td {
  padding: 12px 14px;
  background: var(--gray-100);
  font-weight: 700;
  color: var(--gray-800);
  border-top: 2px solid var(--gray-200);
  text-align: center;
}

/* Grid table for class overview */
.grid-table-wrap {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.grid-table-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #0F2347, #1B3A6B);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}
.grid-table { width: 100%; border-collapse: collapse; }
.grid-table th {
  padding: 11px 12px;
  background: var(--gray-50);
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  border: 1px solid var(--gray-200);
  text-align: center;
  white-space: nowrap;
}
.grid-table td {
  padding: 11px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  border: 1px solid var(--gray-100);
  text-align: center;
}
.grid-table .room-cell { background: var(--gray-50); font-weight: 800; color: var(--gray-800); }
.grid-table .empty-cell { color: var(--gray-300); }
.grid-table .total-row td {
  background: var(--gray-100);
  font-weight: 800;
  color: var(--gray-800);
  border-top: 2px solid var(--gray-200);
}
.grid-table .total-row .room-cell { background: var(--gray-200); }
.grid-table td a {
  display: block;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}
.grid-table td a:hover { color: var(--primary-hover); text-decoration: underline; }

/* ================================================================
   ALERTS & BADGES
   ================================================================ */
.alert {
  padding: 13px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  animation: fadeIn 0.25s ease;
}
.alert-error   { background: var(--danger-50);  color: #991B1B; border-left: 4px solid var(--danger); }
.alert-success { background: var(--success-50); color: #065F46; border-left: 4px solid var(--success); }
.alert-warning { background: var(--warning-50); color: #92400E; border-left: 4px solid var(--warning); }
.alert-info    { background: var(--info-50);    color: #1E40AF; border-left: 4px solid var(--info); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
}
.badge-primary { background: var(--primary-50); color: var(--primary); }
.badge-success { background: var(--success-50); color: #065F46; }
.badge-danger  { background: var(--danger-50);  color: #991B1B; }
.badge-warning { background: var(--warning-50); color: #92400E; }

/* ================================================================
   REPORT BANNER
   ================================================================ */
.report-banner {
  background: linear-gradient(135deg, #0F2347 0%, #1B3A6B 60%, #1E4D8C 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(15,35,71,0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}
.report-banner-title { font-size: 18px; font-weight: 700; }
.report-banner-sub {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 3px;
}
.report-banner-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.report-banner-form label { font-size: 13px; font-weight: 600; opacity: 0.9; }
.report-banner-form input[type="date"] {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--gray-700);
  background: rgba(255,255,255,0.95);
  cursor: pointer;
  min-height: 38px;
}

/* ================================================================
   PUBLIC LAYOUT  (non-admin pages)
   ================================================================ */
.public-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  background: linear-gradient(135deg, #0F2347 0%, #1B3A6B 60%, #1E4D8C 100%);
  color: #fff;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-lg);
  min-height: 66px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Decorative icons ลวดลายเบา ๆ บน header */
.site-header::before {
  content: '✅ 📋 📱 🎓 ✅ 📋 📱 🎓 ✅ 📋';
  position: absolute;
  right: -20px; top: -4px;
  font-size: 20px;
  opacity: 0.06;
  letter-spacing: 8px;
  white-space: nowrap;
  pointer-events: none;
}
.site-header-logo {
  width: 44px; height: 44px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.site-header-logo-placeholder {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.site-header-info { flex: 1; min-width: 0; }
.site-header-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}
.site-header-sub { font-size: 12px; color: var(--gray-300); }

.site-nav {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  padding: 13px 18px;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.site-nav a:hover { color: var(--primary); background: var(--primary-50); }
.site-nav a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; background: var(--primary-50); }
.site-nav a.cta { color: var(--primary-light); font-weight: 700; }
.site-nav a.cta:hover { color: var(--primary); background: var(--primary-50); }

.site-content {
  flex: 1;
  padding: 22px 22px;
}

/* ================================================================
   BACK LINK
   ================================================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 18px;
  transition: gap var(--transition);
  touch-action: manipulation;
}
.back-link:hover { gap: 10px; }

/* ================================================================
   SECTION DIVIDER HEADER
   ================================================================ */
.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  gap: 10px;
}
.section-title-bar.warning { background: linear-gradient(135deg, #F59E0B, #D97706); }
.section-title-bar.success { background: linear-gradient(135deg, #10B981, #059669); }
.section-title-bar.primary { background: linear-gradient(135deg, #0F2347, #1B3A6B); }
.section-title-bar.danger  { background: linear-gradient(135deg, #EF4444, #DC2626); }
.section-title-bar.navy    { background: linear-gradient(135deg, #0F2347 0%, #1B3A6B 100%); }

/* ================================================================
   DATE PICKER INLINE
   ================================================================ */
.date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.date-row label { font-size: 14px; font-weight: 600; color: var(--gray-500); white-space: nowrap; }

/* ================================================================
   CHART CARDS
   ================================================================ */
.chart-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
}
.chart-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}
.chart-canvas-wrap { position: relative; height: 270px; }
.charts-row-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 18px; margin-bottom: 18px; }
.charts-row-1 { display: grid; grid-template-columns: 1fr; gap: 18px; }

/* ================================================================
   CHECKBOX
   ================================================================ */
.chk-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
input.chk-box {
  width: 20px; height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ================================================================
   FOOTER
   ================================================================ */
.app-footer {
  text-align: center;
  padding: 18px 22px;
  color: var(--gray-400);
  font-size: 12px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
  flex-shrink: 0;
}

/* ================================================================
   ANIMATIONS
   ================================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeIn 0.3s ease both; }

/* ================================================================
   UTILITIES
   ================================================================ */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--gray-400); }
.text-sm      { font-size: 13px; }
.font-bold    { font-weight: 700; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.gap-sm       { gap: 8px; }
.gap-md       { gap: 14px; }
.gap-lg       { gap: 20px; }
.mt-sm        { margin-top: 10px; }
.mt-md        { margin-top: 18px; }
.mt-lg        { margin-top: 26px; }
.mb-sm        { margin-bottom: 10px; }
.mb-md        { margin-bottom: 18px; }
.mb-lg        { margin-bottom: 26px; }
.w-full       { width: 100%; }

/* ================================================================
   RESPONSIVE BREAKPOINTS
   ================================================================ */

/* Tablet */
@media (max-width: 1023px) {
  :root { --sidebar-width: 220px; }
  .page-content { padding: 20px; }
  .charts-row-2 { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 767px) {
  body { font-size: 14px; }

  /* Admin: sidebar slides in from left */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }

  .page-wrapper { margin-left: 0 !important; }
  .app-topbar { display: none; }
  .mobile-topbar { display: flex; }

  .page-content {
    padding: 14px;
    padding-bottom: calc(var(--bottomnav-h) + 14px);
  }
  .bottom-nav { display: block; }

  /* Stats stacked */
  .stats-row { grid-template-columns: 1fr; gap: 10px; }
  .stat-value { font-size: 24px; }

  /* Public layout */
  .site-header { padding: 12px 14px; }
  .site-header-title { font-size: 14px; }
  .site-content { padding: 14px; }

  /* Report banner */
  .report-banner { flex-direction: column; align-items: flex-start; }
  .report-banner-title { font-size: 16px; }

  /* Tables */
  .data-table { min-width: 480px; }
  .grid-table { min-width: 360px; }

  .page-header { flex-direction: column; align-items: flex-start; }

  /* Charts */
  .chart-canvas-wrap { height: 220px; }
}

/* Small phone */
@media (max-width: 374px) {
  :root { --bottomnav-h: 60px; }
  .site-header-title { font-size: 13px; }
}

/* ============================================================
   FLASH TOAST NOTIFICATION
   ============================================================ */
#flash-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  z-index: 9999;
  min-width: 280px;
  max-width: calc(100vw - 32px);
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  line-height: 1.4;
}
#flash-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
#flash-toast.toast-success {
  background: #ECFDF5;
  color: #065F46;
  border-left: 5px solid var(--success);
}
#flash-toast.toast-error {
  background: #FEF2F2;
  color: #991B1B;
  border-left: 5px solid var(--danger);
}
#flash-toast.toast-info {
  background: var(--primary-50);
  color: var(--primary);
  border-left: 5px solid var(--primary);
}
.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-msg  { flex: 1; }
.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: inherit;
  opacity: 0.5;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }

/* ============================================================
   SAVE PROGRESS BAR OVERLAY
   ============================================================ */
#save-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(15, 35, 71, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#save-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.save-overlay-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  padding: 32px 40px;
  text-align: center;
  min-width: 260px;
  max-width: calc(100vw - 48px);
  animation: slideUp 0.35s ease;
}
.save-overlay-icon {
  font-size: 40px;
  margin-bottom: 10px;
  animation: pulse 1s infinite alternate;
}
@keyframes pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.12); }
}
.save-overlay-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 18px;
}
.save-progress-track {
  width: 100%;
  height: 8px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
}
.save-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10B981, #1B3A6B);
  border-radius: 99px;
  transition: width 0.05s linear;
}
