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

:root {
  --bg:           #F0F2F8;
  --surface:      #FFFFFF;
  --border:       #E4E7EF;
  --text:         #0F172A;
  --text-sub:     #64748B;
  --text-muted:   #94A3B8;
  --accent:       #6366F1;
  --accent-light: #EEF2FF;
  --accent-dark:  #4338CA;
  --today-bg:     #FEFCE8;
  --today-border: #FBBF24;
  --weekend-bg:   #F8FAFC;
  --shadow-sm:    0 1px 4px rgba(0,0,0,.06);
  --shadow-md:    0 8px 24px rgba(0,0,0,.10);
  --shadow-lg:    0 20px 48px rgba(0,0,0,.14);
  --radius:       10px;
  --radius-lg:    16px;
  --emp-w:        220px;
  --day-w:        54px;
  --row-h:        58px;
  --left-pad:     16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ─────────────────────────────────────────────────── */
.header {
  height: 72px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
}
.header-left   { display: flex; align-items: center; gap: 14px; flex: 1;  }
.header-right  { display: flex; align-items: center; gap: 12px; flex: 1;  justify-content: flex-end; }
.header-center { display: flex; align-items: center; gap: 10px; }

.logo {
  font-size: 18px; font-weight: 800; color: var(--text);
  letter-spacing: -.3px; display: flex; align-items: center; gap: 10px;
  width: 210px;
  flex-shrink: 0;
}
.logo-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.dept {
  font-size: 13px; color: var(--text-muted); font-weight: 500;
  background: var(--bg); padding: 4px 12px; border-radius: 20px;
  border: 1px solid var(--border);
}

.nav-btn {
  width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 20px; color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.nav-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.period-label {
  min-width: 220px; text-align: center;
  font-size: 17px; font-weight: 700; color: var(--text);
}

.today-btn {
  padding: 7px 16px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-sub);
  transition: all .15s;
}
.today-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.view-switcher {
  display: flex; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 3px;
}
.view-btn {
  padding: 6px 16px; border: none; background: transparent;
  border-radius: 7px; cursor: pointer; font-size: 13px;
  font-weight: 600; color: var(--text-sub); transition: all .15s;
}
.view-btn.active {
  background: var(--surface); color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ── Skeleton shimmer for calendar cells ────────────────────── */
@keyframes shimmer {
  0%   { opacity: .45; }
  50%  { opacity: .15; }
  100% { opacity: .45; }
}
.skeleton-cell {
  width: 38px; height: 22px; border-radius: 5px;
  background: var(--border);
  animation: shimmer 1.4s ease-in-out infinite;
  margin: auto;
}

/* ── Page switcher (TeamOversigt / Project Calendar) ────────── */
.view-switcher:has(.page-btn) {
  margin-right: 4px;
}

.page-btn {
  padding: 6px 16px; border: none; background: transparent;
  border-radius: 7px; cursor: pointer; font-size: 13px;
  font-weight: 600; color: var(--text-sub); transition: all .15s;
}
.page-btn.active {
  background: var(--surface); color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.page-btn:hover:not(.active) {
  background: var(--accent-light); color: var(--accent);
}

.user-pill {
  display: none; align-items: center; gap: 6px;
  background: var(--accent-light); color: var(--accent);
  font-size: 13px; font-weight: 700;
  padding: 6px 14px; border-radius: 20px;
  max-width: 200px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid rgba(99,102,241,.2);
}

/* ── Main ───────────────────────────────────────────────────── */
.main { flex: 1; padding: 28px 32px; }

/* ── Loading / error ────────────────────────────────────────── */
.state-box {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 320px; gap: 14px; color: var(--text-sub);
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.err-icon { font-size: 42px; }
.err-msg  { font-size: 15px; font-weight: 500; color: #EF4444; }
.retry-btn {
  padding: 9px 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; border: none; border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(99,102,241,.35);
}

/* ── Calendar wrapper ───────────────────────────────────────── */
.cal-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.cal-scroll { overflow-x: auto; }

/* ── Table ──────────────────────────────────────────────────── */
.cal-table { border-collapse: collapse; min-width: max-content; width: 100%; }

.cal-head th {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-size: 12px; font-weight: 700; color: var(--text-sub);
  text-align: center; white-space: nowrap;
  position: sticky; top: 0; z-index: 10;
  text-transform: uppercase; letter-spacing: .04em;
}
.th-emp {
  width: var(--emp-w); min-width: var(--emp-w);
  text-align: left !important;
  padding: 12px 16px 12px calc(var(--left-pad) + 10px) !important;
  position: sticky !important; left: 0;
  background: var(--bg) !important;
  border-right: 2px solid var(--border);
  z-index: 20 !important;
}
.th-day { width: var(--day-w); min-width: var(--day-w); padding: 10px 2px; }
.th-day.is-today   { background: var(--today-bg); }
.th-day.is-weekend { background: var(--weekend-bg); }

.day-num  { display: block; font-size: 16px; font-weight: 800; color: var(--text); line-height: 1; }
.day-name { display: block; font-size: 10px; font-weight: 600; color: var(--text-muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .06em; }
.th-day.is-today .day-num,
.th-day.is-today .day-name { color: var(--accent); }

/* ── Rows ───────────────────────────────────────────────────── */
.cal-row td {
  border-bottom: 1px solid var(--border);
  height: var(--row-h); padding: 0;
}
.cal-row:last-child td { border-bottom: none; }
.cal-row:hover .td-emp              { background: #F8FAFF; }
.cal-row:hover .td-day:not(.absent) { background: #F8FAFF; }

.td-emp {
  padding: 0 16px 0 var(--left-pad);
  position: sticky; left: 0;
  background: var(--surface);
  border-right: 2px solid var(--border);
  z-index: 5; white-space: nowrap;
}
.emp-info { display: flex; align-items: center; gap: 12px; margin-left: 10px; }

.emp-name-block {
  display: flex; flex-direction: column;
  gap: 3px; min-width: 0;
}
.emp-today-badge {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  width: fit-content; letter-spacing: .02em; white-space: nowrap;
}

/* ── Avatar ── works for both <div> (initials) and <img> (photo) */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff;
  flex-shrink: 0; letter-spacing: .02em;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  object-fit: cover;
}
.avatar-sm {
  width: 24px; height: 24px;
  font-size: 9px;
}

.emp-name { font-size: 14px; font-weight: 600; color: var(--text); }

.td-day {
  text-align: center; vertical-align: middle;
  padding: 4px 3px; transition: background .1s;
}
.td-day.is-today   { background: var(--today-bg); }
.td-day.is-weekend { background: var(--weekend-bg); }

.abs-block {
  width: 100%; height: 34px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff;
  cursor: pointer; transition: opacity .15s, transform .15s;
  overflow: hidden; letter-spacing: .03em;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.abs-block:hover { opacity: .9; transform: scaleY(1.06); }

/* ── Legend ─────────────────────────────────────────────────── */
.legend {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 14px; padding: 14px 24px;
  border-top: 1px solid var(--border); background: var(--bg);
}
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--text-sub); }
.legend-dot  { width: 11px; height: 11px; border-radius: 3px; }
.absent-dot  { background: var(--accent); }
.weekend-dot { background: var(--weekend-bg); border: 1px solid var(--border); }
.today-dot   { background: var(--today-bg); border: 1px solid var(--today-border); }
.legend-right { margin-left: auto; font-size: 12px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   Vagter panel — always today, below the calendar
══════════════════════════════════════════════════════════════ */
.vagter-panel {
  margin-top: 20px;
}
.vagter-title {
  font-size: 12px; font-weight: 700; color: var(--text-sub);
  text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 12px;
}
.vagter-cards {
  display: flex; gap: 16px; flex-wrap: wrap;
}
.vagter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 200px;
}
.vagter-card-header {
  padding: 9px 16px;
  font-size: 12px; font-weight: 700; color: #fff;
  letter-spacing: .03em;
}
.vagter-card-body {
  padding: 12px 16px;
  display: flex; gap: 14px; flex-direction: column; align-items: flex-start;
  min-height: 64px;
}
.vagter-person {
  display: flex; align-items: center;
  align-items: center; gap: 12px;
}
.vagter-person-name {
  font-size: 11px; font-weight: 600;
  color: var(--text-sub); white-space: nowrap;
}
.vagter-empty {
  font-size: 12px; color: var(--text-muted); font-style: italic;
}

.vagter-person        { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.vagter-person-info   { display: flex; flex-direction: column; gap: 3px }
.vagter-person-name   { font-weight: 600; font-size: 0.85rem; }
.vagter-person-mobile { font-size: 0.75rem; color: #6B7280; margin-left: -3px; display: flex; align-items: center; gap: 5px }

/* ══════════════════════════════════════════════════════════════
   DAY VIEW & TODAY SUMMARY
══════════════════════════════════════════════════════════════ */
.day-view { border-top: 2px solid var(--border); }

.day-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--text-sub);
  text-transform: uppercase; letter-spacing: .07em;
  padding: 14px calc(var(--left-pad) + 10px) 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.day-section-title .count-badge {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-sub); font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}

.day-cards { display: flex; flex-direction: column; }

.day-card {
  display: flex; align-items: stretch;
  height: var(--row-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background .1s;
}
.day-card:last-child { border-bottom: none; }
.day-card:hover { background: #F8FAFF; }

.day-card-emp {
  width: var(--emp-w); min-width: var(--emp-w);
  flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px 0 calc(var(--left-pad) + 10px);
  border-right: 2px solid var(--border);
  box-shadow: none;
}
.day-card.absent .day-card-emp {
  box-shadow: inset 4px 0 0 currentColor;
  padding-left: calc(var(--left-pad) + 6px);
}

.day-card-body {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.day-card-info  { min-width: 0; }
.day-card-name  { font-size: 14px; font-weight: 600; color: var(--text); }
.day-card-event { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

.day-card-badge {
  font-size: 11px; font-weight: 700;
  padding: 4px 12px; border-radius: 20px; color: #fff;
  white-space: nowrap; letter-spacing: .03em;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

/* ── Tooltip ────────────────────────────────────────────────── */
.tooltip {
  position: fixed; background: #1E293B; color: #fff;
  padding: 11px 15px; border-radius: 10px; font-size: 13px; line-height: 1.6;
  pointer-events: none; opacity: 0; transition: opacity .12s;
  z-index: 1000; max-width: 260px; box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.08);
}
.tooltip.visible { opacity: 1; }
.tooltip strong  { display: block; font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.tooltip small   { color: #94A3B8; }

.cal-week-row .th-week {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #6B7280;
  padding: 4px 0 2px;
  border-bottom: 1px solid #E5E7EB;
  border-right: 2px solid #D1D5DB;
}