/* ── Button ───────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
  height: 36px;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-ghost {
  color: var(--color-text-secondary);
}
.btn-ghost:hover { background: var(--color-bg-secondary); color: var(--color-text-primary); }

.btn-danger {
  background: var(--color-error);
  color: var(--color-on-accent);
}
.btn-danger:hover { filter: brightness(0.94); }

.btn-sm { height: 30px; padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { height: 42px; padding: var(--space-3) var(--space-6); font-size: var(--text-base); }
.btn-block { width: 100%; }

/* ── Segmented control ────────────────────────
   A pill group of mutually-exclusive toggles (grain, dimension, tabs).
   Reads as one control, not a row of loose buttons. */
.seg {
  display: inline-flex;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn:hover { color: var(--color-text-primary); }
.seg-btn.is-active {
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Control bar ──────────────────────────────
   Labeled clusters of filters/toggles that wrap cleanly on mobile. */
.control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
}
.control-group { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.control-group.grow { flex: 1; min-width: 0; }
/* Keep a control bar on one straight line; scroll horizontally if cramped. */
.control-bar.nowrap { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.control-bar.nowrap::-webkit-scrollbar { display: none; }
.control-bar.nowrap .control-group { flex-wrap: nowrap; flex-shrink: 0; }
.control-label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* ── Input ────────────────────────────────── */
.form-group { margin-bottom: var(--space-4); }

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
}

.form-input {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  height: 38px;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.form-input::placeholder { color: var(--color-text-tertiary); }

.form-input-error { border-color: var(--color-error); }
.form-input-error:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1); }

textarea.form-input { height: auto; min-height: 80px; resize: vertical; }
select.form-input { cursor: pointer; }

.form-input-sm {
  height: 30px;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

.form-error-text {
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: var(--space-1);
}

/* ── Table ────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: var(--font-weight-medium);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-primary);
  vertical-align: middle;
}

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

.table tbody tr { background: var(--color-bg); transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--color-bg-secondary); }

/* ── Card ─────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.card-body { padding: var(--space-4) var(--space-5); }

.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

/* ── Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: var(--space-4);
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--text-lg);
  transition: background var(--transition-fast);
}
.modal-close:hover { background: var(--color-bg-secondary); }

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* ── Toast ────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-text-primary);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.toast-success .toast-dot { background: var(--color-success); }
.toast-error .toast-dot { background: var(--color-error); }
.toast-info .toast-dot { background: var(--color-accent); }

/* ── Badge ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
}

.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-success .badge-dot { background: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-warning .badge-dot { background: var(--color-warning); }
.badge-error { background: var(--color-error-light); color: var(--color-error); }
.badge-error .badge-dot { background: var(--color-error); }
.badge-info { background: var(--color-info-light); color: var(--color-info); }
.badge-info .badge-dot { background: var(--color-info); }
.badge-neutral { background: var(--color-bg-tertiary); color: var(--color-text-secondary); }
.badge-neutral .badge-dot { background: var(--color-text-tertiary); }

/* ── Empty State ──────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
  text-align: center;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-xl);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-4);
}

.empty-state-icon svg { width: 24px; height: 24px; }

.empty-state-title {
  font-size: var(--text-md);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  max-width: 360px;
  margin-bottom: var(--space-5);
}

/* ── Stat Card ────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  line-height: 1;
}

/* ── Loading Skeleton ─────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg-tertiary) 25%, var(--color-bg-secondary) 50%, var(--color-bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text { height: 14px; margin-bottom: var(--space-2); }
.skeleton-heading { height: 24px; width: 60%; margin-bottom: var(--space-4); }
.skeleton-avatar { width: 32px; height: 32px; border-radius: var(--radius-full); }

/* ── Avatar ───────────────────────────────── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-inverse);
  flex-shrink: 0;
}

.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar-xl { width: 56px; height: 56px; font-size: var(--text-lg); }

/* ── Dropdown ─────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: var(--space-1);
  z-index: 50;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

/* ── Tabs ─────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}

.tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.tab:hover { color: var(--color-text-primary); }

.tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* ── Search Results ──────────────────────── */
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 60;
}

.search-section { padding: var(--space-2) 0; }
.search-section + .search-section { border-top: 1px solid var(--color-border-light); }

.search-section-title {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  padding: var(--space-1) var(--space-4);
}

.search-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.search-item:hover, .search-item.active { background: var(--color-bg-secondary); }
.search-item svg { color: var(--color-text-tertiary); flex-shrink: 0; }
.search-item-title { font-size: var(--text-sm); font-weight: var(--font-weight-medium); color: var(--color-text-primary); }
.search-item-sub { font-size: var(--text-xs); color: var(--color-text-secondary); }

.search-empty {
  padding: var(--space-4);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

/* ── Notification Panel ──────────────────── */
.notif-panel {
  position: absolute;
  top: calc(var(--topbar-height) - 4px);
  right: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 360px;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.notif-panel-header span {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
}

.notif-list {
  overflow-y: auto;
  flex: 1;
}

.notif-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.notif-item:hover { background: var(--color-bg-secondary); }
.notif-item.unread { background: var(--color-accent-light); }
.notif-item.unread:hover { background: var(--color-info-light); }

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: var(--text-sm); font-weight: var(--font-weight-medium); color: var(--color-text-primary); }
.notif-body { font-size: var(--text-xs); color: var(--color-text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 10px; color: var(--color-text-tertiary); margin-top: 2px; }

.notif-empty {
  padding: var(--space-8);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

/* ── AI Panel ────────────────────────────── */
.ai-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: transform var(--transition-normal);
}

.ai-panel.hidden { transform: translateX(100%); }

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.ai-panel-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.ai-panel-close:hover { background: var(--color-bg-secondary); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ai-msg { display: flex; }
.ai-msg-user { justify-content: flex-end; }

.ai-msg-content {
  max-width: 85%;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--line-height-normal);
}

.ai-msg-user .ai-msg-content {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border-bottom-right-radius: var(--radius-sm);
}

.ai-msg-bot .ai-msg-content {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

.ai-msg-content ul { margin: var(--space-1) 0; padding-left: var(--space-4); }
.ai-msg-content li { margin-bottom: 2px; }

.ai-typing {
  display: inline-block;
  animation: pulse 1.5s infinite;
  color: var(--color-text-secondary);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.ai-input-wrap {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
}

.ai-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: var(--color-bg);
  outline: none;
}

.ai-input:focus { border-color: var(--color-accent); }

/* ── Org Chart ────────────────────────────── */
.orgchart-tree {
  padding: var(--space-2) 0;
}

.orgchart-node:hover { background: var(--color-bg-secondary); }

/* ── Progress Bar ────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  transition: width 0.3s ease;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
  .ai-panel { width: 100%; }
  .notif-panel { width: calc(100vw - var(--space-4)); right: var(--space-2); }
  .search-results { max-height: 300px; }
  .modal { max-width: calc(100vw - var(--space-4)); margin: var(--space-2); }
  .modal-overlay { padding: var(--space-2); }
  .modal-header, .modal-body, .modal-footer { padding: var(--space-3); }

  .tabs {
    overflow-x: auto;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }

  .card { border-radius: var(--radius-md); }
  .card-header { padding: var(--space-3); flex-wrap: wrap; gap: var(--space-2); }
  .card-body { padding: var(--space-3); }
  .card-footer { padding: var(--space-2) var(--space-3); }

  .form-input { font-size: 16px; }

  .table-wrap { border-radius: var(--radius-md); }

  .toast {
    bottom: calc(52px + var(--space-3));
    max-width: calc(100vw - var(--space-4));
    left: 50%;
  }

  .empty-state { padding: var(--space-8) var(--space-3); }

  .page-header { flex-wrap: wrap !important; gap: var(--space-2) !important; }
  .page-header .btn, .card-header .btn { font-size: var(--text-xs); }

  .content > div > [style*="display:flex"][style*="justify-content:space-between"],
  .content .page-header[style*="display:flex"],
  .content .card-header[style*="display:flex"] {
    flex-wrap: wrap !important;
    gap: var(--space-2);
  }

  .stat-grid { max-width: 100%; overflow: hidden; }
}

@media (max-width: 640px) {
  .btn { height: 32px; padding: var(--space-1) var(--space-2); font-size: var(--text-xs); }
  .btn-sm { height: 28px; padding: var(--space-1) var(--space-2); font-size: 11px; }
  .btn-lg { height: 36px; padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }

  .table th, .table td { padding: var(--space-2); font-size: 11px; }
  .table th { padding: var(--space-2); letter-spacing: 0; }

  .badge { font-size: 10px; padding: 1px var(--space-1); }

  .modal { max-width: 100vw; border-radius: var(--radius-md); }
  .modal-title { font-size: var(--text-md); }
}

/* ── Attendance Cards ────────────────────── */
.att-checkin-card {
  min-height: 200px;
}

.att-stats-card {
  min-height: 200px;
}

/* ── Attendance Heatmap & Layout ─────────── */
.att-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.att-mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.att-mini-stat { text-align: center; }

.att-mini-stat-value {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
}

.att-mini-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-tertiary);
  margin-top: 2px;
}

.att-legend {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  flex-wrap: wrap;
}

.att-legend-item { display: flex; align-items: center; gap: 4px; }
.att-legend-dot { width: 8px; height: 8px; border-radius: var(--radius-full); flex-shrink: 0; }

.heatmap { user-select: none; }

.heatmap-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.heatmap-day-name {
  text-align: center;
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-tertiary);
  padding: var(--space-1) 0;
}

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

.heatmap-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  background: var(--color-bg-secondary);
}

.heatmap-cell.empty { background: transparent; }

.heatmap-cell.present { background: var(--color-success-light); border: 1px solid var(--color-success); }
.heatmap-cell.late { background: var(--color-warning-light); border: 1px solid var(--color-warning); }
.heatmap-cell.absent { background: var(--color-error-light); border: 1px solid var(--color-error); }
.heatmap-cell.leave { background: var(--color-info-light); border: 1px solid var(--color-info); }
.heatmap-cell.off { background: var(--color-bg-tertiary); border: 1px solid var(--color-border-light); }
.heatmap-cell.future { opacity: 0.35; }

.heatmap-cell.today {
  box-shadow: 0 0 0 2px var(--color-accent);
}

.heatmap-cell.clickable { cursor: pointer; }
.heatmap-cell.clickable:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
  z-index: 2;
}

.heatmap-day {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
}

.heatmap-hours {
  font-size: 9px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.heatmap-reg-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-warning);
}

[data-theme="dark"] .heatmap-cell.present { background: rgba(22, 163, 74, 0.15); border-color: rgba(22, 163, 74, 0.4); }
[data-theme="dark"] .heatmap-cell.late { background: rgba(217, 119, 6, 0.15); border-color: rgba(217, 119, 6, 0.4); }
[data-theme="dark"] .heatmap-cell.absent { background: rgba(220, 38, 38, 0.15); border-color: rgba(220, 38, 38, 0.4); }
[data-theme="dark"] .heatmap-cell.leave { background: rgba(37, 99, 235, 0.15); border-color: rgba(37, 99, 235, 0.4); }

@media (max-width: 768px) {
  .att-top-row { grid-template-columns: 1fr; }
  .heatmap-cell { min-height: 36px; }
  .heatmap-day { font-size: var(--text-xs); }
  .heatmap-hours { display: none; }
  .att-legend { gap: var(--space-2); }
}

/* ── Leave Balance Cards ─────────────────── */
.leave-balance-card {
  flex: 0 0 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}

.leave-bal-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-1);
}

.leave-bal-code {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.leave-bal-avail {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  line-height: 1;
}

.leave-bal-name {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.leave-bal-bar {
  height: 4px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-2);
}

.leave-bal-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
}

.leave-bal-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--color-text-tertiary);
}

@media (max-width: 768px) {
  .leave-balance-card { flex: 0 0 150px; padding: var(--space-2) var(--space-3); }
}

/* ============================================================
   Layout utilities — compose these instead of inlining token-laced
   style="" strings. Targets the most-repeated inline patterns; the
   Phase 3b unwind converts existing views onto them. (DESIGN.md §9)
   ============================================================ */
.u-row       { display: flex; align-items: center; gap: var(--space-2); }
.u-row-3     { display: flex; align-items: center; gap: var(--space-3); }
.u-row-wrap  { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.u-stack     { display: grid; gap: var(--space-3); }
.u-stack-4   { display: grid; gap: var(--space-4); }
.u-center    { text-align: center; }
.u-muted     { color: var(--color-text-secondary); }
.u-meta      { font-size: var(--text-xs); color: var(--color-text-tertiary); }
.u-sm-muted  { font-size: var(--text-sm); color: var(--color-text-secondary); }
