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

:root {
  --font-base: 'Google Sans', 'Google Sans Text', 'Poppins', 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  --color-primary: #6366f1;
  --color-primary-dark: #4338ca;
  --color-primary-light: #818cf8;
  --color-accent: #06b6d4;
  --color-success: #10b981;
  --color-success-bg: #d1fae5;
  --color-success-text: #065f46;
  --color-danger: #ef4444;
  --color-danger-bg: #fee2e2;
  --color-danger-text: #991b1b;
  --color-warning: #f59e0b;
  --color-warning-bg: #fef3c7;
  --color-warning-text: #92400e;
  --color-info-bg: #e0f2fe;
  --color-text: #1e2130;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-surface: #ffffff;
  --color-bg: #f3f4fb;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(30, 33, 48, 0.06), 0 1px 2px rgba(30, 33, 48, 0.04);
  --shadow-md: 0 8px 24px rgba(76, 81, 191, 0.08), 0 2px 6px rgba(30, 33, 48, 0.05);
  --shadow-lg: 0 16px 40px rgba(76, 81, 191, 0.14);
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #06b6d4 100%);
  --gradient-primary-hover: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #0891b2 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-base);
  background: var(--color-bg);
  background-image:
    radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.06), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(6, 182, 212, 0.06), transparent 40%);
  background-attachment: fixed;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -0.01em; }

/* ---------------------------------------------------------------------
   Login
--------------------------------------------------------------------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--gradient-primary);
  position: relative;
  overflow: hidden;
}

.login-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.18), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(255,255,255,0.14), transparent 40%);
}

.login-card {
  background: rgba(255, 255, 255, 0.97);
  padding: 2.75rem 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(30, 20, 90, 0.35);
  width: 380px;
  position: relative;
  z-index: 1;
}

.login-card h1 {
  font-size: 1.3rem;
  margin: 0 0 0.25rem;
  text-align: center;
  color: var(--color-text);
  font-weight: 800;
}

.subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 1.75rem;
}

/* Two-panel login layout (public/login.php) */
.login-shell {
  display: flex;
  width: min(920px, 92vw);
  min-height: 560px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(20, 15, 80, 0.4);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.login-brand {
  flex: 1 1 44%;
  background: var(--gradient-primary);
  color: #fff;
  padding: 3rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,0.16), transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(255,255,255,0.12), transparent 45%);
}

.login-brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  position: relative;
}

.login-brand h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 0.85rem;
  position: relative;
}

.login-brand p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.88);
  margin: 0 0 1.5rem;
  position: relative;
}

.login-brand-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
}

.login-brand-features li {
  font-size: 0.87rem;
  color: rgba(255, 255, 255, 0.92);
  padding-left: 1.5rem;
  position: relative;
}

.login-brand-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 800;
  color: #fff;
}

.login-panel {
  flex: 1 1 56%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  gap: 1.5rem;
}

.login-panel .login-card {
  box-shadow: none;
  padding: 0;
  width: 100%;
  max-width: 340px;
}

.login-step-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  background: rgba(99, 102, 241, 0.1);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 1rem;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.login-footer {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0;
}

@media (max-width: 820px) {
  .login-shell { flex-direction: column; width: min(420px, 92vw); min-height: 0; }
  .login-brand { padding: 2rem; }
  .login-brand-features { display: none; }
  .login-panel { padding: 2.25rem; }
}

/* Step 2: site-password gate */
.gate-card {
  background: rgba(255, 255, 255, 0.98);
  padding: 2.5rem 2.5rem 2rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(30, 20, 90, 0.35);
  width: 380px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.gate-lock-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--gradient-primary);
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.gate-card h1 {
  font-size: 1.3rem;
  margin: 0.65rem 0 0.25rem;
  font-weight: 800;
  color: var(--color-text);
}

.gate-card .subtitle { margin-bottom: 1.25rem; }

.gate-user-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  margin-bottom: 1.25rem;
  text-align: left;
}

.gate-user-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gate-user-name { font-size: 0.87rem; font-weight: 700; color: var(--color-text); }
.gate-user-email { font-size: 0.76rem; color: var(--color-text-muted); }

.gate-password-input {
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 1.1rem;
  font-weight: 700;
}

.gate-switch-account {
  display: block;
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-decoration: none;
}

.gate-switch-account:hover { color: var(--color-primary); text-decoration: underline; }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-form label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.login-form input {
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.login-form button {
  margin-top: 1.5rem;
  padding: 0.8rem;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.login-form button:hover {
  background: var(--gradient-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(99, 102, 241, 0.45);
}

.login-form button:active { transform: translateY(0); }

.btn-google-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 1.5rem;
  padding: 0.8rem;
  background: #fff;
  color: #3c4043;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.98rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.btn-google-login:hover {
  border-color: var(--color-primary);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
  transform: translateY(-1px);
}

.btn-google-login:active { transform: translateY(0); }

.login-hint {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------
   Alerts
--------------------------------------------------------------------- */
.alert {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  border: 1px solid transparent;
}

.alert-error { background: var(--color-danger-bg); color: var(--color-danger-text); border-color: #fecaca; }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); border-color: #a7f3d0; }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); padding: 0.7rem 1rem; border-radius: var(--radius-sm); font-size: 0.9rem; border-color: #fde68a; }

.alert ul { margin: 0; padding-left: 1.1rem; }

/* ---------------------------------------------------------------------
   Topbar / Nav
--------------------------------------------------------------------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.75rem;
  background: var(--gradient-primary);
  box-shadow: 0 4px 16px rgba(76, 81, 191, 0.25);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-weight: 800; color: #fff; letter-spacing: -0.01em; }

.topbar-link { color: inherit; text-decoration: none; }

.topbar-nav { display: flex; gap: 0.35rem; }

.topbar-nav a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar-nav a:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.topbar-nav a.active {
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-primary-dark);
}

.topbar-nav .nav-dropdown { position: relative; }

.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: rgba(255, 255, 255, 0.82);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-dropdown-toggle svg { transition: transform 0.15s ease; opacity: 0.8; }

.nav-dropdown-toggle:hover,
.nav-dropdown-toggle.active { background: rgba(255, 255, 255, 0.14); color: #fff; }

.nav-dropdown:hover .nav-dropdown-toggle svg,
.nav-dropdown:focus-within .nav-dropdown-toggle svg { transform: rotate(180deg); }

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 190px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(30, 32, 60, 0.22);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 60;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown-menu a {
  color: var(--color-text, #1e2145);
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 600;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.nav-dropdown-menu a:hover { background: rgba(76, 81, 191, 0.1); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.87rem;
  color: rgba(255, 255, 255, 0.9);
}

.btn-logout {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.btn-logout:hover { background: rgba(255, 255, 255, 0.28); }

.user-chip { position: relative; }

.user-chip-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0.3rem 0.9rem 0.3rem 0.3rem;
  cursor: pointer;
  color: #fff;
  font: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  transition: background 0.15s ease;
}

.user-chip-toggle:hover,
.user-chip-toggle.active { background: rgba(255, 255, 255, 0.22); }

.user-chip-toggle svg { opacity: 0.85; transition: transform 0.15s ease; }

.user-chip:hover .user-chip-toggle svg,
.user-chip:focus-within .user-chip-toggle svg { transform: rotate(180deg); }

.user-chip-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-chip-avatar-fallback {
  background: linear-gradient(135deg, #ffffff 0%, #d7dbff 100%);
  color: var(--color-primary-dark);
  font-weight: 800;
  font-size: 0.85rem;
}

.user-chip-avatar-lg { width: 44px; height: 44px; font-size: 1.1rem; }

.user-chip-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip-menu {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  min-width: max-content;
  width: max-content;
  max-width: 320px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(30, 32, 60, 0.22);
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 60;
}

.user-chip:hover .user-chip-menu,
.user-chip:focus-within .user-chip-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-chip-menu-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.6rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.5rem;
}

.user-chip-menu-name { font-weight: 700; color: var(--color-text); font-size: 0.92rem; }
.user-chip-menu-email { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 0.1rem; white-space: nowrap; }
.user-chip-menu-role { font-size: 0.75rem; color: var(--color-primary-dark); margin-top: 0.25rem; font-weight: 600; }

.user-chip-logout {
  display: block;
  text-align: center;
  color: var(--color-danger);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.55rem;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.user-chip-logout:hover { background: var(--color-danger-bg); }

/* ---------------------------------------------------------------------
   Layout
--------------------------------------------------------------------- */
.content { padding: 2rem; }
.content-wide { padding: 1.5rem 2rem; }

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.dash-header h1 { margin: 0; font-weight: 800; }

.table-actions-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.25rem;
}

.dash-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  margin-left: auto;
}

.period-filter { display: flex; gap: 0.5rem; }

.period-filter select,
.period-filter button {
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  font-size: 0.9rem;
  background: var(--color-surface);
}

.period-filter button {
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.period-filter button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.period-status { color: var(--color-text-muted); margin: 1rem 0; }

.warnings { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }

/* ---------------------------------------------------------------------
   Stat cards
--------------------------------------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
  margin-top: 1.5rem;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--color-primary);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

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

.card-grid .stat-card:nth-child(4n+1) { border-top-color: #6366f1; }
.card-grid .stat-card:nth-child(4n+2) { border-top-color: #06b6d4; }
.card-grid .stat-card:nth-child(4n+3) { border-top-color: #f59e0b; }
.card-grid .stat-card:nth-child(4n+4) { border-top-color: #10b981; }

.stat-label { font-size: 0.83rem; color: var(--color-text-muted); margin-bottom: 0.4rem; font-weight: 600; }
.stat-value { font-size: 1.7rem; font-weight: 800; color: var(--color-text); }
.stat-sub { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.4rem; }

/* ---------------------------------------------------------------------
   Trend table
--------------------------------------------------------------------- */
.trend-section { margin-top: 2rem; }

.trend-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.trend-table th, .trend-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.9rem;
}

.trend-table th { background: #f5f5fd; color: var(--color-text-muted); font-weight: 700; }

.empty-state { color: var(--color-text-muted); font-size: 0.9rem; padding: 1rem 0; }

/* ---------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------- */
.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); background: var(--gradient-primary-hover); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary-dark);
  border: 1.5px solid #ddd9fb;
  padding: 0.55rem 1.05rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-secondary:hover { background: #f5f3ff; border-color: var(--color-primary-light); }

.btn-clear { color: var(--color-text-muted); text-decoration: none; font-size: 0.85rem; align-self: center; }
.btn-clear:hover { color: var(--color-primary-dark); }

/* ---------------------------------------------------------------------
   Filters
--------------------------------------------------------------------- */
.filter-bar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }

.filter-bar input, .filter-bar select {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--color-surface);
}

.filter-bar input:focus, .filter-bar select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.filter-bar button {
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gradient-primary);
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.result-count { color: var(--color-text-muted); font-size: 0.85rem; margin: 0.5rem 0; }

/* ---------------------------------------------------------------------
   Tables
--------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

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

.data-table th, .data-table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.88rem;
  white-space: nowrap;
}

.data-table th {
  background: #f5f5fd;
  color: #494d80;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.data-table tbody tr { transition: background 0.1s ease; }
.data-table tbody tr:hover { background: #faf9ff; }
.data-table tbody tr:nth-child(even) { background: #fcfcff; }
.data-table tbody tr:nth-child(even):hover { background: #faf9ff; }

.text-muted { color: #9ca3af; font-size: 0.85rem; }

/* ---------------------------------------------------------------------
   Badges
--------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.badge-active { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-resigned { background: var(--color-danger-bg); color: var(--color-danger-text); }
.badge-suspended { background: var(--color-warning-bg); color: var(--color-warning-text); }

/* ---------------------------------------------------------------------
   Actions / links
--------------------------------------------------------------------- */
.actions { display: flex; gap: 0.85rem; }

.actions a {
  color: var(--color-primary-dark);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.actions a:hover { text-decoration: underline; }

.link-danger { color: var(--color-danger) !important; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-primary-dark);
  text-decoration: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.link-button:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------
   Forms
--------------------------------------------------------------------- */
.form-title { max-width: 900px; margin: 0 auto 1rem; text-align: center; font-weight: 800; }

.entity-form {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  max-width: 900px;
  margin: 0 auto;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; }

.form-field { display: flex; flex-direction: column; gap: 0.35rem; }

.form-field label { font-size: 0.85rem; font-weight: 700; color: #374151; }

.form-field-wide { grid-column: 1 / -1; }

.form-field-checkbox { flex-direction: row; align-items: center; }

.form-field-checkbox label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }

.form-field input, .form-field select {
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field input:focus, .form-field select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-actions { margin-top: 1.75rem; display: flex; gap: 0.75rem; }

/* ---------------------------------------------------------------------
   Settings hub
--------------------------------------------------------------------- */
.settings-grid { margin-top: 1.5rem; }

.settings-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  border: 1.5px solid transparent;
}

.settings-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #ddd9fb; }

.settings-card-title { font-weight: 800; font-size: 1.05rem; margin-bottom: 0.35rem; color: var(--color-primary-dark); }
.settings-card-desc { color: var(--color-text-muted); font-size: 0.85rem; }

.settings-group-title {
  margin: 1.5rem 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  border-bottom: 2px solid #ede9fe;
  padding-bottom: 0.4rem;
}

.settings-group-title:first-child { margin-top: 0; }

.breadcrumb { font-size: 0.85rem; margin-bottom: 0.75rem; color: var(--color-text-muted); }
.breadcrumb a { color: var(--color-primary-dark); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------
   Attendance
--------------------------------------------------------------------- */
.attendance-form { max-width: none; }

.attendance-table select, .attendance-table input {
  padding: 0.35rem 0.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.82rem;
}

.attendance-table input[type="text"] { width: 120px; }

.weekend-row { background: #faf9ff; }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0; }

.legend-item {
  font-size: 0.75rem;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  color: #1f2937;
  white-space: nowrap;
  font-weight: 600;
}

.grid-wrap { max-height: 75vh; overflow: auto; border-radius: var(--radius-md); }

.attendance-grid { min-width: unset; border-collapse: separate; border-spacing: 0; }

.attendance-grid th, .attendance-grid td { white-space: nowrap; padding: 0.35rem 0.5rem; }

.attendance-grid .day-col { text-align: center; padding: 0.2rem; min-width: 46px; }

.attendance-grid .weekend-col { background: #f4f4fc; }

.attendance-grid .grid-cell {
  width: 42px;
  padding: 0.2rem;
  border: 1.5px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.75rem;
  text-align: center;
  transition: border-color 0.1s ease;
}

.attendance-grid .grid-cell:focus { outline: none; border-color: var(--color-primary); }

.sticky-col { position: sticky; background: #fff; z-index: 1; }

.attendance-grid thead th { position: sticky; top: 0; z-index: 2; background: #f5f5fd; }

thead .sticky-col { z-index: 4; background: #f5f5fd; }

.col-code { left: 0; min-width: 90px; }
.col-name { left: 90px; min-width: 160px; }
.col-rate { left: 250px; min-width: 80px; text-align: right; }

.data-table td.summary-col, .summary-col {
  text-align: center;
  font-weight: 700;
  background: #eef2ff;
  min-width: 60px;
}

.summary-wide { min-width: 220px; white-space: normal; text-align: left; }

.summary-wide .legend-item { display: inline-block; margin: 0.1rem 0.2rem 0.1rem 0; }

/* ---------------------------------------------------------------------
   Payroll table
--------------------------------------------------------------------- */
.payroll-table thead th { position: sticky; top: 0; z-index: 2; background: #f5f5fd; }
.payroll-table thead th.sticky-col { z-index: 4; }

.payroll-col-code { left: 0; min-width: 90px; }
.payroll-col-name { left: 90px; min-width: 160px; }

.summary-late { background: var(--color-danger-bg); color: var(--color-danger-text); }

/* ---------------------------------------------------------------------
   Leaves table
--------------------------------------------------------------------- */
.leave-type-head { text-align: center; background: #eef2ff; border-left: 3px solid #a5b4fc; }
.leave-group-start { border-left: 3px solid #a5b4fc; }

.leaves-table thead th { text-align: center; position: sticky; z-index: 2; background: #f5f5fd; }
.leaves-table thead th.sticky-col { z-index: 4; }
.leaves-table thead tr:nth-child(1) th { top: 0; }
.leaves-table thead tr:nth-child(2) th { top: var(--leaves-row1-height, 44px); }

.leaves-col-code { left: 0; min-width: 90px; }
.leaves-col-name { left: 90px; min-width: 160px; }

.late-cell { box-shadow: inset 0 0 0 2px var(--color-warning); }

.unmatched-row { background: #fff1f2; }
.unmatched-row select { border-color: #fda4af; }

/* ---------------------------------------------------------------------
   Payroll actions / forms
--------------------------------------------------------------------- */
.payroll-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.reason-form { display: flex; gap: 0.6rem; margin: 0.75rem 0; align-items: center; }

.reason-form input[type="text"] {
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  min-width: 260px;
}

.hidden { display: none; }

.allowance-input {
  width: 90px;
  padding: 0.32rem 0.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.pagination { display: flex; align-items: center; gap: 1rem; justify-content: center; margin-top: 1.5rem; }
