:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar-width: 240px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
}

/* ---- LAYOUT ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .logo-mark {
  width: 36px;
  height: 36px;
  background: #2563eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.sidebar-brand .logo-text h1 {
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-brand .logo-text p {
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 1px;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 12px 16px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: #334155;
  color: #fff;
}

.sidebar-nav a.active {
  background: #1e3a6e;
  color: #fff;
  border-left-color: var(--primary);
}

.sidebar-nav a .icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #334155;
}

.user-info { margin-bottom: 10px; }
.user-info .name { font-size: 0.875rem; font-weight: 600; color: #fff; }
.user-info .emp-id { font-size: 0.7rem; color: #64748b; }

.btn-logout {
  display: block;
  width: 100%;
  padding: 8px;
  background: #334155;
  color: #cbd5e1;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.btn-logout:hover { background: #ef4444; color: #fff; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h2 { font-size: 1.125rem; font-weight: 700; color: #0f172a; }
.topbar .sub { font-size: 0.8rem; color: #64748b; }

.page-body { padding: 24px 28px; }

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

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid #e2e8f0;
}

.stat-card .label { font-size: 0.75rem; color: #64748b; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: #0f172a; margin: 4px 0; line-height: 1; }
.stat-card .sub { font-size: 0.75rem; color: #94a3b8; }

.stat-card.blue  .value { color: var(--primary); }
.stat-card.green .value { color: #16a34a; }
.stat-card.amber .value { color: #d97706; }

/* ---- PANELS ---- */
.panel {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  margin-bottom: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.panel-header h3 { font-size: 0.95rem; font-weight: 600; }
.panel-body { padding: 20px; }

/* ---- FILTERS ---- */
.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-row input, .filter-row select {
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s;
}

.filter-row input:focus, .filter-row select:focus { border-color: var(--primary); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.text-muted { color: #94a3b8; font-size: 0.8rem; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger  { background: #ef4444; color: #fff; }
.btn-danger:hover  { background: #dc2626; }

.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ---- FORMS ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label { font-size: 0.8rem; font-weight: 600; color: #374151; }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-group .hint { font-size: 0.73rem; color: #94a3b8; }

.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
}

.login-card .logo { text-align: center; margin-bottom: 28px; }
.login-card .logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.login-card .logo p { font-size: 0.8rem; color: #94a3b8; margin-top: 4px; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-admin    { background: #dbeafe; color: #1d4ed8; }
.badge-employee { background: #f0fdf4; color: #16a34a; }
.badge-inactive { background: #f1f5f9; color: #94a3b8; }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.alert-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }

/* ---- PAGINATION ---- */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 16px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}

.pagination button:hover { background: #f1f5f9; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #94a3b8; line-height: 1; }
.modal-close:hover { color: #0f172a; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; display: flex; gap: 8px; justify-content: flex-end; }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 48px 20px; color: #94a3b8; }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.875rem; }

/* ---- UTILITIES ---- */
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }

/* ---- MOBILE RESPONSIVE ---- */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: #1e293b;
  z-index: 150;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}

.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.25s;
}

.mobile-topbar .brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.open { display: block; }

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    top: 0;
    z-index: 200;
  }

  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding-top: 56px;
  }

  .topbar { padding: 12px 16px; }
  .page-body { padding: 16px; }

  /* Stack grids to single column */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .stat-cards {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
  }

  .stat-card .value { font-size: 1.5rem; }

  /* Filter row stacks nicely */
  .filter-row { gap: 8px; }
  .filter-row input, .filter-row select { width: 100%; }

  /* Table scrolls horizontally */
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* Topbar buttons stack */
  .topbar > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
  }

  .modal { max-width: 100%; margin: 0 8px; }

  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
}
