:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0f172a;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --dark: #1e293b;
  --gray: #64748b;
  --light-gray: #f1f5f9;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --body-bg: #f8fafc;
  --radius: 10px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background-color: var(--body-bg);
  color: var(--dark);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header & Nav */
header.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.25rem;
}

.brand-icon-img {
  height: 38px;
  width: auto;
  display: block;
}

.brand h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--secondary);
}

.brand span {
  font-size: 0.8rem;
  color: var(--gray);
  display: block;
  font-weight: 400;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.live-clock {
  background: var(--light-gray);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Container */
.container {
  max-width: 1280px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-btn {
  padding: 0.6rem 1.1rem;
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--gray);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--light-gray);
  color: var(--dark);
}

.tab-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Cards & Grid */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  transition: transform 0.15s ease;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--secondary);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-title {
  font-size: 0.82rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--secondary);
}

.stat-desc {
  font-size: 0.8rem;
  color: var(--gray);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

thead {
  background-color: var(--light-gray);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--dark);
}

tbody tr:hover {
  background-color: #f8fafc;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-present {
  background: var(--success-bg);
  color: var(--success);
}

.badge-late {
  background: var(--warning-bg);
  color: #b45309;
}

.badge-half-day {
  background: #f3e8ff;
  color: #7e22ce;
}

.badge-leave {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-absent {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-overtime {
  background: #fef3c7;
  color: #92400e;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: white;
  border-color: var(--border);
  color: var(--dark);
}

.btn-outline:hover {
  background: var(--light-gray);
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.05rem;
}

/* Form inputs */
.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.35rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--dark);
  outline: none;
  background-color: white;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  background: white;
  border-radius: var(--radius);
  max-width: 580px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: var(--light-gray);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  background: var(--secondary);
  color: white;
  font-size: 0.88rem;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 260px;
}

.toast.toast-success {
  background: #065f46;
  border-left: 4px solid var(--success);
}

.toast.toast-error {
  background: #991b1b;
  border-left: 4px solid var(--danger);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Attendance penalty notes + rules explainer (My Attendance History) */
.penalty-note {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--danger);
  line-height: 1.3;
}

.penalty-note-tier {
  font-weight: 400;
  color: var(--gray);
}

.policy-box {
  margin-top: 1rem;
  background: var(--warning-bg);
  border-left: 4px solid var(--warning);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  font-size: 0.85rem;
  color: var(--dark);
}

.policy-box h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.policy-box p {
  margin: 0.4rem 0;
}

.policy-box ul {
  margin: 0.3rem 0 0.5rem;
  padding-left: 1.25rem;
}

.policy-box li {
  margin: 0.15rem 0;
}

/* Printable Payslip Styles */
@media print {
  body {
    background: white;
    color: black;
  }
  header.app-header, .no-print, .btn, .tab-nav, #toast-container {
    display: none !important;
  }
  .payslip-container {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
}
