:root {
  --bg-dark: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-color: #e2e8f0;
  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.15);
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --success: #10b981;
  --warning: #d97706;
  --danger: #ef4444;
  --info: #2563eb;
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-primary), #6366f1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-text h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item a:hover {
  background: #f1f5f9;
  color: var(--accent-primary);
}

.nav-item.active a {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.user-profile {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info p {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.user-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-logout {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: #fee2e2;
}

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem;
  max-width: calc(100vw - var(--sidebar-width));
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.header-bar h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.header-bar p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Cards & Grid */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-val {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.25rem;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-icon.primary { background: #eef2ff; color: var(--accent-primary); }
.stat-icon.success { background: #ecfdf5; color: var(--success); }
.stat-icon.warning { background: #fffbeb; color: var(--warning); }
.stat-icon.info { background: #eff6ff; color: var(--info); }

/* Content Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed var(--accent-primary);
  background: #f5f3ff;
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dropzone:hover {
  background: #ede9fe;
}

.dropzone p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Controls & Buttons */
.btn {
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.form-control, .form-select {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ================= TABLES & STICKY FREEZE PANES ================= */
.table-responsive {
  width: 100%;
  max-height: 600px;
  overflow: auto;
  position: relative;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
  white-space: nowrap;
}

th, td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid #f1f5f9;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: middle;
}

/* Sticky Header */
thead tr:nth-child(1) th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--text-main);
  font-weight: 700;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

thead tr:nth-child(2) th {
  position: sticky;
  top: 36px;
  background: #f8fafc;
  color: var(--text-secondary);
  font-weight: 600;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* Merged Sticky Left Columns (No, Pegawai Info) */
.col-no {
  position: sticky;
  left: 0px;
  min-width: 45px;
  max-width: 45px;
  width: 45px;
  text-align: center;
}

.col-pegawai {
  position: sticky;
  left: 45px;
  min-width: 250px;
  max-width: 250px;
  width: 250px;
  border-right: 2.5px solid #cbd5e1 !important;
}

/* Stacked Employee Info Cell Styling */
.emp-cell-name {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.85rem;
  line-height: 1.25;
}

.emp-cell-nip {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.2;
  margin-top: 2px;
}

.emp-cell-pos {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.2;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  margin-top: 1px;
}

/* Z-Index hierarchy for Sticky Elements */
td.sticky-col {
  z-index: 5;
  background: #ffffff;
}

tbody tr:hover td.sticky-col {
  background: var(--bg-card-hover);
}

th.sticky-col {
  z-index: 25 !important;
  background: #f1f5f9 !important;
}

/* Date Separation Styling */
.date-header-group {
  border-right: 2.5px solid #cbd5e1 !important;
  border-left: 1px solid #e2e8f0;
  background: #f1f5f9 !important;
  font-weight: 700 !important;
  color: #334155 !important;
}

.date-sep-right {
  border-right: 2.5px solid #cbd5e1 !important;
}

.date-bg-even {
  background-color: #f8fafc;
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

/* Status Badges */
.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-hadir { background: #d1fae5; color: #047857; }
.badge-cuti { background: #dbeafe; color: #1d4ed8; }
.badge-sakit { background: #fef3c7; color: #b45309; }
.badge-tk { background: #fee2e2; color: #b91c1c; }
.badge-libur { background: #f1f5f9; color: #64748b; }

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 650px;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.conflict-list {
  max-height: 250px;
  overflow-y: auto;
  margin: 1rem 0;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem;
}

.conflict-item {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-main);
}

.conflict-item:last-child {
  border-bottom: none;
}
