/* ============================================
   HR Dashboard Redesign - Design Tokens & Components
   Prefix: hrd- (HR Dashboard)
   Version: 2026-02-11
   ============================================ */

/* ---- 1. Design Tokens (scoped under .hrd-root) ---- */

.hrd-root {
  /* Spacing scale */
  --hrd-space-xs: 4px;
  --hrd-space-sm: 8px;
  --hrd-space-md: 12px;
  --hrd-space-lg: 16px;
  --hrd-space-xl: 24px;
  --hrd-space-2xl: 32px;

  /* Surface / border / text — aliased to global theme tokens so HR follows dark mode */
  --hrd-surface:         var(--card-bg);
  --hrd-surface-muted:   var(--bg-tertiary);
  --hrd-border:          var(--border-color);
  --hrd-text-primary:    var(--text-primary);
  --hrd-text-secondary:  var(--text-muted);
  --hrd-text-inverse:    #FFFFFF;

  /* Semantic alert colors */
  --hrd-alert-danger-bg: #FEF2F2;
  --hrd-alert-danger-border: #FCA5A5;
  --hrd-alert-danger-text: #991B1B;
  --hrd-alert-danger-icon: #DC2626;
  --hrd-alert-warning-border: #F59E0B;
  --hrd-alert-warning-text: #92400E;
  --hrd-alert-warning-subtext: #B45309;

  /* Radius */
  --hrd-radius-sm: 6px;
  --hrd-radius-md: 8px;
  --hrd-radius-lg: 12px;
  --hrd-radius-pill: 100px;

  /* Transitions */
  --hrd-transition: 200ms ease;
}


/* ---- 2. Loading Overlay ---- */

.hrd-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
}

.hrd-loading-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.hrd-loading-content {
  text-align: center;
}

.hrd-loading-content .loading-spinner {
  margin: 0 auto 16px;
}

.hrd-loading-text {
  color: var(--hrd-text-secondary);
  font-size: 14px;
}

.hrd-loading-host {
  position: relative;
  min-height: 400px;
}


/* ---- 3. Welcome Card Enhancements ---- */

.hrd-status-row {
  display: flex;
  align-items: center;
  gap: var(--hrd-space-sm);
  margin-top: var(--hrd-space-sm);
}

.hrd-status-label {
  font-size: 13px;
  opacity: 0.8;
}

.hrd-welcome-actions {
  display: flex;
  align-items: center;
  gap: var(--hrd-space-sm);
  flex-wrap: wrap;
}

/* Status dot for "In the Office" */
.hrd-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
  display: inline-block;
}

/* Status icon wrapper (active leave) */
.hrd-status-icon {
  display: inline-flex;
  align-items: center;
}


/* ---- 4. Button State Classes ---- */

/* Leave request locked */
.hrd-btn-blocked {
  background: var(--hrd-alert-danger-bg) !important;
  border-color: var(--hrd-alert-danger-border) !important;
  color: var(--hrd-alert-danger-text) !important;
}

/* Welcome card button default */
.hrd-btn-welcome-default {
  background: var(--card-bg);
  color: var(--hrd-text-primary);
}

/* Top bar button default (inherits base .btn styles) */
.hrd-btn-topbar-default {
  background: unset;
  border-color: unset;
  color: unset;
}

/* WFH button */
.hrd-btn-wfh {
  background: var(--tech-cyan, #06B6D4);
  border-color: var(--tech-cyan, #06B6D4);
  color: #FFFFFF;
  margin-left: var(--hrd-space-sm);
}


/* ---- 5. Banner Cards ---- */

/* Full-width banner spanning the grid */
.hrd-banner-card {
  grid-column: 1 / -1;
  border-radius: var(--hrd-radius-lg);
  padding: var(--hrd-space-lg);
}

/* Warning banner (letter signatures, training) */
.hrd-banner-warning {
  background: var(--alert-warning-bg);
  border: 2px solid var(--hrd-alert-warning-border);
}

.hrd-banner-warning-header {
  display: flex;
  align-items: center;
  gap: var(--hrd-space-md);
  margin-bottom: var(--hrd-space-lg);
}

.hrd-banner-warning-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.hrd-banner-warning-title {
  font-size: 16px;
  margin: 0;
  color: var(--hrd-alert-warning-text);
}

.hrd-banner-warning-subtitle {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: var(--hrd-alert-warning-subtext);
}

/* Danger banner (documentation required) */
.hrd-banner-danger {
  background: var(--hrd-alert-danger-bg);
  border: 1px solid var(--hrd-alert-danger-border);
  border-radius: var(--hrd-radius-lg);
  padding: var(--hrd-space-lg);
  margin-bottom: 20px;
}

.hrd-banner-danger-header {
  display: flex;
  align-items: flex-start;
  gap: var(--hrd-space-md);
  margin-bottom: var(--hrd-space-md);
}

.hrd-banner-danger-title {
  font-weight: 600;
  color: var(--hrd-alert-danger-icon);
  margin-bottom: 4px;
}

.hrd-banner-danger-body {
  color: var(--hrd-alert-danger-text);
  font-size: 13px;
}

.hrd-banner-danger-list {
  display: flex;
  flex-direction: column;
  gap: var(--hrd-space-md);
}


/* ---- 6. Documentation Items ---- */

.hrd-doc-item {
  background: var(--card-bg);
  border-radius: var(--hrd-radius-md);
  padding: var(--hrd-space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--hrd-space-md);
}

.hrd-doc-item-title {
  font-weight: 500;
  color: var(--text-primary);
}

.hrd-doc-item-dates {
  font-size: 12px;
  color: var(--text-muted);
}

.hrd-doc-item-deadline {
  font-size: 12px;
  margin-top: 4px;
  color: var(--hrd-alert-warning-text);
}

.hrd-doc-item-deadline--overdue {
  color: var(--hrd-alert-danger-icon);
  font-weight: 500;
}

.hrd-doc-item-actions {
  display: flex;
  gap: var(--hrd-space-sm);
}


/* ---- 7. Avatar Components ---- */

.hrd-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.hrd-avatar--initials {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-weight: 600;
  font-size: 14px;
}

.hrd-avatar--birthday {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
}

.hrd-avatar--anniversary {
  background: linear-gradient(135deg, #06B6D4 0%, #4FC3CA 100%);
}

.hrd-avatar--off {
  background: linear-gradient(135deg, #94A3B8 0%, #64748B 100%);
}

.hrd-leave-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--card-bg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* ---- 8. Date Labels & Person Items ---- */

.hrd-date-label {
  color: var(--text-muted);
  font-size: 12px;
}

.hrd-date-badge--today-birthday {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #FFFFFF;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.hrd-date-badge--today-anniversary {
  background: linear-gradient(135deg, #06B6D4 0%, #4FC3CA 100%);
  color: #FFFFFF;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.hrd-person-item {
  padding: 10px 8px 10px 0;
}

.hrd-person-item .info-item-content {
  min-width: 0;
}

.hrd-person-item .info-item-title {
  font-weight: 600;
}

.hrd-person-item .info-item-subtitle {
  color: var(--text-muted);
  font-size: 12px;
}

.hrd-person-date {
  text-align: right;
  flex-shrink: 0;
  padding-right: 4px;
}


/* ---- 9. Current Leave Highlight ---- */

.hrd-leave-current {
  background: var(--alert-warning-bg);
  border-left: 3px solid #F59E0B;
}


/* ---- 10. Skeleton Loading ---- */

@keyframes hrd-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

.hrd-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: hrd-shimmer 1.5s infinite;
  border-radius: var(--hrd-radius-sm);
}

.hrd-skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.hrd-skeleton-line--short {
  width: 50%;
}

.hrd-skeleton-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.hrd-skeleton-card {
  padding: var(--hrd-space-xl);
  border-radius: var(--hrd-radius-md);
  min-height: 120px;
}


/* ---- 11. Accessibility & Utilities ---- */

/* Focus ring for keyboard navigation */
.hrd-root :focus-visible {
  outline: 2px solid var(--amt-turquoise, #4FC3CA);
  outline-offset: 2px;
}

/* Screen reader only */
.hrd-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Hide element (replaces style="display:none") */
.hrd-hidden {
  display: none !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hrd-skeleton {
    animation: none;
  }
}

/* Upload document success button (used in documentation alert) */
.hrd-btn-success {
  background: #10B981;
  border-color: #10B981;
  color: #FFFFFF;
}

.hrd-btn-success:hover {
  background: #059669;
  border-color: #059669;
}


/* ============================================
   12. Visual Polish — Enhanced Design Layer
   Scoped under .hrd-root to avoid side effects
   ============================================ */

/* ---- 12A. Welcome Card Upgrade ---- */

.hrd-root .welcome-card {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--hrd-radius-lg);
  padding: 20px 24px;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.hrd-root .welcome-avatar {
  width: 56px;
  height: 56px;
  background: color-mix(in srgb, var(--amt-turquoise) 12%, var(--bg-tertiary));
  color: var(--text-primary);
  border: 1px solid color-mix(in srgb, var(--amt-turquoise) 28%, var(--border-light));
  box-shadow: none;
}

.hrd-root .welcome-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

/* Pulsing green dot for "In the Office" */
.hrd-status-dot {
  animation: hrd-pulse 2s ease-in-out infinite;
}

@keyframes hrd-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50% { opacity: 0.85; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
}

/* Welcome card buttons */
.hrd-root .hrd-welcome-actions .btn {
  border-radius: var(--hrd-radius-md);
  font-weight: 600;
  padding: 10px 18px;
  transition: background var(--hrd-transition), border-color var(--hrd-transition), color var(--hrd-transition);
}

.hrd-root .hrd-btn-welcome-default {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  backdrop-filter: none;
}

.hrd-root .hrd-btn-welcome-default:hover {
  background: var(--bg-hover);
  border-color: var(--border-medium);
}

.hrd-root .hrd-btn-wfh {
  border-color: color-mix(in srgb, var(--amt-turquoise) 40%, transparent);
}

.hrd-root .hrd-btn-wfh:hover {
  background: var(--amt-turquoise-dark);
  border-color: var(--amt-turquoise-dark);
}


/* ---- 12B. Cards — Shadows, Borders, Hover ---- */

.hrd-root .info-card,
.hrd-root .balance-card {
  border: 1px solid var(--hrd-border);
  border-radius: var(--hrd-radius-lg);
  background: var(--hrd-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: box-shadow var(--hrd-transition), transform var(--hrd-transition);
}

.hrd-root .info-card:hover,
.hrd-root .balance-card:hover {
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.06),
    0 10px 15px -3px rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

/* Card headings — refined */
.hrd-root .info-card h3,
.hrd-root .balance-card h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hrd-text-secondary);
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hrd-border);
}


/* ---- 12C. Info Items — Refined List Items ---- */

.hrd-root .info-item {
  padding: 10px 12px;
  background: var(--hrd-surface-muted);
  border-radius: var(--hrd-radius-md);
  margin-bottom: 6px;
  transition: background var(--hrd-transition);
}

.hrd-root .info-item:hover {
  background: var(--alert-info-bg);
}

.hrd-root .info-item:last-child {
  margin-bottom: 0;
}

.hrd-root .info-item-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--hrd-radius-md);
  border: 1px solid var(--hrd-border);
  background: var(--card-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.hrd-root .info-item-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--hrd-text-primary);
}

.hrd-root .info-item-subtitle {
  font-size: 12px;
  color: var(--hrd-text-secondary);
  margin-top: 1px;
}

/* Badges — pill shape with softer colors */
.hrd-root .info-item-badge {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--hrd-radius-pill);
  letter-spacing: 0.01em;
}


/* ---- 12D. Balance Card Polish ---- */

.hrd-root .balance-card {
  padding: 24px 28px;
}

.hrd-root .balance-number {
  font-size: 34px;
  font-weight: 800;
  color: var(--tech-green, #10B981);
}

.hrd-root .balance-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--hrd-text-secondary);
}

.hrd-root .balance-row {
  padding: 10px 0;
  font-size: 13.5px;
}

.hrd-root .balance-row.total {
  border-top: 2px solid var(--hrd-border);
  font-weight: 700;
}

.hrd-root .balance-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.hrd-root .balance-value {
  font-weight: 700;
  font-size: 14px;
}

.hrd-root .balance-footer {
  font-size: 12px;
  color: var(--hrd-text-secondary);
  opacity: 0.8;
}

/* ---- 12M. Leave balance — multi-segment donut (matches legend colours) ---- */

.hrd-root .balance-chart {
  position: relative;
  filter: drop-shadow(0 2px 10px rgba(15, 23, 42, 0.07));
}

.hrd-root .balance-donut-svg {
  display: block;
  color: var(--hrd-border);
}

.hrd-root .balance-track {
  opacity: 0.38;
}

.hrd-root .balance-arc {
  transition:
    stroke-dasharray 0.88s cubic-bezier(0.22, 1, 0.36, 1),
    stroke-dashoffset 0.88s cubic-bezier(0.22, 1, 0.36, 1),
    stroke-width 0.22s ease,
    opacity 0.22s ease;
}

.hrd-root .balance-chart--empty .balance-arc {
  opacity: 0;
}

.hrd-root .balance-center-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-top: 6px;
}

.hrd-root .balance-unit {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--hrd-text-secondary);
  line-height: 1.2;
}

.hrd-root .balance-label-line {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hrd-text-secondary);
  opacity: 0.88;
  line-height: 1.2;
}

/* Tap / click legend row → emphasise matching ring segment */
.hrd-root .balance-row--seg {
  cursor: pointer;
  margin-inline: -6px;
  padding-inline: 6px;
  border-radius: var(--hrd-radius-md);
  transition: background 0.2s ease;
  outline: none;
}

.hrd-root .balance-row--seg:focus-visible {
  box-shadow: 0 0 0 2px var(--amt-turquoise, #4fc3ca);
}

.hrd-root .balance-row--seg:hover {
  background: var(--hrd-surface-muted);
}

.hrd-root .balance-row--seg.balance-row--active {
  background: rgba(79, 195, 202, 0.12);
}

.hrd-root .balance-chart[data-focus-seg='taken'] .balance-arc--taken {
  stroke-width: 4.75;
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.35));
}

.hrd-root .balance-chart[data-focus-seg='taken'] .balance-arc:not(.balance-arc--taken) {
  opacity: 0.3;
}

.hrd-root .balance-chart[data-focus-seg='pending'] .balance-arc--pending {
  stroke-width: 4.75;
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.45));
}

.hrd-root .balance-chart[data-focus-seg='pending'] .balance-arc:not(.balance-arc--pending) {
  opacity: 0.3;
}

.hrd-root .balance-chart[data-focus-seg='remaining'] .balance-arc--remaining {
  stroke-width: 4.75;
  opacity: 1;
  filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.4));
}

.hrd-root .balance-chart[data-focus-seg='remaining'] .balance-arc:not(.balance-arc--remaining) {
  opacity: 0.3;
}

@media (hover: none) {
  .hrd-root .balance-row--seg:hover {
    background: transparent;
  }

  .hrd-root .balance-row--seg.balance-row--active:hover {
    background: rgba(79, 195, 202, 0.12);
  }
}


/* ---- 12E. Person Items (Birthdays / Anniversaries) ---- */

.hrd-root .hrd-person-item {
  padding: 10px 12px;
  border-radius: var(--hrd-radius-md);
  transition: background var(--hrd-transition);
}

.hrd-root .hrd-person-item:hover {
  background: var(--alert-success-bg);
}

.hrd-root .hrd-avatar {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 2px solid var(--card-bg);
}

/* Today badges — subtle glow */
.hrd-date-badge--today-birthday {
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.3);
}

.hrd-date-badge--today-anniversary {
  box-shadow: 0 1px 4px rgba(6, 182, 212, 0.3);
}


/* ---- 12F. Empty States — Nicer Visual ---- */

.hrd-root .empty-state {
  padding: 40px 24px;
  color: var(--hrd-text-secondary);
}

.hrd-root .empty-state svg {
  width: 40px;
  height: 40px;
  opacity: 0.3;
  margin-bottom: 12px;
  stroke-width: 1.2;
}

.hrd-root .empty-state div {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}


/* ---- 12G. Current Leave Highlight — Enhanced ---- */

.hrd-root .hrd-leave-current {
  background: var(--alert-warning-bg);
  border-left: 3px solid #F59E0B;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.08);
}


/* ---- 12H. Banner Polish ---- */

.hrd-root .hrd-banner-warning {
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.12);
}

.hrd-root .hrd-banner-danger {
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
}

.hrd-root .hrd-doc-item {
  border: 1px solid rgba(252, 165, 165, 0.2);
  transition: box-shadow var(--hrd-transition);
}

.hrd-root .hrd-doc-item:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}


/* ---- 12I. Button Polish ---- */

.hrd-root .hrd-btn-blocked {
  border-radius: var(--hrd-radius-md);
  transition: all var(--hrd-transition);
}

.hrd-root .hrd-btn-blocked:hover {
  background: var(--alert-danger-bg) !important;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
}

.hrd-root .hrd-btn-success {
  border-radius: var(--hrd-radius-md);
  font-weight: 600;
  transition: all var(--hrd-transition);
}

.hrd-root .hrd-btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.25);
}


/* ---- 12J. Dashboard Grid Spacing ---- */

.hrd-root .dashboard-grid {
  gap: 20px;
}


/* ---- 12K. Info List Scrollbar ---- */

.hrd-root .info-list {
  scrollbar-width: thin;
  scrollbar-color: var(--hrd-border) transparent;
}

.hrd-root .info-list::-webkit-scrollbar {
  width: 4px;
}

.hrd-root .info-list::-webkit-scrollbar-track {
  background: transparent;
}

.hrd-root .info-list::-webkit-scrollbar-thumb {
  background: var(--hrd-border);
  border-radius: var(--hrd-radius-pill);
}

.hrd-root .info-list::-webkit-scrollbar-thumb:hover {
  background: var(--border-medium);
}


/* ---- 12L. Reduced Motion — Disable all visual polish transitions ---- */

@media (prefers-reduced-motion: reduce) {
  .hrd-root .info-card,
  .hrd-root .balance-card,
  .hrd-root .info-item,
  .hrd-root .hrd-person-item,
  .hrd-root .hrd-doc-item,
  .hrd-root .hrd-btn-success,
  .hrd-root .hrd-btn-blocked,
  .hrd-root .hrd-welcome-actions .btn {
    transition: none;
  }

  .hrd-root .info-card:hover,
  .hrd-root .balance-card:hover,
  .hrd-root .hrd-btn-welcome-default:hover,
  .hrd-root .hrd-btn-wfh:hover,
  .hrd-root .hrd-btn-success:hover {
    transform: none;
  }

  .hrd-status-dot {
    animation: none;
  }

  .hrd-root .balance-arc {
    transition: none;
  }
}


/* ============================================
   13. Inline Style Replacements
   ============================================ */

/* Balance dot colors (replace inline style="background: var(--tech-*)") */
.hrd-dot-remaining { background: var(--tech-green, #5DBB63); }
.hrd-dot-taken { background: var(--tech-blue, #3B82F6); }
.hrd-dot-pending { background: var(--tech-yellow, #F59E0B); }

/* Heading icon alignment (replace inline style on SVGs in card h3) */
.hrd-heading-icon {
  vertical-align: -4px;
  margin-right: 8px;
}


/* ============================================
   14. Mobile Responsive — Dashboard Layout
   ============================================ */

/* ---- 14A. Tablet (≤ 900px) ---- */
@media (max-width: 900px) {
  .hrd-root .dashboard-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

/* ---- 14B. Mobile (≤ 640px) ---- */
@media (max-width: 640px) {
  /* Welcome card — left-aligned, stacked buttons */
  .hrd-root .welcome-card {
    padding: 20px;
    text-align: left;
  }

  .hrd-root .welcome-left {
    flex-direction: row;
  }

  .hrd-root .hrd-welcome-actions {
    width: 100%;
    flex-direction: column;
  }

  .hrd-root .hrd-welcome-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .hrd-root .hrd-btn-wfh {
    margin-left: 0;
  }

  /* Balance card — vertical stack */
  .hrd-root .balance-content {
    flex-direction: column;
    gap: 20px;
  }

  .hrd-root .balance-chart {
    width: 136px;
    height: 136px;
    margin: 0 auto;
  }

  .hrd-root .balance-number {
    font-size: 32px;
  }

  .hrd-root .balance-unit {
    font-size: 10px;
  }

  /* Dashboard grid — single column */
  .hrd-root .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Cards — compact padding, no hover transform */
  .hrd-root .info-card,
  .hrd-root .balance-card {
    padding: 18px;
  }

  .hrd-root .info-card:hover,
  .hrd-root .balance-card:hover {
    transform: none;
  }

  /* Touch-friendly list items (44px min) */
  .hrd-root .info-item {
    min-height: 44px;
    padding: 10px 12px;
  }

  .hrd-root .hrd-person-item {
    min-height: 44px;
  }

  /* Date badges — prevent overflow */
  .hrd-root .hrd-person-date {
    white-space: nowrap;
  }
}

/* ---- 14C. Small mobile (≤ 400px) ---- */
@media (max-width: 400px) {
  .hrd-root .welcome-card {
    padding: 16px;
  }

  .hrd-root .welcome-name {
    font-size: 18px;
  }

  .hrd-root .welcome-avatar {
    width: 44px;
    height: 44px;
  }

  .hrd-root .info-card,
  .hrd-root .balance-card {
    padding: 14px;
    border-radius: var(--hrd-radius-md);
  }
}

/* ============================================
   15. Sheet modals (leave + WFH) — range calendar & mobile layout
   ============================================ */

.hr-sheet-modal {
  width: min(520px, calc(100vw - 24px));
  max-height: min(92dvh, 920px);
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--hrd-radius-lg);
  overflow: hidden;
  box-shadow:
    0 25px 50px -12px rgba(15, 23, 42, 0.25),
    0 0 0 1px rgba(15, 23, 42, 0.04);
}

.hr-sheet-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
}

.leave-modal-shell {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  min-height: 0;
}

.hr-sheet-modal .leave-modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.hr-sheet-modal .leave-modal-header {
  flex-shrink: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--card-bg) 0%, var(--bg-tertiary) 100%);
  align-items: flex-start;
  gap: 12px;
}

.leave-modal-heading {
  flex: 1;
  min-width: 0;
}

.leave-modal-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-family: inherit;
}

.leave-modal-subtitle {
  margin: 6px 0 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.hr-sheet-modal .leave-modal-close {
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  border-radius: var(--hrd-radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hr-sheet-modal .leave-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: none;
  padding: 18px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}

.hr-sheet-modal .leave-modal-footer {
  flex-shrink: 0;
  padding: 14px 20px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  gap: 10px;
  justify-content: stretch;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.hr-sheet-modal .leave-modal-footer .btn,
.hr-sheet-modal .leave-modal-footer .btn-secondary {
  flex: 1;
  min-height: 48px;
  font-weight: 600;
  border-radius: var(--hrd-radius-md);
  touch-action: manipulation;
}

.leave-modal-btn-primary {
  background: var(--amt-turquoise, #4fc3ca);
  border-color: var(--amt-turquoise, #4fc3ca);
  color: #fff;
}

.leave-modal-btn-primary:hover {
  filter: brightness(0.95);
}

.leave-field-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.leave-req {
  color: var(--status-error, #dc2626);
}

.leave-req-muted {
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-muted);
}

.leave-field-tight {
  margin-bottom: 16px;
}

.hr-sheet-modal .leave-input,
.hr-sheet-modal textarea.input {
  min-height: 48px;
  font-size: 16px;
  border-radius: var(--hrd-radius-md);
  border: 1px solid var(--border-color);
  touch-action: manipulation;
}

.hr-sheet-modal textarea.input {
  min-height: 100px;
  resize: vertical;
}

.leave-field-group {
  margin-bottom: 18px;
}

.leave-range-hint {
  margin: 0 0 12px 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.leave-range-chips {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 14px;
}

.leave-range-chip {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--hrd-radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.leave-range-chip--from {
  border-color: rgba(79, 195, 202, 0.45);
  box-shadow: inset 0 0 0 1px rgba(79, 195, 202, 0.12);
}

.leave-range-chip--to {
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.08);
}

.leave-range-chip-kicker {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.leave-range-chip-date {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.leave-range-arrow {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.leave-range-calendar-stack {
  border-radius: var(--hrd-radius-lg);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  overflow: hidden;
}

.leave-range-calendar-stack .leave-range-calendar-host {
  border: none;
  border-radius: 0;
  background: transparent;
}

.leave-cal-live-summary {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(79, 195, 202, 0.07);
}

.leave-cal-live-summary-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.leave-cal-live-summary-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.leave-cal-live-summary-value {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--tech-blue);
  line-height: 1.15;
  min-width: 2.5ch;
  text-align: right;
  flex-shrink: 0;
}

.leave-cal-live-summary-sub {
  margin: 6px 0 0;
  padding: 0;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--alert-warning-text);
}

.leave-range-calendar-host {
  border-radius: var(--hrd-radius-lg);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  overflow: hidden;
}

.leave-cal {
  padding: 12px 12px 14px;
}

.leave-cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.leave-cal-title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text-primary);
  flex: 1;
  text-align: center;
}

.leave-cal-nav {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--hrd-radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--hrd-transition);
  touch-action: manipulation;
}

.leave-cal-nav:hover {
  background: var(--bg-hover);
}

.leave-cal-nav:focus-visible {
  outline: 2px solid var(--amt-turquoise, #4fc3ca);
  outline-offset: 2px;
}

.leave-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}

.leave-cal-wd {
  text-align: center;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 4px 0;
}

.leave-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.leave-cal-slot--pad {
  min-height: 44px;
}

.leave-cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  min-height: 44px;
  border: none;
  border-radius: var(--hrd-radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
}

.leave-cal-day-num {
  line-height: 1.15;
}

.leave-cal-day-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  align-items: center;
  min-height: 7px;
}

.leave-cal-badge {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.leave-cal-badge--weekend-off {
  background: rgba(148, 163, 184, 0.95);
}

.leave-cal-badge--holiday {
  background: var(--alert-warning-text, #d97706);
}

.leave-cal-badge--substituted {
  background: #a855f7;
}

.leave-cal-badge--wwd {
  width: 5px;
  height: 5px;
  background: transparent;
  border: 2px solid #16a34a;
}

.leave-cal-day--weekend-off:not(.leave-cal-day--start):not(.leave-cal-day--end):not(.leave-cal-day--single):not(.leave-cal-day--in-range) {
  background: rgba(148, 163, 184, 0.14);
}

.leave-cal-day--weekend-off.leave-cal-day--in-range:not(.leave-cal-day--start):not(.leave-cal-day--end) {
  background: rgba(79, 195, 202, 0.22);
}

.leave-cal-day--substituted:not(.leave-cal-day--start):not(.leave-cal-day--end):not(.leave-cal-day--single):not(.leave-cal-day--in-range) {
  box-shadow: inset 0 0 0 1px rgba(168, 85, 247, 0.45);
}

.leave-cal-day--bank-holiday:not(.leave-cal-day--start):not(.leave-cal-day--end):not(.leave-cal-day--single):not(.leave-cal-day--in-range) {
  box-shadow: inset 0 0 0 2px rgba(217, 119, 6, 0.55);
}

.leave-cal-day--holiday-cal:not(.leave-cal-day--bank-holiday):not(.leave-cal-day--start):not(.leave-cal-day--end):not(.leave-cal-day--single):not(.leave-cal-day--in-range) {
  box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.28);
}

.leave-cal-day--start .leave-cal-badge--weekend-off,
.leave-cal-day--end .leave-cal-badge--weekend-off,
.leave-cal-day--single .leave-cal-badge--weekend-off {
  background: rgba(255, 255, 255, 0.92);
}

.leave-cal-day--start .leave-cal-badge--holiday,
.leave-cal-day--end .leave-cal-badge--holiday,
.leave-cal-day--single .leave-cal-badge--holiday {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.9);
}

.leave-cal-day--start .leave-cal-badge--substituted,
.leave-cal-day--end .leave-cal-badge--substituted,
.leave-cal-day--single .leave-cal-badge--substituted {
  background: #fae8ff;
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.85);
}

.leave-cal-day--start .leave-cal-badge--wwd,
.leave-cal-day--end .leave-cal-badge--wwd,
.leave-cal-day--single .leave-cal-badge--wwd {
  border-color: rgba(220, 252, 231, 0.95);
}

.leave-cal-legend {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.leave-cal-legend-title {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.leave-cal-legend-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leave-cal-legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.leave-cal-legend-note {
  margin: 8px 0 0;
  line-height: 1.35;
}

.leave-cal-day:hover {
  background: var(--bg-hover);
}

.leave-cal-day--today:not(.leave-cal-day--start):not(.leave-cal-day--end):not(.leave-cal-day--single) {
  box-shadow: inset 0 0 0 2px var(--amt-turquoise, #4fc3ca);
}

.leave-cal-day--in-range {
  background: rgba(79, 195, 202, 0.18);
  color: var(--text-primary);
  border-radius: 0;
}

.leave-cal-day--start,
.leave-cal-day--end {
  background: var(--amt-turquoise, #4fc3ca);
  color: #fff;
}

.leave-cal-day--start.leave-cal-day--in-range {
  border-radius: var(--hrd-radius-sm) 0 0 var(--hrd-radius-sm);
}

.leave-cal-day--end.leave-cal-day--in-range {
  border-radius: 0 var(--hrd-radius-sm) var(--hrd-radius-sm) 0;
}

.leave-cal-day--single {
  background: linear-gradient(135deg, var(--amt-turquoise, #4fc3ca) 0%, #3b82f6 100%);
  color: #fff;
  border-radius: var(--hrd-radius-md);
}

.leave-cal-day:focus-visible {
  outline: 2px solid var(--tech-blue);
  outline-offset: 2px;
  z-index: 1;
}

.leave-half-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 420px) {
  .leave-half-grid {
    grid-template-columns: 1fr;
  }
}

.leave-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--hrd-radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  min-height: 48px;
  touch-action: manipulation;
}

.leave-check input {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.leave-days-calc {
  padding: 14px 16px !important;
  border-radius: var(--hrd-radius-lg) !important;
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(79, 195, 202, 0.08) 100%) !important;
  border: 1px solid var(--border-color) !important;
  margin-bottom: 16px !important;
}

.leave-request-holiday-info {
  margin-top: 10px;
}

/* WFH sheet modal — cyan accents & disabled past dates */
.wfh-modal-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wfh-modal-icon {
  display: inline-flex;
  color: #06b6d4;
  flex-shrink: 0;
}

.wfh-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.wfh-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  touch-action: manipulation;
}

.wfh-days-calc.wfh-days-calc {
  background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%) !important;
  border-color: rgba(34, 211, 238, 0.45) !important;
}

html[data-theme="dark"] .wfh-days-calc.wfh-days-calc {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.14) 0%, rgba(8, 145, 178, 0.1) 100%) !important;
  border-color: rgba(34, 211, 238, 0.22) !important;
}

.wfh-days-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.wfh-days-number {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #0891b2;
}

html[data-theme="dark"] .wfh-days-number {
  color: #22d3ee;
}

.wfh-weekend-note {
  margin-top: 8px;
  font-size: 0.75rem;
  line-height: 1.4;
  align-items: flex-start;
  gap: 6px;
  color: #0e7490;
}

html[data-theme="dark"] .wfh-weekend-note {
  color: var(--text-muted);
}

.wfh-modal-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #06b6d4 !important;
  border-color: #06b6d4 !important;
  color: #fff !important;
}

.wfh-modal-btn-primary:hover {
  filter: brightness(0.95);
}

.wfh-modal-v2 .leave-range-chip--from.wfh-range-chip--from {
  border-color: rgba(6, 182, 212, 0.45);
  box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.12);
}

.wfh-modal-v2 .leave-range-chip--to.wfh-range-chip--to {
  border-color: rgba(8, 145, 178, 0.4);
  box-shadow: inset 0 0 0 1px rgba(8, 145, 178, 0.1);
}

.wfh-modal-v2 .leave-cal-day--start,
.wfh-modal-v2 .leave-cal-day--end {
  background: #06b6d4;
  color: #fff;
}

.wfh-modal-v2 .leave-cal-day--in-range {
  background: rgba(6, 182, 212, 0.22);
}

.wfh-modal-v2 .leave-cal-day--single {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.wfh-modal-v2 .leave-cal-day--today:not(.leave-cal-day--start):not(.leave-cal-day--end):not(.leave-cal-day--single) {
  box-shadow: inset 0 0 0 2px #06b6d4;
}

.leave-cal-day--disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .leave-cal-day,
  .leave-cal-nav {
    transition: none;
  }
}

/* ============================================
   Training section — segmented sub-tabs (Company / Requests)
   ============================================ */

#section-training .training-subtabs {
  display: flex;
  width: 100%;
  gap: 6px;
  padding: 5px;
  margin-bottom: 22px;
  box-sizing: border-box;
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: 14px;
}

#section-training .training-subtab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  margin: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.25;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
  touch-action: manipulation;
}

#section-training .training-subtab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.55);
}

#section-training .training-subtab.active {
  background: var(--card-bg);
  color: var(--text-main);
  box-shadow:
    inset 0 0 0 1px rgba(79, 195, 202, 0.35),
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 4px 14px rgba(15, 23, 42, 0.07);
}

html[data-theme='dark'] #section-training .training-subtab:hover {
  background: rgba(255, 255, 255, 0.07);
}

html[data-theme='dark'] #section-training .training-subtab.active {
  box-shadow:
    inset 0 0 0 1px rgba(79, 195, 202, 0.4),
    0 2px 16px rgba(0, 0, 0, 0.45);
}

#section-training .training-subtab:focus-visible {
  outline: 2px solid var(--amt-turquoise, #4fc3ca);
  outline-offset: 2px;
}

#section-training .training-subtab-badge.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  #section-training .training-subtab {
    transition: none;
  }
}

/* Training request modal — range calendar accent (matches WFH cyan) */
.training-modal-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #06b6d4 !important;
  border-color: #06b6d4 !important;
  color: #fff !important;
}

.training-modal-btn-primary:hover {
  filter: brightness(0.95);
}

.training-request-modal-v2 .leave-range-chip--from.training-range-chip--from {
  border-color: rgba(6, 182, 212, 0.45);
  box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.12);
}

.training-request-modal-v2 .leave-range-chip--to.training-range-chip--to {
  border-color: rgba(8, 145, 178, 0.4);
  box-shadow: inset 0 0 0 1px rgba(8, 145, 178, 0.1);
}

.training-request-modal-v2 .leave-cal-day--start,
.training-request-modal-v2 .leave-cal-day--end {
  background: #06b6d4;
  color: #fff;
}

.training-request-modal-v2 .leave-cal-day--in-range {
  background: rgba(6, 182, 212, 0.22);
}

.training-request-modal-v2 .leave-cal-day--single {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.training-request-modal-v2 .leave-cal-day--today:not(.leave-cal-day--start):not(.leave-cal-day--end):not(.leave-cal-day--single) {
  box-shadow: inset 0 0 0 2px #06b6d4;
}
