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

:root {
  --primary: #1a3a5c;
  --primary-light: #e8f0f8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warning: #92400e;
  --warning-bg: #fef9c3;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --text: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--gray-50);
  min-height: 100vh;
}

/* ── Auth ───────────────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, #1e4976 100%);
}

.auth-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}
.auth-logo-sub {
  font-size: 0.82rem;
  color: var(--gray-600);
  margin-top: 2px;
}

.auth-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--gray-800);
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-800);
  margin-bottom: 5px;
}
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.92rem;
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
textarea { resize: vertical; min-height: 60px; }
input:disabled, select:disabled { background: var(--gray-100); color: var(--gray-600); cursor: not-allowed; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #166534; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #991b1b; }
.btn-outline { background: white; color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-outline:hover:not(:disabled) { background: var(--gray-100); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-lg { padding: 11px 24px; font-size: 0.95rem; }

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

.topbar {
  background: var(--primary);
  color: white;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.topbar-brand { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.topbar-brand span { opacity: 0.6; font-weight: 400; margin-left: 6px; font-size: 0.82rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: 0.82rem; opacity: 0.8; }
.topbar-btn {
  background: rgba(255,255,255,0.12);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}
.topbar-btn:hover { background: rgba(255,255,255,0.2); }

.tabs {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 20px;
  display: flex;
  gap: 0;
  overflow-x: auto;
}
.tab {
  padding: 14px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--gray-600);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.page { padding: 24px 20px; max-width: 860px; margin: 0 auto; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.card-header h2 { font-size: 0.95rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Status badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-submitted { background: #dbeafe; color: #1e40af; }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }

/* ── Alert ──────────────────────────────────────────────────────────────────── */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
  line-height: 1.5;
}
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #86efac; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fca5a5; }
.alert strong { font-weight: 600; }

/* ── Timesheet grid ─────────────────────────────────────────────────────────── */
.ts-week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.ts-week-label { font-size: 1rem; font-weight: 600; color: var(--gray-800); }

.ts-grid { width: 100%; border-collapse: collapse; }
.ts-grid th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.ts-grid td { padding: 8px 10px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.ts-grid tr:last-child td { border-bottom: none; }
.ts-grid .day-col { font-weight: 600; font-size: 0.88rem; min-width: 50px; }
.ts-grid .date-col { font-size: 0.82rem; color: var(--gray-600); min-width: 80px; }
.ts-grid .hours-col { width: 100px; }
.ts-grid .notes-col { min-width: 160px; }
.ts-grid .hours-col input { text-align: right; }
.ts-grid .total-row td { background: var(--gray-50); font-weight: 600; border-top: 2px solid var(--gray-200); border-bottom: none; }
.ts-grid .today-row td { background: #eff6ff; }

.ts-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--gray-100); font-size: 0.88rem; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.data-table .actions { display: flex; gap: 6px; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 0.95rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-600); line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* ── History list ────────────────────────────────────────────────────────────── */
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 10px;
  flex-wrap: wrap;
}
.history-item:last-child { border-bottom: none; }
.history-item-info { flex: 1; min-width: 0; }
.history-item-week { font-size: 0.88rem; font-weight: 600; }
.history-item-sub { font-size: 0.78rem; color: var(--gray-600); margin-top: 2px; }
.history-item-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Section title ───────────────────────────────────────────────────────────── */
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-600);
  margin-bottom: 12px;
  margin-top: 24px;
}
.section-title:first-child { margin-top: 0; }

/* ── Pending timesheet card ──────────────────────────────────────────────────── */
.pending-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  background: white;
  box-shadow: var(--shadow);
}
.pending-card-header {
  padding: 14px 16px;
  background: var(--primary-light);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.pending-card-name { font-weight: 600; font-size: 0.92rem; }
.pending-card-week { font-size: 0.82rem; color: var(--gray-600); }
.pending-card-body { padding: 16px; }
.pending-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── Summary stat ───────────────────────────────────────────────────────────── */
.stat-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-box {
  flex: 1;
  min-width: 120px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-box-val { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-box-label { font-size: 0.75rem; color: var(--gray-600); margin-top: 2px; }

/* ── Inline review grid ─────────────────────────────────────────────────────── */
.review-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.review-day { text-align: center; }
.review-day-name { font-size: 0.72rem; font-weight: 600; color: var(--gray-600); text-transform: uppercase; }
.review-day-hours { font-size: 1.1rem; font-weight: 700; color: var(--primary); margin-top: 2px; }
.review-day-date { font-size: 0.7rem; color: var(--gray-400); margin-top: 1px; }
.review-total { font-size: 0.88rem; color: var(--gray-600); margin-bottom: 4px; }
.review-total strong { color: var(--text); }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 40px 20px; color: var(--gray-600); font-size: 0.88rem; }
.empty-icon { font-size: 2rem; margin-bottom: 10px; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--gray-800);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease;
  max-width: 300px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Admin form panel ───────────────────────────────────────────────────────── */
.add-panel {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.add-panel h3 { font-size: 0.88rem; font-weight: 600; margin-bottom: 14px; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .ts-grid .notes-col { display: none; }
  .review-grid { grid-template-columns: repeat(4, 1fr); }
  .page { padding: 16px 14px; }
  .card-body { padding: 14px; }
  .stat-box { min-width: 100px; }
}

.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.82rem; }
.text-muted { color: var(--gray-600); }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.wrap { flex-wrap: wrap; }
