/* =====================================================
   CATALYST — App Stylesheet
   ===================================================== */

:root {
  --primary:       #1a4a6b;
  --primary-light: #2e7d9a;
  --accent:        #f0a500;
  --danger:        #c0392b;
  --success:       #27ae60;
  --warning:       #e8791d;
  --purple:        #7d3c98;

  --bg:            #f0f4f8;
  --surface:       #ffffff;
  --surface2:      #f8fafc;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;

  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);

  --font:          'DM Sans', system-ui, sans-serif;
  --font-mono:     'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s ease;
}

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

.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.logo-icon .material-icons-round { font-size: 20px; }
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: .04em; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  padding: 12px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: background .15s, color .15s;
}
.nav-item .material-icons-round { font-size: 18px; }
.nav-item:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }

.nav-stage { border-left: 3px solid transparent; padding-left: 8px; }
.nav-stage.active,
.nav-stage:hover { border-left-color: var(--stage-color, var(--accent)); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.sidebar-user .user-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.sidebar-user .user-role { font-size: 11px; color: rgba(255,255,255,.5); text-transform: capitalize; }
.sidebar-user .user-info { flex: 1; min-width: 0; }
.logout-btn { color: rgba(255,255,255,.5); display: flex; }
.logout-btn:hover { color: #fff; }
.logout-btn .material-icons-round { font-size: 18px; }

/* =====================================================
   LAYOUT
   ===================================================== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  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;
}

.sidebar-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
}
.sidebar-toggle .material-icons-round { font-size: 22px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  text-decoration: none;
}

.main-content {
  flex: 1;
  padding: 28px 28px;
  max-width: 1400px;
  width: 100%;
}

/* =====================================================
   PAGE HEADER
   ===================================================== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
.page-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 3px; }

/* =====================================================
   CARDS
   ===================================================== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* =====================================================
   STATS GRID
   ===================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card .stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-card .stat-icon  { font-size: 20px; opacity: .6; margin-bottom: 6px; }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn .material-icons-round { font-size: 16px; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: #153d5a; }
.btn-accent   { background: var(--accent); color: #fff; }
.btn-accent:hover   { background: #d4920a; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #229954; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #a93226; }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* =====================================================
   FORMS
   ===================================================== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-label span { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(46,125,154,.15); }
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* =====================================================
   TABLES
   ===================================================== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

/* =====================================================
   BADGES & STAGE
   ===================================================== */
.stage-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .04em;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.badge-active  { background: #dcfce7; color: #166534; }
.badge-hold    { background: #fef9c3; color: #713f12; }
.badge-done    { background: #ede9fe; color: #4c1d95; }
.badge-cancel  { background: #fee2e2; color: #7f1d1d; }
.badge-low     { background: #f0fdf4; color: #166534; }
.badge-medium  { background: #fff7ed; color: #7c2d12; }
.badge-high    { background: #fef2f2; color: #7f1d1d; }

/* =====================================================
   AVATAR
   ===================================================== */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* =====================================================
   KANBAN BOARD
   ===================================================== */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}

.kanban-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--stage-col-color, var(--primary));
  font-size: 13px;
  font-weight: 600;
}
.kanban-col-header .col-count {
  margin-left: auto;
  background: var(--bg);
  border-radius: 12px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.kanban-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.kanban-card .card-dept {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 6px;
}
.kanban-card .card-title { font-size: 13px; font-weight: 600; line-height: 1.4; margin-bottom: 6px; }
.kanban-card .card-client { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.kanban-card .card-footer { display: flex; align-items: center; justify-content: space-between; }
.kanban-card .card-due { font-size: 11px; color: var(--text-muted); }
.kanban-card .card-due.overdue  { color: var(--danger); font-weight: 600; }
.kanban-card .card-due.due-soon { color: var(--warning); font-weight: 600; }

/* =====================================================
   VIEW TOGGLE
   ===================================================== */
.view-toggle { display: flex; gap: 4px; }
.view-toggle button {
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
  font-family: var(--font);
}
.view-toggle button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.view-toggle button:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.view-toggle button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.view-toggle button .material-icons-round { font-size: 16px; }

/* =====================================================
   FILTERS BAR
   ===================================================== */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}
.filters-bar .form-control { max-width: 180px; }
.search-input { max-width: 260px !important; }

/* =====================================================
   PROJECT DETAIL
   ===================================================== */
.project-detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
.project-stage-bar {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.stage-step {
  flex: 1;
  padding: 10px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  transition: background .2s;
  position: relative;
}
.stage-step:last-child { border-right: none; }
.stage-step.done    { background: #f0fdf4; color: var(--success); }
.stage-step.current { color: #fff; }
.stage-step .material-icons-round { display: block; font-size: 16px; margin: 0 auto 2px; }

.detail-meta { display: flex; flex-direction: column; gap: 12px; }
.meta-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.meta-row .meta-label { color: var(--text-muted); width: 110px; flex-shrink: 0; font-weight: 500; padding-top: 1px; }
.meta-row .meta-val   { color: var(--text); }

.update-feed { display: flex; flex-direction: column; gap: 12px; }
.update-item { display: flex; gap: 10px; }
.update-item .update-body { flex: 1; }
.update-item .update-header { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.update-item .update-name  { font-weight: 600; color: var(--text); }
.update-item .update-text  { font-size: 13px; line-height: 1.5; }

.milestone-list { display: flex; flex-direction: column; gap: 8px; }
.milestone-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 13px;
}
.milestone-item.done { opacity: .65; }
.milestone-item.done .ms-title { text-decoration: line-through; }
.milestone-item .ms-title { flex: 1; font-weight: 500; }
.milestone-item .ms-date  { font-size: 11px; color: var(--text-muted); }
.milestone-check { cursor: pointer; color: var(--text-muted); }
.milestone-check.checked { color: var(--success); }

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-16px) scale(.97); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-close .material-icons-round { font-size: 20px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* =====================================================
   TOAST
   ===================================================== */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 320px;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* =====================================================
   LOGIN PAGE
   ===================================================== */
.login-page {
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-logo .logo-icon { width: 44px; height: 44px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.login-logo .logo-icon .material-icons-round { font-size: 24px; color: var(--primary); }
.login-logo .logo-text { font-size: 24px; font-weight: 700; color: var(--primary); }
.login-subtitle { font-size: 13px; color: var(--text-muted); }
.login-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }

/* =====================================================
   PIPELINE PROGRESS
   ===================================================== */
.pipeline-overview {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}
.pipeline-stage {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-top: 3px solid var(--stage-color, var(--primary));
  padding: 14px 12px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s;
}
.pipeline-stage:hover { box-shadow: var(--shadow); }
.pipeline-stage .ps-count { font-size: 26px; font-weight: 700; color: var(--stage-color, var(--primary)); }
.pipeline-stage .ps-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-top: 2px; }
.pipeline-stage .ps-icon  { font-size: 18px; color: var(--stage-color, var(--primary)); opacity: .7; margin-bottom: 4px; }

/* =====================================================
   DEPT BREAKDOWN
   ===================================================== */
.dept-bars { display: flex; flex-direction: column; gap: 10px; }
.dept-bar-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.dept-bar-label { width: 80px; font-weight: 500; flex-shrink: 0; }
.dept-bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.dept-bar-fill  { height: 100%; border-radius: 4px; transition: width .4s ease; }
.dept-bar-count { width: 24px; text-align: right; font-weight: 600; color: var(--text-muted); font-size: 12px; }

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .material-icons-round { font-size: 40px; opacity: .4; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .project-detail-grid { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: repeat(3, minmax(200px, 1fr)); }
  .pipeline-overview { grid-template-columns: repeat(3, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .pipeline-overview { grid-template-columns: repeat(2, 1fr); }
}

/* Utilities */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.fw-600 { font-weight: 600; }
.overdue  { color: var(--danger) !important; }
.due-soon { color: var(--warning) !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
