/* =========================================================
   BIMFederate — Design System & Global Styles
   ========================================================= */

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
  /* Backgrounds */
  --bg-0: #080c10;
  --bg-1: #0d1117;
  --bg-2: #161b22;
  --bg-3: #21262d;
  --bg-4: #2d333b;
  --bg-hover: #30363d;

  /* Borders */
  --border-subtle: rgba(240, 246, 252, 0.07);
  --border-default: rgba(240, 246, 252, 0.12);
  --border-emphasis: rgba(240, 246, 252, 0.22);

  /* Text */
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-tertiary: #6e7681;
  --text-disabled: #484f58;

  /* Accent Colors */
  --blue:   #2f81f7;
  --blue-muted: #1d4f90;
  --cyan:   #39d0d8;
  --cyan-muted: #1a545c;
  --purple: #a371f7;
  --purple-muted: #4a2a8a;
  --green:  #3fb950;
  --green-muted: #1a5c26;
  --amber:  #e3b341;
  --amber-muted: #6a4e1a;
  --red:    #f85149;
  --red-muted: #6a1f1c;
  --orange: #f0883e;
  --orange-muted: #6a3a12;
  --pink:   #f778ba;

  /* Discipline Colors */
  --disc-arch:      #c9d1d9;   /* Architecture */
  --disc-struct:    #a371f7;   /* Structure */
  --disc-mech:      #39d0d8;   /* Mechanical */
  --disc-elec:      #e3b341;   /* Electrical */
  --disc-plumb:     #3fb950;   /* Plumbing */
  --disc-civil:     #f0883e;   /* Civil */
  --disc-fire:      #f85149;   /* Fire */
  --disc-facade:    #f778ba;   /* Facade */

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.7);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.35s ease;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 56px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-1);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---- Typography ---- */
h1 { font-size: 1.714rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.285rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.071rem; font-weight: 600; }
h4 { font-size: 0.928rem; font-weight: 600; }
p  { color: var(--text-secondary); line-height: 1.6; }

code, kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.857rem;
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--cyan);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* =========================================================
   LAYOUT
   ========================================================= */

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-0);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 100;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--cyan) 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--blue) 0%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Project selector */
.project-selector {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.project-selector-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.project-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.857rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  text-align: left;
}

.project-selector-btn:hover { background: var(--bg-3); border-color: var(--border-emphasis); }

.project-selector-btn .chevron {
  margin-left: auto;
  color: var(--text-tertiary);
  transition: transform var(--transition-fast);
}

.project-selector-btn.open .chevron { transform: rotate(180deg); }

.project-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-disabled);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.857rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-2);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(47, 129, 247, 0.12);
  color: var(--blue);
  border-color: rgba(47, 129, 247, 0.2);
}

.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.nav-badge.blue { background: var(--blue); }

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-card:hover { background: var(--bg-2); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

.avatar-sm { width: 22px; height: 22px; font-size: 0.6rem; }
.avatar-md { width: 32px; height: 32px; font-size: 0.857rem; }
.avatar-lg { width: 40px; height: 40px; font-size: 1rem; }

.user-card-info { overflow: hidden; }
.user-card-name { font-size: 0.857rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-role { font-size: 0.75rem; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Main Content --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-1);
}

/* --- Top Bar --- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-0);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 50;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.857rem;
  color: var(--text-secondary);
}

.topbar-breadcrumb .crumb-active { color: var(--text-primary); font-weight: 600; }
.topbar-breadcrumb .sep { color: var(--text-disabled); }

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.icon-btn:hover {
  background: var(--bg-3);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.icon-btn svg { width: 16px; height: 16px; }

.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
  border: 1px solid var(--bg-0);
}

/* Page Content */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 0.857rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  font-family: inherit;
  text-decoration: none;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.btn-primary:hover { background: #4a9cf7; box-shadow: 0 0 0 3px rgba(47,129,247,0.2); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-emphasis); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text-primary); }

.btn-danger {
  background: rgba(248, 81, 73, 0.1);
  color: var(--red);
  border-color: rgba(248, 81, 73, 0.3);
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.2); }

.btn-sm { padding: 4px 10px; font-size: 0.786rem; }
.btn-lg { padding: 10px 20px; font-size: 1rem; }
.btn-icon { padding: 7px; }
.btn-icon.btn-sm { padding: 4px; }

/* =========================================================
   BADGES
   ========================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Status Badges */
.badge-open      { background: rgba(248,81,73,0.12); color: var(--red);    border-color: rgba(248,81,73,0.25); }
.badge-progress  { background: rgba(47,129,247,0.12); color: var(--blue);   border-color: rgba(47,129,247,0.25); }
.badge-review    { background: rgba(227,179,65,0.12); color: var(--amber);  border-color: rgba(227,179,65,0.25); }
.badge-resolved  { background: rgba(63,185,80,0.12);  color: var(--green);  border-color: rgba(63,185,80,0.25); }
.badge-closed    { background: rgba(139,148,158,0.12);color: var(--text-secondary); border-color: rgba(139,148,158,0.2); }

/* Priority Badges */
.badge-critical { background: rgba(248,81,73,0.15);  color: var(--red);    border-color: rgba(248,81,73,0.3); }
.badge-high     { background: rgba(240,136,62,0.15); color: var(--orange); border-color: rgba(240,136,62,0.3); }
.badge-medium   { background: rgba(227,179,65,0.15); color: var(--amber);  border-color: rgba(227,179,65,0.3); }
.badge-low      { background: rgba(63,185,80,0.15);  color: var(--green);  border-color: rgba(63,185,80,0.3); }

/* Type Badges */
.badge-clash    { background: rgba(248,81,73,0.1);  color: var(--red);    border-color: rgba(248,81,73,0.2); }
.badge-rfi      { background: rgba(47,129,247,0.1); color: var(--blue);   border-color: rgba(47,129,247,0.2); }
.badge-design   { background: rgba(163,113,247,0.1);color: var(--purple); border-color: rgba(163,113,247,0.2); }
.badge-comment  { background: rgba(139,148,158,0.1);color: var(--text-secondary); border-color: rgba(139,148,158,0.2); }

/* Discipline Badges */
.badge-arch   { background: rgba(201,209,217,0.1);  color: var(--disc-arch);   border-color: rgba(201,209,217,0.2); }
.badge-struct { background: rgba(163,113,247,0.1);  color: var(--disc-struct); border-color: rgba(163,113,247,0.2); }
.badge-mep    { background: rgba(57,208,216,0.1);   color: var(--disc-mech);   border-color: rgba(57,208,216,0.2); }
.badge-elec   { background: rgba(227,179,65,0.1);   color: var(--disc-elec);   border-color: rgba(227,179,65,0.2); }
.badge-civil  { background: rgba(240,136,62,0.1);   color: var(--disc-civil);  border-color: rgba(240,136,62,0.2); }

/* =========================================================
   CARDS
   ========================================================= */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
  cursor: pointer;
}

.stat-card:hover {
  border-color: var(--border-emphasis);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.stat-card.blue::before   { background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.stat-card.green::before  { background: linear-gradient(90deg, var(--green), #62de78); }
.stat-card.amber::before  { background: linear-gradient(90deg, var(--amber), #f0a935); }
.stat-card.red::before    { background: linear-gradient(90deg, var(--red), #f07070); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--purple), #c49af8); }

.stat-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.stat-card-icon svg { width: 18px; height: 18px; }
.stat-card-icon.blue   { background: rgba(47,129,247,0.15); color: var(--blue); }
.stat-card-icon.green  { background: rgba(63,185,80,0.15);  color: var(--green); }
.stat-card-icon.amber  { background: rgba(227,179,65,0.15); color: var(--amber); }
.stat-card-icon.red    { background: rgba(248,81,73,0.15);  color: var(--red); }
.stat-card-icon.purple { background: rgba(163,113,247,0.15);color: var(--purple); }

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label { font-size: 0.857rem; color: var(--text-secondary); font-weight: 500; }
.stat-trend {
  font-size: 0.786rem;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* =========================================================
   ISSUE CARDS
   ========================================================= */
.issue-card {
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.issue-card:hover {
  border-color: var(--border-emphasis);
  background: var(--bg-3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.issue-card.selected {
  border-color: var(--blue);
  background: rgba(47, 129, 247, 0.05);
}

.issue-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.issue-card-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.issue-card-title {
  font-size: 0.928rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}

.issue-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.issue-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.issue-card-assignee {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.786rem;
  color: var(--text-tertiary);
}

.issue-card-date {
  font-size: 0.75rem;
  color: var(--text-disabled);
}

.issue-card-comments {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.786rem;
  color: var(--text-tertiary);
}

/* =========================================================
   FORMS & INPUTS
   ========================================================= */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.857rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label.required::after {
  content: ' *';
  color: var(--red);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.857rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,129,247,0.15);
  background: var(--bg-2);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-disabled); }

.form-select {
  appearance: none;
  cursor: pointer;
  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='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.search-input-wrap { position: relative; }
.search-input-wrap .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
.search-input-wrap .search-icon svg { width: 14px; height: 14px; }
.search-input-wrap input { padding-left: 32px; }

/* =========================================================
   MODAL
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 580px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

.modal-lg { width: 760px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--bg-3); color: var(--text-primary); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* =========================================================
   DROPDOWN
   ========================================================= */
.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--bg-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  overflow: hidden;
  animation: fadeIn 0.1s ease;
}

.dropdown.right { left: auto; right: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.857rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--bg-3); color: var(--text-primary); }
.dropdown-item.active { color: var(--blue); background: rgba(47,129,247,0.08); }
.dropdown-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }
.dropdown-section-label {
  padding: 8px 14px 4px;
  font-size: 0.714rem;
  color: var(--text-disabled);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* =========================================================
   TOAST
   ========================================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  background: var(--bg-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.857rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.2s ease;
  min-width: 280px;
  max-width: 400px;
}

.toast-icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast.warning { border-left: 3px solid var(--amber); }

/* =========================================================
   DASHBOARD
   ========================================================= */
.dashboard {
  padding: 24px;
  max-width: 1400px;
}

.dashboard-header {
  margin-bottom: 24px;
}

.dashboard-header h1 { margin-bottom: 4px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  margin-bottom: 16px;
}

.discipline-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 16px;
}

.discipline-card {
  background: var(--bg-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.discipline-card:hover { background: var(--bg-hover); border-color: var(--border-default); }

.discipline-color {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.discipline-info { flex: 1; min-width: 0; }
.discipline-name { font-size: 0.857rem; font-weight: 600; color: var(--text-primary); }
.discipline-meta { font-size: 0.75rem; color: var(--text-tertiary); }

.discipline-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.discipline-status.loaded  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.discipline-status.pending { background: var(--amber); }
.discipline-status.missing { background: var(--text-disabled); }

/* Activity Feed */
.activity-feed { padding: 0 4px; }

.activity-item {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  transition: background var(--transition-fast);
  cursor: pointer;
  border-radius: var(--radius-md);
}

.activity-item:hover { background: var(--bg-3); }

.activity-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding-top: 2px;
}

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-connector {
  width: 1px;
  background: var(--border-subtle);
  flex: 1;
  margin-top: 4px;
}

.activity-content { flex: 1; }
.activity-text { font-size: 0.857rem; color: var(--text-secondary); line-height: 1.4; }
.activity-text strong { color: var(--text-primary); }
.activity-time { font-size: 0.75rem; color: var(--text-tertiary); margin-top: 2px; }

/* =========================================================
   ISSUE TRACKER
   ========================================================= */
.issue-tracker {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.issue-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg-1);
  flex-wrap: wrap;
}

.issue-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 0.786rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  user-select: none;
}

.filter-pill:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-emphasis); }
.filter-pill.active { background: rgba(47,129,247,0.12); color: var(--blue); border-color: rgba(47,129,247,0.3); }
.filter-pill svg { width: 12px; height: 12px; }

.issue-list-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.issue-count-bar {
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.786rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* =========================================================
   ISSUE DETAIL
   ========================================================= */
.issue-detail {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.issue-detail-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  border-right: 1px solid var(--border-subtle);
}

.issue-detail-sidebar {
  width: 280px;
  overflow-y: auto;
  padding: 20px;
  flex-shrink: 0;
}

.issue-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.issue-id-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  background: var(--bg-3);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.issue-detail-title {
  font-size: 1.285rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
}

.detail-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.viewpoint-screenshot {
  width: 100%;
  height: 180px;
  background: var(--bg-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-disabled);
  font-size: 0.857rem;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 16px;
}

.viewpoint-screenshot:hover { border-color: var(--border-emphasis); }
.viewpoint-screenshot canvas { width: 100% !important; height: 100% !important; }

.viewpoint-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.857rem;
  color: white;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.viewpoint-screenshot:hover .viewpoint-overlay { opacity: 1; }

/* Detail Sidebar Properties */
.detail-prop {
  margin-bottom: 16px;
}

.detail-prop-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.detail-prop-value {
  font-size: 0.857rem;
  color: var(--text-primary);
}

/* Comment Thread */
.comment-thread { margin-top: 24px; }

.comment-thread-header {
  font-size: 0.857rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.comment-body {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.comment-author { font-size: 0.857rem; font-weight: 600; color: var(--text-primary); }
.comment-time { font-size: 0.75rem; color: var(--text-tertiary); }

.comment-text { font-size: 0.857rem; color: var(--text-secondary); line-height: 1.6; }

.comment-status-change {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.786rem;
  color: var(--text-tertiary);
  padding: 8px 0;
  border-left: 2px solid var(--border-subtle);
  padding-left: 12px;
  margin: 8px 0 8px 18px;
}

/* Comment Input */
.comment-input-area {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.comment-box {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.comment-box:focus-within { border-color: var(--blue); }

.comment-box textarea {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.857rem;
  font-family: inherit;
  resize: none;
  min-height: 60px;
}

.comment-box-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 8px;
  border-top: 1px solid var(--border-subtle);
  gap: 6px;
}

/* =========================================================
   FEDERATED VIEWER
   ========================================================= */
.viewer-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.viewer-main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#viewer-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  cursor: grab;
}

#viewer-canvas:active { cursor: grabbing; }

.viewer-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Viewer Toolbar (floating) */
.viewer-toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13,17,23,0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: all;
  box-shadow: var(--shadow-lg);
}

.viewer-tool {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  border: 1px solid transparent;
  background: transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.viewer-tool:hover { background: var(--bg-3); color: var(--text-primary); }
.viewer-tool.active { background: rgba(47,129,247,0.2); color: var(--blue); border-color: rgba(47,129,247,0.3); }
.viewer-tool svg { width: 15px; height: 15px; }

.viewer-tool-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 2px;
}

/* Viewer Side Panel */
.viewer-panel {
  width: 300px;
  background: var(--bg-0);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.viewer-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
}

.viewer-panel-tab {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.786rem;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  text-align: center;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  user-select: none;
}

.viewer-panel-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.viewer-panel-tab:hover:not(.active) { color: var(--text-secondary); }

.viewer-panel-content { flex: 1; overflow-y: auto; }

/* Discipline Layer Item */
.layer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.layer-item:last-child { border-bottom: none; }
.layer-item:hover { background: var(--bg-2); }

.layer-toggle {
  width: 36px; height: 20px;
  border-radius: var(--radius-full);
  background: var(--bg-4);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition-base);
  border: none;
}

.layer-toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-disabled);
  transition: all var(--transition-base);
}

.layer-toggle.on { background: rgba(47,129,247,0.3); }
.layer-toggle.on::after { left: 18px; background: var(--blue); }

.layer-color {
  width: 12px; height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.layer-info { flex: 1; min-width: 0; }
.layer-name { font-size: 0.857rem; font-weight: 600; color: var(--text-primary); }
.layer-meta { font-size: 0.75rem; color: var(--text-tertiary); }

.layer-opacity {
  width: 60px;
  accent-color: var(--blue);
}

/* Model Uploader */
.upload-zone {
  margin: 12px 16px;
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-md);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--blue);
  background: rgba(47,129,247,0.04);
}

.upload-zone-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: rgba(47,129,247,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  color: var(--blue);
}

.upload-zone-icon svg { width: 18px; height: 18px; }
.upload-zone-text { font-size: 0.786rem; color: var(--text-tertiary); line-height: 1.4; }
.upload-zone-text strong { color: var(--blue); }

/* Issue pin in viewer */
.issue-pin {
  position: absolute;
  width: 28px; height: 28px;
  transform: translate(-50%, -100%);
  cursor: pointer;
  pointer-events: all;
  transition: transform var(--transition-fast);
}

.issue-pin:hover { transform: translate(-50%, -100%) scale(1.2); }
.issue-pin svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6)); }

/* Properties Panel */
.properties-panel { padding: 12px 16px; }
.prop-group { margin-bottom: 14px; }
.prop-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-disabled);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.prop-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.786rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.prop-row:last-child { border-bottom: none; }
.prop-key { color: var(--text-tertiary); width: 100px; flex-shrink: 0; }
.prop-val { color: var(--text-primary); font-weight: 500; word-break: break-all; }

/* =========================================================
   PROJECTS LIST (modal)
   ========================================================= */
.projects-list { display: flex; flex-direction: column; gap: 8px; }

.project-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.project-item:hover { border-color: var(--border-emphasis); background: var(--bg-hover); transform: translateX(2px); }
.project-item.selected { border-color: var(--blue); background: rgba(47,129,247,0.05); }

.project-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.project-item-info { flex: 1; }
.project-item-name { font-size: 0.928rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.project-item-meta { font-size: 0.786rem; color: var(--text-tertiary); }

.project-item-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.project-issue-count {
  font-size: 0.786rem;
  color: var(--text-tertiary);
}

/* =========================================================
   EMPTY STATES
   ========================================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
}

.empty-state-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-xl);
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--text-disabled);
}

.empty-state-icon svg { width: 28px; height: 28px; }
.empty-state h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.857rem; max-width: 280px; }

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.animate-spin { animation: spin 1s linear infinite; }
.animate-pulse { animation: pulse 2s ease infinite; }
.animate-fade { animation: fadeIn 0.3s ease; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius-md);
}

/* =========================================================
   MISC UTILITIES
   ========================================================= */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-sm { font-size: 0.857rem; }
.text-xs { font-size: 0.75rem; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-muted { color: var(--text-disabled); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Progress bar */
.progress-bar {
  height: 4px;
  background: var(--bg-4);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width var(--transition-slow);
}

/* Viewer status bar */
.viewer-status-bar {
  position: absolute;
  bottom: 12px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(13,17,23,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  pointer-events: none;
  font-family: 'JetBrains Mono', monospace;
}

.viewer-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }

/* Notification badge on icon buttons */
.btn-notif {
  position: relative;
}
.btn-notif::after {
  content: '';
  position: absolute;
  top: 2px; right: 2px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1px solid var(--bg-0);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}

/* =========================================================
   GANTT & 4D PLANNING COMPONENT STYLES
   ========================================================= */
.gantt-task-bar:hover {
  transform: translateY(-1px);
  filter: brightness(1.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45) !important;
}

.gantt-task-wbs-row:hover {
  background: rgba(255, 255, 255, 0.04) !important;
}

.gantt-milestone-marker:hover {
  transform: translateX(-50%) scale(1.15) !important;
  transition: transform 0.15s ease;
}

.gantt-right-pane::-webkit-scrollbar {
  height: 8px;
}

.gantt-right-pane::-webkit-scrollbar-track {
  background: var(--bg-1);
}

.gantt-right-pane::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

.gantt-right-pane::-webkit-scrollbar-thumb:hover {
  background: var(--border-emphasis);
}

