:root {
  --bg: #F4F7FB;
  --surface: #FFFFFF;
  --border: #E3E9F0;
  --text: #1F2A37;
  --muted: #7C8B9E;
  --primary: #1E3A5F;
  --primary-hover: #28496F;
  --amber: #D9A441;
  --amber-soft: #FBF0DC;
  --danger: #C1473E;
  --success: #227A57;
  --warning: #D9A441;
  --info: #2F6FB2;
  --info-soft: #E4EFF9;
  --radius: 9px;
  --radius-card: 14px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body { overflow-x: hidden; }

body {
  margin: 0;
  font-family: 'Cairo', "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.num-font { font-family: 'Manrope', sans-serif; }

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* App shell: sidebar icon rail + topbar + content */
.app-shell { display: flex; min-height: 100vh; }

.rail {
  width: 72px;
  flex-shrink: 0;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 10px;
}

.rail-logo {
  width: 36px;
  height: 36px;
  border: 2px dashed var(--amber);
  border-radius: 50%;
  opacity: 0.7;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.rail-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #A9BAD0;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  position: relative;
}

.rail-btn svg,
details.rail-flyout > summary svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }

a.rail-btn:hover { color: #fff; }

.rail-btn.active { background: var(--amber); color: var(--primary); }
.rail-btn.active svg { stroke: var(--primary); }

details.rail-flyout { list-style: none; position: relative; }
details.rail-flyout > summary {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #A9BAD0;
  cursor: pointer;
  list-style: none;
}
details.rail-flyout[open] > summary,
details.rail-flyout > summary:hover { color: #fff; }
details.rail-flyout.active > summary { background: var(--amber); color: var(--primary); }
details.rail-flyout.active > summary svg { stroke: var(--primary); }
details.rail-flyout > summary::-webkit-details-marker { display: none; }
details.rail-flyout > summary::marker { content: ""; }

.flyout-menu {
  position: absolute;
  inset-inline-start: 100%;
  top: 0;
  margin-inline-start: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem;
  min-width: 190px;
  box-shadow: 0 10px 24px rgba(30, 58, 95, 0.14);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.flyout-menu form { margin: 0; }
.flyout-menu a, .flyout-menu button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: none;
  background: none;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  text-align: inherit;
}
.flyout-menu a:hover, .flyout-menu button:hover { background: var(--bg); color: var(--primary); }

/* Topbar user menu — compact avatar+name chip that opens a flyout-menu below it
   instead of two full-size buttons crowding the header. */
details.user-menu { position: relative; list-style: none; }
details.user-menu > summary { list-style: none; cursor: pointer; }
details.user-menu > summary::-webkit-details-marker { display: none; }
details.user-menu > summary::marker { content: ""; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem 0.3rem 0.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.user-chip:hover, details.user-menu[open] .user-chip { border-color: var(--primary); background: var(--bg); }
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.72rem;
  flex-shrink: 0;
}
.user-chip-text { display: flex; flex-direction: column; line-height: 1.2; text-align: start; }
.user-chip-name { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.user-chip-role { font-size: 0.72rem; color: var(--muted); }
.user-chip-caret { width: 14px; height: 14px; color: var(--muted); transition: transform 0.15s; flex-shrink: 0; }
details.user-menu[open] .user-chip-caret { transform: rotate(180deg); }

/* Explicit position: absolute at every breakpoint (not just desktop) so this never
   inherits the shared mobile .flyout-menu rule below, which switches to position: fixed
   for the rail's own (much longer) nav menus — those need to escape the rail's
   horizontally-scrolling container, but .user-menu lives in the topbar, which never
   scrolls, so plain absolute positioning relative to the trigger works fine everywhere
   and keeps this small two-item menu compact instead of stretching near full-width. */
.user-menu .flyout-menu {
  position: absolute;
  inset-inline-start: auto;
  inset-inline-end: 0;
  top: 100%;
  margin-inline-start: 0;
  margin-top: 8px;
  width: max-content;
  min-width: 190px;
  max-width: calc(100vw - 24px);
}

/* Rail tooltips (desktop only, hover) */
.rail-btn[data-tooltip]::after,
details.rail-flyout > summary[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  inset-inline-start: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-inline-start: 10px;
  background: var(--text);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
  z-index: 40;
}
.rail-btn[data-tooltip]:hover::after,
details.rail-flyout > summary[data-tooltip]:hover::after { opacity: 1; }
details.rail-flyout[open] > summary::after { opacity: 0 !important; }

.shell { flex: 1; display: flex; flex-direction: column; min-width: 0; }

header.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 30px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.breadcrumb { font-size: 13px; color: var(--muted); }
.breadcrumb b { color: var(--primary); font-weight: 700; }

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.lang-form { display: inline-flex; }
.lang-toggle-app {
  border: 1px solid var(--border);
  background: none;
  padding: 7px 14px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 8px;
  color: var(--primary);
  font-family: inherit;
  font-weight: 600;
}
.lang-toggle-app:hover { border-color: var(--primary); }

main {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 26px 30px;
}

body.auth-shell main { max-width: none; margin: 0; padding: 0; min-height: 100vh; }

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: 0 6px 20px rgba(30, 58, 95, 0.06);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14.5px; font-weight: 700; color: var(--primary); margin: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
}

th, td {
  padding: 0.6rem 0.8rem;
  text-align: start;
  border-bottom: 1px solid var(--border);
}

th { background: #FAFCFE; font-weight: 600; color: var(--muted); font-size: 0.75rem; }
th a.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort-link:hover { color: var(--primary); }

tr:last-child td { border-bottom: none; }

.totals-row td { background: #FAFCFE; border-top: 2px solid var(--border); }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
}

.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn.secondary {
  background: var(--surface);
  color: var(--primary);
}

.btn.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.btn.danger:hover { background: #a53c34; border-color: #a53c34; }

.edit-dates-link { margin-inline-start: 0.75rem; padding: 0.15rem 0.6rem; font-size: 0.82rem; }

.warning-box {
  background: var(--amber-soft);
  color: #8A6216;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.warning-box strong { display: block; margin-bottom: 0.25rem; }

.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  background: #e5e7eb;
}

.badge.open { background: #FBE6E4; color: var(--danger); }
.badge.in_progress { background: var(--amber-soft); color: #8A6216; }
.badge.closed { background: #E1F3EA; color: var(--success); }

.badge.pending { background: var(--amber-soft); color: #8A6216; }
.badge.approved { background: #E1F3EA; color: var(--success); }
.badge.rejected { background: #FBE6E4; color: var(--danger); }
.badge.cancelled { background: #e5e7eb; color: #4b5563; }

.badge.danger { background: #FBE6E4; color: var(--danger); }
.badge.neutral { background: #E3E9F0; color: var(--muted); }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
.messages li.success { background: #E1F3EA; color: var(--success); }
.messages li.error { background: #FBE6E4; color: var(--danger); }

.errorlist { list-style: none; padding: 0; margin: 0.3rem 0; }
.errorlist li { color: var(--danger); font-size: 0.85rem; font-weight: 600; }

form p { margin: 0.6rem 0; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; font-size: 0.9rem; color: #4E5D70; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
}
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}
input[type="checkbox"], input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}

/* Unified segmented control for every RadioSelect/CheckboxSelectMultiple filter in the
   site (period, status, report columns, export mode/types, event type/order...) — one
   adjacent capsule instead of separately-spaced pills. Django renders these as a <div>
   per field containing one <div><label><input>text</label></div> per option; the radio
   dot itself is visually hidden since the fill color is the selection indicator. Reused
   directly (class="segmented") or via the {% segmented %} template tag
   (templates/partials/segmented.html) for the common case with no extra markup between
   options. */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.segmented > div { margin: 0; display: contents; }
.segmented label {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.88rem;
  white-space: nowrap;
  color: var(--text);
  border-inline-end: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}
.segmented label:last-child { border-inline-end: none; }
.segmented input[type="radio"], .segmented input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
}
.segmented label:has(input:checked) {
  background: var(--primary);
  color: #fff;
}
.segmented label:has(input:focus-visible) { outline: 2px solid var(--amber); outline-offset: -2px; }

/* Plain pill-checkbox list for the workflow action's "which days does this apply to"
   picker (events/event_detail.html) — an action-target selector, not a list filter, so
   it's kept out of this filter redesign and out of .segmented's single-capsule shape. */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.toggle-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}
.toggle-group label:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.muted { color: var(--muted); font-size: 0.9rem; }

.activity-log { list-style: none; padding: 0; }
.activity-log li {
  border-inline-start: 3px solid var(--primary);
  padding: 0.4rem 0.8rem;
  margin-bottom: 0.4rem;
  background: var(--bg);
}

.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.page-actions form { display: inline-flex; }
.back-btn { font-size: 0.9rem; padding: 0.4rem 0.9rem; }

.date-shortcuts { display: inline-flex; gap: 0.4rem; margin-inline-start: 0.5rem; }
.date-shortcuts .btn { width: auto; padding: 0.4rem 0.7rem; font-size: 0.85rem; }

.date-filter-toggle { align-self: flex-end; }
.date-filter-toggle > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.date-filter-toggle > summary::-webkit-details-marker { display: none; }
.date-filter-toggle > summary::marker { content: ""; }
.date-filter-toggle .date-filter-fields { display: flex; gap: 0.75rem; margin-top: 0.5rem; flex-wrap: wrap; }

/* Site-wide filter bar shell: one compact, short card holding a row of segmented
   controls / compact selects, applied via onchange auto-submit everywhere. */
.filter-card { padding: 0.65rem 1rem; }
.filter-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
}
.filter-fields label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.9rem;
  white-space: nowrap;
}
.filter-fields select {
  width: auto;
  min-width: 100px;
}
.filter-fields input[type="text"], .filter-fields input[type="date"] {
  width: auto;
  min-width: 150px;
}
/* Two or more related fields (e.g. month + year, from-date + to-date) sitting side by
   side as one compact group, with no separate label row above each — only an
   aria-label per field for screen readers. */
.compact-select-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.compact-select-row select, .compact-select-row input[type="date"] { padding: 0.4rem 0.6rem; min-width: 84px; }
/* Month/year (reports/_period_filter.html) additionally stays hidden until "شهر محدد"
   (a specific month) is explicitly selected — including on a fresh page load where no
   radio is checked yet. Pure CSS, no JS. */
.month-year-fields { display: none; }
.filter-fields:has(input[name="period"][value="month"]:checked) .month-year-fields { display: flex; }

/* Export form's month-vs-custom-range toggle (reports/employee_export.html) — same
   idea, mirrored for its own field/value names. */
.export-month-fields, .export-custom-fields { display: none; }
.filter-fields:has(input[name="mode"][value="month"]:checked) .export-month-fields { display: flex; }
.filter-fields:has(input[name="mode"][value="custom"]:checked) .export-custom-fields { display: flex; }

.hidden-note { font-size: 0.85rem; color: var(--muted); }
.hidden-note a { margin-inline-start: 0.3rem; font-weight: 600; }

.row-actions { display: inline-flex; gap: 0.3rem; flex-wrap: wrap; }
.row-actions .btn { width: auto; padding: 0.35rem 0.6rem; font-size: 0.8rem; }

.reorder-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.reorder-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.04);
}
.reorder-list li.dragging { opacity: 0.6; box-shadow: 0 8px 20px rgba(30, 58, 95, 0.15); }
.reorder-name { flex: 1; font-weight: 600; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: 0.2rem 0.4rem; touch-action: none; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.dashboard-header h1 { margin: 0; }

.stat-group { margin-bottom: 1.75rem; }
.stat-group h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
  margin: 0 0 0.75rem;
}
.stat-group h2::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--stat-accent, var(--primary));
  flex-shrink: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 220px));
  gap: 0.9rem;
}

.stat-tile {
  --stat-accent: var(--primary);
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 1rem 1.25rem;
  box-shadow: 0 6px 20px rgba(30, 58, 95, 0.06);
  border-inline-start: 4px solid var(--stat-accent);
}

.stat-tile.warning { --stat-accent: var(--amber); }
.stat-group.warning h2 { --stat-accent: var(--amber); }

.stat-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; font-weight: 600; }
.stat-value {
  font-family: 'Manrope', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.stat-value.compact { font-size: 1.3rem; }
.stat-sub { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }
.stat-chip {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.68rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--amber-soft);
  color: #8A6216;
  font-weight: 700;
}

.stat-tile-link { display: block; color: inherit; text-decoration: none; }
.stat-tile-link:hover .stat-label, .stat-tile-link:hover .stat-value { color: var(--amber); }
.stat-sub a { color: inherit; text-decoration: underline dotted; }
.stat-sub a:hover { color: var(--primary); }

/* Employee profile header */
.profile-head { display: flex; gap: 1.1rem; align-items: center; }
.avatar {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--primary);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.profile-head h2 { margin: 0; font-size: 1.15rem; color: var(--primary); }

/* Home page: open-events-by-employee cards */
.employee-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
}
.employee-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 0.9rem 1.1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 6px 20px rgba(30, 58, 95, 0.06);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.employee-card:hover { border-color: var(--primary); box-shadow: 0 10px 24px rgba(30, 58, 95, 0.12); }
.employee-card .avatar { width: 44px; height: 44px; font-size: 1rem; border-radius: 12px; }
.employee-card-body { flex: 1; min-width: 0; }
.employee-card-name { font-weight: 700; color: var(--primary); }
.employee-card-summary { font-size: 0.82rem; margin-top: 0.15rem; }
.employee-card-total {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  flex-shrink: 0;
  min-width: 2rem;
  text-align: center;
}
.employee-card-total.danger { color: var(--danger); }
.employee-card-total.warning { color: var(--amber); }
.employee-card-total.info { color: var(--info); }

/* Employee report page: open/in-progress/closed row coloring */
tr.report-row-open { background: #FBE6E4; }
tr.report-row-open td:first-child { border-inline-start: 4px solid var(--danger); }
tr.report-row-in_progress { background: var(--amber-soft); }
tr.report-row-in_progress td:first-child { border-inline-start: 4px solid var(--amber); }
tr.report-row-closed td:first-child { border-inline-start: 4px solid var(--border); }

/* Leave request page: form fields + info box */
.leave-request-card .field { margin-bottom: 1rem; }
.info-box {
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius);
  margin: -0.5rem 0 1rem;
  font-size: 0.9rem;
}
.hidden-box { display: none; }
.info-box.loading { background: var(--bg); color: var(--muted); }
.info-box.success { background: #E1F3EA; color: var(--success); }
.info-box.error { background: #FBE6E4; color: var(--danger); }

.date-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: start;
}

.days-box { margin: 0.75rem 0 1rem; font-weight: 600; }

.message { margin-top: 0.75rem; font-weight: 600; }
.message.loading { color: var(--muted); }
.message.success { color: var(--success); }
.message.error { color: var(--danger); }

/* Leave request page: full-page confirmation after a successful submission */
.confirm-wrap {
  display: none;
  min-height: 70vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.confirm-wrap.visible { display: flex; }
.confirm-card { max-width: 460px; width: 100%; text-align: center; padding: 2.5rem 2rem; }
.confirm-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  background: #E1F3EA;
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}
.confirm-card h1 { font-size: 1.4rem; margin: 0 0 0.6rem; color: var(--primary); }
.confirm-card p { color: var(--muted); margin: 0 0 1.5rem; line-height: 1.7; }
.confirm-number { display: inline-block; margin-bottom: 1.75rem; }
.confirm-actions { display: flex; gap: 0.6rem; }
.confirm-actions .btn { flex: 1; }

/* Leave request: dynamic availability calendar */
.calendar-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-top: 0.5rem;
  background: var(--surface);
}
.calendar-panel.hidden-calendar { display: none; }

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.calendar-toolbar .nav-btn { padding: 0.3rem 0.75rem; }
.calendar-title { font-weight: 700; color: var(--primary); }

.calendar-months {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.month { flex: 1 1 260px; min-width: 240px; }
.month-title { font-weight: 600; text-align: center; margin-bottom: 0.4rem; color: var(--primary); }

.weekdays, .days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
}
.weekday { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 0.2rem 0; }

.day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: 'Manrope', sans-serif;
  padding: 0;
}
.day:hover:not(:disabled) { border-color: var(--primary); }
.day.empty { visibility: hidden; border: none; }
.day.weekend { background: var(--bg); }

.day.disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; opacity: 0.6; }
.day.full { background: #FBE6E4; color: var(--danger); border-color: var(--danger); cursor: not-allowed; }
.day.rule-blocked { background: var(--amber-soft); color: #8A6216; border-color: var(--amber); cursor: not-allowed; }
.day.start-blocked { border: 1px dashed var(--amber); color: #8A6216; }

.day.in-range { background: #E5EBFA; border-color: var(--primary); }
.day.start, .day.end {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--muted); }
.legend-swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.legend-swatch.available { background: var(--surface); }
.legend-swatch.full { background: #FBE6E4; border-color: var(--danger); }
.legend-swatch.rule-blocked { background: var(--amber-soft); border-color: var(--amber); }
.legend-swatch.start-blocked { background: var(--surface); border: 1px dashed var(--amber); }
.legend-swatch.disabled { background: var(--bg); }

/* Login screen */
#page-login { min-height: 100vh; display: flex; }
.login-side {
  flex: 1;
  background: linear-gradient(160deg, var(--primary), var(--primary-hover));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
  color: #fff;
}
.login-side .rail-logo { margin-bottom: 0; opacity: 0.8; }
.login-side .tagline { font-size: 24px; font-weight: 700; line-height: 1.6; max-width: 380px; }
.login-side .foot { font-size: 12px; color: #A9BAD0; }

.login-form-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
  background: var(--surface);
}
.mobile-sort { display: none; }
.login-form-wrap .lang-form { position: absolute; top: 22px; inset-inline-start: 22px; }
.login-card { width: min(360px, 100%); }
.login-card h1 { font-size: 23px; font-weight: 800; color: var(--primary); margin: 0 0 5px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.login-card .btn { width: 100%; padding: 12px; font-size: 14.5px; margin-top: 4px; }

@media (max-width: 640px) {
  .app-shell { flex-direction: column; }
  .rail {
    width: 100%;
    flex-direction: row;
    padding: 10px 14px;
    gap: 8px;
    overflow-x: auto;
  }
  .flyout-menu {
    position: fixed;
    inset-inline-start: 12px;
    inset-inline-end: 12px;
    top: 66px;
    margin-inline-start: 0;
    margin-top: 0;
    width: auto;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    z-index: 40;
  }
  .rail-btn[data-tooltip]::after, details.rail-flyout > summary[data-tooltip]::after { display: none; }

  header.topbar { padding: 0.75rem 1rem; height: auto; }
  .user-chip-text { display: none; }
  .user-chip { padding: 0.3rem; }
  .breadcrumb { font-size: 12px; }

  main { padding: 1rem 0.75rem; }
  .card { padding: 1rem; }

  table { font-size: 0.85rem; }
  th, td { padding: 0.5rem; }

  form p { margin: 0.75rem 0; }
  .card form button.btn[type="submit"] { width: 100%; }

  .page-actions .btn, .page-actions button.btn { flex: 1; text-align: center; }

  .date-shortcuts { display: flex; margin-inline-start: 0; margin-top: 0.4rem; }
  .date-shortcuts .btn { flex: 1; text-align: center; }

  .dashboard-header .btn { flex: 1; text-align: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat-tile { padding: 0.75rem 0.9rem; }
  .stat-value { font-size: 1.5rem; }

  .calendar-months { gap: 0.75rem; }
  .month { min-width: 0; }
  .day { font-size: 0.8rem; }

  .segmented { flex-direction: column; align-self: stretch; }
  .segmented label { width: 100%; border-inline-end: none; border-bottom: 1px solid var(--border); }
  .segmented label:last-child { border-bottom: none; }
  .toggle-group { flex-direction: column; }
  .toggle-group label { width: 100%; }

  #page-login { flex-direction: column; }
  .login-side { padding: 28px; flex: none; }
  .login-side .tagline { font-size: 19px; }
  .login-form-wrap { padding: 28px; }

  /* Leave requests list: one card per request instead of a wide table */
  .mobile-sort { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0.5rem 0; font-size: 0.85rem; }
  .requests-table, .requests-table tbody { display: block; }
  .requests-table thead { display: none; }
  .requests-table tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 0.9rem;
    margin-bottom: 0.75rem;
  }
  .requests-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .requests-table .c-employee { order: 1; grid-column: 1 / 3; font-weight: 700; color: var(--primary); }
  .requests-table .c-employee .num-font { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
  .requests-table .c-status { order: 2; grid-column: 3; justify-self: end; }
  .requests-table .c-type { order: 3; grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; }
  .requests-table .c-from, .requests-table .c-to, .requests-table .c-days {
    background: var(--bg);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    order: 4;
  }
  .requests-table [data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--muted);
    margin-bottom: 0.1rem;
  }
  .requests-table .c-number { order: 5; }
  .requests-table .c-submitted { order: 6; }
  .requests-table .c-number, .requests-table .c-submitted {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--muted);
  }
  .requests-table .c-number::before, .requests-table .c-submitted::before { display: inline; margin: 0; }
  .requests-table .c-actions { order: 7; grid-column: 1 / -1; margin-top: 0.25rem; }
  .requests-table .c-actions:not(:has(form)) { display: none; }
  .requests-table .row-actions { display: flex; gap: 0.4rem; }
  .requests-table .row-actions .btn { flex: 1; text-align: center; padding: 0.5rem 0.25rem; }
  .requests-table tr:has(td[colspan]) { display: block; text-align: center; }
}

/* Leave grid (جدول متابعة الإجازات) — intentionally LTR even on an RTL site, per the
   paper-grid convention the user is porting: day 1 at the start (left), increasing
   rightward. Everything around it (controls, legend, headings) stays RTL as normal. */
:root {
  --weekend: #D8DEEA;
  --weekend-head: #CBD3E2;
}
.leave-grid-legend {
  display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--muted); margin-bottom: 0.75rem;
}
.leave-grid-legend .item { display: flex; gap: 0.4rem; align-items: center; }
.leave-grid-legend .sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.leave-grid-legend .sw.pending { background: var(--amber); }
.leave-grid-legend .sw.weekend { background: var(--weekend); border: 1px solid var(--border); }
.leave-grid-legend .sw.workday { background: var(--surface); border: 1px solid var(--border); }

.color-swatch { width: 18px; height: 18px; border-radius: 4px; display: inline-block; border: 1px solid var(--border); }

.leave-grid-panel { overflow: auto; max-width: 100%; padding: 0; }
table.leave-grid {
  direction: ltr;
  /* Fixed layout: every day column is exactly --leave-grid-day-w wide regardless of
     whether it holds a mark or not — without this, a browser's auto layout sizes each
     column to its widest cell, so any column with a colored mark grows wider than its
     empty neighbors (the bug reported: "كل علامة تتسبب في زيادة عرض العمود"). */
  table-layout: fixed;
  border-collapse: separate; border-spacing: 0;
  font-size: 11px; width: auto;
}
:root { --leave-grid-day-w: 22px; --leave-grid-row-h: 24px; }
.leave-grid th, .leave-grid td { font-family: 'Cairo', sans-serif; padding: 0; }
.leave-grid thead th.daynum, .leave-grid thead th.dow { font-family: 'Manrope', sans-serif; }
.leave-grid thead th.daynum {
  width: var(--leave-grid-day-w);
  color: var(--text); font-weight: 700; text-align: center; padding: 5px 0 2px;
  border-bottom: 1px solid var(--bg); font-size: 11px;
  background: var(--surface); position: sticky; top: 0; z-index: 2;
}
.leave-grid thead th.dow {
  width: var(--leave-grid-day-w);
  color: var(--muted); font-weight: 600; text-align: center; padding: 1px 0 5px;
  border-bottom: 2px solid var(--border); font-size: 9px;
  background: var(--surface); position: sticky; top: 22px; z-index: 2;
}
.leave-grid thead th.daynum.weekend, .leave-grid thead th.dow.weekend {
  background: var(--weekend-head); color: #5A6478;
}
.leave-grid thead th.name-col, .leave-grid thead th.id-col {
  position: sticky; top: 0; z-index: 4; background: var(--surface); text-align: right;
  padding: 6px 10px; border-bottom: 2px solid var(--border); font-size: 11px;
  color: var(--muted); font-weight: 700;
}
.leave-grid thead th.name-col { inset-inline-start: 0; width: 130px; border-inline-end: 1px solid var(--border); }
.leave-grid thead th.id-col { inset-inline-start: 130px; width: 80px; border-inline-end: 1px solid var(--border); }

.leave-grid td {
  width: var(--leave-grid-day-w); height: var(--leave-grid-row-h); text-align: center;
  border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--bg);
}
.leave-grid td.daycell.weekend { background: var(--weekend); }
.leave-grid tbody tr:hover td { background: var(--bg); }
.leave-grid tbody tr:hover td.weekend { background: #CDD5E3; }

.leave-grid .sticky-col { position: sticky; z-index: 1; background: var(--surface); }
.leave-grid .name-cell { inset-inline-start: 0; width: 130px; text-align: right; padding: 0 10px; border-inline-end: 1px solid var(--border); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leave-grid .id-cell { inset-inline-start: 130px; width: 80px; text-align: center; padding: 0 6px; border-inline-end: 1px solid var(--border); font-family: 'Manrope', sans-serif; color: var(--muted); font-size: 11px; }
.leave-grid tbody tr:hover td.sticky-col { background: var(--bg); }

.leave-grid .mark { display: block; width: 12px; height: 12px; border-radius: 4px; margin: 0 auto; }
.leave-grid .mark.approved { background: var(--success); }
.leave-grid .mark.pending { background: var(--amber); }

.leave-grid-group-row td {
  position: sticky; inset-inline-start: 0;
  background: var(--bg); color: var(--primary); font-weight: 700;
  font-size: 11.5px; text-align: right; padding: 6px 14px;
  border-bottom: 1px solid var(--border); border-top: 1px solid var(--border);
}

/* Approval stepper (طلبات الإجازة — دورة الاعتماد بمرحلتين) */
.approval-stepper { display: flex; align-items: flex-start; gap: 0; }
.approval-node { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 150px; flex-shrink: 0; }
.approval-dot {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; background: var(--surface); border: 2px solid var(--border); color: var(--muted);
}
.approval-node.done .approval-dot { background: var(--success); border-color: var(--success); color: #fff; }
.approval-node.rejected .approval-dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.approval-node.active .approval-dot { background: var(--amber); border-color: var(--amber); color: var(--primary); box-shadow: 0 0 0 4px var(--amber-soft); }
.approval-label { font-size: 11.5px; font-weight: 700; color: var(--text); text-align: center; }
.approval-node.active .approval-label { color: #8A6216; }
.approval-sub { font-size: 10.5px; text-align: center; color: #8A6216; }
.approval-sub.success { color: var(--success); font-weight: 700; }
.approval-sub.danger { color: var(--danger); font-weight: 700; }
.approval-sub.muted { color: var(--muted); }
.approval-reason { font-size: 10px; color: var(--danger); text-align: center; max-width: 140px; line-height: 1.5; }
.approval-date { font-size: 9.5px; color: var(--muted); }
.approval-connector { flex: 1; height: 3px; background: var(--border); margin: 13px -2px 0; }
.approval-connector.done { background: var(--success); }
.approval-connector.rejected { background: var(--danger); }

.approval-stepper.compact { align-items: center; gap: 0; }
.approval-stepper.compact .approval-node { width: auto; flex-direction: row; gap: 0; }
.approval-stepper.compact .approval-dot { width: 11px; height: 11px; font-size: 0; border-width: 0; }
.approval-stepper.compact .approval-connector { flex: none; width: 14px; height: 2px; margin: 0 2px; }

.pending-status-box {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  background: #FAFCFE; margin: -0.5rem 0 1rem;
}
.pending-status-header { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.pending-status-meta { font-size: 11.5px; color: var(--muted); margin-top: 10px; font-family: 'Manrope', sans-serif; }
.pending-status-divider { border-top: 1px dashed var(--border); margin: 16px 0; }

/* Bulk compensation-credit form — employee checklist with a live filter above it. */
.bulk-select-toolbar { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.bulk-select-toolbar input[type="text"] { flex: 1; min-width: 180px; }
.bulk-select-list {
  max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; background: var(--surface);
}
.bulk-select-list > div > div { padding: 4px 0; border-bottom: 1px solid var(--border); }
.bulk-select-list > div > div:last-child { border-bottom: none; }
.bulk-select-list label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* Home-page "طلبات الإجازة" widget — each request is just its approval stepper,
   clickable straight through to the request detail page. */
.leave-request-stepper-list { display: flex; flex-direction: column; gap: 0.75rem; }
.leave-request-stepper-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 0.9rem 1.1rem 1.1rem;
  text-decoration: none; color: inherit; box-shadow: 0 6px 20px rgba(30, 58, 95, 0.06);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.leave-request-stepper-card:hover { border-color: var(--primary); box-shadow: 0 10px 24px rgba(30, 58, 95, 0.12); }
.leave-request-stepper-label { font-weight: 700; color: var(--primary); font-size: 0.9rem; margin-bottom: 0.9rem; }

/* Full approval stepper on narrow screens: the 3 fixed-width nodes (150px each) used on
   desktop don't fit a ~360-390px phone viewport — shrink nodes/text so all 3 stages stay
   visible without clipping, and keep a horizontal-scroll fallback for anything still
   tight (same "wide content scrolls in its own box" convention used elsewhere in this
   app, e.g. .table-scroll). */
@media (max-width: 640px) {
  .approval-stepper { overflow-x: auto; padding-bottom: 2px; }
  .approval-node { width: 96px; gap: 4px; }
  .approval-dot { width: 24px; height: 24px; font-size: 11px; }
  .approval-label { font-size: 10px; }
  .approval-sub { font-size: 9px; }
  .approval-reason { font-size: 8.5px; max-width: 90px; }
  .approval-date { font-size: 8.5px; }
  .approval-connector { margin: 11px -2px 0; }
}

.confirm-stepper-box { margin-bottom: 1.75rem; }
.confirm-stepper-box .approval-stepper { justify-content: center; }
