:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --text: #1F1F1F;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --accent: #2563EB;
  --status-pending: #F59E0B;
  --status-approved: #10B981;
  --status-rejected: #EF4444;
  --header-h: 64px;
  --radius: 10px;
  --transition: 180ms ease;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

h1, h2, h3, h4, .section-title { font-family: 'Inter', system-ui, sans-serif; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1040;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}

.app-header__inner {
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 600;
  white-space: nowrap;
}

.app-header__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
}

.app-header__title { font-size: 18px; }

.app-header__controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.self-select { max-width: 180px; }

.mode-switch {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.mode-switch__btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.mode-switch__btn.is-active {
  background: var(--accent);
  color: #fff;
}

.btn-submit-request {
  background: var(--accent);
  border-color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform var(--transition), box-shadow var(--transition);
}
.btn-submit-request:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.25); }

/* ---------- Workspace grid ---------- */
.workspace {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "employees"
    "filters"
    "calendar"
    "feed";
  gap: 16px;
  align-items: start;
}

.filters-bar { grid-area: filters; }
.calendar-panel { grid-area: calendar; }
.employees-panel { grid-area: employees; }
.feed-panel { grid-area: feed; }
.sidebar { display: contents; }

@media (min-width: 768px) {
  .workspace {
    grid-template-columns: 65fr 35fr;
    grid-template-areas:
      "filters sidebar"
      "calendar sidebar";
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    grid-area: sidebar;
    position: sticky;
    top: calc(var(--header-h) + 16px);
    max-height: calc(100vh - var(--header-h) - 32px);
    overflow-y: auto;
  }
}

/* ---------- Filters ---------- */
.filters-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.filters-collapse {
  display: none;
  gap: 16px;
  flex-wrap: wrap;
}
.filters-collapse.show { display: flex; }

@media (min-width: 768px) {
  .filters-collapse { display: flex !important; }
  .filters-toggle { display: none; }
}

.filter-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.filter-field select { min-width: 160px; }

/* ---------- Panels ---------- */
.calendar-panel, .employees-panel, .feed-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
}

/* ---------- Calendar ---------- */
.calendar-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-title { font-size: 16px; font-weight: 600; margin: 0; text-transform: capitalize; }

.calendar-nav-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.calendar-nav-btn:hover { background: var(--bg); }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0 2px 6px;
}
.calendar-weekdays span { text-align: center; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  touch-action: pan-y;
}

.calendar-day {
  min-height: 78px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface);
}
.calendar-day.is-empty { border: none; background: transparent; }
.calendar-day.is-weekend { background: #FAFAFB; }

.calendar-day__num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.calendar-day__bars {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.vacation-bar {
  height: 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform var(--transition), filter var(--transition);
}
.vacation-bar:hover { transform: scaleY(1.15); filter: brightness(1.05); }
.vacation-bar.is-approved { opacity: 1; }
.vacation-bar.is-pending {
  opacity: .85;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 4px, transparent 4px 8px);
}

/* ---------- Employee cards ---------- */
.employee-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (max-width: 767.98px) {
  .employee-cards {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .employee-card { min-width: 220px; flex: 0 0 auto; }
}

.employee-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.employee-card.is-self { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }

.employee-card__top { display: flex; align-items: center; gap: 8px; }
.employee-card__dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.employee-card__name { font-weight: 600; font-size: 14px; flex: 1; }
.employee-card__role { font-size: 12px; font-weight: 500; color: var(--text-muted); }

.employee-card__bar-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.employee-card__bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 350ms ease;
}

.employee-card__stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}
.employee-card__stats strong { color: var(--text); font-weight: 500; }

/* ---------- Request feed ---------- */
.request-feed { display: flex; flex-direction: column; gap: 8px; }

.request-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity var(--transition), transform var(--transition);
}

.request-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.request-card__employee { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.request-card__dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.request-card__dates { font-size: 12px; color: var(--text-muted); }

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  transition: background var(--transition), color var(--transition);
}
.badge-status.pending { background: rgba(245,158,11,.15); color: #92650a; }
.badge-status.approved { background: rgba(16,185,129,.15); color: #067a55; }
.badge-status.rejected { background: rgba(239,68,68,.15); color: #b91c1c; }

.request-card__actions { display: flex; gap: 6px; }
.request-card__actions .btn {
  font-size: 12px;
  padding: 4px 10px;
  transition: transform var(--transition), opacity var(--transition);
}
.request-card__actions .btn:active { transform: scale(.95); }

.request-card.is-deciding { opacity: .55; pointer-events: none; }

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 24px 8px;
  color: var(--text-muted);
}
.empty-state i { font-size: 28px; color: var(--border); }
.empty-state strong { color: var(--text); font-size: 14px; }
.empty-state span { font-size: 12px; }

/* ---------- Modal / form ---------- */
.live-counter {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.live-counter.is-over {
  background: rgba(239,68,68,.08);
  border-color: var(--status-rejected);
  color: var(--status-rejected);
}
.live-counter.is-ok {
  background: rgba(16,185,129,.08);
  border-color: var(--status-approved);
  color: #067a55;
}

.invalid-hint {
  font-size: 12px;
  color: var(--status-rejected);
  margin-top: 6px;
  min-height: 16px;
}

#submitRequestBtn:disabled { pointer-events: none; opacity: .55; }
.submit-btn-wrap[data-disabled="true"] { cursor: not-allowed; }

@media (max-width: 767.98px) {
  #requestModal .modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100%;
  }
  #requestModal .modal-content {
    height: 100%;
    border-radius: 0;
  }
}

/* ---------- Toast ---------- */
.toast-ms {
  min-width: 280px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
}
.toast-ms.is-danger { border-left: 4px solid var(--status-rejected); }
.toast-ms.is-success { border-left: 4px solid var(--status-approved); }

/* ---------- Tooltip for calendar bars ---------- */
.vacation-tooltip {
  position: fixed;
  z-index: 1090;
  background: #1F1F1F;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms ease, transform 150ms ease;
  max-width: 220px;
}
.vacation-tooltip.is-visible { opacity: 1; transform: translateY(0); }
