/* ============================================
   CSS Reset & Custom Properties
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1E40AF;
  --primary-light: #3B82F6;
  --primary-lighter: #DBEAFE;
  --sidebar-bg: #0F172A;
  --sidebar-text: #94A3B8;
  --sidebar-active: #FFFFFF;
  --bg: #F1F5F9;
  --card-bg: #FFFFFF;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
  --critical: #DC2626;
  --critical-bg: #FEE2E2;
  --high: #F59E0B;
  --high-bg: #FEF3C7;
  --medium: #3B82F6;
  --medium-bg: #DBEAFE;
  --low: #6B7280;
  --low-bg: #F3F4F6;
  --success: #10B981;
  --success-bg: #D1FAE5;
  --warning: #F59E0B;
  --warning-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --text: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --input-border: #CBD5E1;
  --input-focus: #3B82F6;
  --radius: 8px;
  --radius-sm: 4px;
  --sidebar-width: 250px;
  --topbar-height: 60px;
  --transition: 0.2s ease;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--primary-light);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img { max-width: 100%; }
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ============================================
   Layout
   ============================================ */
#app {
  min-height: 100vh;
}

#main-view {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
  color: var(--primary-light);
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-text {
  color: white;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-item:hover {
  color: white;
  background: rgba(255,255,255,0.06);
  text-decoration: none;
}

.nav-item.active {
  color: white;
  background: rgba(59, 130, 246, 0.2);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--critical);
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  margin-left: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

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

.user-name {
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  color: var(--sidebar-text);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .btn-icon {
  color: var(--sidebar-text);
}

.sidebar-user .btn-icon:hover {
  color: white;
}

/* ============================================
   Content Area
   ============================================ */
#content-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   Topbar
   ============================================ */
#topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.mobile-menu-toggle {
  display: none;
}

#breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.breadcrumb-link {
  color: var(--text-muted);
}

.breadcrumb-link:hover {
  color: var(--primary-light);
}

.breadcrumb-sep {
  color: var(--text-light);
  font-size: 0.8rem;
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 600;
}

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

/* ============================================
   Main Content
   ============================================ */
#main-content {
  flex: 1;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: #1E3A8A;
}

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

.btn-danger {
  background: white;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.card.clickable {
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}

.card.clickable:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-1px);
}

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

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

.card-body.no-padding {
  padding: 0;
}

.card-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.card-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.card-full {
  grid-column: 1 / -1;
}

.property-card .card-body h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.team-card .card-body {
  text-align: center;
}

.team-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-lighter);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

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

.team-card h3 {
  margin-bottom: 4px;
}

.team-card .card-stats {
  justify-content: center;
}

/* ============================================
   Stats Cards (Dashboard)
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================
   Dashboard Grid
   ============================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ============================================
   Bar Charts (CSS)
   ============================================ */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-label {
  width: 80px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  min-width: 2px;
}

.bar-value {
  width: 32px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.bar-critical { background: var(--critical); }
.bar-high { background: var(--high); }
.bar-medium { background: var(--medium); }
.bar-low { background: var(--low); }
.bar-open { background: #3B82F6; }
.bar-in-progress { background: #8B5CF6; }
.bar-on-hold { background: #F59E0B; }
.bar-completed { background: #10B981; }

/* ============================================
   Tables
   ============================================ */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}

.table td {
  padding: 12px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.table tbody tr:hover {
  background: rgba(59, 130, 246, 0.03);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: rgba(59, 130, 246, 0.05) !important;
}

.row-warning {
  background: rgba(245, 158, 11, 0.06) !important;
}

.row-critical {
  background: rgba(220, 38, 38, 0.06) !important;
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-critical { background: var(--critical-bg); color: var(--critical); }
.badge-high { background: var(--high-bg); color: #B45309; }
.badge-medium { background: var(--medium-bg); color: var(--primary); }
.badge-low { background: var(--low-bg); color: var(--low); }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-success { background: var(--success-bg); color: #059669; }
.badge-danger { background: var(--critical-bg); color: var(--critical); }
.badge-info { background: var(--medium-bg); color: var(--primary); }

.badge-status-open { background: #DBEAFE; color: #1E40AF; }
.badge-status-in_progress { background: #EDE9FE; color: #6D28D9; }
.badge-status-on_hold { background: #FEF3C7; color: #B45309; }
.badge-status-completed { background: #D1FAE5; color: #065F46; }

.badge-asset-operational { background: var(--success-bg); color: #065F46; }
.badge-asset-needs_repair { background: var(--warning-bg); color: #B45309; }
.badge-asset-out_of_service { background: var(--danger-bg); color: var(--danger); }
.badge-asset-retired { background: var(--low-bg); color: var(--low); }

.badge-property-residential { background: #DBEAFE; color: #1E40AF; }
.badge-property-commercial { background: #EDE9FE; color: #6D28D9; }
.badge-property-vacation { background: #FEF3C7; color: #B45309; }
.badge-property-ranch { background: #D1FAE5; color: #065F46; }
.badge-property-other { background: var(--low-bg); color: var(--low); }

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: 16px;
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder {
  color: var(--text-light);
}

.form-control-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.inline-select {
  display: inline-block;
  width: auto;
}

/* ============================================
   Filters Bar
   ============================================ */
.filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.status-tabs {
  display: flex;
  gap: 4px;
  background: var(--card-bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
}

.status-tab {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.status-tab:hover {
  color: var(--text);
  background: var(--bg);
}

.status-tab.active {
  background: var(--primary);
  color: white;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.1);
  font-size: 0.75rem;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  margin-left: 4px;
}
.status-tab.active .tab-count {
  background: rgba(255,255,255,0.25);
}

.filter-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toggle-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.toggle-filter input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  font-family: inherit;
}

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

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

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* ============================================
   Detail View
   ============================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.detail-field p {
  font-size: 0.9rem;
  color: var(--text);
}

.detail-field-full {
  grid-column: 1 / -1;
}

/* ============================================
   Comments
   ============================================ */
.comments-list {
  margin-bottom: 16px;
}

.comment {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child {
  border-bottom: none;
}

.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.comment-content {
  flex: 1;
  min-width: 0;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-header strong {
  font-size: 0.875rem;
}

.comment-header .text-muted {
  font-size: 0.75rem;
}

.comment-content p {
  font-size: 0.875rem;
  color: var(--text);
  white-space: pre-wrap;
}

.comment-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.comment-form textarea {
  flex: 1;
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.empty-state h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.empty-state-sm {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.error-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--danger);
}

/* ============================================
   Loading
   ============================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  gap: 12px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Toast Notifications
   ============================================ */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: auto;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  max-width: 360px;
}

.toast.show {
  transform: translateX(0);
}

.toast svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.toast-error { border-left: 4px solid var(--danger); }
.toast-error svg { color: var(--danger); }

.toast-info { border-left: 4px solid var(--primary-light); }
.toast-info svg { color: var(--primary-light); }

.toast-warning { border-left: 4px solid var(--warning); }
.toast-warning svg { color: var(--warning); }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ============================================
   Login
   ============================================ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 100%);
  padding: 16px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 420px;
  padding: 40px 32px;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 40px;
  height: 40px;
  color: var(--primary);
  margin-bottom: 12px;
}

.login-brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.login-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.login-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  font-family: inherit;
}

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

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

/* Passkey login */
.passkey-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  font-size: 0.95rem;
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.login-divider span {
  padding: 0 12px;
}

/* Passkey settings */
.passkey-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.passkey-item:last-child {
  border-bottom: none;
}

.passkey-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.passkey-info svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
  flex-shrink: 0;
}

.passkey-actions {
  display: flex;
  gap: 6px;
}

/* ============================================
   Settings
   ============================================ */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.avatar-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.user-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.75rem;
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text);
}

/* ============================================
   User Cell
   ============================================ */
.user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

/* ============================================
   Quick Adjust (Parts)
   ============================================ */
.quick-adjust {
  display: flex;
  gap: 4px;
}

.quick-adjust .btn {
  padding: 4px 8px;
}

.quick-adjust .btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.font-bold { font-weight: 700; }

.icon-sm {
  width: 14px;
  height: 14px;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .detail-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  #sidebar {
    transform: translateX(-100%);
    width: 250px;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #content-wrapper {
    margin-left: 0;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .filters-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-tabs {
    overflow-x: auto;
    width: 100%;
    flex-wrap: nowrap;
  }

  .filter-controls {
    width: 100%;
  }

  .filter-controls .form-control {
    flex: 1;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  #main-content {
    padding: 16px;
  }

  .table {
    font-size: 0.82rem;
  }

  .table th, .table td {
    padding: 8px 10px;
  }

  .comment-form {
    flex-direction: column;
  }

  .color-picker-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .topbar-actions .btn span {
    display: none;
  }
}

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

  .login-card {
    padding: 28px 20px;
  }
}

/* Overlay for mobile sidebar */
#sidebar.open::after {
  content: '';
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 250px;
  background: rgba(0,0,0,0.3);
  z-index: -1;
}

/* ============================================
   Procedures / Checklists
   ============================================ */

/* Step list in procedure detail view */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.step-info {
  flex: 1;
}

.step-info strong {
  display: block;
  margin-bottom: 4px;
}

.step-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge-sm {
  font-size: 0.7rem;
  padding: 1px 6px;
}

/* Step builder in form view */
.step-builder-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.step-builder-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.step-builder-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-builder-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.step-builder-fields input[type="text"] {
  flex: 1;
  min-width: 160px;
}

.step-builder-fields select {
  width: 130px;
}

.step-required-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}

.step-builder-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-sm svg {
  width: 14px;
  height: 14px;
}

/* Procedure blocks in work order detail */
.procedure-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.procedure-block:last-child {
  margin-bottom: 0;
}

.procedure-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.procedure-block-header strong {
  margin-right: 8px;
}

.procedure-progress {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.procedure-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 14px;
}

.procedure-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.procedure-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.procedure-step {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
}

.procedure-step-done {
  border-left-color: var(--success);
  background: var(--success-bg);
}

.procedure-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text-muted);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.procedure-step-done .procedure-step-num {
  background: var(--success);
}

.procedure-step-content {
  flex: 1;
}

.procedure-step-title {
  font-weight: 500;
  margin-bottom: 6px;
}

.procedure-step-input {
  display: flex;
  align-items: center;
}

.step-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.step-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.step-text-input {
  display: flex;
  gap: 6px;
  align-items: center;
}

.step-text-input input {
  max-width: 250px;
}

.step-pass-fail {
  display: flex;
  gap: 6px;
}

.step-notes-section {
  margin-top: 6px;
}

.step-notes-section textarea {
  max-width: 350px;
  font-size: 0.85rem;
}

.step-out-of-range {
  border-color: #e67e22 !important;
  background-color: #fef9e7 !important;
  box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.2);
}

.step-range-indicator {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.step-range-warning {
  color: #e67e22;
}

.step-range-warning-text {
  font-size: 0.8rem;
  color: #e67e22;
  font-weight: 500;
  margin-top: 2px;
}

.step-builder-range {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.step-add-details-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
}

.step-add-details-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.text-danger {
  color: var(--danger);
}

/* ============================================
   Reports & Analytics
   ============================================ */
.report-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.report-filters {
  margin-bottom: 16px;
}

.report-filters .filter-controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group-inline label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.progress-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.progress-bar-inline {
  height: 8px;
  background: var(--success);
  border-radius: 4px;
  flex: 1;
  max-width: 80px;
}

.time-log-summary {
  padding: 8px 0 12px;
  font-size: 0.95rem;
  color: var(--text);
}

/* ============================================
   Notifications
   ============================================ */
.notification-bell-wrapper {
  position: relative;
}

#notification-bell {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  pointer-events: none;
}

.notification-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  z-index: 200;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notification-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.notification-panel-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.notification-panel-body {
  overflow-y: auto;
  max-height: 400px;
}

.notification-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

.notification-item:last-child {
  border-bottom: none;
}

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

.notification-item-unread {
  background: rgba(59, 130, 246, 0.04);
}

.notification-item-unread .notification-item-title {
  font-weight: 700;
}

.notification-item-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-lighter);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-item-icon svg {
  width: 16px;
  height: 16px;
}

.notification-item-content {
  flex: 1;
  min-width: 0;
}

.notification-item-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.notification-item-message {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.notification-item-time {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 4px;
}

@media (max-width: 480px) {
  .notification-panel {
    width: calc(100vw - 32px);
    right: -8px;
  }
}

/* ============================================
   Messages Layout
   ============================================ */
.messages-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height) - 100px);
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.messages-sidebar {
  width: 320px;
  min-width: 320px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages-sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

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

.channel-group-label {
  padding: 12px 16px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

.channel-item:hover {
  background: rgba(59, 130, 246, 0.04);
}

.channel-item.active {
  background: var(--primary-lighter);
}

.channel-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.channel-icon svg {
  width: 18px;
  height: 18px;
}

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

.channel-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.channel-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-time {
  font-size: 0.72rem;
  color: var(--text-light);
  flex-shrink: 0;
}

.channel-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.channel-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================
   Chat Area
   ============================================ */
.messages-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.messages-empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 24px;
}

.messages-empty-chat .empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  color: var(--text-light);
}

.messages-empty-chat h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.messages-empty-chat p {
  font-size: 0.9rem;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-info svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

.chat-header-info h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 75%;
}

.chat-message-own {
  align-self: flex-end;
}

.chat-message-other {
  align-self: flex-start;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 100%;
  word-wrap: break-word;
}

.chat-message-own .chat-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message-other .chat-bubble {
  background: var(--card-bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--card-shadow);
}

.chat-sender {
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--primary-light);
}

.chat-message-own .chat-sender {
  color: rgba(255,255,255,0.8);
}

.chat-text {
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-time {
  font-size: 0.68rem;
  margin-top: 4px;
  opacity: 0.6;
}

.chat-message-own .chat-time {
  text-align: right;
}

.chat-input-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}

.chat-input-form textarea {
  flex: 1;
  resize: none;
  min-height: 38px;
  max-height: 120px;
}

.chat-input-form .btn {
  flex-shrink: 0;
  height: 38px;
  width: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-input-form .btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   DM User List (modal)
   ============================================ */
.dm-user-list {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 8px;
}

.dm-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

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

.dm-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.dm-user-email {
  font-size: 0.75rem;
}

/* ============================================
   Messages Responsive
   ============================================ */
@media (max-width: 768px) {
  .messages-layout {
    flex-direction: column;
    height: auto;
  }

  .messages-sidebar {
    width: 100%;
    min-width: 0;
    max-height: 250px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .messages-chat {
    min-height: 400px;
  }

  .chat-message {
    max-width: 90%;
  }
}

/* ============================================
   Activity Stream
   ============================================ */
.activity-stream { padding: 0; }
.activity-stream-tabs { display: flex; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.stream-tab { padding: 6px 14px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer; white-space: nowrap; font-family: inherit; transition: all 0.15s; }
.stream-tab:hover { color: var(--text); border-color: var(--text-muted); }
.stream-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.stream-list { overflow-y: auto; max-height: calc(100vh - 200px); }
.stream-message { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.stream-message:hover { background: var(--bg); }
.stream-channel-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; font-weight: 600; color: var(--primary); background: var(--primary-lighter); padding: 2px 8px; border-radius: 10px; margin-bottom: 4px; }
.stream-channel-badge svg { width: 12px; height: 12px; }
.stream-sender { font-weight: 600; font-size: 0.85rem; color: var(--text); }
.stream-content { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stream-time { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; margin-left: auto; flex-shrink: 0; }
.stream-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }

/* ============================================
   Channel Groups (Sidebar)
   ============================================ */
.channel-group { margin-bottom: 4px; }
.channel-group-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); cursor: pointer; user-select: none; }
.channel-group-header:hover { color: var(--text); }
.channel-group-header svg { width: 14px; height: 14px; transition: transform 0.2s; }
.channel-group-header.collapsed svg { transform: rotate(-90deg); }
.channel-group-badge { background: var(--primary); color: white; font-size: 0.65rem; padding: 1px 6px; border-radius: 8px; font-weight: 700; }
.channel-group-items { }
.channel-group-items.collapsed { display: none; }
.channel-item-starred .channel-name::before { content: '\2605 '; color: #F59E0B; }

/* ============================================
   Mention Styles
   ============================================ */
.mention { color: var(--primary); font-weight: 600; background: var(--primary-lighter); padding: 0 4px; border-radius: 3px; cursor: pointer; }
.mention-dropdown { position: absolute; bottom: 100%; left: 0; right: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 -4px 12px rgba(0,0,0,0.1); max-height: 200px; overflow-y: auto; z-index: 100; }
.mention-dropdown-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 0.85rem; }
.mention-dropdown-item:hover, .mention-dropdown-item.active { background: var(--bg); }
.mention-dropdown-item .chat-avatar { width: 24px; height: 24px; font-size: 0.7rem; }

/* ============================================
   Reactions
   ============================================ */
.reaction-bar { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.reaction-pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 12px; border: 1px solid var(--border); font-size: 0.75rem; cursor: pointer; background: var(--card-bg); transition: all 0.15s; user-select: none; }
.reaction-pill:hover { border-color: var(--primary-light); background: var(--primary-lighter); }
.reaction-pill.active { border-color: var(--primary); background: var(--primary-lighter); }
.reaction-pill .reaction-count { font-weight: 600; color: var(--text-muted); }
.reaction-picker { position: absolute; bottom: calc(100% + 4px); right: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 -2px 8px rgba(0,0,0,0.1); padding: 6px; display: flex; gap: 2px; z-index: 50; }
.reaction-picker button { background: none; border: none; font-size: 1.2rem; padding: 4px 6px; border-radius: 6px; cursor: pointer; transition: background 0.1s; }
.reaction-picker button:hover { background: var(--bg); }

/* ============================================
   Pinned Messages
   ============================================ */
.chat-pinned { background: var(--bg); border-bottom: 1px solid var(--border); padding: 8px 16px; }
.chat-pinned-header { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); cursor: pointer; padding: 4px 0; }
.chat-pinned-header svg { width: 14px; height: 14px; color: #F59E0B; }
.pinned-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.pinned-item:last-child { border-bottom: none; }
.pinned-item .pinned-sender { font-weight: 600; font-size: 0.8rem; }
.pinned-item .pinned-text { color: var(--text-muted); margin-top: 2px; }

/* ============================================
   Thread Panel
   ============================================ */
.thread-indicator { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--primary); cursor: pointer; padding: 4px 0; font-weight: 500; }
.thread-indicator:hover { text-decoration: underline; }
.thread-panel { position: absolute; right: 0; top: 0; bottom: 0; width: 360px; background: var(--card-bg); border-left: 1px solid var(--border); box-shadow: -4px 0 12px rgba(0,0,0,0.05); display: flex; flex-direction: column; z-index: 20; }
.thread-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.thread-messages { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* ============================================
   Attachments
   ============================================ */
.attachment-strip { display: flex; gap: 8px; padding: 8px 0; overflow-x: auto; }
.attachment-thumb { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); flex-shrink: 0; }
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-thumb .attachment-remove { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,0.6); color: white; border: none; font-size: 0.7rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.message-attachment { margin-top: 8px; }
.message-attachment img { max-width: 240px; max-height: 180px; border-radius: 8px; cursor: pointer; border: 1px solid var(--border); }
.lightbox-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; z-index: 1000; cursor: pointer; }
.lightbox-overlay img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

/* ============================================
   Read Receipts
   ============================================ */
.read-receipts { display: flex; gap: -4px; margin-top: 4px; justify-content: flex-end; }
.read-receipt-dot { width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 0.5rem; font-weight: 700; margin-left: -4px; border: 1.5px solid var(--card-bg); }

/* ============================================
   System & Announcement Messages
   ============================================ */
.chat-message-system { justify-content: center; padding: 8px 16px; }
.chat-message-system .chat-bubble { background: transparent; box-shadow: none; text-align: center; font-style: italic; font-size: 0.8rem; color: var(--text-muted); padding: 4px 12px; }
.chat-message-system .system-icon { width: 14px; height: 14px; vertical-align: middle; margin-right: 4px; }
.announcement-banner { background: linear-gradient(135deg, var(--primary-lighter), #EDE9FE); border-left: 3px solid var(--primary); padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 8px 16px; }
.announcement-banner .announcement-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--primary); margin-bottom: 4px; }
[data-theme="dark"] .announcement-banner { background: rgba(59, 130, 246, 0.1); }

/* ============================================
   Message Hover Actions
   ============================================ */
.chat-message { position: relative; }
.message-actions { position: absolute; top: -8px; right: 16px; display: none; background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); padding: 2px; }
.chat-message:hover .message-actions { display: flex; }
.message-action-btn { background: none; border: none; padding: 4px 6px; cursor: pointer; color: var(--text-muted); border-radius: 4px; display: flex; align-items: center; }
.message-action-btn:hover { background: var(--bg); color: var(--text); }
.message-action-btn svg { width: 14px; height: 14px; }

/* ============================================
   Message Search
   ============================================ */
.message-search-overlay { padding: 16px; }
.message-search-results { max-height: 400px; overflow-y: auto; margin-top: 12px; }
.message-search-result { display: flex; gap: 12px; padding: 10px; border-radius: 8px; cursor: pointer; transition: background 0.15s; }
.message-search-result:hover { background: var(--bg); }
.search-result-channel { font-size: 0.7rem; font-weight: 600; color: var(--primary); }
.search-result-text { font-size: 0.85rem; color: var(--text); }
.search-highlight { background: #FEF08A; padding: 0 2px; border-radius: 2px; }
[data-theme="dark"] .search-highlight { background: rgba(234, 179, 8, 0.3); }

/* ============================================
   Messages Enhanced Responsive
   ============================================ */
@media (max-width: 768px) {
  .messages-layout { flex-direction: column; }
  .messages-sidebar { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
  .thread-panel { width: 100%; }
  .reaction-picker { position: fixed; bottom: 0; left: 0; right: 0; border-radius: 12px 12px 0 0; padding: 12px; justify-content: center; }
}

/* ============================================
   Vendors & Purchase Orders
   ============================================ */
.badge-secondary { background: #F3F4F6; color: #6B7280; }
.badge-primary { background: var(--primary-bg); color: var(--primary); }

.filter-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-light);
  transition: all 0.15s ease;
}

.filter-tab:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.filter-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.po-item-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.po-item-row:last-child {
  border-bottom: none;
}

.po-item-row .form-row {
  align-items: flex-end;
}

.link {
  color: var(--primary);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

table tfoot td {
  border-top: 2px solid var(--border);
  font-weight: 600;
}

/* ============================================
   Pagination
   ============================================ */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}
.pagination-info {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pagination-current {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 100px;
  text-align: center;
}

/* ============================================
   User Management System
   ============================================ */

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.status-badge.status-active { background: #DCFCE7; color: #166534; }
.status-badge.status-suspended { background: #FEF9C3; color: #854D0E; }
.status-badge.status-deactivated { background: #FEE2E2; color: #991B1B; }
.status-badge.status-invited { background: #DBEAFE; color: #1E40AF; }

/* Dark theme status badges */
[data-theme="dark"] .status-badge.status-active { background: #166534; color: #DCFCE7; }
[data-theme="dark"] .status-badge.status-suspended { background: #854D0E; color: #FEF9C3; }
[data-theme="dark"] .status-badge.status-deactivated { background: #991B1B; color: #FEE2E2; }
[data-theme="dark"] .status-badge.status-invited { background: #1E40AF; color: #DBEAFE; }

/* Role badges */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.role-badge.role-admin { background: #FEE2E2; color: #991B1B; }
.role-badge.role-manager { background: #DBEAFE; color: #1E40AF; }
.role-badge.role-technician { background: #F3F4F6; color: #374151; }

[data-theme="dark"] .role-badge.role-admin { background: #991B1B; color: #FEE2E2; }
[data-theme="dark"] .role-badge.role-manager { background: #1E40AF; color: #DBEAFE; }
[data-theme="dark"] .role-badge.role-technician { background: #374151; color: #F3F4F6; }

/* Sidebar section labels */
.nav-section-label {
  padding: 16px 20px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text);
  opacity: 0.5;
}

/* User management table */
.user-table { width: 100%; border-collapse: collapse; }
.user-table th { text-align: left; padding: 10px 12px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.user-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
.user-table tr:hover { background: var(--bg); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .user-avatar-sm { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.user-cell a { color: var(--text); font-weight: 500; text-decoration: none; }
.user-cell a:hover { color: var(--primary); }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filter-bar .form-control { height: 36px; font-size: 0.85rem; }
.filter-bar select { min-width: 140px; }

/* Bulk action toolbar */
.bulk-toolbar { display: flex; gap: 8px; align-items: center; padding: 10px 16px; background: var(--primary-lighter); border-radius: 8px; margin-bottom: 16px; }
.bulk-toolbar .bulk-count { font-size: 0.85rem; font-weight: 600; color: var(--primary); margin-right: 8px; }

[data-theme="dark"] .bulk-toolbar { background: rgba(59, 130, 246, 0.15); }

/* User detail page */
.user-detail-header { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.user-detail-header .user-avatar-xl { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 1.5rem; flex-shrink: 0; }
.user-detail-info h1 { font-size: 1.5rem; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.user-detail-actions { margin-left: auto; display: flex; gap: 8px; }

/* Tabs */
.tab-bar { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn { padding: 10px 20px; font-size: 0.9rem; font-weight: 600; border: none; background: none; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; font-family: inherit; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: 10px; padding: 20px; box-shadow: var(--card-shadow); }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.stat-card .stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Permission grid */
.perm-grid { display: grid; gap: 16px; }
.perm-group { background: var(--card-bg); border-radius: 8px; padding: 16px; border: 1px solid var(--border); }
.perm-group-title { font-size: 0.9rem; font-weight: 700; text-transform: capitalize; margin-bottom: 10px; color: var(--text); }
.perm-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.perm-row label { font-size: 0.85rem; color: var(--text); cursor: pointer; }
.perm-row input[type="checkbox"] { accent-color: var(--primary); }
.perm-row.perm-override { background: #FEF9C3; padding: 4px 8px; border-radius: 4px; margin: 2px -8px; }
[data-theme="dark"] .perm-row.perm-override { background: rgba(234, 179, 8, 0.15); }

/* Activity feed */
.activity-feed { list-style: none; }
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.activity-time { font-size: 0.75rem; color: var(--text-muted); }
.activity-text { font-size: 0.85rem; color: var(--text); }

/* Review cards */
.review-card { background: var(--card-bg); border-radius: 10px; padding: 20px; box-shadow: var(--card-shadow); margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.review-card-info { flex: 1; }
.review-card-info h3 { font-size: 1rem; margin-bottom: 4px; }
.review-card-info h3 a { color: var(--text); text-decoration: none; }
.review-card-info h3 a:hover { color: var(--primary); }
.review-card-meta { display: flex; gap: 16px; font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }
.review-card-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: 16px; }

/* Approval cards */
.approval-card { background: var(--card-bg); border-radius: 10px; padding: 20px; box-shadow: var(--card-shadow); margin-bottom: 12px; }
.approval-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.approval-card-entity { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; background: var(--primary-lighter); color: var(--primary); }
.approval-card-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Delegation cards */
.delegation-card { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.delegation-card:last-child { border-bottom: none; }
.delegation-info { display: flex; align-items: center; gap: 12px; }
.delegation-dates { font-size: 0.8rem; color: var(--text-muted); }

/* Invite page */
.invite-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 100%); padding: 16px; }
.invite-card { background: var(--card-bg); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); width: 100%; max-width: 420px; padding: 40px 32px; }
.invite-brand { text-align: center; margin-bottom: 28px; }
.invite-brand h1 { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.invite-brand p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.invite-success { text-align: center; padding: 20px 0; }
.invite-success svg { width: 48px; height: 48px; color: #22C55E; margin-bottom: 12px; }
.invite-error { text-align: center; padding: 20px 0; }
.invite-error svg { width: 48px; height: 48px; color: #EF4444; margin-bottom: 12px; }

/* Comparison table */
.compare-table { width: 100%; border-collapse: collapse; }
.compare-table th { text-align: left; padding: 10px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.compare-table td { padding: 10px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.compare-table .metric-label { font-weight: 600; color: var(--text-muted); }
.compare-highlight { background: rgba(34, 197, 94, 0.1); font-weight: 700; }

/* Register admin warning */
.register-admin-warning {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: #FEF9C3;
  border: 1px solid #FDE68A;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: #854D0E;
}
.register-admin-warning svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.register-admin-warning strong { display: block; margin-bottom: 2px; }
.register-admin-warning p { margin: 0; opacity: 0.85; }
[data-theme="dark"] .register-admin-warning { background: rgba(234, 179, 8, 0.15); border-color: rgba(234, 179, 8, 0.3); color: #FDE68A; }

/* ============================================
   Guide: Users & Permissions Charts
   ============================================ */

/* Role hierarchy */
.hierarchy-chart { display: flex; flex-direction: column; align-items: center; padding: 8px 0; }
.hier-node { display: flex; align-items: center; gap: 16px; padding: 16px 24px; background: var(--card-bg); border: 2px solid var(--border); border-radius: 12px; width: 100%; max-width: 560px; }
.hier-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hier-icon svg { width: 22px; height: 22px; }
.hier-details strong { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin-bottom: 4px; }
.hier-details p { font-size: 0.8rem; color: var(--text-muted); margin: 0; line-height: 1.4; }
.hier-line { width: 2px; height: 24px; background: var(--border); }

.hier-fork { width: 100%; max-width: 560px; }
.hier-fork-line { width: 50%; height: 24px; margin: 0 auto; border-left: 2px solid var(--border); border-right: 2px solid var(--border); border-bottom: 2px solid var(--border); border-radius: 0 0 12px 12px; }
.hier-fork-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: -1px; }
.hier-fork-branches .hier-node { max-width: none; }
.hier-fork-branches .hier-node::before { content: ''; display: block; width: 2px; height: 16px; background: var(--border); position: absolute; top: -16px; left: 50%; }
.hier-fork-branches .hier-node { position: relative; }

/* Permission flow diagram */
.perm-flow-diagram { display: flex; flex-direction: column; gap: 12px; }
.perm-flow-row { display: flex; align-items: center; gap: 12px; }
.perm-flow-box { flex: 1; padding: 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--card-bg); }
.perm-flow-box i:first-child { width: 20px; height: 20px; color: var(--primary); margin-bottom: 6px; display: block; }
.perm-flow-box strong { display: block; margin-bottom: 4px; font-size: 0.9rem; }
.perm-flow-box span { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.perm-flow-box code { background: var(--bg); padding: 1px 5px; border-radius: 3px; font-size: 0.75rem; }
.perm-flow-arrow { flex-shrink: 0; color: var(--text-muted); }
.perm-flow-arrow svg { width: 20px; height: 20px; }
.perm-flow-plus { text-align: center; color: var(--primary); }
.perm-flow-plus svg { width: 24px; height: 24px; }
.perm-flow-effective { border-color: var(--primary) !important; background: var(--primary-lighter) !important; }
.perm-flow-override { border-style: dashed; }
.perm-flow-note { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; background: var(--bg); border-radius: 8px; font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }

/* Property access diagram */
.prop-access-diagram { }
.prop-access-rule { display: flex; align-items: flex-start; gap: 16px; padding: 16px; background: var(--bg); border-radius: 10px; margin-bottom: 16px; }
.prop-access-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.prop-access-icon svg { width: 22px; height: 22px; }
.prop-access-rule p { font-size: 0.85rem; color: var(--text-muted); margin: 6px 0 0; line-height: 1.4; }
.prop-access-examples { display: flex; flex-direction: column; gap: 8px; }
.prop-access-example { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); }
.prop-access-scenario { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 0.85rem; }
.prop-access-scenario svg { width: 18px; height: 18px; flex-shrink: 0; }
.prop-access-result { font-size: 0.8rem; color: var(--text-muted); flex: 1; }

/* Review / approval chain */
.chain-diagram { }
.chain-section { padding: 12px 0; }
.chain-flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chain-flow > svg { width: 18px; height: 18px; flex-shrink: 0; }
.chain-step { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chain-step small { font-size: 0.7rem; color: var(--text-muted); }
.chain-step-outcome { flex-direction: row; gap: 6px; padding: 6px 12px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; }
.chain-step-outcome svg { width: 16px; height: 16px; }
.chain-step-approve { background: #DCFCE7; color: #166534; }
.chain-step-rework { background: #FEF9C3; color: #854D0E; }
.chain-step-reject { background: #FEE2E2; color: #991B1B; }
[data-theme="dark"] .chain-step-approve { background: #166534; color: #DCFCE7; }
[data-theme="dark"] .chain-step-rework { background: #854D0E; color: #FEF9C3; }
[data-theme="dark"] .chain-step-reject { background: #991B1B; color: #FEE2E2; }

@media (max-width: 768px) {
  .hier-fork-branches { grid-template-columns: 1fr; }
  .perm-flow-row { flex-direction: column; }
  .perm-flow-arrow svg { transform: rotate(90deg); }
  .chain-flow { flex-direction: column; align-items: flex-start; }
}

/* ============================================
   Team Tags (multi-team display)
   ============================================ */
.team-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.team-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 14px; font-size: 0.75rem; font-weight: 600; background: var(--primary-lighter); color: var(--primary); }
.team-tag button { background: none; border: none; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 0.85rem; opacity: 0.7; font-family: inherit; }
.team-tag button:hover { opacity: 1; }
.team-tags select { height: 28px; font-size: 0.75rem; padding: 0 8px; border-radius: 14px; border: 1px dashed var(--border); background: transparent; color: var(--text-muted); cursor: pointer; }
[data-theme="dark"] .team-tag { background: rgba(59, 130, 246, 0.2); }

/* God mode badge */
.god-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: linear-gradient(135deg, #7C3AED, #A855F7);
  color: white;
  box-shadow: 0 1px 4px rgba(124, 58, 237, 0.3);
}
.btn-god {
  background: linear-gradient(135deg, #7C3AED, #A855F7);
  color: white;
  border: none;
}
.btn-god:hover { opacity: 0.9; }
