@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000&display=swap');

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4d;
  --text: #e6edf3;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.container { max-width: 1400px; margin: 0 auto; padding: 1rem 1.5rem; }

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
nav .container { display: flex; align-items: center; gap: 1.5rem; padding: 0; }
nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}
nav a:hover, nav a.active { color: var(--accent); }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.75rem; color: var(--text-muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

form label { display: block; margin-bottom: 0.25rem; color: var(--text-muted); font-size: 0.875rem; }
form input, form select, form textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}
form input[type="time"] { max-width: 10rem; }
form textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  font-size: 0.9375rem;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8125rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: 0.8125rem; text-transform: uppercase; }
tr:hover td { background: var(--surface-hover); }
.report-table { table-layout: fixed; }
.report-table th, .report-table td { padding: 0.45rem 0.5rem; font-size: 0.875rem; }
.report-table th { font-size: 0.75rem; }
.report-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-highlight { background: rgba(234, 179, 8, 0.14); }
tr:hover td.col-highlight { background: rgba(234, 179, 8, 0.18); }
.col-totaldays { background: rgba(148, 163, 184, 0.14); }
tr:hover td.col-totaldays { background: rgba(148, 163, 184, 0.18); }
.col-offdays { background: rgba(168, 85, 247, 0.12); }
tr:hover td.col-offdays { background: rgba(168, 85, 247, 0.16); }
.col-present { background: rgba(34, 197, 94, 0.14); }
tr:hover td.col-present { background: rgba(34, 197, 94, 0.18); }
.col-pay { background: rgba(59, 130, 246, 0.14); }
tr:hover td.col-pay { background: rgba(59, 130, 246, 0.18); }
.report-table td.col-present,
.report-table th.col-present {
  position: relative;
  font-weight: 800;
  transform: translateZ(0);
  z-index: 2;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  box-shadow:
    -10px 0 0 var(--surface),
    10px 0 0 var(--surface),
    0 10px 22px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(34, 197, 94, 0.35);
}
.report-table td.col-present::after,
.report-table th.col-present::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 rgba(34, 197, 94, 0.0);
  animation: presentGlow 1.8s ease-in-out infinite;
}
@keyframes presentGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(34, 197, 94, 0.0); }
  50% { box-shadow: 0 0 18px rgba(34, 197, 94, 0.28); }
}
.report-table td.col-pay,
.report-table th.col-pay {
  position: relative;
  font-weight: 800;
  transform: translateZ(0);
  z-index: 2;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  box-shadow:
    -10px 0 0 var(--surface),
    10px 0 0 var(--surface),
    0 10px 22px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}
.report-table td.col-pay::after,
.report-table th.col-pay::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 rgba(59, 130, 246, 0.0);
  animation: payGlow 1.8s ease-in-out infinite;
}
@keyframes payGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(59, 130, 246, 0.0); }
  50% { box-shadow: 0 0 18px rgba(59, 130, 246, 0.26); }
}
@media (prefers-reduced-motion: reduce) {
  .report-table td.col-present::after,
  .report-table th.col-present::after { animation: none; }
  .report-table td.col-pay::after,
  .report-table th.col-pay::after { animation: none; }
}
.col-leave { background: rgba(239, 68, 68, 0.12); }
tr:hover td.col-leave { background: rgba(239, 68, 68, 0.16); }
.col-credit { background: rgba(59, 130, 246, 0.12); }
tr:hover td.col-credit { background: rgba(59, 130, 246, 0.16); }
.col-half { background: rgba(234, 179, 8, 0.10); }
tr:hover td.col-half { background: rgba(234, 179, 8, 0.14); }
.col-late { background: rgba(239, 68, 68, 0.08); }
tr:hover td.col-late { background: rgba(239, 68, 68, 0.12); }
.col-sundayleave { background: rgba(20, 184, 166, 0.10); }
tr:hover td.col-sundayleave { background: rgba(20, 184, 166, 0.14); }
.report-name-link { color: #fff; text-decoration: none; font-weight: 500; }
.report-name-link:hover { color: var(--accent); text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-present { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-half { background: rgba(234, 179, 8, 0.2); color: var(--warning); }
.badge-absent { background: rgba(139, 156, 179, 0.2); color: var(--text-muted); }
.badge-leave { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge-late { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.alert-error { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.flex { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.text-muted { color: var(--text-muted); }
.mb-1 { margin-bottom: 1rem; }
.mt-1 { margin-top: 1rem; }

/* Month calendar */
.calendar-legend { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.calendar-legend .calendar-day-none { margin-left: 0.25rem; }
.calendar-grid { width: 100%; }
.calendar-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 2px; }
.calendar-row.calendar-header .calendar-cell {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted);
  padding: 0.4rem; text-align: center;
}
.calendar-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
}
.calendar-day { position: relative; }
.calendar-day .day-num { pointer-events: none; }
.calendar-day .late-tag {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.22);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.55);
  letter-spacing: 0.02em;
  pointer-events: none;
}
.calendar-day .leave-tag {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.22);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.55);
  letter-spacing: 0.02em;
  pointer-events: none;
}
.calendar-day-empty { background: transparent; }
.calendar-day {
  border: 1px solid var(--border);
}
.calendar-day-present { background: rgba(34, 197, 94, 0.25); color: var(--success); border-color: var(--success); }
.calendar-day-half { background: rgba(234, 179, 8, 0.25); color: var(--warning); border-color: var(--warning); }
.calendar-day-absent { background: rgba(239, 68, 68, 0.15); color: var(--danger); border-color: var(--danger); }
.calendar-day-leave { background: rgba(239, 68, 68, 0.18); color: var(--danger); border-color: rgba(239, 68, 68, 0.65); }
.calendar-day-none { background: var(--surface-hover); color: var(--text-muted); }
.calendar-day-holiday { background: rgba(139, 156, 179, 0.15); color: var(--text-muted); border-style: dashed; }
.calendar-day-sunday { background: rgba(107, 114, 128, 0.2); color: var(--text-muted); border-style: dashed; }
.calendar-day-clickable { cursor: pointer; }
.calendar-day-clickable:hover { filter: brightness(1.1); }
.calendar-day-selected { outline: 2px solid var(--accent); outline-offset: 2px; }

.day-details-table { width: auto; min-width: 200px; }
.day-details-table th { width: 6rem; color: var(--text-muted); font-weight: 500; }
.day-details-table td { border-bottom: none; }

/* Day details popup */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-backdrop.modal-visible {
  opacity: 1;
  visibility: visible;
}
.modal-popup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.modal-popup .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-popup .modal-header h2 {
  margin: 0;
  font-size: 1.125rem;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 4px;
}
.modal-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.modal-popup .modal-body {
  padding: 1.25rem;
}
.modal-popup .modal-body .mb-1 { margin-bottom: 1rem; }

@media (max-width: 640px) {
  table { font-size: 0.875rem; }
  th, td { padding: 0.5rem; }
  .calendar-cell { font-size: 0.8rem; }
}
