/* ============================================================
   DESIGN SYSTEM — Thai Government Payroll
   Aesthetic: Clean government-grade with Thai warmth
   ============================================================ */
:root {
  --primary:    #1a56db;
  --primary-dk: #1341a8;
  --primary-lt: #e8f0fe;
  --accent:     #0ea5e9;
  --success:    #10b981;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-300:   #cbd5e1;
  --gray-400:   #94a3b8;
  --gray-500:   #64748b;
  --gray-600:   #475569;
  --gray-700:   #334155;
  --gray-800:   #1e293b;
  --gray-900:   #0f172a;
  --sidebar-w:  260px;
  --header-h:   64px;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.06);
  --shadow:     0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 10px 40px rgba(0,0,0,.12);
  --font:       'Sarabun', sans-serif;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ============ AUTH PAGE ============ */
#auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a56db 0%, #0ea5e9 100%);
  position: relative;
  overflow: hidden;
}

#auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -200px; right: -200px;
}
#auth-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  bottom: -100px; left: -100px;
}

.auth-box {
  background: #fff;
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: fadeUp .4s ease;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo .icon {
  width: 72px; height: 72px;
  background: var(--primary-lt);
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 28px;
  overflow: hidden;
  padding: 8px;
}
.auth-logo h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.4;
}
.auth-logo p {
  font-size: .85rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--gray-500);
  transition: all .2s;
}
.auth-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--primary-dk); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-lt); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-sm      { padding: 7px 14px; font-size: .85rem; }
.btn-icon    { padding: 8px; border-radius: 8px; }

.hint {
  font-size: .8rem;
  color: var(--gray-400);
  text-align: center;
  margin-top: 16px;
}

/* ============ APP LAYOUT ============ */
#app-page { display: none; }

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

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.sidebar-brand-sub {
  font-size: .7rem;
  color: var(--gray-400);
  font-weight: 400;
}

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
}
.sidebar-user-info { margin-left: 10px; overflow: hidden; }
.sidebar-user-name {
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: .72rem;
  color: var(--gray-400);
}

.sidebar-nav { flex: 1; padding: 12px 12px; overflow-y: auto; }
.nav-section-label {
  font-size: .68rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 12px 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--gray-400);
  font-size: .9rem;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .icon { font-size: 18px; width: 20px; text-align: center; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  padding: 2px 6px;
  border-radius: 99px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
/**
 * activity_log.css — Styles for Activity Dashboard Add-on (v2 fixed)
 */

/* ========== ACTIVITY STAT CARDS ========== */
.act-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.act-stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 14px 18px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.act-stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  border-radius: 0 0 12px 12px;
}
.act-stat-card.blue   { border-top: 3px solid #1a56db; }
.act-stat-card.green  { border-top: 3px solid #10b981; }
.act-stat-card.red    { border-top: 3px solid #ef4444; }
.act-stat-card.amber  { border-top: 3px solid #f59e0b; }
.act-stat-card.purple { border-top: 3px solid #8b5cf6; }
.act-stat-card.blue::after   { background: #1a56db; }
.act-stat-card.green::after  { background: #10b981; }
.act-stat-card.red::after    { background: #ef4444; }
.act-stat-card.amber::after  { background: #f59e0b; }
.act-stat-card.purple::after { background: #8b5cf6; }

.act-stat-icon {
  font-size: 20px;
  line-height: 1;
  display: block;
}
.act-stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  min-height: 36px;
  display: flex;
  align-items: center;
}
.act-stat-label {
  font-size: .72rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.3;
}

/* ========== FILTER BAR ========== */
.act-filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: #fff;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.act-filter-bar select,
.act-filter-bar input[type="text"],
.act-filter-bar input[type="date"] {
  padding: 8px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-family: 'Sarabun', sans-serif;
  font-size: .88rem;
  color: #334155;
  background: #fff;
  outline: none;
  transition: border-color .2s;
  height: 38px;
}
.act-filter-bar select:focus,
.act-filter-bar input:focus {
  border-color: #1a56db;
  box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}
#act-range-row {
  display: none;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ========== CHART ========== */
.act-chart-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.act-chart-title {
  font-size: .92rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.act-chart-container {
  height: 200px;
  position: relative;
}

/* ========== TABLE ========== */
.act-table-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  overflow: hidden;
  margin-bottom: 20px;
}
.act-table-scroll { overflow-x: auto; }
.act-table-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
  min-width: 580px;
}
.act-table-card thead tr {
  background: linear-gradient(135deg, #1a56db, #0ea5e9);
}
.act-table-card th {
  padding: 11px 12px;
  color: #fff;
  font-weight: 700;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.act-table-card td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #475569;
  vertical-align: middle;
  line-height: 1.4;
}
.act-table-card tbody tr:hover td { background: #f0f7ff; }
.act-table-card tbody tr:last-child td { border-bottom: none; }
.tc { text-align: center; }

/* ========== BADGES ========== */
.act-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.act-badge-blue   { background: #dbeafe; color: #1d4ed8; }
.act-badge-green  { background: #d1fae5; color: #059669; }
.act-badge-red    { background: #fee2e2; color: #dc2626; }
.act-badge-amber  { background: #fef3c7; color: #d97706; }
.act-badge-gray   { background: #f1f5f9; color: #64748b; }

/* ========== PAGINATION ========== */
.act-pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  padding: 14px 16px;
  flex-wrap: wrap;
  border-top: 1px solid #f1f5f9;
}
.act-pag-btn {
  min-width: 34px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-family: 'Sarabun', sans-serif;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.act-pag-btn:hover { border-color: #1a56db; color: #1a56db; background: #eff6ff; }
.act-pag-btn.active { background: #1a56db; color: #fff; border-color: #1a56db; }

/* ========== LOADING ========== */
#act-loading {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.8);
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 12px;
}

/* ========== EXPORT BUTTON ========== */
.act-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: linear-gradient(135deg, #1a56db, #0ea5e9);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Sarabun', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(26,86,219,.3);
  white-space: nowrap;
}
.act-export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(26,86,219,.4);
}

/* ========== INFO NOTICE ========== */
.act-notice {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: .86rem;
  color: #1e40af;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.6;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .act-stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .act-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .act-stat-value { font-size: 1.5rem; }
  .act-filter-bar { flex-direction: column; align-items: stretch; }
  .act-filter-bar select,
  .act-filter-bar input { width: 100%; }
}
@media (max-width: 420px) {
  .act-stat-card { padding: 12px 10px 14px; }
  .act-stat-value { font-size: 1.3rem; }
}


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

.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-600);
  padding: 4px;
}

.breadcrumb {
  font-size: .85rem;
  color: var(--gray-500);
}
.breadcrumb span { color: var(--gray-800); font-weight: 600; }

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

.content { flex: 1; padding: 28px 28px; }

/* ============ CARDS ============ */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.card-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px 24px; }

/* STAT CARDS */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 0 var(--radius) 0 80px;
  opacity: .08;
}
.stat-card.blue  { border-top: 3px solid var(--primary); }
.stat-card.green { border-top: 3px solid var(--success); }
.stat-card.red   { border-top: 3px solid var(--danger); }
.stat-card.amber { border-top: 3px solid var(--warning); }
.stat-card.blue::before  { background: var(--primary); }
.stat-card.green::before { background: var(--success); }
.stat-card.red::before   { background: var(--danger); }
.stat-card.amber::before { background: var(--warning); }

.stat-label {
  font-size: .8rem;
  color: var(--gray-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.stat-sub {
  font-size: .8rem;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
thead tr { background: var(--gray-50); border-bottom: 2px solid var(--gray-200); }
th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--gray-600);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
td {
  padding: 13px 16px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ============ BADGE ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-blue  { background: var(--primary-lt); color: var(--primary); }
.badge-green { background: #d1fae5; color: var(--success); }
.badge-red   { background: #fee2e2; color: var(--danger); }
.badge-amber { background: #fef3c7; color: #d97706; }


/* ===== TABS ===== */
.act-tabs {
  display: flex;
  margin-bottom: 20px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.act-tab-btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  background: transparent;
  font-family: 'Sarabun', sans-serif;
  font-size: .92rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all .2s;
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.act-tab-btn:hover { background: #f8fafc; color: #1e293b; }
.act-tab-btn.active { color: #1a56db; border-bottom: 3px solid #1a56db; background: #eff6ff; }
.act-tab-btn .tab-count {
  background: #e2e8f0; color: #64748b;
  font-size: .7rem; padding: 2px 7px;
  border-radius: 99px; font-weight: 700; transition: all .2s;
}
.act-tab-btn.active .tab-count { background: #dbeafe; color: #1a56db; }

/* ===== TAB PANELS ===== */
.act-tab-panel { display: none; animation: fadeUp .2s ease; }
.act-tab-panel.active { display: block; }

/* ===== PDF SUMMARY CARDS ===== */
.pdf-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.pdf-summary-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  text-align: center;
}
.pdf-summary-card.teal   { border-top: 3px solid #0d9488; }
.pdf-summary-card.indigo { border-top: 3px solid #6366f1; }
.pdf-summary-card.rose   { border-top: 3px solid #f43f5e; }
.pdf-summary-card.sky    { border-top: 3px solid #0ea5e9; }
.pdf-summary-num {
  font-size: 1.6rem; font-weight: 800; color: #0f172a;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.pdf-summary-label {
  font-size: .7rem; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: .04em; margin-top: 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) { .pdf-summary-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
  .act-tabs { flex-direction: column; }
  .act-tab-btn { border-bottom: none; border-left: 3px solid transparent; }
  .act-tab-btn.active { border-left: 3px solid #1a56db; border-bottom: none; background: #eff6ff; }
  .pdf-summary-grid { grid-template-columns: 1fr 1fr; }
  .act-filter-bar select, .act-filter-bar input { width: 100%; }
}



/* ============ SLIP MODAL ============ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .3s ease;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--gray-800); }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 24px; }

/* ============ SLIP DESIGN ============ */
.slip {
  font-family: var(--font);
  max-width: 640px;
  margin: 0 auto;
}
.slip-header {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 24px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  text-align: center;
}
.slip-header h2 { font-size: 1.1rem; font-weight: 700; }
.slip-header p { font-size: .85rem; opacity: .85; margin-top: 4px; }
.slip-period {
  display: inline-block;
  background: rgba(255,255,255,.2);
  padding: 4px 16px;
  border-radius: 99px;
  font-size: .9rem;
  font-weight: 700;
  margin-top: 8px;
}
.slip-info {
  background: var(--gray-50);
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-200);
}
.slip-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}
.slip-info-item label {
  font-size: .75rem;
  color: var(--gray-400);
  font-weight: 600;
  text-transform: uppercase;
}
.slip-info-item p {
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-top: 1px;
}
.slip-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--gray-200);
}
.slip-col {
  padding: 16px 20px;
}
.slip-col:first-child {
  border-right: 1px solid var(--gray-200);
}
.slip-col-title {
  font-size: .95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-200);
}
.slip-col-title.income { border-color: var(--success); color: var(--success); }
.slip-col-title.deduct { border-color: var(--danger);  color: var(--danger);  }
.slip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: .85rem;
}
.slip-row label { color: var(--gray-600); }
.slip-row span  { font-weight: 600; color: var(--gray-800); }
.slip-total {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  margin-top: 8px;
  border-top: 2px solid var(--gray-300);
  font-weight: 700;
  font-size: .95rem;
}
.slip-net {
  background: var(--gray-900);
  color: #d0d0d4;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.slip-net label { font-size: 1.5rem; font-weight: 700; opacity: .99; }
.slip-net span { font-size: 1.6rem; font-weight: 800; color: #4ade80; }

/* ============ FILTER BAR ============ */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-bar select, .filter-bar input {
  padding: 9px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .88rem;
  color: var(--gray-700);
  background: #fff;
  outline: none;
}
.filter-bar select:focus, .filter-bar input:focus {
  border-color: var(--primary);
}

/* ============ SECTION HEADERS ============ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
}
.page-subtitle {
  font-size: .85rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ============ CHART CONTAINER ============ */
.chart-container {
  position: relative;
  height: 260px;
}

/* ============ EMPTY STATE ============ */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty p { font-size: .9rem; }

/* ============ LOADING ============ */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin: 0 auto;
}
.loading-center { text-align: center; padding: 40px; }

/* ============ OVERLAY ============ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ============ ANIMATIONS ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.fade-in { animation: fadeUp .3s ease; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }

  .main { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .content { padding: 16px; }

  .stat-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }

  .slip-cols { grid-template-columns: 1fr; }
  .slip-col:first-child { border-right: none; border-bottom: 1px solid var(--gray-200); }
  .slip-info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .auth-box { padding: 32px 24px; margin: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}



/* ============ VIEWS ============ */
.view { display: none; animation: fadeUp .25s ease; }
.view.active { display: block; }

/* ============ ADMIN IMPORT ZONE ============ */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--primary); background: var(--primary-lt); }
.drop-zone-icon { font-size: 40px; margin-bottom: 12px; }
.drop-zone p { color: var(--gray-500); font-size: .9rem; }
.drop-zone strong { color: var(--primary); }

/* Chart tooltip */
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--gray-600); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
/* ===== FOOTER ===== */
.footer {
  background: #0f172a;
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: .85rem;
  border-top: 3px solid #1a56db;
}

.footer img {
  height: 36px;
}

.footer span {
  opacity: .9;
  font-weight: 500;
}

@media (max-width: 600px){
  .footer {
    flex-direction: column;
    text-align: center;
    gap: 6px;
  }
}
/* ================= PRINT WATERMARK ================= */

/* Swal wide modal for payroll edit */
.swal-wide-popup { font-family: var(--font) !important; }
.swal-wide-popup .swal2-html-container { overflow-y: auto; max-height: 70vh; padding: 0 4px; }
.swal-wide-popup input[type=number]::-webkit-inner-spin-button { opacity: .4; }

/* ============ MAINTENANCE ============ */
#maintenance-page {
  display: none;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
#maintenance-page::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px; border-radius: 50%;
  background: radial-gradient(circle, rgba(239,68,68,.15), transparent 70%);
  top: -100px; left: -100px;
  animation: mpulse 4s ease-in-out infinite;
}
#maintenance-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(26,86,219,.1), transparent 70%);
  bottom: -100px; right: -100px;
  animation: mpulse 4s ease-in-out infinite reverse;
}
@keyframes mpulse {
  0%,100% { transform: scale(1); opacity: .7; }
  50%      { transform: scale(1.1); opacity: 1; }
}
.maint-box {
  text-align: center;
  z-index: 1;
  padding: 20px;
  animation: fadeUp .5s ease;
}
.maint-icon {
  font-size: 72px;
  margin-bottom: 20px;
  display: block;
  animation: mspin 10s linear infinite;
}
@keyframes mspin { to { transform: rotate(360deg); } }
.maint-title { font-size: 2rem; font-weight: 800; color: #fff; margin-bottom: 12px; }
.maint-msg   { font-size: 1.05rem; color: #94a3b8; margin-bottom: 32px; max-width: 480px; line-height: 1.7; }
.maint-dev-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 24px; border-radius: 99px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  color: #94a3b8; font-size: .85rem; cursor: pointer;
  transition: all .2s; font-family: var(--font);
}
.maint-dev-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

/* MAINTENANCE STATUS BAR — Developer only */
#maint-bar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  height: 40px;
  background: linear-gradient(90deg, #b91c1c, #dc2626);
  color: #fff; font-size: .83rem; font-weight: 600;
  padding: 0 20px;
  align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(220,38,38,.45);
}
#maint-bar.show { display: flex; }
.mbar-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  margin-right: 8px; flex-shrink: 0;
  animation: mblink 1.2s ease-in-out infinite;
}
@keyframes mblink { 0%,100%{opacity:1} 50%{opacity:.25} }
.mbar-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 14px; border-radius: 99px;
  background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: .8rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: background .2s;
}
.mbar-btn:hover { background: rgba(0,0,0,.4); }
/* ดัน layout ลงเมื่อ bar แสดง */
body.has-mbar .sidebar  { top: 40px; height: calc(100vh - 40px); }
body.has-mbar .topbar   { top: 40px; }
body.has-mbar .content  { padding-top: 28px; }

/* ============ PRINT STYLES ============ */

@media print {
sidebar, .topbar, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .modal-close { display: none; }
  .slip { max-width: 100%; position: relative; z-index: 1; }

  body::before{
    content: "";
    position: fixed;
    top: 50%;
    left: 50%;
    width: 520px;
    height: 520px;
    transform: translate(-50%, -50%);
    background-image: url("logo.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.07;
    z-index: 0;
    pointer-events: none;
  }
}

