/* ==========================================================================
   AutoPulse CRM — Dashboard Stylesheet
   Inherits design tokens and base themes from styles.css
   Scoped under .page-dashboard to prevent conflicts with login page
   ========================================================================== */

/* ---------- 1. Dashboard Scoped Tokens ---------- */
.page-dashboard {
  --sidebar-w: 260px;
  --dash-topbar-h: 72px;
  --series-1: var(--accent-primary);
  --series-2: var(--accent-secondary);
  --series-3: #8B5CF6;
  --late: var(--warning);
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
}

/* Skip link for keyboard accessibility */
.skip-link {
  position: fixed;
  top: -100px;
  left: 20px;
  z-index: 1000;
  padding: 10px 18px;
  background: var(--accent-primary);
  color: #0A0E17;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  text-decoration: none;
  transition: top 0.2s var(--ease-out);
}

.skip-link:focus {
  top: 16px;
}

/* ---------- 2. Layout Shell ---------- */
.dash-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ---------- 3. Sidebar Navigation ---------- */
.dash-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card-solid);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: transform 0.3s var(--ease-out);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.sidebar-header {
  height: var(--dash-topbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 20px 4px;
  margin: 0;
  font-weight: 600;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
}

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

.side-nav {
  padding: 12px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  text-align: left;
  transition: var(--theme-transition);
  position: relative;
}

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

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-primary-strong);
  font-weight: 600;
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3.5px;
  background: var(--accent-primary);
  border-radius: 0 4px 4px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
}

.soon-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--border-color);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.branch-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}

.sidebar-branch-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 35;
}

/* ---------- 4. Main Column & Top Bar ---------- */
.dash-main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dash-topbar {
  height: var(--dash-topbar-h);
  background: color-mix(in srgb, var(--bg-primary) 85%, transparent);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.menu-toggle-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 7px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
}

.topbar-title-group {
  min-width: 0;
}

.dash-topbar h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dash-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 7px 30px 7px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: var(--theme-transition);
}

.dash-select:hover,
.dash-select:focus {
  border-color: var(--accent-primary);
}

.dash-icon-btn {
  position: relative;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--theme-transition);
}

.dash-icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 17px;
  height: 17px;
  background: var(--accent-action);
  color: #fff;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
}

.user-menu-wrapper {
  position: relative;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 3px 10px 3px 3px;
  cursor: pointer;
  transition: var(--theme-transition);
}

.user-menu-btn:hover {
  border-color: var(--accent-primary);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.04em;
}

.user-caret {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 220px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 14px 35px -10px rgba(0, 0, 0, 0.5);
  z-index: 50;
  animation: pop-in 0.2s var(--ease-out);
}

.user-menu-info {
  padding: 4px 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-menu-info strong {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.user-role-tag {
  font-size: 0.78rem;
  color: var(--accent-primary);
  font-weight: 600;
}

.user-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 0;
}

.menu-item {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  transition: background 0.15s ease;
}

.menu-item:hover {
  background: var(--bg-hover);
}

.menu-item-danger {
  color: var(--danger);
}

.menu-item-danger:hover {
  background: var(--danger-soft);
}

/* ---------- 5. Content & Cards Grid ---------- */
.dash-content {
  padding: 24px 28px 48px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* KPI Cards 4-Column Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease-out), border-color 0.25s ease;
  animation: rise-in 0.4s var(--ease-out) backwards;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.kpi-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.kpi-icon-chip {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-meta {
  flex: 1;
}

.kpi-label {
  font-size: 0.84rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin: 0;
}

.kpi-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 2px 0 0;
  display: block;
}

.kpi-body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.kpi-trend.is-good {
  background: var(--success-soft);
  color: var(--success);
}

.kpi-trend.is-bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.kpi-spark {
  width: 100%;
  height: 28px;
  margin-top: 4px;
}

.kpi-spark polyline {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 12-Column Dashboard Grid */
.dash-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.card-chart { grid-column: span 8; }
.card-side  { grid-column: span 4; }
.card-table { grid-column: span 8; }
.card-feed  { grid-column: span 4; }

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  animation: rise-in 0.45s var(--ease-out) backwards;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-count {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-primary);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

/* Range toggle buttons */
.range-btn-group {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.range-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: calc(var(--radius-sm) - 2px);
  transition: all 0.2s ease;
}

.range-btn.is-active {
  background: var(--accent-primary);
  color: #0A0E17;
}

/* ---------- 6. SVG Charts & Legends ---------- */
.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.legend-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.legend-btn[aria-pressed="false"] {
  opacity: 0.45;
  text-decoration: line-through;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.chart-body {
  width: 100%;
  min-height: 260px;
  position: relative;
}

.chart-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.grid-line {
  stroke: var(--border-color);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.axis-label {
  font-size: 11px;
  fill: var(--text-muted);
  font-family: var(--font-body);
}

.chart-tooltip {
  position: absolute;
  z-index: 25;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--text-primary);
  box-shadow: 0 10px 25px -8px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transform: translate(-50%, -100%);
  margin-top: -10px;
  white-space: nowrap;
  animation: pop-in 0.15s var(--ease-out);
}

/* Side Card: Donut & Gauge */
.side-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 10px 0;
}

.donut-svg,
.gauge-svg {
  max-width: 220px;
  height: auto;
}

.side-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.side-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}

.side-legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.side-legend-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* ---------- 7. Table Component ---------- */
.table-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.dash-search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 7px 12px 7px 32px;
  font-size: 0.85rem;
  width: 200px;
  transition: var(--theme-transition);
}

.dash-search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  width: 230px;
}

.table-wrap {
  overflow-x: auto;
  margin: 6px -24px 0;
  padding: 0 24px;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.dash-table th {
  padding: 10px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.dash-table th button {
  background: transparent;
  border: none;
  font: inherit;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  cursor: pointer;
}

.dash-table th button:hover {
  color: var(--text-primary);
}

.dash-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

.dash-table tr:hover td {
  background: var(--bg-hover);
}

.staff-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-primary);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.status-present { background: var(--success-soft); color: var(--success); }
.badge.status-late    { background: rgba(245, 158, 11, 0.14); color: var(--warning); }
.badge.status-leave   { background: rgba(59, 130, 246, 0.14); color: var(--accent-secondary); }
.badge.status-sick    { background: var(--danger-soft); color: var(--danger); }

.kpi-score-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.kpi-track {
  flex: 1;
  height: 6px;
  background: var(--gauge-track);
  border-radius: 999px;
  overflow: hidden;
}

.kpi-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-primary);
  transition: width 0.4s var(--ease-out);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
}

.table-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- 8. Activity / Leave Feed ---------- */
.feed-title-wrap {
  display: flex;
  align-items: center;
}

.feed-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-hover);
  transition: all 0.3s var(--ease-out);
}

.feed-item.is-leaving {
  opacity: 0;
  transform: translateX(30px);
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  overflow: hidden;
}

.feed-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.feed-person {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.feed-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.feed-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.btn-feed-approve {
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--success);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-feed-approve:hover {
  opacity: 0.9;
}

.btn-feed-reject {
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-feed-reject:hover {
  background: var(--danger-soft);
}

/* Workshop stall queue items */
.stall-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-hover);
}

.stall-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stall-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.stall-plate {
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.stall-job {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* ---------- 9. States, Footer & Toasts ---------- */
.empty-box {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.dash-footer {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 12px;
}

.toast-region {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.dash-toast {
  pointer-events: auto;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.88rem;
  color: var(--text-primary);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: pop-in 0.25s var(--ease-out);
  max-width: 360px;
}

.dash-toast.is-success {
  border-left: 4px solid var(--success);
}

.dash-toast.is-info {
  border-left: 4px solid var(--accent-primary);
}

/* ---------- 10. Responsive Breakpoints ---------- */
@media (max-width: 1279px) {
  .card-chart { grid-column: span 12; }
  .card-side  { grid-column: span 12; }
  .card-table { grid-column: span 12; }
  .card-feed  { grid-column: span 12; }
}

@media (max-width: 1023px) {
  .dash-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.7);
  }

  .dash-sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: inline-flex;
  }

  .sidebar-backdrop.is-open {
    display: block;
  }

  .menu-toggle-btn {
    display: inline-flex;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .dash-topbar {
    padding: 0 16px;
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
    flex-wrap: wrap;
  }

  .dash-content {
    padding: 16px 16px 36px;
  }

  .topbar-controls {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
  }

  .dash-search-input {
    width: 100%;
  }

  .dash-search-input:focus {
    width: 100%;
  }

  .table-tools {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Sub-view Panels & Interactive Modules (Presensi, Komisi, Tim, Prospek, Laporan)
   ========================================================================== */

.subview-panel {
  animation: fadeIn 0.25s var(--ease-out);
}

.subview-panel[hidden] {
  display: none !important;
}

.subview-card {
  margin-top: 20px;
}

.btn-compact {
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.info-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, transparent);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.88rem;
  margin-top: 20px;
  margin-bottom: 20px;
}

.info-banner svg {
  color: var(--accent-primary);
  flex-shrink: 0;
}

/* Team Directory */
.team-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.team-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.team-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.2s var(--ease-out), border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.team-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.team-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.team-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.team-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.team-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--bg-card-solid);
}

.team-status-dot.status-present { background: var(--success); }
.team-status-dot.status-late { background: var(--warning); }
.team-status-dot.status-leave { background: var(--text-muted); }
.team-status-dot.status-sick { background: var(--danger); }

.team-info {
  flex: 1;
  min-width: 0;
}

.team-name {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-role {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.team-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.team-kpi-badge {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.team-kpi-badge.high { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.team-kpi-badge.mid { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

.team-card-actions {
  margin-top: auto;
  padding-top: 4px;
}

.team-contact-btn {
  width: 100%;
}

/* Leads Funnel */
.funnel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.funnel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 3px solid var(--accent-primary);
}

.funnel-count {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--text-primary);
}

.funnel-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stage-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.stage-pill.stage_inquiry { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.stage-pill.stage_contacted { background: rgba(139, 92, 246, 0.15); color: #A78BFA; }
.stage-pill.stage_testdrive { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.stage-pill.stage_negotiation { background: rgba(236, 72, 153, 0.15); color: #F472B6; }
.stage-pill.stage_delivered { background: rgba(16, 185, 129, 0.15); color: #34D399; }

/* Status & Payroll Badges */
.badge-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-payroll-ready { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-payroll-review { background: rgba(245, 158, 11, 0.15); color: var(--warning); }

/* Reports View */
.reports-header-card {
  padding: 22px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.report-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-primary) 15%, transparent);
  color: var(--accent-primary);
  font-weight: 600;
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.reports-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.reports-header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

@media (max-width: 900px) {
  .reports-grid {
    grid-template-columns: 1fr;
  }
}

.card-body-padded {
  padding: 20px;
}

.report-stats-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.report-stat-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.report-stat-label {
  color: var(--text-secondary);
}

.report-stat-val {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.highlights-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.highlight-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.highlight-icon {
  color: var(--success);
  flex-shrink: 0;
  margin-top: 2px;
}

