:root {
  --bg: #07111f;
  --bg-soft: rgba(255,255,255,0.08);
  --panel: rgba(255,255,255,0.10);
  --border: rgba(255,255,255,0.16);
  --text: #f4f7fb;
  --muted: #aac0d9;
  --accent: #79c0ff;
  --accent-2: #9b8cff;
  --success: #6ee7b7;
  --warning: #ffd166;
  --danger: #ff7b92;
  --shadow: 0 24px 70px rgba(0,0,0,0.32);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: 'Inter', system-ui, sans-serif; color: var(--text); background: radial-gradient(circle at top left, #123055, #07111f 40%, #040914 100%); }
body { position: relative; overflow-x: hidden; }
.bg-orb {
  position: fixed; border-radius: 999px; filter: blur(80px); opacity: 0.35; pointer-events: none;
}
.orb-1 { width: 360px; height: 360px; background: #3b82f6; top: -120px; left: -60px; }
.orb-2 { width: 320px; height: 320px; background: #8b5cf6; top: 20%; right: -60px; }
.orb-3 { width: 260px; height: 260px; background: #14b8a6; bottom: 10%; left: 15%; }
.app-shell { max-width: 1600px; margin: 0 auto; padding: 28px; position: relative; z-index: 2; }
.glass {
  background: linear-gradient(180deg, rgba(255,255,255,0.13), rgba(255,255,255,0.08));
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.glass-soft {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.hero { border-radius: 28px; padding: 28px; display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 22px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.18em; color: var(--accent); font-size: 12px; margin: 0 0 8px; }
.hero h1 { margin: 0; font-size: clamp(28px, 4vw, 46px); }
.hero-sub { margin: 10px 0 0; max-width: 900px; color: var(--muted); line-height: 1.6; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn { padding: 12px 16px; border-radius: 14px; text-decoration: none; color: var(--text); border: 1px solid rgba(255,255,255,0.18); font-weight: 700; cursor: pointer; background: transparent; }
.btn-primary { background: linear-gradient(135deg, rgba(121,192,255,0.35), rgba(155,140,255,0.35)); }
.btn-secondary { background: rgba(255,255,255,0.08); }
.kpi-grid { display: grid; gap: 16px; margin-bottom: 22px; }
.kpi-grid-extended { grid-template-columns: repeat(9, 1fr); }
.kpi { border-radius: 24px; padding: 18px; min-height: 128px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi span { color: var(--muted); font-size: 14px; }
.kpi strong { font-size: 38px; line-height: 1; margin: 10px 0; }
.kpi small { color: #d1deeb; opacity: 0.8; }
.layout-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.top-grid { grid-template-columns: 1.05fr 1.95fr; }
.charts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bottom-grid { grid-template-columns: 1fr 1fr; }
.schedule-grid { grid-template-columns: 1.35fr 1fr; }
.workforce-charts-grid { margin-top: 18px; }
.workforce-tables-grid { margin-top: 18px; }
.panel { border-radius: 28px; padding: 20px; }
.wide-panel { min-height: 360px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.panel-header h2 { margin: 0; font-size: 20px; }
.badge, .muted { color: var(--muted); font-size: 13px; }
.alerts-list { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow: auto; }
.alert-item { padding: 14px; border-radius: 18px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); }
.alert-item strong { display: block; margin-bottom: 6px; }
.alert-item.warning { border-color: rgba(255,209,102,0.45); }
.alert-item.danger { border-color: rgba(255,123,146,0.45); }
.alert-item.info { border-color: rgba(121,192,255,0.45); }
.table-wrap { overflow: auto; }
.table-wrap.tall { max-height: 420px; }
.table-wrap.xl-tall { max-height: 720px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 14px; vertical-align: top; }
thead th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: rgba(7,17,31,0.88); backdrop-filter: blur(8px); z-index: 2; }
.status-pill, .ob-pill, .mini-pill { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-done { background: rgba(110,231,183,0.18); color: #b6f5da; }
.status-upcoming { background: rgba(121,192,255,0.18); color: #c6e3ff; }
.status-missing { background: rgba(255,123,146,0.18); color: #ffcada; }
.ob-pill { background: rgba(155,140,255,0.18); color: #ddd6ff; }
.mini-pill { background: rgba(255,255,255,0.08); color: #dce9f7; margin: 4px 6px 0 0; }
.mini-pill-wrap { margin-top: 10px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.summary-card { padding: 16px; border-radius: 20px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); }
.summary-card h3 { margin: 0 0 8px; font-size: 16px; }
.summary-card strong { font-size: 34px; display: block; margin-bottom: 6px; }
.footer-bar { padding: 14px 18px; border-radius: 20px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; margin-top: 18px; }
.empty-state { color: var(--muted); padding: 12px; }

.scroll-area, .alerts-list, .table-wrap, .timeline-wrap {
  scrollbar-gutter: stable both-edges;
  scrollbar-width: auto;
  scrollbar-color: rgba(121,192,255,0.7) rgba(255,255,255,0.08);
}
.scroll-area::-webkit-scrollbar,
.alerts-list::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.timeline-wrap::-webkit-scrollbar {
  width: 14px;
  height: 14px;
  -webkit-appearance: none;
}
.scroll-area::-webkit-scrollbar-thumb,
.alerts-list::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.timeline-wrap::-webkit-scrollbar-thumb {
  background: rgba(121,192,255,0.7);
  border-radius: 999px;
  border: 3px solid rgba(7,17,31,0.88);
}
.scroll-area::-webkit-scrollbar-track,
.alerts-list::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track,
.timeline-wrap::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
}
.scroll-area::-webkit-scrollbar-corner,
.alerts-list::-webkit-scrollbar-corner,
.table-wrap::-webkit-scrollbar-corner,
.timeline-wrap::-webkit-scrollbar-corner {
  background: transparent;
}
canvas { width: 100% !important; height: 320px !important; }
.tabs-bar {
  display: inline-flex;
  gap: 10px;
  padding: 10px;
  border-radius: 22px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tab-btn {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
}
.tab-btn.active {
  background: linear-gradient(135deg, rgba(121,192,255,0.28), rgba(155,140,255,0.28));
  border-color: rgba(121,192,255,0.4);
}
.dashboard-tab { display: none; }
.dashboard-tab.active { display: block; }
.timeline-wrap {
  display: flex;
  flex-direction: row;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 6px 16px;
  margin: 0 -6px;
  scroll-snap-type: x proximity;
}
.timeline-day {
  border-radius: 24px;
  padding: 18px;
  min-width: 440px;
  max-width: 520px;
  flex: 0 0 460px;
  scroll-snap-align: start;
}
.timeline-day-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.timeline-day-header h3 { margin: 0; font-size: 18px; }
.timeline-day-header span { color: var(--muted); font-size: 13px; }
.timeline-items { display: flex; flex-direction: column; gap: 12px; }
.timeline-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 14px;
  border-radius: 18px;
  padding: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.timeline-item-missing { border-color: rgba(255,123,146,0.4); }
.timeline-time { color: var(--accent); font-weight: 800; font-size: 14px; }
.timeline-content { min-width: 0; }
.timeline-topline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.timeline-sub { color: var(--muted); line-height: 1.5; margin-bottom: 8px; }
.timeline-team { line-height: 1.5; }
.text-danger { color: #ffcada; }
@media (max-width: 1480px) {
  .kpi-grid-extended { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1280px) {
  .top-grid, .bottom-grid, .charts-grid, .schedule-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { padding: 16px; }
  .hero { flex-direction: column; align-items: flex-start; }
  .kpi-grid-extended { grid-template-columns: repeat(2, 1fr); }
  .footer-bar { flex-direction: column; }
  .timeline-wrap { flex-direction: column; overflow-x: visible; }
  .timeline-day { min-width: 100%; max-width: 100%; flex-basis: auto; }
  .timeline-item { grid-template-columns: 1fr; }
  .tabs-bar { display: flex; }
}


/* Adaptive schedule layout fixes */
.schedule-grid-fixed {
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  align-items: start;
}
.schedule-timeline-panel,
.coverage-panel {
  min-width: 0;
  width: 100%;
  overflow: hidden;
}
.schedule-timeline-panel .panel-header,
.coverage-panel .panel-header {
  min-width: 0;
}
.timeline-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 18px;
  margin: 0;
}
.timeline-day {
  min-width: clamp(280px, 28vw, 420px);
  max-width: clamp(280px, 28vw, 420px);
  flex: 0 0 clamp(280px, 28vw, 420px);
}
.coverage-panel .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
}
.coverage-panel table {
  min-width: 760px;
}
@media (max-width: 1280px) {
  .schedule-grid-fixed {
    grid-template-columns: 1fr;
  }
  .timeline-day {
    min-width: min(360px, 82vw);
    max-width: min(360px, 82vw);
    flex-basis: min(360px, 82vw);
  }
}
@media (max-width: 760px) {
  .schedule-grid-fixed {
    grid-template-columns: 1fr;
  }
  .timeline-wrap {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 18px;
  }
  .timeline-day {
    min-width: 85vw;
    max-width: 85vw;
    flex: 0 0 85vw;
  }
}


.chart-scroll-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
}
.chart-scroll-inner {
  min-width: 100%;
  height: 320px;
}
.chart-scroll-wrap canvas {
  height: 320px !important;
}

.filters-panel { margin-bottom: 18px; }
.filters-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}
.filter-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.filter-field span { color: var(--muted); font-size: 13px; }
.filter-field select,
.filter-field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}
.filter-actions { display: flex; align-items: end; }
.chart-scroll-wrap { overflow-x: auto; overflow-y: hidden; padding-bottom: 10px; }
.chart-scroll-inner { min-width: 100%; }
.heatmap-wrap {
  overflow: auto;
  max-width: 100%;
  padding-bottom: 10px;
}
.heatmap-grid {
  display: grid;
  gap: 8px;
  min-width: max-content;
}
.heatmap-header,
.heatmap-row {
  display: grid;
  grid-template-columns: 170px repeat(var(--heatmap-cols), 44px);
  gap: 8px;
  align-items: center;
}
.heatmap-label {
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(7,17,31,0.9);
  font-size: 13px;
  white-space: nowrap;
}
.heatmap-day-label {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.heatmap-cell {
  width: 44px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.heatmap-cell.level-0 { background: rgba(255,255,255,0.04); color: var(--muted); }
.heatmap-cell.level-1 { background: rgba(110,231,183,0.16); color: #cff8e8; }
.heatmap-cell.level-2 { background: rgba(121,192,255,0.18); color: #d7ecff; }
.heatmap-cell.level-3 { background: rgba(255,209,102,0.22); color: #ffeeb8; }
.heatmap-cell.level-4 { background: rgba(255,123,146,0.24); color: #ffd6e0; }
.heatmap-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}
.heatmap-legend .mini-pill { margin: 0; }
@media (max-width: 1280px) {
  .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


.panel { display: flex; flex-direction: column; }
.panel > .table-wrap,
.panel > .chart-scroll-wrap,
.panel > .heatmap-wrap,
.panel > #scheduleTimeline { flex: 1 1 auto; min-height: 0; }

.filter-field select,
.filter-field input,
.filter-field select option {
  background: #122034;
  color: #eef6ff;
}
.filter-field select option { color: #eef6ff; }
.filter-field select:focus,
.filter-field input:focus {
  outline: none;
  border-color: rgba(121,192,255,0.5);
  box-shadow: 0 0 0 3px rgba(121,192,255,0.16);
}

.table-wrap-wide {
  width: 100%;
  max-width: 100%;
  overflow: auto;
}
.table-wrap-wide table {
  min-width: 720px;
}
#projectSummaryTable { min-width: 100%; }

.chart-scroll-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 10px;
  scrollbar-gutter: stable both-edges;
}
.chart-scroll-inner {
  min-width: 100%;
  height: 320px;
}
.chart-scroll-inner canvas {
  display: block;
  width: 100% !important;
  height: 320px !important;
}

.chart-scroll-wrap,
.heatmap-wrap,
.table-wrap-wide {
  scrollbar-gutter: stable both-edges;
  scrollbar-width: auto;
  scrollbar-color: rgba(121,192,255,0.7) rgba(255,255,255,0.08);
}
.chart-scroll-wrap::-webkit-scrollbar,
.heatmap-wrap::-webkit-scrollbar,
.table-wrap-wide::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
.chart-scroll-wrap::-webkit-scrollbar-thumb,
.heatmap-wrap::-webkit-scrollbar-thumb,
.table-wrap-wide::-webkit-scrollbar-thumb {
  background: rgba(121,192,255,0.7);
  border-radius: 999px;
  border: 3px solid rgba(7,17,31,0.88);
}
.chart-scroll-wrap::-webkit-scrollbar-track,
.heatmap-wrap::-webkit-scrollbar-track,
.table-wrap-wide::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
}

.schedule-grid-fixed {
  align-items: stretch;
}
.schedule-timeline-panel,
.coverage-panel {
  height: 100%;
}
.coverage-panel .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.coverage-panel table {
  min-width: 760px;
}

@media (max-width: 1280px) {
  .schedule-grid-fixed {
    grid-template-columns: 1fr;
  }
  .coverage-panel,
  .schedule-timeline-panel {
    height: auto;
  }
}


.planning-grid { margin-top: 18px; }
.availability-wrap .heatmap-grid {
  min-width: max-content;
}
.availability-wrap .heatmap-header,
.availability-wrap .heatmap-row {
  grid-template-columns: 170px repeat(var(--heatmap-cols), 72px);
}
.availability-wrap .heatmap-day-label {
  white-space: nowrap;
  font-size: 11px;
}
.availability-cell {
  width: 72px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
}
.availability-free { background: rgba(255,255,255,0.04); color: var(--muted); }
.availability-working { background: rgba(110,231,183,0.18); color: #d8ffef; }
.availability-busy { background: rgba(255,209,102,0.24); color: #ffeeb8; }
