:root {
  --primary: #7D07F8;
  --primary-light: #9574EB;
  --secondary: #00FE95;
  --accent-green: #04A800;
  --primary-dark: #5a05b8;
  --bg: #0D0D1A;
  --bg-card: #14142A;
  --bg-card2: #1A1A35;
  --border: #2A2A50;
  --text: #E8E8FF;
  --text-muted: #8888AA;
  --danger: #FF4757;
  --warning: #FFA502;
  --info: #1E90FF;
  --success: #04A800;
  --sidebar-width: 260px;
  --sidebar-collapsed: 68px;
  --topbar-height: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(125,7,248,0.15);
  --transition: 0.25s ease;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 3px; }

/* ── Layout ── */
body.authenticated { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-section { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 12px; }
.sidebar.collapsed .user-avatar { margin: 0 auto; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-text { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: 0.5px; }

.sidebar-toggle, .topbar-toggle {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.sidebar-toggle:hover, .topbar-toggle:hover { color: var(--primary); background: rgba(125,7,248,0.1); }

.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  color: white; flex-shrink: 0;
  text-transform: uppercase;
}

.user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; padding: 2px 8px; border-radius: 20px; margin-top: 2px; display: inline-block; }
.badge-admin { background: rgba(125,7,248,0.2); color: var(--primary-light); }
.badge-manager { background: rgba(0,254,149,0.15); color: var(--secondary); }
.badge-employee { background: rgba(149,116,235,0.15); color: var(--primary-light); }

.nav-menu { list-style: none; flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section {
  font-size: 10px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 1px; padding: 12px 12px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  font-size: 13px; font-weight: 500;
}
.nav-link:hover { color: var(--text); background: rgba(125,7,248,0.1); }
.nav-link.active { color: var(--primary-light); background: rgba(125,7,248,0.15); }
.nav-link i { width: 18px; text-align: center; font-size: 15px; }
.nav-link-danger:hover { color: var(--danger); background: rgba(255,71,87,0.1); }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}
.main-content.expanded { margin-left: var(--sidebar-collapsed); }

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

.page-title {
  font-size: 18px; font-weight: 600;
  color: var(--text); flex: 1;
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content-area { padding: 24px; flex: 1; }

/* ── Auth ── */
.auth-main {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 50%, rgba(125,7,248,0.08) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(0,254,149,0.05) 0%, transparent 50%);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo .logo-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
}
.auth-logo h1 { font-size: 28px; font-weight: 700; color: var(--text); }
.auth-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.purple { background: rgba(125,7,248,0.15); color: var(--primary-light); }
.stat-icon.green { background: rgba(4,168,0,0.15); color: var(--accent-green); }
.stat-icon.cyan { background: rgba(0,254,149,0.15); color: var(--secondary); }
.stat-icon.orange { background: rgba(255,165,2,0.15); color: var(--warning); }

.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 16px rgba(125,7,248,0.4); }
.btn-secondary { background: rgba(149,116,235,0.15); color: var(--primary-light); border: 1px solid rgba(149,116,235,0.3); }
.btn-secondary:hover { background: rgba(149,116,235,0.25); }
.btn-success { background: var(--accent-green); color: white; }
.btn-success:hover { background: #038a00; }
.btn-danger { background: rgba(255,71,87,0.1); color: var(--danger); border: 1px solid rgba(255,71,87,0.3); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-warning { background: rgba(255,165,2,0.15); color: var(--warning); border: 1px solid rgba(255,165,2,0.3); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(125,7,248,0.15); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: var(--bg-card2); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.color-picker-group { display: flex; align-items: center; gap: 10px; }
.color-preview {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
  transition: background var(--transition);
}
input[type="color"] {
  width: 60px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card2);
  cursor: pointer; padding: 2px;
}

/* Checkboxes */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 14px;
  cursor: pointer; transition: all var(--transition);
}
.checkbox-item:has(input:checked) { border-color: var(--primary); background: rgba(125,7,248,0.1); color: var(--primary-light); }
.checkbox-item input { accent-color: var(--primary); width: 16px; height: 16px; }

/* Locations multi-select */
.location-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.location-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card2);
  cursor: pointer; font-size: 12px; font-weight: 500;
  transition: all var(--transition);
}
.location-chip:has(input:checked) { border-color: transparent; color: white; }
.location-chip input { display: none; }
.location-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Alerts ── */
.alert {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  position: relative;
}
.alert-close { background: none; border: none; cursor: pointer; margin-left: auto; color: inherit; opacity: 0.6; }
.alert-close:hover { opacity: 1; }
.alert-success { background: rgba(4,168,0,0.15); border: 1px solid rgba(4,168,0,0.3); color: #4ade80; }
.alert-danger { background: rgba(255,71,87,0.15); border: 1px solid rgba(255,71,87,0.3); color: #ff7b86; }
.alert-warning { background: rgba(255,165,2,0.15); border: 1px solid rgba(255,165,2,0.3); color: #ffc107; }
.alert-info { background: rgba(30,144,255,0.15); border: 1px solid rgba(30,144,255,0.3); color: #60b4ff; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse;
}
table.data-table th {
  background: rgba(125,7,248,0.1);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text);
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: rgba(125,7,248,0.05); }

/* ── Employee dot / color badge ── */
.emp-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
}
.emp-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Hour badges ── */
.hour-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.hour-badge.normal { background: rgba(0,254,149,0.1); color: var(--secondary); }
.hour-badge.overtime { background: rgba(255,165,2,0.15); color: var(--warning); }
.hour-badge.absent { background: rgba(255,71,87,0.1); color: var(--danger); }
.hour-badge.late { background: rgba(255,165,2,0.1); color: var(--warning); }

/* ── Filter bar ── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

/* ── Calendar wrapper ── */
#calendar-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* FullCalendar overrides */
.fc { color: var(--text); }
.fc-toolbar-title { font-size: 18px !important; font-weight: 700 !important; color: var(--text) !important; }
.fc .fc-button {
  background: rgba(125,7,248,0.15) !important;
  border: 1px solid rgba(125,7,248,0.3) !important;
  color: var(--primary-light) !important;
  font-size: 12px !important;
  padding: 6px 14px !important;
  border-radius: var(--radius-sm) !important;
  font-weight: 500 !important;
}
.fc .fc-button:hover { background: var(--primary) !important; color: white !important; }
.fc .fc-button-active { background: var(--primary) !important; color: white !important; }
.fc-col-header-cell { background: rgba(125,7,248,0.08) !important; }
.fc-col-header-cell-cushion { color: var(--text-muted) !important; font-size: 12px !important; text-transform: uppercase; }
.fc-daygrid-day-number { color: var(--text-muted) !important; font-size: 12px !important; }
.fc-day-today { background: rgba(125,7,248,0.05) !important; }
.fc-event { cursor: pointer; border-radius: 6px !important; border: none !important; padding: 2px 6px !important; font-size: 11px !important; }
.fc-event-title { font-weight: 500 !important; }
.fc-timegrid-slot { height: 30px !important; }
.fc-scrollgrid { border-color: var(--border) !important; }
.fc-scrollgrid-section-header th,
.fc-scrollgrid-section-body td,
.fc-scrollgrid td, .fc-scrollgrid th { border-color: var(--border) !important; }
.fc-daygrid-more-link { color: var(--primary-light) !important; font-size: 11px !important; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed;
  inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }
.modal-close:hover { color: var(--danger); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-admin { background: rgba(125,7,248,0.2); color: var(--primary-light); }
.badge-manager { background: rgba(0,254,149,0.15); color: var(--secondary); }
.badge-employee { background: rgba(149,116,235,0.15); color: var(--primary-light); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 0; overflow: hidden; }
  .sidebar.mobile-open { width: var(--sidebar-width); }
  .main-content { margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar .form-group { min-width: 100%; }
}

/* ── View toggle ── */
.view-toggle { display: flex; gap: 4px; background: var(--bg-card2); border-radius: var(--radius-sm); padding: 4px; }
.view-toggle-btn { padding: 6px 14px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; cursor: pointer; background: none; border: none; color: var(--text-muted); transition: all var(--transition); }
.view-toggle-btn.active { background: var(--primary); color: white; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 16px; color: var(--border); }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Schedule grid (week view table) ── */
.schedule-grid { overflow-x: auto; }
.week-grid { min-width: 700px; }
.week-header-row { display: grid; grid-template-columns: 120px repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.week-day-header { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; padding: 8px 4px; background: rgba(125,7,248,0.08); border-radius: var(--radius-sm); }
.week-day-header.today { color: var(--secondary); background: rgba(0,254,149,0.08); }

.week-row { display: grid; grid-template-columns: 120px repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.week-emp-cell { display: flex; align-items: center; gap: 8px; padding: 8px; font-size: 12px; font-weight: 500; }
.week-shift-cell { min-height: 50px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; background: var(--bg-card2); position: relative; cursor: pointer; transition: border-color var(--transition); }
.week-shift-cell:hover { border-color: var(--primary); }
.week-shift-cell.has-shift { border-color: transparent; }

.shift-block { border-radius: 6px; padding: 4px 6px; font-size: 11px; font-weight: 500; color: white; margin-bottom: 2px; cursor: pointer; display: flex; flex-direction: column; }
.shift-block.absent { opacity: 0.6; text-decoration: line-through; }
.shift-block .shift-hours { font-size: 10px; opacity: 0.8; }
.shift-block .shift-tag { font-size: 10px; color: rgba(255,255,255,0.8); }

/* ── Tooltips ── */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--bg-card2); border: 1px solid var(--border);
  color: var(--text); font-size: 11px; padding: 4px 10px;
  border-radius: var(--radius-sm); white-space: nowrap; z-index: 200;
  pointer-events: none;
}

/* ── Report preview ── */
.report-table thead th { background: rgba(125,7,248,0.15); color: var(--primary-light); font-size: 11px; text-transform: uppercase; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.report-summary-row td { background: rgba(125,7,248,0.05); font-weight: 600; }

/* ── Loading ── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(125,7,248,0.3); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
