/* ============================================================
   HRMS2 — Light Professional Theme
   Font: Inter + JetBrains Mono
   ============================================================ */

:root {
  --bg:         #f5f6fa;
  --surface:    #ffffff;
  --surface2:   #f0f2f8;
  --border:     #e2e6f0;
  --border2:    #c8d0e8;
  --primary:    #2563eb;
  --primary-lt: #eff4ff;
  --primary-dk: #1d4ed8;
  --accent:     #059669;
  --warn:       #dc2626;
  --orange:     #d97706;
  --purple:     #7c3aed;
  --teal:       #0d9488;
  --text:       #111827;
  --text2:      #374151;
  --muted:      #6b7280;
  --radius:     8px;
  --sidebar-w:  234px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px;
  flex-shrink: 0;
  letter-spacing: -.5px;
}
.brand-name { font-size: 15px; font-weight: 700; color: var(--text); }
.brand-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }

.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  padding: 12px 18px 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-left: 3px solid transparent;
  transition: all .12s;
  text-decoration: none;
}
.nav-link svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-link:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-lt); color: var(--primary); border-left-color: var(--primary); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-avatar {
  width: 30px; height: 30px;
  background: var(--primary-lt);
  color: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--muted); text-transform: capitalize; }
.logout-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--muted);
  transition: all .12s;
  flex-shrink: 0;
}
.logout-btn:hover { background: #fee2e2; color: var(--warn); text-decoration: none; }

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

/* ── Page header ── */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 16px; font-weight: 700; color: var(--text); }
.page-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Content area ── */
.content { padding: 20px 24px; flex: 1; }

/* ── Flash messages ── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 500;
}
.flash button { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; opacity: .6; }
.flash-success { background: #d1fae5; color: #065f46; border-bottom: 1px solid #a7f3d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border-bottom: 1px solid #fecaca; }
.flash-info    { background: #dbeafe; color: #1e40af; border-bottom: 1px solid #bfdbfe; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text); }
.card-body  { padding: 18px; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--text); }
.stat-value.blue   { color: var(--primary); }
.stat-value.green  { color: var(--accent); }
.stat-value.orange { color: var(--orange); }
.stat-value.red    { color: var(--warn); }
.stat-value.purple { color: var(--purple); }
.stat-value.teal   { color: var(--teal); }

/* ── Grid layouts ── */
.grid-2    { display: grid; grid-template-columns: 1fr 360px; gap: 14px; }
.grid-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3    { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.gap-16    { display: flex; flex-direction: column; gap: 14px; }
.row       { display: flex; gap: 10px; }
.col       { flex: 1; min-width: 0; }

/* ── Forms ── */
.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 5px;
}
.field-label .req { color: var(--warn); }
input[type=text], input[type=number], input[type=date],
input[type=month], input[type=time], input[type=password],
input[type=email], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
input[readonly] { background: var(--surface2); color: var(--muted); }
.check-row { display: flex; gap: 18px; flex-wrap: wrap; }
.check-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; cursor: pointer; }
.check-label input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .12s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); text-decoration: none; color: #fff; }
.btn-ghost { background: var(--surface2); color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--border); text-decoration: none; }
.btn-danger { background: #fee2e2; color: var(--warn); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; text-decoration: none; }
.btn-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.btn-success:hover { background: #a7f3d0; text-decoration: none; }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-xs  { padding: 3px 8px;  font-size: 11px; }
.btn-teal { background: #ccfbf1; color: var(--teal); border: 1px solid #99f6e4; }
.btn-teal:hover { background: #99f6e4; text-decoration: none; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--surface2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }
.empty-state { text-align: center; color: var(--muted); padding: 40px; font-style: italic; }
.mono { font-family: 'JetBrains Mono', monospace; }
.text-muted   { color: var(--muted); }
.text-primary { color: var(--primary); }
.mt-4 { margin-top: 4px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-blue    { background: #dbeafe; color: #1e40af; }
.badge-orange  { background: #fef3c7; color: #92400e; }
.badge-gray    { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.badge-teal    { background: #ccfbf1; color: #134e4a; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }

/* ── Period bar ── */
.period-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 500;
}
.period-bar select { width: auto; padding: 5px 8px; }

/* ── Attendance grid ── */
.att-cell {
  min-width: 52px;
  height: 54px;
  text-align: center;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: background .1s;
  position: relative;
  padding: 3px 2px 2px;
  user-select: none;
}
.att-cell:hover { filter: brightness(0.93); }

/* time sub-display in cell — stacked IN / OUT */
.att-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-top: 2px;
}
.att-time-in,
.att-time-out {
  display: block;
  font-size: 8.5px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.25;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.att-P   { background: #d1fae5; color: #065f46; }
.att-H   { background: #fef3c7; color: #92400e; }
.att-DD  { background: #dbeafe; color: #1e40af; }
.att-A   { background: #fee2e2; color: #991b1b; }
.att-L   { background: #ede9fe; color: #5b21b6; }
.att-PL  { background: #d1fae5; color: #065f46; }
.att-HOL { background: #e0e7ff; color: #3730a3; }

.note-dot {
  position: absolute; top: 3px; right: 3px;
  width: 5px; height: 5px;
  background: var(--orange);
  border-radius: 50%;
}

.sticky-left {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
  border-right: 2px solid var(--border2);
}
.day-hdr {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  padding: 4px 2px;
  min-width: 32px;
}
.day-hdr.holiday { background: #e0e7ff; color: #3730a3; }
.day-hdr.weekend { background: #f5f5f5; color: var(--muted); }
.dept-hdr-row td {
  font-weight: 700;
  font-size: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.subgroup-row td {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 12px;
  background: #fafbff;
  border-bottom: 1px solid var(--border);
}

/* ── Legend ── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 11px;
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot  { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 10px;
  padding: 24px;
  min-width: 340px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Login ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 36px; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-logo-icon { width: 44px; height: 44px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 14px; }
.login-logo-text { font-size: 20px; font-weight: 800; }
.login-logo-sub  { font-size: 12px; color: var(--muted); }
.login-title { font-size: 18px; font-weight: 700; }
.login-sub   { font-size: 13px; color: var(--muted); margin-bottom: 20px; margin-top: 2px; }
.login-error { background: #fee2e2; color: #991b1b; border-radius: 6px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }

/* ── Punch Page ── */
.punch-board {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.punch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.punch-card:hover { border-color: var(--border2); }
.punch-card.punched { border-left: 3px solid var(--accent); }
.punch-card.punched-half { border-left: 3px solid var(--orange); }
.punch-card.punched-absent { border-left: 3px solid var(--warn); }
.punch-emp-name { font-size: 13px; font-weight: 600; }
.punch-emp-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.punch-times {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.punch-times label { font-size: 11px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 3px; }
.punch-times input[type=time] { width: 120px; font-size: 13px; }
.punch-break input[type=number] { width: 70px; }
.punch-result {
  min-width: 90px;
  text-align: center;
}
.punch-code-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
}
.punch-hours { font-size: 11px; color: var(--muted); margin-top: 3px; }
.punch-flags { font-size: 10px; margin-top: 2px; }
.flag-late  { color: var(--orange); font-weight: 600; }
.flag-early { color: var(--purple); font-weight: 600; }

/* ── Analysis page ── */
.analysis-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface2);
  overflow: hidden;
  margin-top: 3px;
}
.analysis-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s;
}
.habit-good   { color: var(--accent); }
.habit-warn   { color: var(--orange); }
.habit-bad    { color: var(--warn); }

/* filter bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .field { margin-bottom: 0; }
.filter-bar select, .filter-bar input { width: auto; }

/* ── Misc ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
code { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: var(--surface2); padding: 2px 5px; border-radius: 4px; }
.req { color: var(--warn); }
