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

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e6ee;
  --text: #1a202c;
  --muted: #6b7280;
  --accent: #3b7dd8;
  --accent-dark: #2c65b8;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── PAGES ── */
.page { display: none; }
.page.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ── HEADER ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.3px;
}

.badge {
  font-size: .7rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  vertical-align: middle;
  margin-left: 6px;
}

/* ── MAIN (public page) ── */
#page-public main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── ADMIN LAYOUT ── */
.admin-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

/* ── SIDEBAR ── */
.admin-sidebar {
  width: 220px;
  min-width: 200px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-nav {
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 60px; /* below the sticky header */
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.sidebar-nav-item:hover {
  background: var(--bg);
}
.sidebar-nav-item.active {
  background: #eff6ff;
  color: var(--accent);
  font-weight: 600;
}

.sidebar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .7;
}
.sidebar-nav-item.active .sidebar-icon { opacity: 1; }

/* ── ADMIN PANELS (shown in main area) ── */
.admin-panel {
  display: none;
}
.admin-panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* ── ADMIN MAIN (vacations) ── */
.admin-main {
  flex: 1;
  padding: 32px 32px;
  overflow-y: auto;
  min-width: 0;
}

/* ── TEAM SECTION ── */
.team-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 1.1rem; }

.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 32px;
}

.team-role-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.team-role-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  width: 100%;
  padding-right: 4px;
  margin-bottom: 4px;
}

.team-empty {
  font-size: .85rem;
  color: var(--muted);
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: .85rem;
}

.member-name { font-weight: 500; }

.member-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1;
  padding: 2px 2px;
  border-radius: 50%;
  transition: color .15s, background .15s;
}
.member-remove:hover { color: var(--danger); background: #fee2e2; }

.btn-sm {
  padding: 6px 12px;
  font-size: .82rem;
}

/* ── TOOLBAR ── */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.admin-toolbar h2 { font-size: 1.25rem; }

/* ── CARD GRID ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* ── VACATION CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-person {
  font-size: 1.05rem;
  font-weight: 700;
}

.card-status {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.status-upcoming  { background: #eff6ff; color: #1d4ed8; }
.status-ongoing   { background: #f0fdf4; color: #15803d; }
.status-past      { background: #f3f4f6; color: #6b7280; }

.card-destination {
  font-size: .95rem;
  color: var(--accent);
  font-weight: 600;
}

.card-role {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: -4px;
}

.card-location {
  font-size: .78rem;
  color: var(--muted);
}

.ph-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding: 8px 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
}

.ph-list-label {
  font-size: .75rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 2px;
}

.ph-item {
  font-size: .8rem;
  color: #78350f;
}

/* ── LOCATIONS LIST ── */
.locations-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.loc-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.loc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.loc-name {
  font-weight: 700;
  font-size: .9rem;
}

.loc-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.loc-done {
  border-color: #16a34a !important;
  color: #16a34a !important;
}
.loc-done:hover {
  background: #f0fdf4 !important;
}

.loc-holidays {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
}

.holiday-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px 3px 10px;
  font-size: .82rem;
}

.holiday-date {
  color: var(--accent);
  font-weight: 600;
}

.holiday-label {
  color: var(--text);
}

.member-loc {
  font-weight: 400;
  color: var(--muted);
  font-size: .82em;
}

.card-dates {
  font-size: .85rem;
  color: var(--muted);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

/* ── TYPE TAG ── */
.type-tag {
  font-size: .75rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 7px;
}
.type-vacation { background: #eff6ff; color: #1e40af; }
.type-sick     { background: #fef2f2; color: #b91c1c; }
.type-dayoff   { background: #f0fdf4; color: #15803d; }

/* ── FIELD HINT ── */
.field-hint {
  font-size: .78rem;
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 0;
}

.quarter-tag {
  font-size: .75rem;
  font-weight: 600;
  background: #f3f0ff;
  color: #6d28d9;
  border-radius: 4px;
  padding: 2px 7px;
}

.days-tag {
  font-size: .75rem;
  font-weight: 600;
  background: #f0fdf4;
  color: #15803d;
  border-radius: 4px;
  padding: 2px 7px;
}

/* ── QUOTA TAG ── */
.quota-tag {
  font-size: .75rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
}
.quota-ok   { background: #eff6ff; color: #1d4ed8; }
.quota-low  { background: #fff7ed; color: #c2410c; }
.quota-full { background: #fef2f2; color: #b91c1c; }

/* ── DAY-OF-WEEK STRIP ── */
.dow-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.dow {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 42px;
  text-align: center;
  border-radius: 6px;
  padding: 5px 4px 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
}

.dow-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.dow-day {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .3px;
  line-height: 1.2;
}

.dow-date {
  font-size: .68rem;
  font-weight: 500;
  opacity: .85;
  line-height: 1.3;
  white-space: nowrap;
}

.card-notes {
  font-size: .85rem;
  color: var(--text);
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  white-space: pre-wrap;
}

.card-exception {
  font-size: .8rem;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 5px 10px;
  margin-top: 4px;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ── BUTTONS ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover { background: var(--danger-dark); }

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: .9rem;
  cursor: pointer;
  text-decoration: none;
  padding: 4px 0;
}
.btn-text:hover { text-decoration: underline; }
.btn-text.center { display: block; text-align: center; margin-top: 16px; }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: .82rem;
  cursor: pointer;
  color: var(--muted);
  transition: all .15s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ── LOGIN BOX ── */
#page-login {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
#page-login.active { display: flex; }

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-box h2 {
  font-size: 1.4rem;
  margin-bottom: 24px;
  text-align: center;
}

/* ── FORMS ── */
form label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 4px;
  margin-top: 16px;
  color: var(--text);
}
form label:first-of-type { margin-top: 0; }

form input,
form textarea,
form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: .9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  appearance: auto;
  -webkit-appearance: auto;
}

form input:focus,
form textarea:focus,
form select:focus {
  outline: none;
  border-color: var(--accent);
}

form textarea { resize: vertical; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.muted { color: var(--muted); font-weight: 400; }

/* ── ERROR ── */
.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: .85rem;
  margin-top: 12px;
}

.form-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: .85rem;
  margin-top: 12px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
  font-size: .95rem;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 8px 32px rgba(0,0,0,.16);
}

.modal-sm { max-width: 360px; }

.modal h3 {
  font-size: 1.15rem;
  margin-bottom: 20px;
}

.modal p {
  color: var(--muted);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ── UTILITIES ── */
.hidden { display: none !important; }

@media (max-width: 700px) {
  #page-public main { padding: 20px 16px; }
  .row-2 { grid-template-columns: 1fr; }
  header { padding: 0 16px; }
  .modal { padding: 24px 20px; }
  .login-box { padding: 28px 20px; }
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav { position: static; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; }
  .admin-main { padding: 20px 16px; }
}

/* ── VIEW TABS ── */
.view-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.view-tab {
  background: none;
  border: none;
  padding: 8px 20px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  transition: color .15s, border-color .15s;
}
.view-tab:hover { color: var(--text); }
.view-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── QUARTER VIEW ── */
.qv-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.qv-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qv-label {
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 100px;
  text-align: center;
}

.qv-legend {
  display: flex;
  gap: 12px;
  align-items: center;
}

.qv-leg {
  font-size: .78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
}
.qv-leg-vacation { background: #dbeafe; color: #1e40af; }
.qv-leg-sick     { background: #fee2e2; color: #b91c1c; }
.qv-leg-dayoff   { background: #dcfce7; color: #15803d; }

.qv-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.qv-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: auto;
}

/* Name column */
.qv-name-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
  min-width: 200px;
  width: 200px;
  text-align: left;
  padding: 6px 12px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  border-right: 2px solid var(--border);
  white-space: nowrap;
}

/* Month header row */
.qv-month-header {
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg);
  letter-spacing: .3px;
}

/* Day header cells */
/* Week header cells */
.qv-week-head {
  text-align: center;
  padding: 6px 4px;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  vertical-align: bottom;
  white-space: nowrap;
  cursor: default;
}

.qv-wk-range {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text);
}

/* Name cells in body */
.qv-name-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  padding: 6px 12px;
  border-right: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  min-width: 200px;
  width: 200px;
}
.qv-emp-name {
  display: block;
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
}
.qv-emp-role {
  display: block;
  font-size: .7rem;
  color: var(--muted);
  margin-top: 1px;
}
/* Week data cells */
.qv-week-cell {
  padding: 0;
  height: 40px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  position: relative;
}

/* Leave block inside week cell — absolutely positioned for proportional sizing */
.qv-block {
  display: flex;
  align-items: center;
  overflow: hidden;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
  box-sizing: border-box;
}
.qv-block-vacation { background: #bfdbfe; color: #1e3a8a; }
.qv-block-sick     { background: #fecaca; color: #7f1d1d; }
.qv-block-dayoff   { background: #bbf7d0; color: #14532d; }

.qv-block-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

/* Floating JS tooltip */
.qv-tooltip {
  position: fixed;
  z-index: 9999;
  background: #1f2328;
  color: #fff;
  font-size: .8rem;
  font-weight: 500;
  line-height: 1.6;
  white-space: pre;
  padding: 8px 12px;
  border-radius: 7px;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  max-width: 280px;
  white-space: pre-wrap;
}

/* zebra rows */
.qv-table tbody tr:nth-child(even) .qv-week-cell { background: #fafbfd; }
.qv-table tbody tr:nth-child(even) .qv-name-cell  { background: #fafbfd; }

/* ── ROLES LIST ── */
.roles-list {
  min-height: 32px;
}

.roles-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.roles-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: .85rem;
  font-weight: 500;
}

/* ── ANNUAL SUMMARY TABLE ── */
.summary-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: auto;
}

.summary-table thead th {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 8px 12px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}

.sum-th-name  { min-width: 130px; text-align: left; }
.sum-th-role  { min-width: 160px; text-align: left; }
.sum-th-q     { min-width: 110px; text-align: center; }
.sum-th-total { min-width: 70px;  text-align: center; }

.summary-row td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
  padding: 8px 12px;
}
.summary-row:last-child td { border-bottom: none; }
.summary-table tbody tr:nth-child(even) td { background: #fafbfd; }

.sum-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.sum-role {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}
.sum-cell {
  text-align: center;
}
.sum-chip {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: .75rem;
  font-weight: 600;
  margin: 2px 1px;
  white-space: nowrap;
}
.sum-nil {
  color: var(--muted);
  font-size: .8rem;
}
.sum-total {
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
  font-weight: 600;
}
.sum-total-filled {
  color: var(--text);
  font-weight: 700;
}
