:root {
  --bg: #ffffff;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #252525;
  --charcoal: #252525;
  --muted: #4a4a4a;
  --primary: #f47b20;
  --primary-dark: #e06a0f;
  --primary-text: #c2410c;
  --accent: #f47b20;
  --stride-orange: #f47b20;
  --stride-green: #00a86b;
  --success: #00a86b;
  --danger: #dc2626;
  --warn: #f47b20;
  --warn-text: #b45309;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 24px rgba(16, 24, 40, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--charcoal);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.topbar .brand span { font-size: 20px; }
.topbar .user-area { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar .role-badge {
  background: rgba(255,255,255,0.15);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: capitalize;
}
.topbar button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
}
.topbar button:hover { background: rgba(255,255,255,0.1); }

.nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 9;
  overflow-x: auto;
}
.nav .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
}
.nav a {
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--primary-text); border-bottom-color: var(--primary); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  background: var(--primary);
  color: var(--charcoal);
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f9fafb; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid rgba(249, 115, 22, 0.25);
  border-color: var(--primary);
}
.textarea { min-height: 90px; resize: vertical; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.open { background: #fef3c7; color: #b45309; }
.badge.in_progress { background: #eff6ff; color: #1d4ed8; }
.badge.filed { background: #fff7ed; color: #c2410c; }
.badge.waived { background: #f3f4f6; color: #6b7280; }
.badge.cancelled { background: #f3f4f6; color: #6b7280; }
.badge.overdue { background: #fee2e2; color: #b91c1c; }
.badge.todo { background: #f3f4f6; color: #4b5563; }
.badge.done { background: #fff7ed; color: #c2410c; }
.badge.draft { background: #f3f4f6; color: #4b5563; }
.badge.sent { background: #eff6ff; color: #1d4ed8; }
.badge.accepted { background: #fff7ed; color: #c2410c; }
.badge.declined { background: #fee2e2; color: #b91c1c; }
.badge.expired { background: #f3f4f6; color: #6b7280; }
.badge.terminated { background: #f3f4f6; color: #6b7280; }
.badge.issued { background: #eff6ff; color: #1d4ed8; }
.badge.partially_paid { background: #fef3c7; color: #b45309; }
.badge.paid { background: #fff7ed; color: #c2410c; }
.badge.active { background: #fff7ed; color: #c2410c; }
.badge.inactive { background: #f3f4f6; color: #6b7280; }
.badge.on_leave { background: #fef3c7; color: #b45309; }
.badge.part_time { background: #eff6ff; color: #1d4ed8; }
.badge.low { background: #f3f4f6; color: #4b5563; }
.badge.medium { background: #eff6ff; color: #1d4ed8; }
.badge.high { background: #fef3c7; color: #b45309; }
.badge.urgent { background: #fee2e2; color: #b91c1c; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
}
table.data td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f9fafb; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.danger .num { color: var(--danger); }
.stat.warn .num { color: var(--warn-text); }
.stat.primary .num { color: var(--primary-text); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 130px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .icon { font-size: 38px; margin-bottom: 10px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px; flex-wrap: wrap; }
.tabs button {
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.tabs button.active { background: var(--primary); color: var(--charcoal); }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; margin-bottom: 8px; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; }

.meter { background: #e5e7eb; border-radius: 999px; height: 8px; width: 100%; overflow: hidden; }
.meter > div { height: 100%; background: var(--primary); border-radius: 999px; }
.meter.hot > div { background: var(--danger); }
.meter.warm > div { background: var(--warn); }

.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.staff-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); cursor: pointer; }
.staff-card:hover { border-color: var(--primary); }
.staff-card h3 { margin: 0 0 4px; font-size: 15px; }
.staff-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.staff-card .kv { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.staff-card .kv b { font-weight: 600; }

.letter-doc { white-space: pre-wrap; font-size: 14px; line-height: 1.7; max-width: 720px; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: #4b5563; }

.check-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0; }
.pill-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 6px 12px; border-radius: 999px;
  background: #f3f4f6; color: #1f2937; cursor: pointer; user-select: none;
}
.pill-check input { margin: 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; padding: 22px; position: relative;
}
.modal.wide { max-width: 760px; }
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal .close {
  position: absolute; top: 14px; right: 14px; background: none; border: none;
  font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1;
}
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert.error { background: #fee2e2; color: #b91c1c; }
.alert.warn { background: #fef3c7; color: #92400e; }
.alert.success { background: #fff7ed; color: #c2410c; }

.due { font-weight: 600; }
.due-overdue { color: var(--danger); }
.due-soon { color: var(--warn-text); }
.due-future { color: var(--primary-text); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--charcoal); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.auth-wrap { max-width: 420px; margin: 48px auto; position: relative; z-index: 30; }
.auth-wrap .brand-big { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-wrap .brand-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 24px; }

/* Stride logo */
.brand-img {
  height: 30px;
  width: auto;
  display: block;
  object-fit: contain;
}
.brand-big-img {
  height: 46px;
  width: auto;
  max-width: 100%;
  margin: 0 auto 8px;
  display: block;
  object-fit: contain;
}

/* Animated login box */
.login-box {
  position: relative;
  width: 100%;
  min-height: 380px;
  background: #1c1c1c;
  border-radius: 8px;
  overflow: hidden;
}
.login-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 100%;
  height: 100%;
  background: linear-gradient(0deg, transparent, var(--accent), var(--accent));
  transform-origin: bottom right;
  animation: loginSpin 6s linear infinite;
}
.login-glow--delay { animation-delay: -3s; }
@keyframes loginSpin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.login-inner {
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  background: #28292d;
  z-index: 10;
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
}
.login-inner h2 {
  color: var(--accent);
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.08em;
  margin: 0 0 24px;
}
.inputBox {
  position: relative;
  width: 100%;
  margin-top: 28px;
}
.inputBox input {
  position: relative;
  width: 100%;
  padding: 18px 8px 8px;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1em;
  letter-spacing: 0.04em;
  z-index: 10;
}
.inputBox span {
  position: absolute;
  left: 0;
  padding: 18px 0 8px;
  font-size: 1em;
  color: #8f8f8f;
  pointer-events: none;
  letter-spacing: 0.04em;
  transition: 0.4s;
}
.inputBox input:valid ~ span,
.inputBox input:focus ~ span {
  color: var(--accent);
  transform: translateY(-28px);
  font-size: 0.75em;
}
.inputBox i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  border-radius: 4px;
  transition: 0.4s;
  pointer-events: none;
}
.inputBox input:valid ~ i,
.inputBox input:focus ~ i {
  height: 40px;
}
.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}
.login-links a {
  font-size: 0.8em;
  color: #8f8f8f;
  text-decoration: none;
}
.login-links a:hover { color: var(--accent); }
.login-submit {
  border: none;
  outline: none;
    background: var(--accent);
    color: var(--charcoal);
    padding: 11px 25px;
  width: 100%;
  margin-top: 16px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 1em;
  cursor: pointer;
  transition: opacity 0.2s;
}
.login-submit:active { opacity: 0.8; }

/* ---------------------------------------------------------------------------
   Enlarge Gallery login backdrop (React / @wethegit/react-gallery)
   --------------------------------------------------------------------------- */

#backdrop-root {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: var(--charcoal);
  overflow: hidden;
}
#backdrop-root #gallery-root { height: 100%; }
#backdrop-root .root {
  --thumb-scale: 0.11;
  --thumb-gap: 14px;
  --thumb-bottom: 28px;
  --zoom-duration: 0.8s;
  --zoom-ease: cubic-bezier(0.22, 1, 0.36, 1);

  background: var(--charcoal);
  color: #fff;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  font-family: system-ui, sans-serif;
}
#backdrop-root .gallery { height: 100%; }
#backdrop-root .track { height: 100%; overflow: visible !important; }
#backdrop-root .item {
  inset: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  transform: none !important;
  width: auto !important;
}
#backdrop-root .item[data-active="true"] { z-index: 1 !important; }
#backdrop-root .item[data-active="false"] { z-index: 10 !important; }
#backdrop-root .slide {
  border-radius: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: auto;
  position: absolute;
  transform: translate(0, 0) scale(1);
  transition:
    transform var(--zoom-duration) var(--zoom-ease),
    border-radius var(--zoom-duration) var(--zoom-ease),
    filter 0.25s ease;
  will-change: transform;
}
#backdrop-root .item[data-active="false"] .slide {
  border-radius: 48px;
  filter: brightness(0.7);
  transform: translate(
      calc(var(--offset) * (var(--thumb-scale) * 100vw + var(--thumb-gap))),
      calc((50vh - var(--thumb-scale) * 50vh) - var(--thumb-bottom))
    )
    scale(var(--thumb-scale));
}
#backdrop-root .item[data-active="false"] .slide:hover { filter: brightness(1); }
#backdrop-root .image {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}
#backdrop-root .thumbButton {
  appearance: none;
  background: none;
  border: 0;
  cursor: pointer;
  inset: 0;
  padding: 0;
  position: absolute;
}
#backdrop-root .rail {
  align-items: flex-start;
  background: linear-gradient(90deg, rgb(0 0 0 / 60%), transparent);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  inset: 0 auto 0 0;
  justify-content: center;
  max-width: min(520px, 70%);
  padding: 0 3.5rem 0 3rem;
  pointer-events: none;
  position: absolute;
  z-index: 5;
}
#backdrop-root .content {
  animation: gallery-content-in 0.6s var(--zoom-ease) calc(var(--zoom-duration) * 0.4) backwards;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
@keyframes gallery-content-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}
#backdrop-root .kicker {
  font-size: 0.8rem;
  margin: 0;
  opacity: 0.7;
}
#backdrop-root .title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.05;
  margin: 0;
}
#backdrop-root .description {
  color: rgb(255 255 255 / 85%);
  font-size: clamp(0.9rem, 1.4vw, 1.05rem);
  line-height: 1.6;
  margin: 0;
}
#backdrop-root .controls {
  display: flex;
  gap: 0.75rem;
  pointer-events: auto;
}
#backdrop-root .navBtn {
  align-items: center;
  appearance: none;
  backdrop-filter: blur(8px);
  background: rgb(255 255 255 / 10%);
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  height: 3rem;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
  width: 3rem;
}
#backdrop-root .navBtn:hover:not(:disabled) {
  background: rgb(255 255 255 / 22%);
  border-color: rgb(255 255 255 / 40%);
}
#backdrop-root .navBtn:disabled {
  cursor: default;
  opacity: 0.35;
}
#backdrop-root .visuallyHidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

@media (width <= 640px) {
  #backdrop-root .root {
    --thumb-scale: 0.16;
    --thumb-gap: 10px;
    --thumb-bottom: 20px;
  }
  #backdrop-root .rail {
    max-width: 90%;
    padding: 0 1.5rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  #backdrop-root .slide { transition: none; }
  #backdrop-root .content { animation: none; }
}

body.has-backdrop .auth-wrap .brand-big {
  color: #fff;
  text-shadow: 0 0 22px rgba(255, 255, 255, 0.5);
}
body.has-backdrop .auth-wrap .brand-sub { color: rgba(255, 255, 255, 0.8); }
body.has-backdrop .auth-wrap .login-inner {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
body.has-backdrop .auth-wrap .login-box {
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.5);
}
body.has-backdrop .auth-wrap .login-inner h2 { color: #fff; }
body.has-backdrop .auth-wrap .login-links a { color: #f9a25c; }
body.has-backdrop .auth-wrap .alert.error { background: rgba(185, 28, 28, 0.35); color: #fecaca; }

.back-link { display: inline-block; margin-bottom: 14px; font-size: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }

.export-group { display: inline-flex; gap: 4px; }
.export-group .btn { font-size: 11px; padding: 3px 8px; opacity: 0.7; }
.export-group .btn:hover { opacity: 1; }

/* ---------------------------------------------------------------------------
   Document auto-fill
   --------------------------------------------------------------------------- */

.af-hint { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.af-upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.af-upload input[type=file] {
  flex: 1;
  min-width: 200px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.af-group { margin: 16px 0; }
.af-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.af-group-head input { margin: 0; }
.af-row {
  display: grid;
  grid-template-columns: 20px 190px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
}
.af-row input { margin: 0; }
.af-k { color: var(--muted); font-weight: 600; }
.af-v { color: var(--text); word-break: break-word; }
.af-item {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: baseline;
  padding: 7px 0 7px 26px;
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
}
.af-item b { min-width: 160px; }
.af-item span { color: var(--muted); }

@media (max-width: 560px) {
  .af-row { grid-template-columns: 20px 1fr; }
  .af-v { grid-column: 2; }
}
