:root {
  --bg-app: #f4f6fb;
  --panel: #ffffff;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e6eaf1;
  --primary: #2563eb;
  --primary-2: #6366f1;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --text: #0f172a;
  --sidebar-bg: #0b1220;
  --sidebar-bg-2: #111a2e;
  --sidebar-w: 250px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --field-sm: 160px;
  --field-md: 240px;
  --field-lg: 320px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 14px; }

.icon { width: 20px; height: 20px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }

/* ===== App shell ===== */
.app-shell { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: #cbd5e1;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 22px 18px;
}
.sidebar-brand .logo { width: 38px; height: 38px; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-brand .brand-name { color: #fff; font-weight: 700; font-size: 16px; }
.sidebar-brand .brand-sub { color: var(--muted-2); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 20px; scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.35) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(148,163,184,.28); border-radius: 999px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.5); }
.sidebar-nav:not(:hover)::-webkit-scrollbar-thumb { background: transparent; }
.nav-section { margin: 16px 8px 6px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #5b6b86; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
  color: #aeb9cc; font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link .icon { color: #8593ab; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link:hover .icon { color: #cbd5e1; }
.nav-link.active { background: linear-gradient(90deg, rgba(99,102,241,.25), rgba(37,99,235,.12)); color: #fff; box-shadow: inset 3px 0 0 var(--primary-2); }
.nav-link.active .icon { color: #c7d2fe; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: 0 0 auto; }
.sidebar-user .u-meta { line-height: 1.2; overflow: hidden; }
.sidebar-user .u-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.sidebar-user .u-role { color: var(--muted-2); font-size: 11px; }
.logout-link { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 8px; padding: 9px 12px; border-radius: 10px; background: rgba(255,255,255,.05); color: #aeb9cc; border: none; cursor: pointer; font-size: 13px; font-family: inherit; }
.logout-link:hover { background: rgba(220,38,38,.18); color: #fecaca; }

/* ===== Main column ===== */
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar .page-title { font-weight: 700; font-size: 18px; }
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: 4px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.clock { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ws-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: #f1f5f9; color: var(--muted); border: 1px solid var(--border);
}
.ws-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.ws-connected { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.ws-connected .ws-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.ws-connecting .ws-dot { background: var(--warn); animation: pulse 1s infinite; }
.ws-disconnected { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.ws-disconnected .ws-dot { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.icon-btn { position: relative; background: #f1f5f9; border: 1px solid var(--border); color: var(--muted); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); background: #e9eef6; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid #fff; }

.content { padding: 24px; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.instant-search-input {
  width: min(280px, 100%);
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.instant-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* ===== Date picker ===== */
.dp-wrap { position: relative; display: inline-flex; align-items: stretch; width: auto; max-width: var(--field-sm); vertical-align: top; }
.stack .dp-wrap { display: flex; width: 100%; max-width: none; }
.grid-form .dp-wrap { max-width: var(--field-sm); }
.grid-form label.form-full .dp-wrap { max-width: var(--field-sm); }
.dp-wrap input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.grid-form .dp-wrap input { width: 118px; flex: 0 0 118px; }
.dp-trigger {
  display: grid;
  place-items: center;
  width: 42px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  color: var(--primary);
  cursor: pointer;
}
.dp-trigger:hover { background: #e8eef8; color: #1d4ed8; }
.dp-wrap.is-open .dp-trigger { background: #dbeafe; border-color: var(--primary); }
.dp-panel {
  position: absolute;
  z-index: 120;
  top: calc(100% + 6px);
  left: 0;
  width: min(300px, 92vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .14);
  padding: 12px;
  animation: dp-in .16s ease-out;
}
@keyframes dp-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dp-title { font-weight: 700; font-size: 14px; color: var(--text); }
.dp-nav {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.dp-nav:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.dp-weekdays, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-weekdays { margin-bottom: 4px; }
.dp-weekdays div {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 0;
}
.dp-weekdays .dp-weekend { color: #ef4444; }
.dp-day {
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.dp-day:hover:not(:disabled) { background: #eff6ff; color: var(--primary); }
.dp-day.is-today { box-shadow: inset 0 0 0 1px var(--primary); font-weight: 700; }
.dp-day.is-selected { background: var(--primary); color: #fff; font-weight: 700; }
.dp-day.is-selected:hover { background: #1d4ed8; }
.dp-day.is-empty { pointer-events: none; }
.dp-day:disabled { opacity: .35; cursor: not-allowed; }
.dp-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.dp-today-btn, .dp-clear-btn {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
}
.dp-today-btn { color: var(--primary); }
.dp-today-btn:hover { background: #eff6ff; }
.dp-clear-btn { color: var(--muted); }
.dp-clear-btn:hover { background: #f1f5f9; color: var(--text); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Cards / layout ===== */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow: hidden; }
.table-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.dash-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
a.dash-stat:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, .08);
}
.dash-stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}
.dash-stat-lbl {
  font-size: 12px;
  color: var(--muted);
  text-transform: capitalize;
}
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); text-align: center; }
.stat-card .stat-val { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-card .stat-label { margin-top: 6px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat-card.is-present .stat-val { color: var(--ok); }
.stat-card.is-absent .stat-val { color: var(--danger); }
.stat-card.is-leave .stat-val { color: var(--primary); }
.stat-card.is-hours .stat-val { color: var(--primary-2); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: #fff; padding: 9px 15px; border-radius: 10px; cursor: pointer; font-size: 14px; font-family: inherit; font-weight: 500; color: var(--text); transition: .15s; }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.inline { display: inline; }

/* Compact toolbar / filter forms */
form.inline {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  vertical-align: middle;
}
form.inline > label:not(.inline-label) {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
label.inline-label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.grid-form label.inline-label { flex-direction: row; align-items: center; }
form.inline input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
form.inline select,
form.inline textarea {
  width: auto;
  min-width: 0;
  max-width: 220px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
form.inline input[name="date"],
form.inline input[data-date-picker],
form.inline .field-date {
  width: 130px;
  max-width: 160px;
}
form.inline select {
  min-width: 140px;
  max-width: 260px;
}
form.inline input[type="checkbox"],
form.inline input[type="radio"] {
  width: auto;
  max-width: none;
  padding: 0;
  border: none;
  box-shadow: none;
}
form.inline .dp-wrap,
label.inline-label .dp-wrap,
.form-toolbar .dp-wrap {
  width: auto;
  max-width: 180px;
  flex: 0 0 auto;
}
form.inline .dp-wrap input,
label.inline-label .dp-wrap input,
.form-toolbar .dp-wrap input {
  width: 130px;
  flex: 0 0 130px;
}
form.inline .ss-wrap,
label.inline-label:not([style*="flex:1"]) .ss-wrap {
  width: auto;
  min-width: 140px;
  max-width: 260px;
}
.form-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}
.form-toolbar form.inline { margin: 0; }
.page-head form.inline { margin-left: auto; }

/* ===== Alerts ===== */
.alert { padding: 11px 15px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
.table tbody tr:hover { background: #f8fafc; }

/* Expandable day rows (punch requests) */
.day-expand-toggle { cursor: pointer; }
.day-expand-toggle.is-open { background: #f0f7ff; }
.day-expand-toggle .expand-chevron {
  display: inline-block;
  transition: transform .15s;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.day-expand-toggle.is-open .expand-chevron { transform: rotate(90deg); }
.day-expand-panel > td { padding: 0 !important; background: #f8fafc; }
.table-nested { margin: 0; }
.table-nested th { background: #f1f5f9; }
.day-group-list { display: none; }
.day-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  background: #fff;
}
.day-group-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
}
.day-group-summary::-webkit-details-marker { display: none; }
.day-group-date { font-weight: 700; min-width: 72px; }
.day-group-meta { flex: 1; color: var(--muted); font-size: 13px; }
.day-group-body { padding: 0 12px 12px; }
.mini-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 8px;
  font-size: 14px;
}
.d-only-table { display: table; }
.m-only-cards { display: none; }

/* ===== Forms ===== */
.stack label { display: block; margin-bottom: 14px; }
.stack label span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stack input, .stack select, .stack textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; }

.grid-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
}
.grid-form label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
  gap: 5px;
  align-items: flex-start;
  flex: 0 0 auto;
  min-width: 0;
}
.grid-form label.form-full,
.grid-form .form-actions {
  flex: 1 1 100%;
  width: 100%;
}
.grid-form input:not([type="checkbox"]):not([type="radio"]),
.grid-form select,
.grid-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  max-width: var(--field-md);
}
.grid-form input[type="text"],
.grid-form input[type="email"],
.grid-form input[type="tel"],
.grid-form input[type="password"],
.grid-form input[type="search"] {
  max-width: var(--field-lg);
}
.grid-form input[type="date"],
.grid-form input[type="time"],
.grid-form input[type="number"],
.grid-form input[data-date-picker],
.grid-form input[name="date"],
.grid-form input[name="start_date"],
.grid-form input[name="end_date"],
.grid-form input[name="due_date"],
.grid-form input[name="holiday_date"],
.grid-form input[name="follow_up_date"],
.grid-form input[name="joining_date"] {
  max-width: var(--field-sm);
}
.grid-form label.form-full input,
.grid-form label.form-full select,
.grid-form label.form-full textarea,
.grid-form label.form-full .ss-wrap {
  max-width: none;
}
.grid-form textarea {
  min-height: 80px;
  max-width: none;
  width: 100%;
}
.grid-form .form-full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.badge { font-size: 12px; background: #e2e8f0; color: #334155; padding: 3px 9px; border-radius: 999px; margin-left: 8px; font-weight: 600; }
.muted { color: var(--muted); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.pill-present { background: #dcfce7; color: #166534; }
.pill-absent { background: #fee2e2; color: #991b1b; }
.pill-leave { background: #dbeafe; color: #1e40af; }
.pill-half_day, .pill-half { background: #fef3c7; color: #92400e; }
.pill-holiday { background: #fce7f3; color: #9d174d; }
.pill-birthday { background: #fce7f3; color: #be185d; }
.pill-task { background: #fef3c7; color: #b45309; }
.pill-weekoff { background: #e2e8f0; color: #475569; }
.pill-pending { background: #fef3c7; color: #92400e; }
.pill-approved { background: #dcfce7; color: #166534; }
.pill-rejected { background: #fee2e2; color: #991b1b; }
.pill-completed { background: #dcfce7; color: #166534; }
.pill-in_progress { background: #dbeafe; color: #1e40af; }
.pill-draft { background: #e2e8f0; color: #334155; }
.pill-processed { background: #dbeafe; color: #1e40af; }
.pill-paid { background: #dcfce7; color: #166534; }

/* ===== Notifications ===== */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item.is-new { background: #f0f9ff; margin: 0 -20px; padding: 12px 20px; }
.notif-cat { font-size: 10px; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; height: fit-content; background: #e2e8f0; color: #334155; font-weight: 700; letter-spacing: .03em; }
.cat-punch { background: #dcfce7; color: #166534; }
.cat-timetable { background: #dbeafe; color: #1e40af; }
.cat-chat { background: #ede9fe; color: #5b21b6; }
.notif-body time { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ===== Calendar ===== */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.cal-title { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; }
.cal-nav { display: flex; gap: 6px; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-present { background: var(--ok); } .dot-absent { background: var(--danger); }
.dot-half { background: var(--warn); } .dot-leave { background: var(--primary); }
.dot-holiday { background: #ec4899; } .dot-birthday { background: #db2777; } .dot-task { background: #f59e0b; }

.calendar { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-weekdays { background: #f8fafc; border-bottom: 1px solid var(--border); }
.cal-weekdays div { padding: 10px; text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cal-weekdays .wd-sun, .cal-weekdays .wd-sat { color: #ef4444; }
.cal-cell { min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 8px 10px; position: relative; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.is-empty { background: #fafbfd; }
.cal-cell.is-weekend { background: #fff7f7; }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--primary); border-radius: 6px; background: #eff6ff; }
.cal-daynum { font-size: 13px; font-weight: 600; color: #334155; }
.cal-cell.is-weekend .cal-daynum { color: #ef4444; }
.cal-cell.is-today .cal-daynum { background: var(--primary); color: #fff; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-tags { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }

/* ===== Chat ===== */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 0; height: calc(100vh - 62px - 48px); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; }
.chat-list-item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.chat-list-item:hover, .chat-list-item.active { background: var(--primary-soft); }
.chat-list-item .u-name { font-size: 14px; font-weight: 600; }
.chat-list-item .u-sub { font-size: 12px; color: var(--muted); }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; align-items: center; gap: 10px; }
.voice-call-btn { margin-left: auto; flex-shrink: 0; }

.voice-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(11, 18, 32, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.voice-call-overlay[hidden] { display: none !important; }
.voice-call-card {
  width: min(360px, 100%);
  background: var(--card);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.voice-call-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.voice-call-avatar .icon { width: 32px; height: 32px; }
.voice-call-card h2 { margin: 0 0 6px; font-size: 1.25rem; }
.voice-call-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}
.voice-call-incoming #voice-call-hangup,
.voice-call-incoming #voice-call-mute { display: none; }
.voice-call-active #voice-call-accept { display: none; }
.voice-call-outgoing #voice-call-accept,
.voice-call-outgoing #voice-call-mute { display: none; }

.voice-call-hero { text-align: center; padding: 12px 0 20px; }
.voice-call-list { display: flex; flex-direction: column; gap: 10px; }
.voice-call-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.voice-call-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.voice-status-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 8px;
  border-radius: 999px;
}
.voice-status-pill.status-online { background: #dcfce7; color: #166534; }
.voice-status-pill.status-offline { background: #f1f5f9; color: #64748b; }
.voice-status-pill.status-on-call { background: #ffedd5; color: #c2410c; }

.ws-status.ws-oncall .ws-dot { background: #f97316; box-shadow: 0 0 0 3px rgba(249,115,22,.2); }
.ws-status.ws-oncall { color: #c2410c; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: #f8fafc; }
.msg { max-width: 68%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.4; }
.msg time { display: block; font-size: 10.5px; opacity: .7; margin-top: 3px; }
.msg.mine { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-compose { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.chat-compose input { flex: 1; padding: 11px 14px; border: 1px solid var(--border); border-radius: 999px; font-size: 14px; font-family: inherit; }
.read-receipt { display: block; font-size: 10px; opacity: .85; margin-top: 2px; font-style: italic; }
.msg.mine .read-receipt { color: rgba(255,255,255,.85); }

/* ===== Login + splash ===== */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { position: relative; background: linear-gradient(140deg, #0b1220, #1e3a8a 60%, #4338ca); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.auth-hero::before, .auth-hero::after { content: ""; position: absolute; border-radius: 50%; filter: blur(10px); opacity: .35; }
.auth-hero::before { width: 320px; height: 320px; background: #6366f1; top: -80px; right: -60px; }
.auth-hero::after { width: 260px; height: 260px; background: #38bdf8; bottom: -80px; left: -40px; opacity: .25; }
.auth-hero .hero-brand { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.auth-hero .hero-brand .logo { width: 46px; height: 46px; }
.auth-hero .hero-brand b { font-size: 20px; }
.auth-hero .hero-copy { position: relative; z-index: 1; }
.auth-hero .hero-copy h2 { font-size: 34px; line-height: 1.2; margin-bottom: 16px; border: none; }
.auth-hero .hero-copy p { color: #c7d2fe; font-size: 15px; max-width: 420px; margin: 0; }
.auth-hero .hero-features { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 1; }
.auth-hero .hero-features li { display: flex; align-items: center; gap: 10px; color: #e0e7ff; font-size: 14px; }
.auth-hero .hero-features .icon { color: #a5b4fc; }
.auth-foot { color: #94a3b8; font-size: 12px; position: relative; z-index: 1; }

.auth-form-wrap { display: grid; place-items: center; padding: 40px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .logo-mobile { display: none; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; }

/* Splash */
#splash { position: fixed; inset: 0; z-index: 9999; background: linear-gradient(140deg, #0b1220, #1e3a8a 60%, #4338ca); display: grid; place-items: center; transition: opacity .5s ease, visibility .5s; }
#splash.hide { opacity: 0; visibility: hidden; }
.splash-inner { text-align: center; color: #fff; }
.splash-inner .logo { width: 74px; height: 74px; animation: splashPop .6s ease; }
.splash-inner .splash-name { margin-top: 16px; font-size: 22px; font-weight: 700; letter-spacing: .02em; }
.splash-inner .splash-sub { color: #c7d2fe; font-size: 13px; margin-top: 4px; }
.splash-bar { width: 160px; height: 4px; border-radius: 999px; background: rgba(255,255,255,.2); margin: 22px auto 0; overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; background: #fff; border-radius: 999px; animation: splashLoad 1.1s ease-in-out infinite; }
@keyframes splashPop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes splashLoad { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

/* ===== Searchable select ===== */
.ss-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; }
.ss-wrap { position: relative; width: auto; max-width: var(--field-md); display: inline-block; vertical-align: top; }
.grid-form .ss-wrap { width: 100%; max-width: var(--field-md); }
.grid-form label.form-full .ss-wrap { max-width: none; width: 100%; }
.stack .ss-wrap { width: 100%; max-width: none; display: block; }
.ss-control {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; font-size: 14px; font-family: inherit; color: var(--text);
  cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s;
}
.ss-control:hover { border-color: #cbd5e1; }
.ss-wrap.open .ss-control { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.ss-wrap.ss-invalid .ss-control { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.12); }
.ss-value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-value.is-placeholder { color: var(--muted-2); }
.ss-caret { display: inline-flex; color: var(--muted); transition: transform .18s; }
.ss-wrap.open .ss-caret { transform: rotate(180deg); }

.ss-panel {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15,23,42,.16); overflow: hidden; display: none;
}
.ss-wrap.open .ss-panel { display: block; }
.ss-wrap.ss-up .ss-panel { top: auto; bottom: calc(100% + 6px); }
.ss-search { padding: 8px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.ss-search input { width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.ss-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.ss-options { max-height: 220px; overflow-y: auto; padding: 6px; scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
.ss-options::-webkit-scrollbar { width: 8px; }
.ss-options::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.ss-option { padding: 9px 11px; border-radius: 8px; font-size: 14px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-option:hover, .ss-option.active { background: var(--primary-soft); }
.ss-option.selected { color: var(--primary); font-weight: 600; background: #eff6ff; }
.ss-option.is-placeholder { color: var(--muted-2); }
.ss-option.is-disabled { color: var(--muted-2); cursor: not-allowed; opacity: .6; }
.ss-empty { padding: 14px 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* ===== Empty state ===== */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card .logo-mobile { display: flex; justify-content: center; margin-bottom: 20px; }
  .auth-card .logo-mobile .logo { width: 56px; height: 56px; }
  .chat-layout { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .grid-form input:not([type="checkbox"]):not([type="radio"]),
  .grid-form select,
  .grid-form .ss-wrap,
  .grid-form .dp-wrap {
    max-width: 100%;
  }
  .grid-form label.form-full input,
  .grid-form label.form-full select,
  .grid-form label.form-full .ss-wrap {
    max-width: 100%;
  }
  form.inline input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
  form.inline select {
    max-width: 100%;
  }
  .att-filters select { max-width: none; width: 100%; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .clock { display: none; }
  .att-filters { flex-direction: column; align-items: stretch; }

  /* Standard tables → stacked cards on mobile */
  .table:not(.att-grid):not(.table-nested) thead { display: none; }
  .table:not(.att-grid):not(.table-nested) tbody tr.day-expand-panel { display: none !important; }
  .table:not(.att-grid):not(.table-nested) tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
  }
  .table:not(.att-grid):not(.table-nested) tbody tr:hover { background: #fff; }
  .table:not(.att-grid):not(.table-nested) tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    text-align: right;
  }
  .table:not(.att-grid):not(.table-nested) tbody td:last-child { border-bottom: none; }
  .table:not(.att-grid):not(.table-nested) tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: left;
    flex: 1;
  }
  .table:not(.att-grid):not(.table-nested) tbody td.table-card-full {
    display: block;
    text-align: center;
  }
  .table:not(.att-grid):not(.table-nested) tbody td.table-card-full::before { display: none; }
  .table:not(.att-grid):not(.table-nested) tbody td.expand-chevron-cell::before { display: none; }
  .table:not(.att-grid):not(.table-nested) tbody td.expand-chevron-cell {
    justify-content: flex-end;
    padding-top: 0;
  }

  /* Punch day groups: use card list instead of expandable table on mobile */
  .d-only-table { display: none !important; }
  .m-only-cards { display: block; }
}

/* ===== HR Attendance grid ===== */
.att-page-head { flex-wrap: wrap; gap: 12px; }
.att-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.att-filters select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; max-width: 220px; width: auto; min-width: 140px; }
.att-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.att-tab { padding: 10px 18px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; text-decoration: none; }
.att-tab:hover { color: var(--text); }
.att-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.att-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.att-legend span { display: inline-flex; align-items: center; gap: 6px; }
.att-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.att-month-nav, .att-daily-nav { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.att-month-label { font-weight: 700; font-size: 16px; min-width: 140px; text-align: center; }
.att-monthly-wrap { padding: 0; overflow: hidden; }
.att-grid-scroll { overflow: auto; max-height: calc(100vh - 280px); }
.att-grid { border-collapse: separate; border-spacing: 0; font-size: 11px; min-width: max-content; }
.att-grid th, .att-grid td { border: 1px solid #e8ecf2; padding: 0; text-align: center; vertical-align: top; min-width: 52px; }
.att-grid thead th { background: #f8fafc; position: sticky; top: 0; z-index: 2; padding: 6px 4px; }
.att-sticky-col { position: sticky; left: 0; z-index: 3; background: #fff; min-width: 200px !important; text-align: left !important; padding: 8px 12px !important; border-right: 2px solid #dde3ec !important; }
.att-grid thead .att-sticky-col { z-index: 4; background: #f8fafc; }
.att-emp-cell { display: flex; flex-direction: column; gap: 2px; line-height: 1.3; }
.att-emp-cell strong { font-size: 12px; }
.att-emp-cell .muted { font-size: 10px; }
.att-wd { display: block; font-size: 9px; letter-spacing: .04em; color: var(--muted); }
.att-dn { display: block; font-size: 12px; font-weight: 700; }
.att-sun, .att-sun-col { background: #fff5f5 !important; }
.att-sun .att-wd, .att-sun .att-dn { color: #dc2626; }
.att-cell { height: 52px; padding: 4px 2px !important; }
.att-code { display: block; font-weight: 800; font-size: 12px; line-height: 1.2; }
.att-time { display: block; font-size: 8.5px; color: #334155; line-height: 1.2; white-space: nowrap; }
.att-present { background: #dcfce7 !important; }
.att-absent { background: #fee2e2 !important; }
.att-half { background: #fef9c3 !important; }
.att-short-leave { background: #ede9fe !important; }
.att-leave { background: #dbeafe !important; }
.att-holiday { background: #fae8ff !important; }
.att-weekoff { background: #f1f5f9 !important; }
.att-none { background: #fff !important; color: #94a3b8; }
.att-future { background: #fafbfd !important; }
.att-cell-badge { display: inline-block; font-weight: 800; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
