/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.app-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: .3px;
}
.header-actions { display: flex; gap: 8px; }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
}
.sidebar-section h3 {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #64748b;
  margin-bottom: 12px;
}
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
}
.form-group input[type="date"],
.form-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: .82rem;
  background: #f8fafc;
  color: #1e293b;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus {
  border-color: #3b82f6;
}

/* Checkbox group */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  padding: 4px;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 400;
  color: #374151;
  padding: 3px 4px;
  border-radius: 4px;
  transition: background .1s;
}
.checkbox-group label:hover { background: #f1f5f9; }
.checkbox-group input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: #3b82f6;
}
.dev-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  padding: 20px 24px;
  min-width: 0;
  overflow-x: hidden;
}

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 1400px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border-left: 4px solid #94a3b8;
  transition: transform .15s, box-shadow .15s;
}
.kpi-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.kpi-card.kpi-blue { border-left-color: #3b82f6; }
.kpi-card.kpi-green { border-left-color: #22c55e; }
.kpi-card.kpi-orange { border-left-color: #f97316; }
.kpi-card.kpi-purple { border-left-color: #a855f7; }
.kpi-card.kpi-teal { border-left-color: #14b8a6; }
.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}
.kpi-label {
  font-size: .75rem;
  color: #64748b;
  margin-top: 3px;
  font-weight: 500;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 2px;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 16px;
  width: fit-content;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: .83rem;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.tab:hover { background: #f1f5f9; color: #1e293b; }
.tab.active { background: #fff; color: #1e293b; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== TOOLBAR ===== */
.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 220px;
}
.search-box svg { color: #94a3b8; flex-shrink: 0; }
.search-box input {
  border: none;
  outline: none;
  font-size: .83rem;
  color: #1e293b;
  width: 100%;
  background: transparent;
}
.panel-toolbar select {
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: .82rem;
  background: #fff;
  color: #374151;
  outline: none;
}

/* ===== TABLE ===== */
.table-wrapper {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  overflow-x: auto;
  border: 1px solid #e2e8f0;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.data-table thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table thead th:hover { background: #f1f5f9; }
.data-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody td {
  padding: 9px 12px;
  vertical-align: middle;
  color: #374151;
}
.data-table tbody tr:last-child { border-bottom: none; }

/* Cell types */
.key-link {
  color: #3b82f6;
  font-weight: 600;
  text-decoration: none;
  font-size: .8rem;
  white-space: nowrap;
}
.key-link:hover { text-decoration: underline; }
.summary-cell {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.summary-cell:hover { color: #3b82f6; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.loading-cell { text-align: center; padding: 40px; color: #94a3b8; }

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #f3e8ff; color: #7e22ce; }
.badge-teal    { background: #ccfbf1; color: #0f766e; }
.badge-orange  { background: #ffedd5; color: #c2410c; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 5px 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  font-size: .82rem;
  cursor: pointer;
  color: #374151;
  transition: all .1s;
  min-width: 32px;
  text-align: center;
}
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.page-btn:disabled { opacity: .5; cursor: default; }

/* ===== CHARTS ===== */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.chart-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  border: 1px solid #e2e8f0;
}
.chart-card h3 {
  font-size: .9rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}
.chart-card canvas { max-height: 260px; }
.chart-wide { grid-column: 1 / -1; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  font-size: .83rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-ghost { background: transparent; color: #94a3b8; border: 1px solid rgba(255,255,255,.2); }
.btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-full { width: 100%; justify-content: center; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-header h2 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #64748b;
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: #f1f5f9; }
.modal-body { padding: 20px; }

/* Timeline in modal */
.timeline-list { list-style: none; position: relative; padding-left: 20px; }
.timeline-list::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #e2e8f0;
}
.timeline-item {
  position: relative;
  padding: 8px 0 8px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -13px;
  top: 13px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #3b82f6;
}
.timeline-date { font-size: .73rem; color: #94a3b8; }
.timeline-author { font-weight: 600; color: #374151; margin-right: 6px; }
.timeline-change { font-size: .82rem; }
.arrow { color: #94a3b8; margin: 0 4px; }

/* ===== PROGRESS BARS ===== */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 100px;
}
.progress-bar {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  transition: width .3s ease;
}
.progress-label { font-size: .75rem; color: #64748b; white-space: nowrap; }

/* ===== MISC ===== */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.text-muted { color: #94a3b8; }
.text-sm { font-size: .78rem; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.loading-placeholder { color: #94a3b8; font-size: .8rem; font-style: italic; }

/* Dev color dots */
.dot-MG { background: #3b82f6; }
.dot-JM { background: #22c55e; }
.dot-GO { background: #f97316; }
.dot-FK { background: #a855f7; }
.dot-OD { background: #ef4444; }
.dot-DF { background: #14b8a6; }
.dot-CD { background: #f59e0b; }
.dot-HR { background: #6366f1; }
.dot-other { background: #94a3b8; }

/* Monthly heatmap row */
.heat-low  { background: #f0fdf4; }
.heat-med  { background: #dcfce7; }
.heat-high { background: #bbf7d0; }
.heat-vhigh{ background: #4ade80; color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
