* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blue: #0057D9;
  --blue-dark: #003fa3;
  --blue-soft: #e8f0ff;
  --black: #0f1419;
  --gray-1: #1f2937;
  --gray-2: #6b7280;
  --gray-3: #9ca3af;
  --gray-bg: #f6f7f9;
  --line: #e5e7eb;
  --green: #00A845;
  --red: #E8421A;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(15,20,25,0.06);
  --shadow-md: 0 4px 16px rgba(15,20,25,0.08);
}
html, body {
  font-family: 'Montserrat', -apple-system, sans-serif;
  background: var(--gray-bg);
  color: var(--gray-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.loading-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--gray-bg); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { background: #fff; border-radius: 16px; box-shadow: var(--shadow-md); padding: 40px; max-width: 420px; width: 100%; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: var(--black); }
.login-logo .domain { font-size: 12px; font-weight: 600; color: var(--gray-3); letter-spacing: 0.15em; text-transform: uppercase; margin-top: 4px; }
.login-logo .badge { display: inline-block; margin-top: 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; padding: 3px 10px; border-radius: 3px; background: var(--blue-soft); color: var(--blue); }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-1); margin-bottom: 6px; }
.form-input { width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; outline: none; transition: border 0.15s; }
.form-input:focus { border-color: var(--blue); }
.form-hint { font-size: 12px; color: var(--gray-3); margin-top: 6px; }

.btn { border: none; cursor: pointer; font-family: inherit; font-weight: 600; padding: 12px 20px; border-radius: 8px; font-size: 14px; transition: all 0.15s; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: var(--gray-3); cursor: not-allowed; }
.btn-lg { height: 46px; font-size: 15px; }

.alert { padding: 12px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: #e8fff2; color: #005522; border: 1px solid #b3e6c8; }
.alert-error { background: #fff0ee; color: #8a1d09; border: 1px solid #f3c0b5; }
.alert-info { background: var(--blue-soft); color: var(--blue-dark); border: 1px solid #c5d8f5; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #fff; border-right: 1px solid var(--line); padding: 24px 0; position: fixed; height: 100vh; }
.sidebar-logo { padding: 0 24px 24px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.sidebar-logo-title { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; color: var(--black); }
.sidebar-logo-sub { font-size: 10px; font-weight: 600; color: var(--gray-3); letter-spacing: 0.15em; text-transform: uppercase; margin-top: 4px; }
.sidebar-nav { padding: 8px 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--gray-1); margin-bottom: 2px; text-decoration: none; }
.nav-item:hover { background: var(--gray-bg); }
.nav-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }

.main { margin-left: 240px; flex: 1; padding: 32px; position: relative; }
.page-header { margin-bottom: 28px; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--black); }
.page-sub { font-size: 14px; color: var(--gray-2); margin-top: 4px; }

.user-chip { position: absolute; top: 16px; right: 32px; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; background: #fff; border: 1px solid var(--line); border-radius: 24px; cursor: pointer; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; }

.card { background: #fff; border-radius: 10px; border: 1px solid var(--line); padding: 20px 24px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--black); margin-bottom: 12px; }

/* === LOADING placeholder у сторінках === */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px 0; }

/* === FILTER BAR === */
.filter-bar { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.filter-chip { padding: 7px 14px; border-radius: 20px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.filter-chip:hover { border-color: var(--blue); color: var(--blue); }
.filter-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* === TEAM GRID === */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.team-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; transition: all 0.15s; text-decoration: none; color: inherit; display: block; }
.team-card:hover { border-color: var(--blue); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.team-avatar { width: 80px; height: 80px; border-radius: 50%; background: var(--gray-bg) center/cover no-repeat; margin: 0 auto 12px; }
.team-avatar-letter { display: flex; align-items: center; justify-content: center; background: var(--blue); color: #fff; font-weight: 700; font-size: 28px; }
.team-name { font-size: 14px; font-weight: 700; color: var(--black); margin-bottom: 4px; }
.team-role { font-size: 12px; color: var(--gray-2); }
.team-dept { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 8px; border-radius: 3px; background: var(--blue-soft); color: var(--blue); margin-top: 8px; }

/* === PROFILE === */
.profile-grid { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
.profile-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.profile-avatar { width: 200px; height: 200px; border-radius: 50%; background: var(--gray-bg) center/cover no-repeat; margin: 0 auto; }
.profile-avatar-letter { display: flex; align-items: center; justify-content: center; background: var(--blue); color: #fff; font-weight: 700; font-size: 64px; }
.badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 10px; border-radius: 3px; background: var(--blue-soft); color: var(--blue); }

.contact-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.contact-row:last-child { border: none; }
.contact-label { font-size: 12px; color: var(--gray-2); flex-shrink: 0; min-width: 120px; }
.contact-value { font-size: 13px; color: var(--gray-1); text-align: right; word-break: break-word; }
.contact-value a { color: var(--blue); text-decoration: none; }
.contact-value a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-avatar { width: 160px; height: 160px; }
}

/* === FORM EXTENSIONS === */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
textarea.form-input { padding: 10px 14px; min-height: 70px; font-family: inherit; line-height: 1.5; resize: vertical; }
.btn-secondary { background: #fff; color: var(--gray-1); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--gray-bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; height: auto; }

/* === MODAL === */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,20,25,0.5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; opacity: 0; transition: opacity 0.2s; }
.modal-overlay.open { opacity: 1; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: var(--shadow-md); max-height: calc(100vh - 80px); display: flex; flex-direction: column; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--black); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--gray-2); padding: 4px 8px; }
.modal-close:hover { color: var(--black); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* === USERS TABLE === */
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table th { text-align: left; padding: 14px 20px; background: var(--gray-bg); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gray-3); }
.users-table td { padding: 14px 20px; border-top: 1px solid var(--line); vertical-align: middle; }
.badge-owner { background: #fff0c4; color: #9a6b00; }
.badge-admin { background: var(--blue-soft); color: var(--blue); }
.badge-hr    { background: #e7d9ff; color: #6b39cc; }
.badge-editor { background: #d4edda; color: #137333; }
.badge-viewer { background: #f0f0f0; color: #666; }

/* === PERMISSIONS UI === */
.perm-group { margin-bottom: 18px; }
.perm-group-title { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gray-3); margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.perm-row:last-child { border: none; }
.perm-label { font-size: 13px; font-weight: 600; color: var(--gray-1); }
.perm-desc { font-size: 11px; color: var(--gray-3); margin-top: 2px; }
.perm-btn { background: var(--gray-bg); border: 1px solid var(--line); padding: 6px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit; min-width: 110px; }
.perm-row.perm-role .perm-btn { background: #d4edda; border-color: #b3e6c8; color: #005522; }
.perm-row.perm-explicit .perm-btn { background: var(--blue-soft); border-color: #c5d8f5; color: var(--blue); }
.perm-row.perm-revoked .perm-btn { background: #fff0ee; border-color: #f3c0b5; color: #8a1d09; }

/* === TOAST === */
.toast { position: fixed; bottom: 20px; right: 20px; background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); transform: translateY(20px); opacity: 0; transition: all 0.2s; z-index: 200; max-width: 360px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }

/* Архівовані карточки */
.team-card-archived { opacity: 0.55; position: relative; }
.team-card-archived:hover { opacity: 0.85; }
.team-archived-badge { position: absolute; top: 8px; right: 8px; background: var(--gray-3); color: #fff; font-size: 9px; font-weight: 700; letter-spacing: 0.1em; padding: 3px 7px; border-radius: 3px; }

/* === HR tabs === */
.hr-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.hr-tab { padding: 10px 18px; background: none; border: none; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 600; color: var(--gray-2); cursor: pointer; font-family: inherit; transition: all 0.15s; }
.hr-tab:hover { color: var(--gray-1); }
.hr-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.hr-filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.form-input-sm { height: 34px; padding: 0 10px; font-size: 13px; max-width: 200px; }

.hr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hr-table th { text-align: left; padding: 12px 16px; background: var(--gray-bg); font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gray-3); }
.hr-table td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.hr-table tbody tr:hover { background: #fafafa; }

/* === Page header layout — кнопки під чіпом юзера === */
.main { padding-top: 70px; }   /* Місце для user-chip зверху */
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-right: 220px; min-height: 50px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .page-header-row { padding-right: 0; }
  .main { padding-top: 60px; }
}

/* === Pending badge у sidebar === */
.nav-item { position: relative; }
.nav-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: auto;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* === VACATION STATS CARD === */
.vac-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 16px; }
.vac-header { margin-bottom: 16px; }
.vac-title { font-size: 15px; font-weight: 700; color: var(--black); }
.vac-sub { font-size: 12px; color: var(--gray-2); margin-top: 2px; }
.vac-numbers { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.vac-num { text-align: center; padding: 12px 8px; background: var(--gray-bg); border-radius: 8px; }
.vac-num-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray-3); margin-bottom: 4px; }
.vac-num-val { font-size: 28px; font-weight: 800; color: var(--gray-1); line-height: 1; letter-spacing: -0.02em; }
.vac-bar { position: relative; height: 8px; background: var(--gray-bg); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.vac-bar-used { position: absolute; top: 0; left: 0; bottom: 0; background: var(--blue); }
.vac-bar-pending { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, #c47800, #c47800 4px, #d68a00 4px, #d68a00 8px); opacity: 0.7; }
.vac-others { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.vac-others-title { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; color: var(--gray-3); margin-bottom: 6px; }
.vac-other-item { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; color: var(--gray-2); }
.vac-other-item strong { color: var(--gray-1); }

/* === Absent rows === */
.absent-list { margin-top: 8px; }
.absent-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; transition: background 0.15s; }
.absent-row:first-child { border-top: none; }
.absent-row:hover { background: var(--gray-bg); margin: 0 -12px; padding: 10px 12px; border-radius: 6px; }
.absent-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gray-bg) center/cover no-repeat; flex-shrink: 0; }
.absent-avatar-letter { display: flex; align-items: center; justify-content: center; background: var(--blue); color: #fff; font-weight: 700; font-size: 13px; }
.absent-info { min-width: 0; }
.absent-name { font-size: 14px; font-weight: 600; color: var(--gray-1); }
.absent-meta { font-size: 12px; color: var(--gray-2); margin-top: 1px; }
