/* ============================================================================
   DESIGN TOKENS (21st.dev / shadcn-flavored polish, v20260518c)
   Used by every new component (rewards banner, KB tree, blocks, modals,
   toolbars). Reference these vars instead of hardcoding shadows / radii /
   motion / spacing so palette tweaks are one-line.
   ============================================================================ */
:root {
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px;

  --sh-1: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.06);
  --sh-2: 0 2px 4px rgba(15,23,42,0.05), 0 4px 12px rgba(15,23,42,0.08);
  --sh-3: 0 8px 24px rgba(15,23,42,0.12);

  --t-fast: 120ms ease;
  --t-base: 180ms ease;
  --t-slow: 260ms cubic-bezier(0.2, 0.8, 0.2, 1);

  --border: rgba(15,23,42,0.08);
  --border-strong: rgba(15,23,42,0.14);
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text-1: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
}

/* ===== BASE STYLES ===== */
* {
  font-family: 'Lato', sans-serif;
  box-sizing: border-box;
}

body { 
  margin: 0; 
  padding: 0; 
  background-color: #f1eadd; 
  transition: background-color 0.3s; 
}

body.dark-mode { 
  background-color: #1a1a1a; 
  color: #e5e5e5; 
}

.container { 
  max-width: 1800px; 
  margin: 0 auto; 
  padding: 20px; 
}

/* ===== NAVBAR ===== */
.navbar { 
  background: white; 
  border-bottom: 2px solid #d0ccc5; 
  padding: 12px 24px; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  flex-wrap: wrap; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
}

body.dark-mode .navbar { 
  background: #2a2a2a; 
  border-bottom-color: #404040; 
}

.navbar-left, .navbar-right { 
  display: flex; 
  align-items: center; 
  gap: 16px; 
  flex-wrap: wrap; 
}

.navbar-logo { 
  font-size: 20px; 
  font-weight: 700; 
  color: #3b82f6; 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}

.navbar-links { 
  display: flex; 
  gap: 12px; 
  align-items: center; 
  flex-wrap: wrap; 
}

.navbar-link { 
  color: inherit; 
  text-decoration: none; 
  font-weight: 500; 
  font-size: 14px; 
  padding: 6px 12px; 
  border-radius: 6px; 
  transition: background 0.2s; 
}

.navbar-link:hover { 
  background: rgba(59, 130, 246, 0.1); 
}

/* First Nav Dropdown */
.first-nav-dropdown {
  position: fixed;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  min-width: 200px;
}

body.dark-mode .first-nav-dropdown {
  background: #1f2937;
  border-color: #374151;
}

.first-nav-dropdown a {
  display: block;
  padding: 8px 12px;
  border-radius: 4px;
  text-decoration: none;
  color: #374151;
  transition: background 0.2s;
}

body.dark-mode .first-nav-dropdown a {
  color: #e5e7eb;
}

.first-nav-dropdown a:hover {
  background: #f3f4f6;
}

body.dark-mode .first-nav-dropdown a:hover {
  background: #374151;
}

.first-nav-link {
  cursor: pointer;
  display: flex;
  align-items: center;
}

.first-nav-link:active {
  background: rgba(59, 130, 246, 0.15);
}

/* ===== GLOBAL SEARCH ===== */
.global-search-container {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.global-search-container .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.4;
  pointer-events: none;
}

.global-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
  background: #f9f9f9;
}

.global-search-input:focus {
  outline: none;
  border-color: #3b82f6;
  background: white;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

body.dark-mode .global-search-input {
  background: #333;
  border-color: #555;
  color: white;
}

body.dark-mode .global-search-input:focus {
  background: #3a3a3a;
  border-color: #3b82f6;
}

.search-result-item {
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.search-result-item:hover {
  background: #f9fafb;
  border-color: #3b82f6;
  transform: translateX(4px);
}

body.dark-mode .search-result-item {
  border-color: #374151;
  background: #2a2a2a;
}

body.dark-mode .search-result-item:hover {
  background: #333;
}

/* ===== NOTIFICATION BANNER ===== */
.notification-banner { 
  background: linear-gradient(90deg, #3b82f6, #8b5cf6); 
  color: white; 
  padding: 12px 24px; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  animation: slideDown 0.3s ease-out; 
}

.notification-banner .message { 
  flex: 1; 
  font-size: 14px; 
}

.notification-banner .dismiss-btn { 
  background: rgba(255,255,255,0.2); 
  border: none; 
  color: white; 
  padding: 4px 12px; 
  border-radius: 4px; 
  cursor: pointer; 
  font-size: 12px; 
  transition: background 0.2s; 
}

.notification-banner .dismiss-btn:hover { 
  background: rgba(255,255,255,0.3); 
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== TAB NAVIGATION ===== */
.tab-nav { 
  background: white; 
  border-bottom: 2px solid #e5e5e5; 
  padding: 0 24px; 
  display: flex; 
  gap: 4px; 
  overflow-x: auto;
  align-items: center;
}

body.dark-mode .tab-nav { 
  background: #2a2a2a; 
  border-bottom-color: #404040; 
}

.tab-nav-item { 
  padding: 12px 20px; 
  cursor: pointer; 
  border-bottom: 3px solid transparent; 
  margin-bottom: -2px; 
  font-weight: 500; 
  transition: all 0.2s; 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  font-size: 14px; 
  white-space: nowrap;
}

.tab-nav-item:hover { 
  background: rgba(59, 130, 246, 0.05); 
}

.tab-nav-item.active { 
  border-bottom-color: #3b82f6; 
  color: #3b82f6; 
}

.tab-nav-item.hidden { 
  display: none; 
}

.tab-nav-search {
  margin-left: auto;
  padding: 8px 0;
}

.tab-nav-search .global-search-container {
  max-width: 300px;
}

/* Tab Badge for notifications/counts */
.tab-badge {
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
  margin-left: 4px;
  animation: badgePulse 2s ease-in-out infinite;
}

.tab-nav-item.active .tab-badge {
  background: #dc2626;
}

body.dark-mode .tab-badge {
  background: #dc2626;
}

body.dark-mode .tab-nav-item.active .tab-badge {
  background: #b91c1c;
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* ===== TAB CONTENT ===== */
.tab-content { 
  display: none; 
}

.tab-content.active { 
  display: block; 
}

/* ===== WELCOME BANNER ===== */
.welcome-banner-container {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.welcome-banner { 
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
  color: white; 
  padding: 24px; 
  border-radius: 12px; 
  margin-bottom: 20px; 
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: background 0.5s ease, color 0.5s ease;
}

/* Time-based welcome banner backgrounds */
.time-based-banner.morning {
  background: hsla(201, 81%, 48%, 1);
  background: linear-gradient(315deg, hsla(201, 81%, 48%, 1) 0%, hsla(150, 40%, 94%, 1) 100%);
  background: -moz-linear-gradient(315deg, hsla(201, 81%, 48%, 1) 0%, hsla(150, 40%, 94%, 1) 100%);
  background: -webkit-linear-gradient(315deg, hsla(201, 81%, 48%, 1) 0%, hsla(150, 40%, 94%, 1) 100%);
  color: white;
}

.time-based-banner.afternoon {
  background: hsla(44, 100%, 63%, 1);
  background: linear-gradient(315deg, hsla(44, 100%, 63%, 1) 0%, hsla(42, 100%, 92%, 1) 100%);
  background: -moz-linear-gradient(315deg, hsla(44, 100%, 63%, 1) 0%, hsla(42, 100%, 92%, 1) 100%);
  background: -webkit-linear-gradient(315deg, hsla(44, 100%, 63%, 1) 0%, hsla(42, 100%, 92%, 1) 100%);
  color: #000;
}

.time-based-banner.afternoon h1,
.time-based-banner.afternoon p,
.time-based-banner.afternoon span {
  color: #000;
}

.time-based-banner.evening {
  background: hsla(0, 0%, 40%, 1);
  background: linear-gradient(315deg, hsla(0, 0%, 40%, 1) 0%, hsla(0, 0%, 89%, 1) 100%);
  background: -moz-linear-gradient(315deg, hsla(0, 0%, 40%, 1) 0%, hsla(0, 0%, 89%, 1) 100%);
  background: -webkit-linear-gradient(315deg, hsla(0, 0%, 40%, 1) 0%, hsla(0, 0%, 89%, 1) 100%);
  color: white;
}

.welcome-banner h1 { 
  margin: 0 0 8px 0; 
  font-size: 28px; 
  font-weight: 700; 
}

.welcome-banner p { 
  margin: 0; 
  font-size: 16px; 
  opacity: 0.9; 
}

/* ===== NEXT EVENT WINDOW ===== */
.next-event-window {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  min-width: 250px;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.next-event-window:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

body.dark-mode .next-event-window {
  background: linear-gradient(135deg, #4c51bf 0%, #553c9a 100%);
  box-shadow: 0 4px 12px rgba(76, 81, 191, 0.4);
}

body.dark-mode .next-event-window:hover {
  box-shadow: 0 6px 16px rgba(76, 81, 191, 0.5);
}

.next-event-header {
  opacity: 0.9;
}

.next-event-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.next-event-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.next-event-time {
  font-size: 14px;
  opacity: 0.9;
}

.next-event-countdown {
  font-size: 12px;
  opacity: 0.8;
  font-weight: 500;
}

.next-event-join-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
  margin-top: 4px;
}

.next-event-join-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  text-decoration: none;
  color: white;
}

/* ===== ATTENDANCE TAB ===== */
.attendance-tab-container {
  max-width: 1000px;
  margin: 0 auto;
}

.attendance-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

.attendance-stat-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.dark-mode .attendance-stat-card {
  background: #2a2a2a;
}

.stat-card-header {
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

body.dark-mode .stat-card-header {
  color: #9ca3af;
}

.stat-card-value {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1;
}

.stat-card-description {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
}

body.dark-mode .stat-card-description {
  color: #9ca3af;
}

.attendance-thresholds {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.dark-mode .attendance-thresholds {
  background: #2a2a2a;
}

.thresholds-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.threshold-card {
  text-align: center;
  padding: 20px;
  background: #f9fafb;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
}

body.dark-mode .threshold-card {
  background: #1f2937;
  border-color: #374151;
}

.threshold-number {
  font-size: 36px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 8px;
}

body.dark-mode .threshold-number {
  color: #e5e5e5;
}

.threshold-card .threshold-label {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

body.dark-mode .threshold-card .threshold-label {
  color: #9ca3af;
}

/* Heatmap colors for stat values */
.stat-card-value.safe {
  color: #10b981;
}

.stat-card-value.warning {
  color: #f59e0b;
}

.stat-card-value.danger-low {
  color: #f97316;
}

.stat-card-value.danger-medium {
  color: #ef4444;
}

.stat-card-value.danger-high {
  color: #dc2626;
}

.stat-card-value.danger-critical {
  color: #991b1b;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.attendance-alert {
  padding: 20px;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
}

.attendance-alert.safe {
  background: #d1fae5;
  color: #065f46;
  border: 2px solid #10b981;
}

.attendance-alert.warning {
  background: #fef3c7;
  color: #92400e;
  border: 2px solid #f59e0b;
}

.attendance-alert.danger {
  background: #fee2e2;
  color: #991b1b;
  border: 2px solid #ef4444;
}

body.dark-mode .attendance-alert.safe {
  background: #064e3b;
  color: #d1fae5;
}

body.dark-mode .attendance-alert.warning {
  background: #78350f;
  color: #fef3c7;
}

body.dark-mode .attendance-alert.danger {
  background: #7f1d1d;
  color: #fee2e2;
}

@media (max-width: 768px) {
  .attendance-stats-grid {
    grid-template-columns: 1fr;
  }
  
  .thresholds-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== DASHBOARD CARDS ===== */
.dashboard-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

body.dark-mode .dashboard-card {
  background: #2a2a2a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dashboard-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.dark-mode .dashboard-card-header {
  border-bottom-color: #374151;
}

.dashboard-card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

body.dark-mode .dashboard-card-header h3 {
  color: #ffffff;
}

.dashboard-card-body {
  padding: 16px 20px;
  max-height: 400px;
  overflow-y: auto;
}

.dashboard-task-item {
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: all 0.2s;
}

.dashboard-task-item:last-child {
  border-bottom: none;
}

.dashboard-task-item:hover {
  background: #f9fafb;
  margin: 0 -12px;
  padding-left: 12px;
  padding-right: 12px;
  border-radius: 6px;
}

body.dark-mode .dashboard-task-item {
  border-bottom-color: #374151;
}

body.dark-mode .dashboard-task-item:hover {
  background: #374151;
}

.dashboard-task-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #1f2937;
}

body.dark-mode .dashboard-task-title {
  color: #f3f4f6;
}

.dashboard-task-meta {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

body.dark-mode .dashboard-task-meta {
  color: #9ca3af;
}

/* ===== ATTENDANCE CARD ===== */
.attendance-card-container {
  perspective: 1000px;
}

.attendance-card {
  position: relative;
  width: 100%;
  height: 180px;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.attendance-card.flipped {
  transform: rotateY(180deg);
}

.attendance-card-front,
.attendance-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 20px;
}

.attendance-card-back {
  transform: rotateY(180deg);
}

body.dark-mode .attendance-card-front,
body.dark-mode .attendance-card-back {
  background: #2a2a2a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.attendance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
}

body.dark-mode .attendance-header {
  border-bottom-color: #374151;
}

.attendance-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

body.dark-mode .attendance-header h3 {
  color: #f3f4f6;
}

.btn-flip {
  background: transparent;
  border: 2px solid #3b82f6;
  color: #3b82f6;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.btn-flip:hover {
  background: #3b82f6;
  color: white;
  transform: scale(1.1);
}

body.dark-mode .btn-flip {
  border-color: #60a5fa;
  color: #60a5fa;
}

body.dark-mode .btn-flip:hover {
  background: #60a5fa;
  color: white;
}

.attendance-summary {
  display: flex;
  gap: 24px;
  justify-content: space-around;
}

.attendance-stat {
  flex: 1;
  text-align: center;
  padding: 16px;
  background: #f9fafb;
  border-radius: 8px;
}

body.dark-mode .attendance-stat {
  background: #1f2937;
}

.stat-label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

body.dark-mode .stat-label {
  color: #9ca3af;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.attendance-details {
  max-height: 95px;
  overflow-y: auto;
  padding: 4px;
}

.attendance-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 13px;
}

body.dark-mode .attendance-detail-item {
  background: #1f2937;
}

.attendance-detail-label {
  font-weight: 500;
  color: #1f2937;
}

body.dark-mode .attendance-detail-label {
  color: #f3f4f6;
}

.attendance-detail-value {
  font-weight: 600;
}

/* Heatmap colors for cumulative points */
.points-safe { color: #10b981; } /* < 30 */
.points-verbal { color: #f59e0b; } /* 30-34 */
.points-written { color: #f97316; } /* 35-39 */
.points-final { color: #ef4444; } /* 40-44 */
.points-termination { color: #dc2626; } /* >= 45 */

/* Heatmap colors for emergency bank hours */
.bank-critical { color: #dc2626; } /* 0-2 */
.bank-low { color: #ef4444; } /* 3-5 */
.bank-medium { color: #f59e0b; } /* 6-10 */
.bank-good { color: #10b981; } /* > 10 */

/* Home page specific layout */
#tab-home > div:nth-child(2) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Responsive: Stack on smaller screens */
@media (max-width: 1200px) {
  #tab-home > div:nth-child(2) {
    grid-template-columns: 1fr;
  }
}

/* Calendar day cells */
.calendar-day {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.2s;
  position: relative;
}

.calendar-day:hover {
  transform: scale(1.05);
}

.calendar-date-item {
  transition: all 0.2s;
}

.calendar-date-item:hover {
  background: #f9fafb;
  transform: translateX(4px);
  border-color: #3b82f6 !important;
}

body.dark-mode .calendar-date-item:hover {
  background: #374151;
}

/* ===== USER BADGE ===== */
.user-badge-container {
  position: relative;
}

.user-badge { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  padding: 6px 12px; 
  background: #f3f4f6; 
  border-radius: 20px; 
  font-size: 13px; 
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.user-badge:hover {
  background: #e5e7eb;
}

body.dark-mode .user-badge { 
  background: #374151; 
}

body.dark-mode .user-badge:hover {
  background: #4b5563;
}

.user-badge .avatar { 
  width: 24px; 
  height: 24px; 
  border-radius: 50%; 
  background: #3b82f6; 
  color: white; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 11px; 
  font-weight: 700; 
}

.user-badge .user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}

.user-badge .dropdown-chevron {
  margin-left: 4px;
  opacity: 0.6;
  transition: transform 0.2s;
}

.user-badge:hover .dropdown-chevron {
  opacity: 1;
}

.user-badge .role { 
  padding: 2px 8px; 
  border-radius: 10px; 
  font-size: 10px; 
  text-transform: uppercase; 
  font-weight: 700; 
  letter-spacing: 0.5px; 
}

.role-admin { background: #10b981; color: white; }
.role-manager { background: #3b82f6; color: white; }
.role-agent { background: #6b7280; color: white; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  overflow: hidden;
}

body.dark-mode .user-dropdown {
  background: #374151;
  border-color: #4b5563;
}

.user-dropdown-item {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
}

.user-dropdown-item:hover {
  background: #f3f4f6;
}

body.dark-mode .user-dropdown-item:hover {
  background: #4b5563;
}

.user-dropdown-item svg {
  opacity: 0.6;
}

/* ===== NOTIFICATIONS ===== */
.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
  pointer-events: none;
}

.notifications-dropdown {
  position: absolute;
  top: 60px;
  right: 24px;
  width: 400px;
  max-height: 500px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 10001;
  display: none;
  flex-direction: column;
}

body.dark-mode .notifications-dropdown {
  background: #2a2a2a;
  border: 1px solid #404040;
}

.notifications-dropdown.active {
  display: flex;
}

.notifications-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.dark-mode .notifications-header {
  border-bottom-color: #404040;
}

.notifications-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.notifications-body {
  overflow-y: auto;
  max-height: 400px;
  flex: 1;
}

.notification-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

body.dark-mode .notification-item {
  border-bottom-color: #374151;
}

.notification-item:hover {
  background: #f9fafb;
}

body.dark-mode .notification-item:hover {
  background: #374151;
}

.notification-item.unread {
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
}

body.dark-mode .notification-item.unread {
  background: #1e3a5f;
}

.notification-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.notification-author {
  font-weight: 600;
  font-size: 13px;
}

.notification-time {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
}

.notification-text {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.4;
}

body.dark-mode .notification-text {
  color: #9ca3af;
}

.notification-task {
  font-size: 12px;
  color: #3b82f6;
  font-weight: 500;
  margin-top: 4px;
}

.notifications-empty {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 14px;
}

/* ===== USER MENTION AUTOCOMPLETE ===== */
.mention-autocomplete {
  position: absolute;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10002;
  display: none;
  min-width: 200px;
}

body.dark-mode .mention-autocomplete {
  background: #2a2a2a;
  border-color: #404040;
}

.mention-autocomplete.active {
  display: block;
}

.mention-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  transition: background 0.15s;
}

.mention-item:hover,
.mention-item.selected {
  background: #f3f4f6;
}

body.dark-mode .mention-item:hover,
body.dark-mode .mention-item.selected {
  background: #374151;
}

.mention-item-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.mention-item-name {
  flex: 1;
  font-weight: 500;
}

.mention-item-email {
  font-size: 11px;
  color: #6b7280;
}

.mention-highlight {
  background: transparent;
  color: #189adf;
  padding: 0;
  border-radius: 0;
  font-weight: 600;
}

body.dark-mode .mention-highlight {
  color: #4fb3e8;
}

/* ===== VIEW SWITCHER ===== */
.view-switcher { 
  display: flex; 
  gap: 4px; 
  background: #f3f4f6; 
  padding: 4px; 
  border-radius: 8px; 
}

body.dark-mode .view-switcher { 
  background: #374151; 
}

.view-switcher-btn { 
  padding: 6px 14px; 
  border-radius: 6px; 
  border: none; 
  background: transparent; 
  cursor: pointer; 
  font-size: 13px; 
  font-weight: 500; 
  transition: all 0.2s; 
}

.view-switcher-btn:hover { 
  background: rgba(59, 130, 246, 0.1); 
}

.view-switcher-btn.active { 
  background: #3b82f6; 
  color: white; 
}

body.dark-mode .view-switcher-btn {
  color: white;
}

/* View type buttons (same styling as view switcher) */
.view-type-btn { 
  padding: 6px 14px; 
  border-radius: 6px; 
  border: none; 
  background: transparent; 
  cursor: pointer; 
  font-size: 13px; 
  font-weight: 500; 
  transition: all 0.2s; 
  color: #1f2937;
}

body.dark-mode .view-type-btn {
  color: #e5e5e5;
}

.view-type-btn:hover { 
  background: rgba(59, 130, 246, 0.1); 
}

.view-type-btn.active { 
  background: #3b82f6; 
  color: white; 
}

/* ===== BUTTONS ===== */
.btn { 
  padding: 8px 16px; 
  border-radius: 6px; 
  font-size: 14px; 
  font-weight: 500; 
  border: none; 
  cursor: pointer; 
  transition: all 0.2s; 
  display: inline-block; 
}

.btn-primary { 
  background: #3b82f6; 
  color: white; 
}

.btn-primary:hover { 
  background: #2563eb; 
}

.btn-secondary { 
  background: #6b7280; 
  color: white; 
}

.btn-secondary:hover { 
  background: #4b5563; 
}

.btn-danger { 
  background: #d9534f; 
  color: white; 
}

.btn-danger:hover { 
  background: #c9302c; 
}

.btn-sm { 
  padding: 4px 10px; 
  font-size: 12px; 
}

/* Floating Bulk Actions Button */
.floating-bulk-actions-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.floating-bulk-actions-btn:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.5);
}

.bulk-actions-icon {
  font-size: 18px;
}

body.dark-mode .floating-bulk-actions-btn {
  background: #ef4444;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.6);
}

body.dark-mode .floating-bulk-actions-btn:hover {
  background: #dc2626;
}

/* ===== FILTER SECTION ===== */
.filter-section { 
  background: white; 
  border-radius: 8px; 
  padding: 16px; 
  margin-bottom: 16px; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
}

body.dark-mode .filter-section { 
  background: #2a2a2a; 
}

.filter-header { 
  cursor: pointer; 
  font-weight: 600; 
  margin-bottom: 12px; 
  user-select: none; 
}

.filter-pills { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 8px; 
  margin-top: 8px; 
}

.filter-pill { 
  padding: 6px 14px; 
  border-radius: 16px; 
  font-size: 13px; 
  font-weight: 500; 
  border: 2px solid #d0ccc5; 
  background: white; 
  cursor: pointer; 
  user-select: none; 
  transition: all 0.2s; 
}

body.dark-mode .filter-pill { 
  background: #333; 
  border-color: #404040; 
  color: #e5e5e5; 
}

.filter-pill:hover { 
  border-color: #3b82f6; 
}

.filter-pill.active { 
  background: #3b82f6; 
  color: white; 
  border-color: #3b82f6; 
}

/* ===== SUMMARY CHIPS ===== */
.summary-chips { 
  display: flex; 
  gap: 12px; 
  flex-wrap: wrap; 
  margin-bottom: 16px; 
}

.summary-chip { 
  padding: 8px 16px; 
  border-radius: 20px; 
  font-size: 14px; 
  font-weight: 600; 
  border: 2px solid transparent; 
  cursor: pointer; 
  transition: all 0.2s; 
}

.summary-chip:hover { 
  transform: translateY(-2px); 
}

.summary-chip.active { 
  border-color: #3b82f6; 
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); 
}

.chip-total { background: #e5e7eb; color: #1f2937; }
.chip-not-started { background: #f3f4f6; color: #4b5563; }
.chip-in-progress { background: #dbeafe; color: #1e40af; }
.chip-resolved { background: #d1fae5; color: #065f46; }

body.dark-mode .chip-total { background: #374151; color: #e5e7eb; }
body.dark-mode .chip-not-started { background: #1f2937; color: #9ca3af; }
body.dark-mode .chip-in-progress { background: #1e3a8a; color: #93c5fd; }
body.dark-mode .chip-resolved { background: #065f46; color: #6ee7b7; }

/* ===== ENERGY BAR ===== */
.energy-bar { 
  width: 100%; 
  height: 32px; 
  background: #f3f4f6; 
  border-radius: 16px; 
  overflow: hidden; 
  display: flex; 
  margin-bottom: 16px; 
  position: relative; 
}

.energy-bar-compact {
  flex: 1;
  min-width: 150px;
  height: 16px;
  background: #f3f4f6;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  position: relative;
  flex-shrink: 0;
}

body.dark-mode .energy-bar { 
  background: #374151; 
}

body.dark-mode .energy-bar-compact {
  background: #374151;
}

.energy-segment { 
  height: 100%; 
  transition: width 0.3s ease; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 11px; 
  font-weight: 600; 
  color: white; 
}

.energy-not-started { background: #9ca3af; }
.energy-in-progress { background: #3b82f6; }
.energy-resolved { background: #10b981; }

.energy-bar-tooltip { 
  position: absolute; 
  top: 100%; 
  left: 50%; 
  transform: translateX(-50%); 
  margin-top: 4px; 
  font-size: 12px; 
  color: #666; 
  white-space: nowrap; 
}

body.dark-mode .energy-bar-tooltip { 
  color: #999; 
}

/* ===== TABLE ===== */
.table-container { 
  background: #f9f9f9; 
  border-radius: 8px; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.1); 
  margin-top: 20px; 
}

body.dark-mode .table-container { 
  background: #2a2a2a; 
}

.task-table { 
  width: 100%; 
  border-collapse: collapse; 
}

.task-table thead { 
  background: #ece8de; 
  position: sticky; 
  top: 0; 
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.dark-mode .task-table thead { 
  background: #333;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.task-table th { 
  padding: 12px 8px; 
  text-align: left; 
  font-size: 14px; 
  font-weight: 600; 
  text-transform: uppercase; 
  border-bottom: 2px solid #d0ccc5;
  background: inherit;
}

body.dark-mode .task-table th { 
  border-bottom-color: #404040; 
}

.task-table td { 
  padding: 12px 8px; 
  border-bottom: 1px solid #e5e5e5; 
  vertical-align: top; 
}

body.dark-mode .task-table td { 
  border-bottom-color: #404040; 
  color: #ffffff;
}

.task-table tbody tr:hover { 
  background: #f0f0f0; 
}

body.dark-mode .task-table tbody tr:hover { 
  background: #333; 
}

.task-table tbody tr.selected { 
  background: #dbeafe !important; 
}

body.dark-mode .task-table tbody tr.selected { 
  background: #1e3a5f !important; 
}

/* ===== PILLS ===== */
.pill { 
  display: inline-block; 
  padding: 4px 10px; 
  border-radius: 12px; 
  font-size: 12px; 
  font-weight: 500; 
  border: 1px solid; 
  margin: 2px; 
  white-space: nowrap; 
}

.priority-high { background: #fff0f0; border-color: #ffc9c9; color: #7f1d1d; }
.priority-medium { background: #fff7df; border-color: #ffe3a3; color: #78350f; }
.priority-low { background: #eefdf2; border-color: #c9f5d2; color: #14532d; }
.status-not-started { background: #fafafa; border-color: #dcdcdc; color: #3f3f46; }
.status-in-progress { background: #eef4ff; border-color: #cfe0ff; color: #1e3a8a; }
.status-resolved { background: #eefdf2; border-color: #c9f5d2; color: #14532d; }

.pill.clickable { 
  cursor: pointer; 
  transition: all 0.2s; 
}

.pill.clickable:hover { 
  transform: translateY(-1px); 
  box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

body.dark-mode .priority-high { background: #4a1a1a; border-color: #7f1d1d; color: #ffc9c9; }
body.dark-mode .priority-medium { background: #4a3a0f; border-color: #78350f; color: #ffe3a3; }
body.dark-mode .priority-low { background: #0f2a1a; border-color: #14532d; color: #c9f5d2; }
body.dark-mode .status-not-started { background: #2a2a2a; border-color: #404040; color: #a5a5a5; }
body.dark-mode .status-in-progress { background: #1a2a4a; border-color: #1e3a8a; color: #cfe0ff; }
body.dark-mode .status-resolved { background: #0f2a1a; border-color: #14532d; color: #c9f5d2; }

/* ===== DUE DATE COLORS ===== */
.due-date-normal { color: inherit; }
.due-date-overdue { color: #ef4444; font-weight: 600; }
.due-date-soon { color: #f59e0b; font-weight: 600; }

body.dark-mode .due-date-overdue { color: #fca5a5; }
body.dark-mode .due-date-soon { color: #fbbf24; }

/* ===== ATTACHMENT LINKS ===== */
.attachment-link {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 6px;
  text-decoration: none;
  color: #3b82f6;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
  margin-right: 8px;
  margin-bottom: 4px;
}

.attachment-link:hover {
  background: #e5e7eb;
  transform: translateY(-1px);
}

body.dark-mode .attachment-link {
  background: #374151;
  color: #6db3f6;
}

body.dark-mode .attachment-link:hover {
  background: #4b5563;
}

/* ===== COMMENT BUBBLE ===== */
.comment-bubble {
  background: #e5e7eb;
  color: #6b7280;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.comment-bubble.has-comments {
  background: #3b82f6;
  color: white;
}

body.dark-mode .comment-bubble {
  background: #374151;
  color: #9ca3af;
}

body.dark-mode .comment-bubble.has-comments {
  background: #2563eb;
  color: white;
}

/* ===== COMMENT CARD ===== */
.comment-card {
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

body.dark-mode .comment-card {
  background: #2a2a2a;
  border-color: #404040;
}

.comment-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

/* ===== INLINE MENU ===== */
.inline-menu {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px;
  min-width: 180px;
  max-width: 300px;
}

body.dark-mode .inline-menu {
  background: #2a2a2a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.inline-menu-item {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.2s;
}

.inline-menu-item:hover {
  background: #f3f4f6;
}

body.dark-mode .inline-menu-item:hover {
  background: #374151;
}

.inline-menu-item-checkbox {
  padding: 6px 12px;
  display: flex;
  align-items: center;
  font-size: 13px;
}

.inline-menu-item-checkbox input {
  margin: 0;
  cursor: pointer;
}

.inline-menu-item-checkbox label {
  cursor: pointer;
  user-select: none;
  margin-left: 6px;
}

/* ===== MODALS ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease-out;
}

/* Duty Definition Modal needs higher z-index when opened from Duty Assignment Modal */
#dutyDefinitionModal {
  z-index: 10100;
}

/* Duty Assignment Modal */
#dutyModal {
  z-index: 10000;
}

/* Task modal adjustments when comments are visible */
#taskModal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease-out;
}

#taskModal .modal-content {
  margin-left: 5%;
  margin-right: auto;
  max-width: calc(100vw - 500px); /* Leave room for comments panel */
}

@media (max-width: 1200px) {
  #taskModal .modal-content {
    max-width: 600px;
    margin: 5% auto;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  padding: 0;
  border-radius: 12px;
  max-width: 600px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease-out;
}

body.dark-mode .modal-content {
  background-color: #2a2a2a;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 2px solid #e5e5e5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.dark-mode .modal-header {
  border-bottom-color: #404040;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
  z-index: 20;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #333;
}

body.dark-mode .modal-close:hover {
  background: #374151;
  color: #e5e5e5;
}

.modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 2px solid #e5e5e5;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.dark-mode .modal-footer {
  border-top-color: #404040;
}

/* ===== COMMENTS MODAL (SIDE PANEL) ===== */
.comments-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  right: 0;
  top: 0;
  width: 420px;
  max-width: 90vw;
  height: 100%;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  animation: slideInFromRight 0.3s ease-out;
  flex-direction: column;
}

.comments-modal.active {
  display: flex;
}

@keyframes slideInFromRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.comments-modal-header {
  padding: 20px;
  border-bottom: 2px solid #e5e5e5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  z-index: 10;
  flex-shrink: 0;
}

.comments-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.comments-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.comments-empty {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
  font-size: 14px;
}

.comment-item {
  padding: 12px;
  margin-bottom: 12px;
  border-left: 3px solid #3b82f6;
  background: #f9fafb;
  border-radius: 6px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.comment-author {
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
}

.comment-timestamp {
  font-size: 11px;
  color: #9ca3af;
}

.comment-text {
  font-size: 14px;
  color: #374151;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.comment-input-section {
  background: white;
  padding: 16px 20px;
  border-top: 2px solid #e5e5e5;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
}

.comment-input-section textarea {
  width: 100%;
  min-height: 80px;
  margin-bottom: 10px;
  resize: vertical;
  border: 2px solid #d0ccc5;
  border-radius: 6px;
  padding: 10px 12px;
  font-family: 'Lato', sans-serif;
  font-size: 14px;
}

.comment-input-section button {
  width: 100%;
}

/* Dark mode styles for comments modal */
body.dark-mode .comments-modal {
  background: #1f2937;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

body.dark-mode .comments-modal-header {
  background: #1f2937;
  border-bottom-color: #374151;
}

body.dark-mode .comments-modal-header h3 {
  color: #e5e5e5;
}

body.dark-mode .comment-item {
  background: #111827;
  border-left-color: #2563eb;
}

body.dark-mode .comment-author {
  color: #e5e5e5;
}

body.dark-mode .comment-text {
  color: #d1d5db;
}

body.dark-mode .comment-input-section {
  background: #1f2937;
  border-top-color: #374151;
}

body.dark-mode .comment-input-section textarea {
  background: #111827;
  border-color: #374151;
  color: #e5e5e5;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: #333;
}

body.dark-mode .form-label {
  color: #e5e5e5;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #d0ccc5;
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Lato', sans-serif;
  transition: all 0.2s;
  background: white;
  color: #333;
}

body.dark-mode .form-input {
  background: #333;
  border-color: #404040;
  color: #e5e5e5;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input:read-only {
  background: #f9f9f9;
  cursor: not-allowed;
}

body.dark-mode .form-input:read-only {
  background: #1a1a1a;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

textarea.form-input {
  min-height: 80px;
  resize: vertical;
}

/* ===== SETTINGS MODAL ===== */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #e5e5e5;
  margin-bottom: 20px;
}

body.dark-mode .settings-tabs {
  border-bottom-color: #404040;
}

.settings-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.settings-tab:hover {
  background: rgba(59, 130, 246, 0.05);
  color: #3b82f6;
}

.settings-tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

body.dark-mode .settings-tab {
  color: #999;
}

body.dark-mode .settings-tab:hover {
  color: #6db3f6;
}

.settings-content {
  display: none;
}

.settings-content.active {
  display: block;
}

/* ===== DASHBOARD ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.dashboard-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
}

.dashboard-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body.dark-mode .dashboard-card {
  background: #2a2a2a;
}

.dashboard-card h3 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

body.dark-mode .dashboard-card h3 {
  color: #999;
}

.stat-big {
  font-size: 48px;
  font-weight: 700;
  color: #3b82f6;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 14px;
  color: #999;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.dark-mode .stat-card {
  background: #2a2a2a;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: #3b82f6;
  margin-bottom: 4px;
}

/* ===== RESOURCE CARD ===== */
.resource-card {
  background: white;
  border: 2px solid #e5e5e5;
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
}

.resource-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

body.dark-mode .resource-card {
  background: #2a2a2a;
  border-color: #404040;
}

body.dark-mode .resource-card:hover {
  border-color: #2563eb;
}

.resource-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.resource-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.resource-description {
  color: #666;
  font-size: 14px;
  margin: 8px 0;
}

body.dark-mode .resource-description {
  color: #999;
}

.resource-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.resource-link {
  color: #3b82f6;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.resource-link:hover {
  text-decoration: underline;
}

.resource-tags {
  font-size: 12px;
  color: #999;
  margin-top: 8px;
}

/* ===== CALENDAR EVENT ===== */
.calendar-event {
  background: white;
  border: 2px solid #e5e5e5;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}

.calendar-event:hover {
  border-color: #3b82f6;
  transform: translateX(4px);
}

body.dark-mode .calendar-event {
  background: #2a2a2a;
  border-color: #404040;
}

.event-date {
  font-weight: 700;
  font-size: 14px;
  min-width: 100px;
  color: #3b82f6;
}

.event-title {
  flex: 1;
  font-size: 14px;
}

/* ===== LOADING STATE ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: #999;
  font-style: italic;
}

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .navbar {
    padding: 8px 16px;
  }
  
  .navbar-left, .navbar-right {
    gap: 8px;
  }
  
  .container {
    padding: 12px;
  }
  
  .welcome-banner h1 {
    font-size: 22px;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .tab-nav {
    padding: 0 12px;
  }
  
  .tab-nav-item {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* ===== ANNOUNCEMENTS MARQUEE ===== */
.announcement-marquee-container {
  background: linear-gradient(90deg, #f59e0b, #d97706);
  color: white;
  overflow: hidden;
  padding: 8px 0;
  border-bottom: 2px solid #b45309;
  display: none; /* Hidden by default, shown when announcements exist */
}

body.dark-mode .announcement-marquee-container {
  background: linear-gradient(90deg, #92400e, #78350f);
  border-bottom-color: #451a03;
}

.announcement-marquee {
  display: flex;
  animation: scroll-left 30s linear infinite;
  white-space: nowrap;
}

@keyframes scroll-left {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

.marquee-item {
  display: inline-block;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 500;
}

.marquee-separator {
  display: inline-block;
  padding: 0 10px;
  opacity: 0.7;
}

/* Pause animation on hover */
.announcement-marquee:hover {
  animation-play-state: paused;
}

/* ===== COMMENT STYLES ===== */
.comment-bubble {
  background: #e5e7eb;
  color: #6b7280;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  display: inline-block;
}

.comment-bubble.has-comments {
  background: #3b82f6;
  color: white;
}

body.dark-mode .comment-bubble {
  background: #374151;
  color: #9ca3af;
}

body.dark-mode .comment-bubble.has-comments {
  background: #2563eb;
  color: white;
}

.comment-card {
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

body.dark-mode .comment-card {
  background: #2a2a2a;
  border-color: #404040;
}

.comment-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
}

/* ===== PRIORITY STYLES ===== */
.priority-high {
  background-color: #fecaca !important;
  color: #991b1b !important;
  border-color: #f87171 !important;
}

.priority-medium {
  background-color: #fed7aa !important;
  color: #92400e !important;
  border-color: #fb923c !important;
}

.priority-low {
  background-color: #d1fae5 !important;
  color: #065f46 !important;
  border-color: #6ee7b7 !important;
}

body.dark-mode .priority-high {
  background-color: #7f1d1d !important;
  color: #fecaca !important;
}

body.dark-mode .priority-medium {
  background-color: #78350f !important;
  color: #fed7aa !important;
}

body.dark-mode .priority-low {
  background-color: #064e3b !important;
  color: #d1fae5 !important;
}

/* ===== STATUS STYLES ===== */
.status-not-started {
  background-color: #f3f4f6 !important;
  color: #1f2937 !important;
  border-color: #d1d5db !important;
}

.status-in-progress {
  background-color: #dbeafe !important;
  color: #1e40af !important;
  border-color: #93c5fd !important;
}

.status-resolved {
  background-color: #d1fae5 !important;
  color: #065f46 !important;
  border-color: #6ee7b7 !important;
}

body.dark-mode .status-not-started {
  background-color: #1f2937 !important;
  color: #f3f4f6 !important;
}

body.dark-mode .status-in-progress {
  background-color: #1e3a8a !important;
  color: #dbeafe !important;
}

body.dark-mode .status-resolved {
  background-color: #064e3b !important;
  color: #d1fae5 !important;
}

/* ===== DUE DATE STYLES ===== */
.due-overdue {
  color: #dc2626 !important;
  font-weight: 700 !important;
}

.due-soon {
  color: #f59e0b !important;
  font-weight: 600 !important;
}

body.dark-mode .due-overdue {
  color: #f87171 !important;
}

body.dark-mode .due-soon {
  color: #fbbf24 !important;
}

/* ===== PILL IMPROVEMENTS ===== */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #d1d5db;
  margin: 2px;
  background: white;
  color: #374151;
}

.pill.clickable {
  cursor: pointer;
  transition: all 0.2s;
}

.pill.clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.dark-mode .pill {
  background: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

/* ===== MULTI-SELECT IMPROVEMENTS ===== */
select[multiple] {
  padding: 8px;
}

select[multiple] option {
  padding: 6px 8px;
  border-radius: 4px;
  margin: 2px 0;
}

select[multiple] option:checked {
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

body.dark-mode select[multiple] option:checked {
  background: linear-gradient(90deg, #1e40af 0%, #1e3a8a 100%);
}

/* ===== ATTACHMENT LINK STYLES ===== */
.attachment-link {
  color: #3b82f6;
  text-decoration: none;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.attachment-link:hover {
  background: #eff6ff;
}

body.dark-mode .attachment-link {
  color: #60a5fa;
}

body.dark-mode .attachment-link:hover {
  background: #1e3a8a;
}

/* ===== RESPONSIVE IMPROVEMENTS ===== */
@media (max-width: 768px) {
  .announcement-marquee-container {
    padding: 6px 0;
  }
  
  .marquee-item {
    font-size: 13px;
    padding: 0 15px;
  }
  
  select[multiple] {
    font-size: 14px;
  }
  
  .kanban-board {
    flex-direction: column;
  }
  
  .kanban-column {
    min-width: 100%;
  }
}

/* ===== KANBAN BOARD ===== */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 20px;
  min-height: 600px;
}

.kanban-column {
  flex: 1;
  min-width: 320px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}

body.dark-mode .kanban-column {
  background: #2a2a2a;
}

.kanban-column-header {
  padding: 16px;
  border-bottom: 2px solid #e5e5e5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  border-radius: 12px 12px 0 0;
  z-index: 5;
}

body.dark-mode .kanban-column-header {
  background: #2a2a2a;
  border-bottom-color: #404040;
}

.kanban-column-title {
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kanban-column-count {
  background: #e5e7eb;
  color: #6b7280;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

body.dark-mode .kanban-column-count {
  background: #374151;
  color: #9ca3af;
}

.kanban-column-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kanban-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  border-color: #3b82f6;
}

body.dark-mode .kanban-card {
  background: #1f2937;
  border-color: #374151;
}

body.dark-mode .kanban-card:hover {
  border-color: #2563eb;
}

.kanban-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1f2937;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.dark-mode .kanban-card-title {
  color: #e5e7e5;
}

.kanban-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 11px;
}

.kanban-card-meta .pill {
  margin: 0;
}

.kanban-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #6b7280;
}

body.dark-mode .kanban-card-footer {
  border-top-color: #374151;
  color: #9ca3af;
}

.kanban-card-owners {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.kanban-card-due-date {
  font-weight: 500;
}

.kanban-empty {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
  font-size: 13px;
}

body.dark-mode .kanban-empty {
  color: #6b7280;
}

/* ===== BULK ACTIONS & CHECKBOX GROUP ===== */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

body.dark-mode .checkbox-group {
  background: #1f2937;
  border-color: #374151;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
}

.checkbox-group label:hover {
  background: #f3f4f6;
}

body.dark-mode .checkbox-group label:hover {
  background: #374151;
}

.checkbox-group input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
}

/* ===== RESOURCES FORM DARK MODE ===== */
body.dark-mode #addResourceForm {
  background: #1f2937 !important;
  border-color: #374151;
}

body.dark-mode #addResourceForm .form-label {
  color: #e5e7eb;
}

body.dark-mode #addResourceForm .form-input,
body.dark-mode #addResourceForm input[type="text"],
body.dark-mode #addResourceForm input[type="url"],
body.dark-mode #addResourceForm input[type="number"] {
  background: #111827;
  color: #e5e7eb;
  border-color: #374151;
}

body.dark-mode #addResourceForm .form-input:focus,
body.dark-mode #addResourceForm input:focus {
  border-color: #3b82f6;
  background: #1f2937;
}

body.dark-mode #addResourceForm small {
  color: #9ca3af;
}

body.dark-mode #resourcesList > div > div {
  background: #1f2937 !important;
  border-color: #374151 !important;
}

body.dark-mode #resourcesList .btn-secondary {
  background: #374151;
  color: #e5e7eb;
  border-color: #4b5563;
}

body.dark-mode #resourcesList .btn-secondary:hover {
  background: #4b5563;
}

body.dark-mode #resourcesList .btn-danger {
  background: #991b1b;
  color: #fca5a5;
  border-color: #7f1d1d;
}

body.dark-mode #resourcesList .btn-danger:hover {
  background: #7f1d1d;
}

body.dark-mode .checkbox-group span {
  color: #e5e7eb;
}

/* ===== CALENDAR STYLES ===== */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: #d0ccc5;
  padding: 2px;
  border-radius: 8px;
}

.calendar-header {
  background: #3b82f6;
  color: white;
  padding: 12px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

.calendar-day {
  background: white;
  min-height: 100px;
  padding: 8px;
  position: relative;
}

.calendar-day-empty {
  background: #f5f5f5;
}

.calendar-day-today {
  background: #fff3cd;
  border: 2px solid #ffc107;
}

.calendar-day-number {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
}

.calendar-day-events {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.calendar-event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  cursor: pointer;
}

.calendar-event-more {
  font-size: 10px;
  color: #666;
  font-weight: 600;
}

.calendar-legend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 16px;
}

.calendar-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

/* Gantt Chart Styles */
.gantt-container {
  border: 1px solid #d0ccc5;
  border-radius: 8px;
  overflow-x: auto;
  background: white;
}

.gantt-header {
  display: flex;
  border-bottom: 2px solid #d0ccc5;
  background: #f8f9fa;
}

.gantt-task-header {
  width: 250px;
  min-width: 250px;
  padding: 12px;
  font-weight: 700;
  border-right: 2px solid #d0ccc5;
}

.gantt-timeline-header {
  display: flex;
  flex: 1;
}

.gantt-day-header {
  flex: 1;
  min-width: 30px;
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border-right: 1px solid #e5e5e5;
}

.gantt-row {
  display: flex;
  border-bottom: 1px solid #e5e5e5;
}

.gantt-row:hover {
  background: #f8f9fa;
}

.gantt-task-name {
  width: 250px;
  min-width: 250px;
  padding: 12px;
  border-right: 2px solid #d0ccc5;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.gantt-timeline {
  display: flex;
  flex: 1;
}

.gantt-day-cell {
  flex: 1;
  min-width: 30px;
  border-right: 1px solid #e5e5e5;
  position: relative;
}

.gantt-day-active {
  opacity: 0.7;
}

.gantt-day-start {
  border-left: 3px solid #10b981;
  position: relative;
}

.gantt-day-start::before {
  content: '▶';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  color: #10b981;
}

.gantt-day-due {
  border-right: 3px solid #ef4444;
  position: relative;
}

.gantt-day-due::after {
  content: '◀';
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  color: #ef4444;
}

body.dark-mode .calendar-grid {
  background: #404040;
}

body.dark-mode .calendar-header {
  background: #2563eb;
}

body.dark-mode .calendar-day {
  background: #2a2a2a;
  color: #e5e5e5;
}

body.dark-mode .calendar-day-empty {
  background: #1a1a1a;
}

body.dark-mode .calendar-day-today {
  background: #3a3a1a;
  border-color: #ffc107;
}

body.dark-mode .gantt-container {
  border-color: #404040;
  background: #2a2a2a;
}

body.dark-mode .gantt-header {
  background: #1a1a1a;
  border-bottom-color: #404040;
}

body.dark-mode .gantt-task-header,
body.dark-mode .gantt-task-name {
  border-right-color: #404040;
}

body.dark-mode .gantt-row {
  border-bottom-color: #404040;
}

body.dark-mode .gantt-row:hover {
  background: #333;
}

body.dark-mode .gantt-day-header,
body.dark-mode .gantt-day-cell {
  border-right-color: #404040;
}

/* ===== MENTION DROPDOWN ===== */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #d0ccc5;
  border-radius: 6px;
  box-shadow: 0 -4px 8px rgba(0,0,0,0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  margin-bottom: 8px;
}

.mention-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
}

.mention-item:last-child {
  border-bottom: none;
}

.mention-item:hover,
.mention-item-selected {
  background: #f5f5f5;
}

.mention-item-name {
  font-weight: 600;
  font-size: 13px;
  color: #333;
  margin-bottom: 2px;
}

.mention-item-email {
  font-size: 11px;
  color: #666;
}

body.dark-mode .mention-dropdown {
  background: #2a2a2a;
  border-color: #404040;
}

body.dark-mode .mention-item {
  border-bottom-color: #333;
}

body.dark-mode .mention-item:hover,
body.dark-mode .mention-item-selected {
  background: #333;
}

body.dark-mode .mention-item-name {
  color: #e5e5e5;
}

body.dark-mode .mention-item-email {
  color: #999;
}

/* ===== APP LAUNCHER ===== */
.btn-icon {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: auto;
}

.app-launcher-grid {
  padding: 20px 0;
  min-height: 300px;
  width: 100%;
}

.app-launcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: #f9f9f9;
}

.app-launcher-item:hover {
  background: #e8e8e8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.app-launcher-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #3b82f6;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
}

.app-launcher-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-launcher-name {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

body.dark-mode .app-launcher-item {
  background: #2a2a2a;
}

body.dark-mode .app-launcher-item:hover {
  background: #333;
}

/* ===== COMMENT FEED ===== */
.comment-feed-container {
  background: white;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  overflow: hidden;
}

.comment-feed-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 15px;
  user-select: none;
}

.comment-feed-header:hover {
  opacity: 0.95;
}

.comment-feed-badge {
  background: rgba(255,255,255,0.3);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  display: none;
}

.comment-feed-body {
  padding: 16px 20px;
  max-height: 400px;
  overflow-y: auto;
}

.comment-feed-item {
  padding: 12px;
  border-bottom: 1px solid #eee;
  border-left: 3px solid #3b82f6;
  background: #f9f9f9;
  border-radius: 4px;
  margin-bottom: 8px;
}

.comment-feed-item:last-child {
  margin-bottom: 0;
}

.comment-feed-read-header {
  padding: 12px;
  background: #f3f4f6;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: #666;
  border-radius: 6px;
  user-select: none;
  margin-bottom: 8px;
}

.comment-feed-read-header:hover {
  background: #e5e7eb;
}

body.dark-mode .comment-feed-container {
  background: #2a2a2a;
}

body.dark-mode .comment-feed-body {
  background: #2a2a2a;
}

body.dark-mode .comment-feed-item {
  background: #1f1f1f;
  border-bottom-color: #404040;
}

body.dark-mode .comment-feed-read-header {
  background: #333;
  color: #999;
}

body.dark-mode .comment-feed-read-header:hover {
  background: #404040;
}

/* ===== UTILITY BUTTON STYLES ===== */
.btn-xs {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
}

/* ===== FAVORITE STAR STYLES ===== */
.favorite-star {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 16px;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
  -webkit-user-select: none;
  user-select: none;
}

.favorite-star:hover {
  transform: scale(1.2);
}

.favorite-star.favorited {
  animation: starPop 0.3s ease;
}

@keyframes starPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== ENHANCED MODAL HEADER ===== */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
}

/* ===== CHECKBOX GROUP STYLES ===== */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: #f9f9f9;
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.checkbox-group label:hover {
  background: #e5e5e5;
}

body.dark-mode .checkbox-group {
  background: #2a2a2a;
}

body.dark-mode .checkbox-group label:hover {
  background: #3a3a3a;
}

/* ===== IFRAME VIEWER MODAL STYLES ===== */
#iframeViewerModal {
  z-index: 10500; /* Higher than all other modals to allow viewing attachments from calendar events */
}

#iframeViewerModal.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

#iframeViewerModal .modal-content {
  margin: 0 !important;
  max-width: 95vw !important;
  max-height: 95vh !important;
  width: 95vw;
  height: 95vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#iframeViewerModal .modal-header {
  flex-shrink: 0;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

body.dark-mode #iframeViewerModal .modal-header {
  background: #1f1f1f;
  border-bottom-color: #404040;
}

#iframeViewerModal .modal-body {
  flex: 1 1 auto;
  padding: 0 !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  min-height: 0 !important;
  max-height: none !important; /* Override base modal-body max-height */
  height: 100%;
}

#iframeViewerFrame {
  width: 100%;
  height: 100%;
  border: none;
  flex: 1 1 auto;
  min-height: 0;
  display: block;
}

/* ===== RESOURCE TEAM SECTION DARK MODE ===== */
.resource-team-section {
  transition: background 0.3s, border-color 0.3s;
}

body.dark-mode .resource-team-section {
  background: #2a2a2a !important;
  border-color: #404040 !important;
}

body.dark-mode .resource-team-section > div:first-child {
  background: #333333 !important;
  color: #e5e5e5;
}

.resource-team-header {
  color: #666;
}

body.dark-mode .resource-team-header {
  color: #ffffff !important;
}

/* ===== VIEW CONTENT CONTAINERS ===== */
.view-content {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== DAILY DUTIES ===== */
.duty-section {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.dark-mode .duty-section {
  background: #2a2a2a;
}

.duty-section h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  border-bottom: 2px solid #e5e5e5;
  padding-bottom: 8px;
}

body.dark-mode .duty-section h4 {
  color: #e5e5e5;
  border-bottom-color: #404040;
}

.duties-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.duty-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: #f9fafb;
  border-radius: 6px;
  border: 2px solid transparent;
  transition: all 0.2s;
}

body.dark-mode .duty-item {
  background: #1f2937;
}

.duty-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.1);
}

.duty-item.completed {
  opacity: 0.6;
  background: #f0fdf4;
}

body.dark-mode .duty-item.completed {
  background: #064e3b;
}

.duty-checkbox {
  width: 24px;
  height: 24px;
  min-width: 24px;
  cursor: pointer;
  margin-top: 2px;
}

.duty-content {
  flex: 1;
  min-width: 0;
}

.duty-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: #1f2937;
}

body.dark-mode .duty-title {
  color: #e5e5e5;
}

.duty-description {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
  line-height: 1.5;
}

body.dark-mode .duty-description {
  color: #9ca3af;
}

.duty-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #9ca3af;
}

.duty-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.duty-actions {
  display: flex;
  gap: 4px;
}

.duty-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.2s;
  color: #6b7280;
}

.duty-action-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

/* Week Grid */
.duty-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  margin-top: 20px;
}

@media (max-width: 1200px) {
  .duty-week-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .duty-week-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.duty-day-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  min-height: 200px;
}

body.dark-mode .duty-day-card {
  background: #2a2a2a;
}

.duty-day-card.today {
  border: 2px solid #3b82f6;
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
}

.duty-day-header {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e5e5;
  color: #1f2937;
}

body.dark-mode .duty-day-header {
  color: #e5e5e5;
  border-bottom-color: #404040;
}

.duty-day-date {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 12px;
}

.duty-week-item {
  font-size: 13px;
  padding: 8px;
  margin-bottom: 8px;
  background: #f9fafb;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.dark-mode .duty-week-item {
  background: #1f2937;
}

.duty-week-item.completed {
  opacity: 0.6;
  text-decoration: line-through;
}

.duty-week-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Activity Log */
.duty-activity-item {
  padding: 16px;
  border-bottom: 1px solid #e5e5e5;
}

body.dark-mode .duty-activity-item {
  border-bottom-color: #404040;
}

.duty-activity-item:last-child {
  border-bottom: none;
}

.duty-activity-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.duty-activity-user {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
}

body.dark-mode .duty-activity-user {
  color: #e5e5e5;
}

.duty-activity-time {
  font-size: 12px;
  color: #9ca3af;
}

.duty-activity-action {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 4px;
}

body.dark-mode .duty-activity-action {
  color: #9ca3af;
}

.duty-activity-details {
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
}

/* ===== RESOURCES GRID ===== */
.resources-grid {
  min-height: 200px;
}

/* ===== DUTY DEFINITION MODAL TABS ===== */
.duty-def-tab {
  flex: 1;
  padding: 16px 24px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  color: #6b7280;
  transition: all 0.2s;
}

.duty-def-tab:hover {
  background: #f3f4f6;
  color: #374151;
}

.duty-def-tab.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
  background: white;
}

body.dark-mode .duty-def-tab {
  color: #9ca3af;
}

body.dark-mode .duty-def-tab:hover {
  background: #374151;
  color: #d1d5db;
}

body.dark-mode .duty-def-tab.active {
  color: #60a5fa;
  border-bottom-color: #60a5fa;
  background: #2a2a2a;
}

.duty-def-tab-content {
  display: none;
}

.duty-def-tab-content.active {
  display: block;
}

/* Duty List Item in Edit Tab */
.duty-list-item {
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
  background: white;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: all 0.2s;
}

.duty-list-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

body.dark-mode .duty-list-item {
  background: #1f1f1f;
  border-color: #374151;
}

body.dark-mode .duty-list-item:hover {
  border-color: #60a5fa;
  box-shadow: 0 2px 8px rgba(96, 165, 250, 0.1);
}

.duty-list-content {
  flex: 1;
}

.duty-list-title {
  font-weight: 600;
  font-size: 15px;
  color: #1f2937;
  margin-bottom: 4px;
}

body.dark-mode .duty-list-title {
  color: #f3f4f6;
}

.duty-list-description {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
}

body.dark-mode .duty-list-description {
  color: #9ca3af;
}

.duty-list-resources {
  font-size: 12px;
  color: #3b82f6;
}

.duty-list-actions {
  display: flex;
  gap: 8px;
}

.duty-list-actions button {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.duty-list-actions button:hover {
  background: #f3f4f6;
}

.duty-list-actions button.delete {
  color: #dc2626;
  border-color: #fecaca;
}

.duty-list-actions button.delete:hover {
  background: #fee2e2;
}

body.dark-mode .duty-list-actions button {
  background: #374151;
  border-color: #4b5563;
  color: #d1d5db;
}

body.dark-mode .duty-list-actions button:hover {
  background: #4b5563;
}

/* Calendar toggle checkboxes dark mode */
body.dark-mode .calendar-day-events {
  /* Ensure event dots are visible in dark mode */
}

body.dark-mode #calendarToggleTasks,
body.dark-mode #calendarToggleDuties,
body.dark-mode #calendarToggleGoogleCalendar {
  cursor: pointer;
}

/* ============================================================================
   APP SHELL — locked-chrome layout with full-hide sidebar (v20260518c)
   Shell is 100vh with overflow:hidden; only .app-content scrolls.
   Hamburger fully hides the sidebar (translate-offscreen + grid column → 0).
   Persists `.app-sidebar.hidden` via localStorage['soi.sidebar.hidden'].
   ============================================================================ */
:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --content-max: 1440px;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
}

/* Pre-paint state restore (set by inline <head> script before CSS paints).
   Avoids a flash where sidebar appears, then snaps offscreen. */
html[data-sidebar-init="hidden"] .app-shell { grid-template-columns: 1fr; }
html[data-sidebar-init="hidden"] .app-sidebar { position: absolute; transform: translateX(-100%); }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns var(--t-base);
  position: relative;
}
/* Hidden mode: collapse to single-column grid and absolutize the sidebar so it
   slides offscreen without consuming a grid track. Chrome was leaving .app-main
   at width:0 when we used `0 1fr`. `1fr` + absolute sidebar fixes it. */
.app-shell.shell-no-sidebar { grid-template-columns: 1fr; }
.app-shell.shell-no-sidebar .app-sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: 240px;
  height: 100%;
  z-index: 100;
}

.app-sidebar {
  background: #0f172a;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  position: static;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid #1e293b;
  transform: translateX(0);
  transition: transform var(--t-base);
}
.app-sidebar.hidden { transform: translateX(-100%); }

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.3px;
  border-bottom: 1px solid #1e293b;
  white-space: nowrap;
  min-height: var(--topbar-h);
  box-sizing: border-box;
}
.app-brand-icon { font-size: 20px; flex: 0 0 auto; }

.app-sidebar .app-tab-nav {
  display: flex !important;
  flex-direction: column;
  gap: 1px;
  padding: 8px 8px 16px;
  background: transparent !important;
  border: none !important;
  overflow-x: visible !important;
}

.nav-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  padding: 14px 14px 6px;
  font-weight: 600;
}

.app-sidebar .tab-nav-item {
  display: flex !important;
  align-items: center;
  gap: 12px;
  padding: 9px 12px !important;
  border-radius: var(--r-md) !important;
  cursor: pointer;
  color: #cbd5e1 !important;
  background: transparent !important;
  border: none !important;
  font-weight: 500;
  font-size: 14px;
  text-align: left;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--t-fast), color var(--t-fast);
}
.app-sidebar .tab-nav-item .nav-icon {
  flex: 0 0 auto;
  width: 22px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
}
.app-sidebar .tab-nav-item .nav-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-sidebar .tab-nav-item .tab-badge { flex: 0 0 auto; }
.app-sidebar .tab-nav-item:hover {
  background: #1e293b !important;
  color: #fff !important;
}
.app-sidebar .tab-nav-item.active {
  background: var(--accent-soft) !important;
  color: #fff !important;
  box-shadow: inset 2px 0 0 var(--accent);
}
.app-sidebar .tab-nav-item.hidden {
  display: none !important;
}

/* A11y: visible focus rings */
.app-sidebar .tab-nav-item:focus-visible,
.app-topbar button:focus-visible,
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* MAIN COLUMN */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: #f1eadd;
}
body.dark-mode .app-main { background: #1a1a1a; }

.app-topbar {
  flex: 0 0 auto;
  min-height: var(--topbar-h);
  position: relative;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
/* Override .navbar { flex-wrap: wrap } so topbar children stay on one row */
.app-topbar.navbar { flex-wrap: nowrap; padding: 8px 16px; }
.app-topbar .navbar-left, .app-topbar .navbar-right { flex-wrap: nowrap; min-width: 0; }
.app-topbar .navbar-left { flex: 1 1 auto; min-width: 0; gap: 12px; }
.app-topbar .navbar-right { flex: 0 0 auto; gap: 6px; }
body.dark-mode .app-topbar {
  background: rgba(30, 30, 30, 0.85);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.app-search-slot {
  display: inline-flex !important;
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px 10px;
  gap: 6px;
  min-width: 160px;
  max-width: 460px;
  flex: 1 1 200px;
}
.app-search-slot .global-search-input {
  border: none !important;
  background: transparent !important;
  outline: none !important;
  font-size: 14px;
  flex: 1;
  padding: 4px 0 !important;
}

/* CONTENT: scroll context */
.app-content {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.app-content-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-6) var(--s-7);
  box-sizing: border-box;
}

/* Hamburger is always visible (only way back when sidebar is hidden) */
.sidebar-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* Game cards grid + Rewards card visual treatment */
.game-card .game-card-cta {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: #dcfce7;
  color: #166534;
}

/* ===== REWARDS BANNER — sticky feature card above the games grid ===== */
.rewards-banner {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  margin-top: var(--s-5);
  padding: var(--s-4) var(--s-5);
  border: 1px solid #fbbf24;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 55%, #fff 100%);
  box-shadow: var(--sh-1);
  cursor: pointer;
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.rewards-banner:hover {
  box-shadow: var(--sh-2);
  transform: translateY(-1px);
}
.rewards-banner-left {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex: 1 1 auto;
  min-width: 0;
}
.rewards-banner-icon { font-size: 32px; flex: 0 0 auto; }
.rewards-banner-title { font-size: 16px; font-weight: 700; color: #78350f; }
.rewards-banner-sub { font-size: 13px; color: #92400e; }
.rewards-banner-stats { flex: 0 0 auto; }
.rewards-balance-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: #92400e;
  color: #fef3c7;
  font-size: 13px;
  font-weight: 600;
}
.rewards-banner-actions {
  display: flex;
  gap: var(--s-2);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
@media (max-width: 720px) {
  .rewards-banner { flex-wrap: wrap; }
  .rewards-banner-actions { width: 100%; }
}

/* MOBILE (≤900px): sidebar overlays content as a drawer.
   Default state: hidden offscreen. `.hidden` and the desktop pattern unify here. */
@media (max-width: 900px) {
  .app-shell,
  .app-shell.shell-no-sidebar {
    grid-template-columns: 1fr;
  }
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 1000;
    box-shadow: 2px 0 16px rgba(0,0,0,0.2);
    border-right: none;
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-sidebar.hidden { transform: translateX(-100%); }
  .app-content-inner { padding: 16px; }
  .app-search-slot { min-width: 0; flex: 1; max-width: none; }
}

/* ============================================================================
   KNOWLEDGE BASE v2 (v20260518c)
   Tree rail + main pane + contenteditable blocks + floating toolbars + modal
   ============================================================================ */
.kb-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--s-5);
  align-items: start;
}
@media (max-width: 900px) { .kb-shell { grid-template-columns: 1fr; } }

/* ── Tree rail ───────────────────────────────────────────────────────────── */
.kb-tree-rail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-height: 400px;
  position: sticky;
  top: 0;
  max-height: calc(100vh - var(--topbar-h) - var(--s-7) * 2);
  overflow-y: auto;
}
.kb-tree-header { display: flex; gap: var(--s-2); align-items: center; }
.kb-tree-search {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  background: var(--surface-muted);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.kb-tree-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kb-tree-add { padding: 4px 10px !important; min-width: 32px; }
.kb-tree-section { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; }

.kb-cat { display: flex; flex-direction: column; }
.kb-cat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  cursor: pointer;
  transition: background var(--t-fast);
  user-select: none;
}
.kb-cat-header:hover { background: var(--surface-muted); }
.kb-chevron { display: inline-block; font-size: 12px; color: var(--text-3); transition: transform var(--t-fast); }
.kb-chevron.open { transform: rotate(90deg); }
.kb-cat-icon { font-size: 14px; flex: 0 0 auto; }
.kb-cat-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-cat-pages { display: flex; flex-direction: column; gap: 1px; padding-left: 2px; }

.kb-page-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.kb-page-row:hover { background: var(--surface-muted); color: var(--text-1); }
.kb-page-row.active {
  background: var(--accent-soft);
  color: var(--text-1);
  box-shadow: inset 2px 0 0 var(--accent);
  font-weight: 600;
}
.kb-page-row.kb-dragging { opacity: 0.4; }
.kb-page-row.kb-drop-target { background: var(--accent-soft); outline: 1px dashed var(--accent); }
.kb-cat-header.kb-drop-target { background: var(--accent-soft); outline: 1px dashed var(--accent); }
.kb-page-icon { font-size: 13px; flex: 0 0 auto; }
.kb-page-title { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kb-row-kebab {
  opacity: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-size: 14px;
  line-height: 1;
  transition: opacity var(--t-fast), background var(--t-fast);
}
.kb-page-row:hover .kb-row-kebab, .kb-cat-header:hover .kb-row-kebab { opacity: 1; }
.kb-row-kebab:hover { background: var(--border); color: var(--text-1); }

.kb-tree-footer { display: flex; gap: var(--s-2); margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border); }

/* ── Main pane ───────────────────────────────────────────────────────────── */
.kb-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  min-height: 500px;
  padding: var(--s-6) var(--s-7);
  /* Independent scroll context: long pages scroll inside the pane instead of
     pushing the global scroll past the canvas end. Keeps the bottom
     "+ Add Section" button reachable. */
  max-height: calc(100vh - var(--topbar-h) - var(--s-7));
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 900px) {
  .kb-main { max-height: none; overflow: visible; }
}
.kb-landing { text-align: center; padding: var(--s-8) var(--s-5); color: var(--text-2); }
.kb-pinned-card {
  display: block;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-1);
  text-decoration: none;
  font-size: 14px;
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.kb-pinned-card:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }

.kb-page { display: flex; flex-direction: column; gap: var(--s-3); }
.kb-breadcrumb { font-size: 12px; color: var(--text-3); margin-bottom: var(--s-2); }
.kb-bread-sep { margin: 0 4px; color: var(--text-3); }
.kb-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
.kb-page-title-h1 { margin: 0; font-size: 32px; font-weight: 700; color: var(--text-1); line-height: 1.2; }
.kb-page-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.kb-title-input {
  flex: 1;
  font-size: 28px;
  font-weight: 700;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-1);
  padding: 6px 0;
}

/* ── Block viewer (read-only) ─────────────────────────────────────────────── */
.kb-blocks-view { display: flex; flex-direction: column; gap: var(--s-3); }
.kb-h1 { font-size: 28px; font-weight: 700; margin: 18px 0 6px; color: var(--text-1); }
.kb-h2 { font-size: 22px; font-weight: 700; margin: 14px 0 4px; color: var(--text-1); }
.kb-h3 { font-size: 18px; font-weight: 600; margin: 12px 0 4px; color: var(--text-1); }
.kb-p { margin: 0; line-height: 1.6; color: var(--text-1); }
.kb-p a, .kb-blocks-view a { color: #2563eb; text-decoration: underline; }
.kb-ul, .kb-ol { margin: 0; padding-left: 24px; line-height: 1.6; }
.kb-code { background: #0f172a; color: #e2e8f0; border-radius: var(--r-md); padding: 14px 16px; overflow-x: auto; font-family: 'Menlo', 'Consolas', monospace; font-size: 13px; }
.kb-quote { border-left: 3px solid var(--accent); padding: 4px 14px; color: var(--text-2); background: var(--surface-muted); border-radius: var(--r-sm); }
.kb-divider { border: none; border-top: 1px solid var(--border); margin: var(--s-5) 0; }
.kb-img { max-width: 100%; border-radius: var(--r-md); display: block; }
.kb-img-cap { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 4px; }
.kb-figure { margin: 0; }
.kb-table-wrap { overflow-x: auto; }
.kb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kb-table th, .kb-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.kb-table th { background: var(--surface-muted); font-weight: 600; }
.kb-embed { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); text-decoration: none; background: var(--surface-muted); transition: box-shadow var(--t-base); }
.kb-embed:hover { box-shadow: var(--sh-2); }
.kb-embed-title { color: var(--text-1); font-weight: 600; font-size: 14px; }
.kb-embed-url { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.kb-callout { padding: 12px 14px; border-radius: var(--r-md); border-left: 4px solid; line-height: 1.5; }
.kb-callout-info    { background: #eff6ff; border-color: #3b82f6; color: #1e3a8a; }
.kb-callout-warning { background: #fef3c7; border-color: #f59e0b; color: #78350f; }
.kb-callout-success { background: #d1fae5; border-color: #10b981; color: #065f46; }
.kb-callout-danger  { background: #fee2e2; border-color: #ef4444; color: #7f1d1d; }

/* ── Block editor ────────────────────────────────────────────────────────── */
.kb-editor-blocks { display: flex; flex-direction: column; gap: 2px; }
.kb-block {
  position: relative;
  padding: 6px 10px 6px 24px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.kb-block:hover { background: var(--surface-muted); border-color: var(--border); }
.kb-block.kb-dragging { opacity: 0.4; }
.kb-block-handle {
  position: absolute;
  left: 4px;
  top: 8px;
  font-size: 12px;
  color: var(--text-3);
  cursor: grab;
  opacity: 0;
  transition: opacity var(--t-fast);
  user-select: none;
}
.kb-block:hover .kb-block-handle { opacity: 1; }
.kb-edit-text { outline: none; min-height: 1.5em; }
.kb-edit-text[placeholder]:empty:before { content: attr(placeholder); color: var(--text-3); }
.kb-edit-text.kb-p-edit { font-size: 14px; line-height: 1.6; color: var(--text-1); }
.kb-block-h1 .kb-edit-text { font-size: 28px; font-weight: 700; line-height: 1.2; }
.kb-block-h2 .kb-edit-text { font-size: 22px; font-weight: 700; line-height: 1.25; }
.kb-block-h3 .kb-edit-text { font-size: 18px; font-weight: 600; line-height: 1.3; }
.kb-quote-edit { border-left: 3px solid var(--accent); padding: 6px 14px; background: var(--surface-muted); border-radius: var(--r-sm); }
.kb-list-edit { margin: 0; padding-left: 24px; }
.kb-list-edit li { outline: none; line-height: 1.6; }
.kb-code-edit { width: 100%; min-height: 80px; background: #0f172a; color: #e2e8f0; border-radius: var(--r-md); padding: 12px; font-family: 'Menlo', 'Consolas', monospace; font-size: 13px; border: none; outline: none; resize: vertical; }
.kb-callout-edit { padding: 10px 14px; border-radius: var(--r-md); border-left: 4px solid; }
.kb-callout-edit.kb-callout-info { background: #eff6ff; border-color: #3b82f6; }
.kb-callout-edit.kb-callout-warning { background: #fef3c7; border-color: #f59e0b; }
.kb-callout-edit.kb-callout-success { background: #d1fae5; border-color: #10b981; }
.kb-callout-edit.kb-callout-danger { background: #fee2e2; border-color: #ef4444; }
.kb-callout-tone { font-size: 11px; margin-bottom: 4px; padding: 2px 6px; border-radius: var(--r-sm); border: 1px solid var(--border); }
.kb-divider-edit { border: none; border-top: 2px dashed var(--border); margin: 12px 0; }
.kb-image-edit { border: 1px dashed var(--border-strong); border-radius: var(--r-md); padding: var(--s-3); background: var(--surface); }
.kb-image-edit[data-empty] { padding: var(--s-5); text-align: center; }
.kb-img-drop { color: var(--text-3); padding: 24px; border: 1px dashed var(--border); border-radius: var(--r-md); }
.kb-image-edit img { max-width: 100%; border-radius: var(--r-sm); display: block; }
.kb-table-edit { width: 100%; border-collapse: collapse; font-size: 13px; }
.kb-table-edit td { border: 1px solid var(--border); padding: 6px 10px; outline: none; min-width: 60px; }
.kb-table-edit td:focus { background: var(--accent-soft); }

.kb-add-block-row { margin-top: var(--s-4); }

/* ── Floating block toolbar ──────────────────────────────────────────────── */
.kb-block-toolbar {
  position: absolute;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  z-index: 100;
}
.kb-block-toolbar button {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.kb-block-toolbar button:hover { background: var(--surface-muted); color: var(--text-1); }
.kb-block-toolbar select { border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 12px; padding: 2px 4px; background: var(--surface); }

/* ── Drop indicator (block reorder) ──────────────────────────────────────── */
.kb-drop-indicator { height: 2px; background: var(--accent); margin: 2px 0; border-radius: 1px; box-shadow: 0 0 4px var(--accent-soft); }

/* ── Selection toolbar (B/I/code/link) ───────────────────────────────────── */
.kb-sel-toolbar {
  position: absolute;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: #0f172a;
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  z-index: 200;
}
.kb-sel-toolbar button {
  width: 32px;
  height: 28px;
  border: none;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
  border-radius: var(--r-sm);
  font-size: 13px;
  transition: background var(--t-fast);
}
.kb-sel-toolbar button:hover { background: rgba(255,255,255,0.1); }

/* ── Import modal ────────────────────────────────────────────────────────── */
.kb-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kb-modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  width: min(720px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.kb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.kb-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--r-sm);
  font-size: 20px;
  color: var(--text-2);
  transition: background var(--t-fast);
}
.kb-modal-close:hover { background: var(--surface-muted); color: var(--text-1); }
.kb-modal-body { padding: var(--s-5); overflow-y: auto; flex: 1 1 auto; }
.kb-modal-footer { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); display: flex; gap: var(--s-2); justify-content: flex-end; }
.kb-import-drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s-7) var(--s-5);
  text-align: center;
  color: var(--text-2);
  transition: background var(--t-fast), border-color var(--t-fast);
  cursor: pointer;
}
.kb-import-drop.active { background: var(--accent-soft); border-color: var(--accent); }
.kb-import-drop a { color: var(--accent); text-decoration: underline; }

/* ===== Modal form helper fields (v3) ===== */
.kb-form-field { margin-bottom: var(--s-3); }
.kb-form-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.kb-form-field label .req { color: #dc2626; margin-left: 2px; }
.kb-form-field input,
.kb-form-field textarea,
.kb-form-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  box-sizing: border-box;
}
.kb-form-field input:focus,
.kb-form-field textarea:focus,
.kb-form-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.kb-form-field textarea { min-height: 100px; resize: vertical; }
.kb-form-emoji-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin-top: 6px;
}
.kb-form-emoji-grid button {
  font-size: 16px;
  padding: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.kb-form-emoji-grid button:hover { background: var(--accent-soft); border-color: var(--accent); }

/* Inline toast (non-blocking alert replacement) */
.kb-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #f1f5f9;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  box-shadow: var(--sh-3);
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  z-index: 3000;
  max-width: 480px;
}
.kb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.kb-toast-success { background: #065f46; }
.kb-toast-error { background: #7f1d1d; }

/* ===== Version history side-panel ===== */
.kb-history-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(480px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--sh-3);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow);
}
.kb-history-panel.open { transform: translateX(0); }
.kb-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.kb-history-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.kb-history-list {
  flex: 0 0 auto;
  max-height: 40%;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}
.kb-history-row {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--t-fast);
}
.kb-history-row:hover { background: var(--surface-muted); }
.kb-history-row.active { background: var(--accent-soft); border-left: 3px solid var(--accent); padding-left: 13px; }
.kb-history-when { font-size: 13px; font-weight: 600; color: var(--text-1); }
.kb-history-who { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kb-history-preview {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--s-4) var(--s-5);
}
.kb-history-preview-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--border);
}
.kb-history-preview-html {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-1);
}
.kb-history-preview-html h1,
.kb-history-preview-html h2,
.kb-history-preview-html h3 { margin: 12px 0 4px; }
.kb-history-preview-html h1 { font-size: 22px; }
.kb-history-preview-html h2 { font-size: 18px; }
.kb-history-preview-html h3 { font-size: 16px; }
.kb-history-preview-html p { margin: 0 0 8px; }

/* ===== Rich text selection toolbar (floats above selection in editor) ===== */
.kb-sel-toolbar {
  position: absolute;
  display: none;
  gap: 2px;
  padding: 4px;
  background: #0f172a;
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  z-index: 2200;
  user-select: none;
}
.kb-sel-toolbar.visible { display: flex; align-items: center; }
.kb-sel-toolbar button {
  width: 32px;
  height: 28px;
  border: none;
  background: transparent;
  color: #e2e8f0;
  cursor: pointer;
  border-radius: var(--r-sm);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.kb-sel-toolbar button:hover,
.kb-sel-toolbar button.active { background: rgba(255,255,255,0.15); }
.kb-sel-toolbar .sep { width: 1px; align-self: stretch; background: rgba(255,255,255,0.15); margin: 0 2px; }
/* Make sure rendered formatting shows in viewer */
.kb-blocks-view code, .kb-page-canvas code { background: #f1f5f9; border-radius: 3px; padding: 1px 4px; font-family: 'Menlo','Consolas',monospace; font-size: 0.92em; }
.kb-blocks-view u, .kb-page-canvas u { text-decoration: underline; }
.kb-blocks-view s, .kb-page-canvas s, .kb-blocks-view strike, .kb-page-canvas strike { text-decoration: line-through; }

/* ============================================================================
   KB v2.5 — sections, columns, widgets, palette (v20260518g)
   ============================================================================ */

/* Edit mode swaps the shell into a 3-column layout: tree | canvas | palette */
.kb-shell.kb-editing { grid-template-columns: 260px 1fr 220px; }
@media (max-width: 1200px) {
  .kb-shell.kb-editing { grid-template-columns: 260px 1fr; }
  .kb-shell.kb-editing .kb-palette { display: none; }
}

/* Page canvas (vertical stack of sections) */
.kb-page-canvas { display: flex; flex-direction: column; gap: var(--s-3); padding-bottom: var(--s-8); margin-top: var(--s-4); }

/* SECTIONS */
.kb-section {
  position: relative;
  padding: var(--s-3);
  border-radius: var(--r-md);
  border: 1px dashed transparent;
  transition: border-color var(--t-fast);
}
.kb-editor-page .kb-section { min-height: 100px; }
.kb-editor-page .kb-section:hover { border-color: var(--border); }
.kb-editor-page .kb-section .kb-section-toolbar {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  box-shadow: var(--sh-1);
  z-index: 5;
}
.kb-editor-page .kb-section:hover .kb-section-toolbar { display: flex; }
.kb-editor-page .kb-section-toolbar button {
  width: 26px; height: 26px;
  border: none; background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  transition: background var(--t-fast);
}
.kb-editor-page .kb-section-toolbar button:hover { background: var(--surface-muted); color: var(--text-1); }

/* SECTION COLUMNS (the grid inside each section) */
.kb-section-cols { display: grid; gap: var(--s-4); }
.kb-section-cols[data-layout="1"]     { grid-template-columns: 1fr; }
.kb-section-cols[data-layout="2"]     { grid-template-columns: 1fr 1fr; }
.kb-section-cols[data-layout="3"]     { grid-template-columns: 1fr 1fr 1fr; }
.kb-section-cols[data-layout="50-50"] { grid-template-columns: 1fr 1fr; }
.kb-section-cols[data-layout="70-30"] { grid-template-columns: 7fr 3fr; }
.kb-section-cols[data-layout="30-70"] { grid-template-columns: 3fr 7fr; }
@media (max-width: 768px) {
  .kb-section-cols[data-layout="2"],
  .kb-section-cols[data-layout="3"],
  .kb-section-cols[data-layout="50-50"],
  .kb-section-cols[data-layout="70-30"],
  .kb-section-cols[data-layout="30-70"] { grid-template-columns: 1fr; }
}

/* CELL (a column inside a section) — row-flex with wrap so widgets can sit
   side-by-side when their widthPct values sum ≤ 100%. */
.kb-cell {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--s-3);
  min-height: 60px;
  padding: var(--s-2);
  border-radius: var(--r-sm);
}
.kb-editor-page .kb-cell { border: 1px dashed var(--border); transition: background var(--t-fast), border-color var(--t-fast); }
.kb-editor-page .kb-cell.drag-over { background: var(--accent-soft); border-color: var(--accent); border-style: solid; }
.kb-cell-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: var(--s-3); pointer-events: none; width: 100%; }

/* WIDGET */
.kb-widget { position: relative; padding: 4px 6px; border-radius: var(--r-sm); width: 100%; box-sizing: border-box; }
.kb-editor-page .kb-widget { border: 1px solid transparent; transition: background var(--t-fast), border-color var(--t-fast); cursor: grab; }
.kb-editor-page .kb-widget:hover { background: var(--surface-muted); border-color: var(--border); }
.kb-editor-page .kb-widget.kb-dragging { opacity: 0.5; }

/* Right-edge resize handle: visible on widget hover in edit mode */
.kb-widget-resize {
  position: absolute;
  top: 0;
  right: -5px;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast);
  z-index: 6;
}
.kb-editor-page .kb-widget:hover .kb-widget-resize { opacity: 1; }
.kb-widget-resize::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 28px;
  background: var(--border-strong);
  border-radius: 2px;
}
.kb-widget-resize:hover::before,
.kb-widget-resize.dragging::before { background: var(--accent); height: 40px; width: 3px; }
.kb-widget-resize.dragging { opacity: 1; }
.kb-resize-indicator {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #f1f5f9;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  pointer-events: none;
  white-space: nowrap;
}
.kb-widget-handles {
  position: absolute; top: 4px; right: 4px;
  display: none; gap: 1px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-1);
  z-index: 4;
}
.kb-editor-page .kb-widget:hover .kb-widget-handles { display: flex; }
.kb-widget-handles button {
  width: 24px; height: 24px;
  border: none; background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-2);
  transition: background var(--t-fast);
}
.kb-widget-handles button:hover { background: var(--surface-muted); color: var(--text-1); }
/* Inside a widget, contenteditable should NOT show the grab cursor (would block typing) */
.kb-editor-page .kb-widget [contenteditable] { cursor: text; }

/* ADD SECTION button between sections */
.kb-add-section { display: flex; justify-content: center; padding: var(--s-2); margin: var(--s-1) 0; }
.kb-add-section button {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-2);
  padding: 6px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.kb-add-section button:hover { background: var(--surface-muted); border-color: var(--accent); color: var(--text-1); }

/* LAYOUT PICKER popover */
.kb-layout-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  max-width: 240px;
}
.kb-layout-picker button {
  display: flex;
  gap: 2px;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.kb-layout-picker button:hover { background: var(--accent-soft); border-color: var(--accent); }
.kb-layout-picker .ico-col { display: inline-block; background: var(--text-3); border-radius: 2px; }

/* PALETTE (right pane in edit mode) */
.kb-palette {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100%;
  overflow-y: auto;
}
.kb-palette h4 { margin: 0 0 var(--s-2); font-size: 11px; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.5px; font-weight: 600; }
.kb-palette-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: grab;
  font-size: 13px;
  user-select: none;
  transition: box-shadow var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.kb-palette-item:hover { box-shadow: var(--sh-1); border-color: var(--border-strong); background: var(--surface-muted); }
.kb-palette-item.dragging { opacity: 0.4; }
.kb-palette-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 14px;
  font-weight: 600;
  flex: 0 0 auto;
  color: var(--text-2);
}

/* ============================================================================
   Sketch Showdown — keep canvas + tools + chat visible without scrolling
   (scoped to #sketch-root so the global .dashboard-card-body cap stays
   elsewhere). v20260519c
   ============================================================================ */
#sketch-root .dashboard-card-body { max-height: none; overflow: visible; }
#sketch-root .sketch-game-grid { align-items: stretch; }
#sketch-root .sketch-chat {
  height: auto !important;
  flex: 1 1 0;
  min-height: 320px;
  max-height: 70vh;
}
#sketch-root .sketch-tools {
  position: sticky;
  bottom: 0;
  background: var(--surface, #fff);
  padding: 8px 4px !important;
  margin: 4px -4px 0 !important;
  border-top: 1px solid var(--border, #e2e8f0);
  z-index: 4;
}
@media (max-height: 720px) {
  #sketch-root #sketchCanvas { max-height: 360px; }
}

/* ============================================================================
   Connect 4 — lift the .dashboard-card-body cap so the board + controls fit
   without scrolling. Scoped to #c4-root. v20260519d
   ============================================================================ */
#c4-root .dashboard-card-body { max-height: none; overflow: visible; }
#c4-root #c4Board { max-width: 520px; margin: 0 auto; }
@media (max-height: 720px) {
  #c4-root #c4Board { max-width: 440px; }
}

/* Trivia answer buttons — calm hover with no transform jump */
.trivia-answer-btn { transition: background var(--t-fast), border-color var(--t-fast); will-change: background, border-color; }
.trivia-answer-btn:hover:not(:disabled) { background: var(--surface-muted) !important; border-color: var(--accent) !important; }
.trivia-answer-btn.locked-self { background: var(--accent-soft) !important; border-color: var(--accent) !important; }

/* ============================================================================
   Guest mode — strip the shell down to just the invited game (v20260519e)
   Triggered by body.soi-guest-mode (set in patches.js when /guest/me returns a guest).
   ============================================================================ */
body.soi-guest-mode .app-sidebar { display: none !important; }
body.soi-guest-mode .app-shell   { grid-template-columns: 1fr !important; }
body.soi-guest-mode .sidebar-toggle { display: none !important; }
body.soi-guest-mode .global-search-container { display: none !important; }
body.soi-guest-mode #dropdownSettingsItem { display: none !important; } /* guests keep only dark mode */
body.soi-guest-mode .navbar-right > button { display: none !important; }
body.soi-guest-mode .navbar-right .user-badge-container { display: block !important; }
body.soi-guest-mode #rewardsBanner { display: none !important; }
body.soi-guest-mode #games-index .games-grid { display: none !important; }
body.soi-guest-mode #games-index .welcome-banner { display: none !important; }
body.soi-guest-mode #tournament-banner { display: none !important; }
body.soi-guest-mode #games-top-weekly { display: none !important; }
body.soi-guest-mode #tab-home,
body.soi-guest-mode #tab-tasks,
body.soi-guest-mode #tab-dashboard,
body.soi-guest-mode #tab-dailyduties,
body.soi-guest-mode #tab-attendance,
body.soi-guest-mode #tab-leadership,
body.soi-guest-mode #tab-resources,
body.soi-guest-mode #tab-kb { display: none !important; }
body.soi-guest-mode .role-guest { background: #fde68a !important; color: #78350f !important; padding: 2px 8px !important; border-radius: 8px !important; font-size: 11px !important; font-weight: 700 !important; }


/* Connect 4: idle-turn attention pulse (added 2026-07-13) */
@keyframes c4pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); transform: scale(1); }
  50%      { box-shadow: 0 0 12px 4px rgba(59,130,246,0.55); transform: scale(1.05); }
}
#c4DropRow.c4-attention button:not([disabled]) { animation: c4pulse 1.2s ease-in-out infinite; }
