:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
}

/* Layout */
.app-container { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--primary);
  color: white;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar h1 { font-size: 1.1rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-user { font-size: 0.85rem; opacity: 0.9; }
.topbar-sede { background: rgba(255,255,255,0.2); padding: 2px 10px; border-radius: 12px; font-size: 0.8rem; }

.main-layout { display: flex; flex: 1; }

.sidebar {
  width: 220px;
  background: white;
  border-right: 1px solid var(--gray-200);
  padding: 1rem 0;
  flex-shrink: 0;
}
.sidebar a, .sidebar button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  text-decoration: none;
  color: var(--gray-600);
  font-size: 0.9rem;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar a:hover, .sidebar button:hover { background: var(--gray-50); color: var(--primary); }
.sidebar a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar .divider { height: 1px; background: var(--gray-200); margin: 0.5rem 0; }

.content { flex: 1; padding: 1.5rem; overflow-x: auto; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-header h2 { font-size: 1.15rem; color: var(--gray-800); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--gray-600); margin-bottom: 0.25rem; font-weight: 500; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; }

input[type="text"], input[type="password"], input[type="number"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: white; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.5rem 0.6rem; text-align: left; border-bottom: 1px solid var(--gray-200); font-size: 0.85rem; }
th { background: var(--gray-50); font-weight: 600; color: var(--gray-600); position: sticky; top: 0; z-index: 1; }
tr:hover td { background: var(--gray-50); }

/* Attendance grid */
.att-grid { overflow-x: auto; max-width: 100%; }
.att-grid table { min-width: 600px; border-collapse: separate; border-spacing: 0; }
.att-grid th { font-size: 0.72rem; white-space: nowrap; padding: 0.4rem 0.25rem; border-bottom: 2px solid var(--gray-300); }
.att-grid td { padding: 0.2rem; border-bottom: 1px solid var(--gray-100); }
.att-grid input[type="number"] {
  width: 52px;
  padding: 0.25rem;
  font-size: 0.8rem;
  text-align: center;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  background: white;
}
.att-grid input[type="number"]:focus { border-color: var(--primary); background: #f0f7ff; }
.att-grid input[type="number"]:disabled { background: #f3f4f6; color: #aaa; }
.att-grid input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.att-grid .emp-name {
  position: sticky;
  left: 0;
  background: white;
  z-index: 2;
  font-weight: 600;
  white-space: nowrap;
  min-width: 150px;
  padding: 0.4rem 0.5rem;
  border-right: 3px solid var(--primary);
  font-size: 0.85rem;
}
.att-grid thead th.emp-name-th {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--gray-50);
  border-right: 3px solid var(--primary);
  font-weight: 700;
}
/* Day group separation - thick left border on first column of each day */
.att-grid .day-start { border-left: 3px solid var(--gray-300) !important; }
.att-grid th.day-start { border-left: 3px solid var(--gray-400) !important; }
/* Day header spanning label */
.att-grid .day-header-row th {
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.35rem 0.2rem;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-200);
}
.att-grid .day-header-row th.day-label {
  background: #eef2ff;
  border-left: 3px solid var(--gray-400);
  color: var(--primary-dark);
}
.att-grid .day-header-row th.day-label-weekend {
  background: #fef2f2;
  border-left: 3px solid var(--gray-400);
  color: #b91c1c;
}
/* Zebra striping for day groups */
.att-grid .day-even { background-color: #f8fafc; }
.att-grid .day-odd { background-color: #ffffff; }
/* Sunday and Saturday highlight */
.att-grid .day-sunday { background: #fef2f2 !important; }
.att-grid .day-saturday { background: #fff7ed !important; }
/* Row hover */
.att-grid tbody tr:hover td { background: #eef2ff !important; }
.att-grid tbody tr:hover .emp-name { background: #eef2ff !important; }
/* Total columns */
.att-grid .total-cell { font-weight: 700; background: var(--gray-100) !important; text-align: center; border-left: 3px solid var(--gray-400); }

/* Filters bar */
.filters {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filters .form-group { margin-bottom: 0; min-width: 120px; }
.filters select, .filters input { padding: 0.4rem 0.6rem; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-purple { background: #f3e8ff; color: #6b21a8; }

/* Toast notifications */
.toast-container { position: fixed; top: 70px; right: 20px; z-index: 1000; }
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  color: white;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 350px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
}
.login-box {
  background: white;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 400px;
}
.login-box h1 { text-align: center; margin-bottom: 0.25rem; color: var(--gray-800); }
.login-box .subtitle { text-align: center; color: var(--gray-500); font-size: 0.9rem; margin-bottom: 1.5rem; }
.login-box .btn { width: 100%; justify-content: center; padding: 0.65rem; font-size: 1rem; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 0.5rem; }
.modal-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--gray-400); }
.modal-close:hover { color: var(--gray-700); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; top: 56px; left: 0; bottom: 0; z-index: 99; width: 250px; box-shadow: var(--shadow-md); }
  .content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .menu-toggle { display: block !important; }
  .form-row { flex-direction: column; }
  .att-grid input[type="number"] { width: 44px; }
  .report-filters { grid-template-columns: 1fr !important; }
}
@media (min-width: 769px) {
  .menu-toggle { display: none !important; }
}

/* Misc */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.w-full { width: 100%; }

.loading { text-align: center; padding: 3rem; color: var(--gray-400); }
.empty-state { text-align: center; padding: 3rem; color: var(--gray-400); }
.empty-state p { font-size: 1rem; }
