/* ===== CSS Variables ===== */
:root {
  --primary: #1f00ff;
  --primary-dark: #1600cc;
  --primary-light: #4433ff;
  --primary-faded: rgba(31, 0, 255, 0.12);
  --sidebar-bg: #1a1d23;
  --sidebar-text: #c8cad0;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255,255,255,0.07);
  --bg: #f4f5f9;
  --surface: #ffffff;
  --border: #e2e4ea;
  --text: #1a1d23;
  --text-muted: #6b7080;
  --danger: #e03c4a;
  --success: #1bb96b;
  --warning: #f5a623;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --sidebar-width: 240px;
  --transition: 0.18s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }
img { max-width: 100%; }
ul { list-style: none; }

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Login Screen ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f5f9;
}

.login-box {
  background: #1a1d23;
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
  justify-content: center;
}

.login-logo img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.login-brand {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 28px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
  line-height: 1;
}

.brand-sub {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 3px;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.login-box .form-group label { color: rgba(255,255,255,0.75); }
.login-box .form-group input {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
  color: #ffffff;
}
.login-box .form-group input::placeholder { color: rgba(255,255,255,0.3); }
.login-box .form-group input:focus { border-color: var(--primary); background: rgba(255,255,255,0.1); }

/* ===== Forms ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-weight: 600; font-size: 13px; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-faded); }
.form-group input[type="color"] { padding: 4px 8px; height: 40px; }
.form-group textarea { resize: vertical; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.9); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }

.btn-ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost:hover { background: var(--primary-faded); }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 12px; }

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-icon:hover { background: var(--bg); }
.btn-icon svg { width: 18px; height: 18px; display: block; }

/* ===== Messages ===== */
.error-msg {
  background: #fdf0f1;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.success-msg {
  background: #f0fdf6;
  border: 1px solid var(--success);
  color: #0d7a47;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.days-preview {
  background: var(--primary-faded);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

/* ===== App Shell ===== */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-logo .brand-name { font-size: 18px; font-weight: 700; color: #ffffff; line-height: 1; }
.sidebar-logo .brand-sub { font-size: 10px; color: rgba(255,255,255,0.4); letter-spacing: 0.03em; padding-left: 2px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 16px 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-weight: 500;
  width: 100%;
  transition: background var(--transition), color var(--transition);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
}

.user-details { flex: 1; min-width: 0; }
.user-name { font-weight: 600; color: #fff; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.user-role { font-size: 10px; color: rgba(255,255,255,0.45); text-transform: capitalize; }

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  transition: filter var(--transition);
}
.btn-logout svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-logout:hover { filter: brightness(0.85); }

/* ===== Mobile top bar ===== */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--sidebar-bg);
  z-index: 300;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
}
.mobile-brand { color: #fff; font-size: 14px; font-weight: 700; }

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  flex-shrink: 0;
}
.hamburger:hover { background: var(--sidebar-hover); }
.hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.sidebar-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar-open .hamburger span:nth-child(2) { opacity: 0; }
.sidebar-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 52px; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ===== Mobile brand logo ===== */
.mobile-brand { display: flex; align-items: center; gap: 8px; }
.mobile-brand-logo { width: 24px; height: 24px; object-fit: contain; }
.mobile-brand .brand-name { font-size: 16px; font-weight: 800; }
.mobile-brand-sub { font-size: 8px; font-weight: 600; color: rgba(255,255,255,0.45); letter-spacing: 0.5px; }

/* ===== Mobile breakpoint ===== */
@media (max-width: 700px) {
  .mobile-topbar { display: flex; }

  .app-shell { position: relative; }

  .sidebar {
    position: fixed;
    top: 52px; left: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
  }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-overlay { display: block; }

  /* Sidebar nav — left-aligned, logo hidden on mobile (shown in topbar instead) */
  .sidebar-logo { display: none; }
  .sidebar-nav { padding: 8px 8px; }
  .nav-item { padding: 11px 10px; gap: 10px; }
  .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

  .main-content { padding-top: 52px; }

  .view { padding: 14px 16px; }

  /* Calendar — allow scroll on mobile */
  #view-calendar { overflow-y: auto; height: auto; flex: 1; }

  /* Calendar header */
  #view-calendar .view-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  #view-calendar .view-header h1 { font-size: 16px; }
  .calendar-controls { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; align-self: stretch; }
  .cal-view-toggle { flex-shrink: 0; }
  .cal-toggle-btn { padding: 5px 9px; font-size: 11px; }
  .cal-nav-group { display: flex; align-items: center; gap: 1px; margin-left: auto; min-width: 0; }
  .calendar-month-label { font-size: 12px; font-weight: 700; white-space: nowrap; padding: 0 3px; overflow: hidden; text-overflow: ellipsis; }
  .cal-nav-group .btn.btn-icon { flex-shrink: 0; }
  .btn.btn-icon { padding: 4px 5px; }
  .btn-icon svg { width: 14px; height: 14px; }

  /* Request cards — stack on mobile */
  .request-card {
    display: grid !important;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 0;
    padding: 12px 14px 12px 20px;
    position: relative;
    overflow: hidden;
  }
  .request-card .req-color-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    height: auto;
    border-radius: 4px 0 0 4px;
  }
  .request-card .request-user {
    grid-column: 1 / -1;
    width: auto;
    margin-bottom: 6px;
  }
  .request-card .req-info {
    grid-column: 1;
    min-width: 0;
  }
  .request-card .req-days {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
    align-self: start;
    padding-left: 12px;
  }
  .request-card .req-days span {
    display: block;
    font-size: 10px;
  }
  .request-card .req-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  /* User cards — stack on mobile */
  .user-card {
    display: grid !important;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 0 10px;
    padding: 12px 14px;
    align-items: center;
  }
  .user-card .uc-avatar { grid-row: 1; grid-column: 1; width: 36px; height: 36px; font-size: 12px; }
  .user-card .uc-info { grid-row: 1; grid-column: 2 / -1; min-width: 0; }
  .user-card .uc-name { font-size: 13px; }
  .user-card .uc-email { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .user-card .uc-badge {
    grid-row: 2; grid-column: 1 / -1;
    margin-top: 12px; padding-top: 12px;
    align-self: center;
    border-top: 1px solid var(--border);
  }
  .user-card .uc-badge .badge { font-size: 9px; padding: 3px 8px; letter-spacing: 0.3px; }
  .user-card .req-actions {
    grid-row: 2; grid-column: 1 / -1;
    justify-self: end;
    margin-top: 12px; padding-top: 12px;
  }

  /* Sidebar — force left alignment & user details visible */
  .sidebar { text-align: left; }
  .nav-item { display: flex !important; justify-content: flex-start !important; text-align: left; }
  .sidebar-nav { align-items: stretch; }
  .user-details { display: block !important; }
  .sidebar-user { display: flex !important; align-items: center; gap: 8px; }
}

.view { padding: 20px 24px; display: none; overflow-y: auto; flex: 1; }
.view.active { display: flex !important; flex-direction: column; }

#view-calendar {
  padding: 16px 20px;
  overflow: hidden;
  height: 100%;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}
.view-header h1 { font-size: 18px; font-weight: 700; color: var(--text); }

/* ===== Calendar Controls ===== */
.calendar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}
.cal-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cal-nav-group .btn.btn-icon {
  flex-shrink: 0;
}
.calendar-month-label {
  font-size: 16px;
  font-weight: 700;
  min-width: 0;
  text-align: center;
  color: var(--text);
  white-space: nowrap;
}

/* ===== Allowance Bar ===== */
.allowance-bar {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.allowance-stat { display: flex; flex-direction: column; gap: 2px; }
.allowance-stat .stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
.allowance-stat .stat-value { font-size: 22px; font-weight: 800; color: var(--primary); }
.allowance-divider { width: 1px; height: 40px; background: var(--border); }
.allowance-progress { flex: 1; min-width: 200px; }
.allowance-progress .prog-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.progress-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s ease; }

/* ===== Requests List ===== */
.requests-list { display: flex; flex-direction: column; gap: 10px; }

.absence-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  padding: 4px 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.absence-section-pending { color: var(--warning); }
.absence-section-divider {
  border: none;
  border-top: 1.5px dashed var(--border);
  margin: 6px 0 2px;
}

.request-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.request-card .req-color-bar {
  width: 4px;
  align-self: stretch;
  border-radius: 4px;
  flex-shrink: 0;
}
.request-card .req-info { flex: 1; min-width: 0; }
.request-card .req-type { font-weight: 700; font-size: 14px; }
.request-card .req-dates { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.request-card .req-note { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-style: italic; }
.request-card .req-days { font-weight: 700; font-size: 18px; color: var(--primary); flex-shrink: 0; text-align: right; }
.request-card .req-days span { display: block; font-size: 10px; font-weight: 500; color: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-pending { background: #fff8e1; color: #a07000; border: 1px solid #f5c842; }
.badge-approved { background: #e8faf2; color: #0d7a47; border: 1px solid #1bb96b; }
.badge-rejected { background: #fdf0f1; color: var(--danger); border: 1px solid var(--danger); }

.req-actions { display: flex; gap: 8px; flex-shrink: 0; }

.request-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  width: 200px;
}
.request-user .ru-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.request-user .ru-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Form Card ===== */
.form-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.form-card form { display: flex; flex-direction: column; gap: 20px; }

/* ===== Users List ===== */
.users-list { display: flex; flex-direction: column; gap: 10px; }
.user-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}
.user-card .uc-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-card .uc-info { flex: 1; }
.user-card .uc-name { font-weight: 700; font-size: 14px; }
.user-card .uc-email { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.user-card .uc-badge { flex-shrink: 0; }

/* ===== Admin Sections ===== */
.admin-section {}
.admin-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.admin-section-header svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.admin-section-header h2 { font-size: 15px; font-weight: 700; color: var(--text); }

/* View title with icon */
.view-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.view-title-group svg { width: 22px; height: 22px; color: var(--primary); }

/* Add user panel */
.add-user-panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.add-user-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 16px;
}
.add-user-panel form { display: flex; flex-direction: column; gap: 14px; }
.add-user-panel form .btn { align-self: flex-start; }

/* Sidebar section label */
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.3);
  padding: 12px 12px 4px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ===== PDF Button ===== */
.btn-pdf {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #f5f0ff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background var(--transition);
  cursor: pointer;
}
.btn-pdf svg { width: 18px; height: 18px; }
.btn-pdf:hover { background: var(--primary-faded); }

/* ===== Type Labels ===== */
.type-vacation { color: var(--primary); }
.type-sick { color: var(--danger); }
.type-occasional { color: var(--success); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-close {
  font-size: 22px;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal form { display: flex; flex-direction: column; gap: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ===== Loading spinner ===== */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
