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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  padding: 20px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  text-align: center;
}
.loading h1 { font-size: 24px; color: #f8fafc; margin-bottom: 8px; }
.loading-sub { color: #64748b; font-size: 14px; }

.header {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
}
.header h1 { font-size: 28px; color: #f8fafc; margin-bottom: 8px; }
.header .subtitle { color: #94a3b8; font-size: 14px; }

.refresh-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: #2563eb;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.refresh-btn:hover { background: #1d4ed8; }
.refresh-btn:disabled { background: #475569; cursor: not-allowed; }

/* Back link */
.back-link {
  color: #64748b;
  text-decoration: none;
  font-size: 13px;
  display: inline-block;
  margin-bottom: 12px;
}
.back-link:hover { color: #38bdf8; }

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid #334155;
  padding-bottom: 0;
}
.tab {
  background: none;
  border: none;
  color: #64748b;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: #e2e8f0; }
.tab.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
}

/* Stats */
.stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
}
.stat-card {
  background: #1e293b;
  border-radius: 12px;
  padding: 20px 30px;
  text-align: center;
  min-width: 160px;
  border: 1px solid #334155;
}
.stat-card .value { font-size: 36px; font-weight: 700; color: #38bdf8; }
.stat-card .label { font-size: 13px; color: #94a3b8; margin-top: 4px; }
.stat-card.warning .value { color: #fbbf24; }
.stat-card.success .value { color: #4ade80; }

/* Charts */
.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
.chart-card {
  background: #1e293b;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #334155;
}
.chart-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: #f1f5f9;
}
.chart-card canvas { max-height: 300px; }

/* Table */
.table-section {
  max-width: 1200px;
  margin: 0 auto;
}
.table-section h3 {
  font-size: 18px;
  margin-bottom: 12px;
}
.search { margin-bottom: 12px; }
.search input {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 8px 16px;
  border-radius: 8px;
  width: 300px;
  font-size: 14px;
  outline: none;
}
.search input:focus { border-color: #38bdf8; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #1e293b;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #334155;
}
th {
  background: #334155;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}
th:hover { color: #38bdf8; }
th.sorted-asc::after { content: ' ▲'; }
th.sorted-desc::after { content: ' ▼'; }

td {
  padding: 10px 16px;
  border-top: 1px solid #1e293b;
  font-size: 14px;
}
tr:nth-child(even) td { background: #0f172a22; }
tr:hover td { background: #334155; }

/* Ticket badges */
.ticket-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
}
.tickets-high { background: #dc262622; color: #f87171; }
.tickets-med { background: #f59e0b22; color: #fbbf24; }
.tickets-low { background: #22c55e22; color: #4ade80; }
.tickets-zero { background: #64748b22; color: #64748b; }

/* Activity section */
.activity-section {
  max-width: 1400px;
  margin: 40px auto 0;
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.activity-header h3 {
  font-size: 20px;
  color: #f8fafc;
}

.period-tabs {
  display: flex;
  gap: 4px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 4px;
}
.period-tab {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.period-tab:hover {
  color: #e2e8f0;
}
.period-tab.active {
  background: #2563eb;
  color: #fff;
  font-weight: 600;
}

.activity-meta {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 12px;
}
.activity-meta .stat {
  color: #38bdf8;
  font-weight: 600;
  margin: 0 4px;
}

.activity-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.activity-controls input[type="text"],
.activity-controls select {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.activity-controls input[type="text"] {
  width: 280px;
}
.activity-controls input[type="text"]:focus,
.activity-controls select:focus {
  border-color: #38bdf8;
}
.activity-controls label {
  color: #94a3b8;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.activity-controls input[type="checkbox"] {
  cursor: pointer;
}
.toggle-all-btn {
  background: #334155;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.toggle-all-btn:hover {
  background: #475569;
}
.sort-dir-btn {
  background: #334155;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
.sort-dir-btn:hover { background: #475569; }

.activity-loading {
  text-align: center;
  color: #64748b;
  padding: 40px;
}

/* Activity table */
.activity-table-wrap {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  overflow: hidden;
}
.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.activity-table th {
  background: #334155;
  color: #94a3b8;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.activity-table th:hover {
  color: #38bdf8;
}
.activity-table th.sorted-asc::after { content: ' ▲'; }
.activity-table th.sorted-desc::after { content: ' ▼'; }
.activity-table th[data-col="expand"],
.activity-table th[data-col="projects"],
.activity-table th[data-col="modules"] {
  cursor: default;
}
.activity-table th[data-col="expand"]:hover,
.activity-table th[data-col="projects"]:hover,
.activity-table th[data-col="modules"]:hover {
  color: #94a3b8;
}
.activity-table td {
  padding: 10px 12px;
  border-top: 1px solid #0f172a44;
  vertical-align: middle;
}
.activity-table tbody tr {
  transition: background 0.1s;
}
.activity-table tbody tr:nth-child(4n+1) td {
  background: #0f172a33;
}
.activity-table tbody tr.row-main:hover td {
  background: #33415544;
}
.activity-table tbody tr.empty td {
  opacity: 0.4;
}

.expand-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 8px;
  border-radius: 4px;
  transition: color 0.2s;
}
.expand-btn:hover {
  color: #38bdf8;
}

.activity-name {
  color: #f1f5f9;
  font-weight: 500;
}
.activity-position {
  color: #64748b;
  font-size: 11px;
}

.total-badge {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  min-width: 32px;
  text-align: center;
}
.total-badge.zero {
  background: #33415555;
  color: #64748b;
}
.source-count {
  display: inline-block;
  color: #94a3b8;
  font-weight: 600;
  min-width: 24px;
}
.source-count.zero {
  color: #475569;
}

.inline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 280px;
}
.mini-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #334155;
  color: #e2e8f0;
  white-space: nowrap;
  cursor: default;
}
.mini-chip.cai { background: #3b82f622; color: #60a5fa; }
.mini-chip.acn { background: #64748b33; color: #cbd5e1; }
.mini-chip.infra { background: #f9731622; color: #fb923c; }
.mini-chip.module {
  background: #8b5cf622;
  color: #a78bfa;
  position: relative;
}
.mini-chip.chip-recent {
  background: #16a34a33;
  color: #4ade80;
}
.mini-chip.module.has-subs {
  cursor: pointer;
}
.mini-chip.module .sub-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 6px 8px;
  z-index: 50;
  min-width: 140px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
.mini-chip.module:hover .sub-tooltip {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sub-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: #cbd5e1;
  padding: 2px 0;
}
.sub-tooltip-row .count {
  color: #38bdf8;
  font-weight: 600;
  margin-left: 8px;
}
.mini-chip a {
  color: inherit;
  text-decoration: none;
}
.mini-chip a:hover { text-decoration: underline; }
.mini-chip .count {
  color: #38bdf8;
  font-weight: 600;
  margin-left: 4px;
}

/* Expanded row */
.row-detail {
  display: none;
}
.row-detail.expanded {
  display: table-row;
}
.row-detail td {
  background: #0f172a !important;
  padding: 16px 12px 20px 12px;
}

/* Week navigation */
.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.week-nav button {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.week-nav button:hover {
  color: #38bdf8;
  border-color: #38bdf8;
}
.week-nav span {
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 500;
}

/* 7-day timeline grid */
.tl-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #334155;
  border: 1px solid #334155;
  border-radius: 8px;
  overflow: hidden;
}
.tl-column {
  background: #0f172a;
  min-width: 0;
}
.tl-column.tl-weekend {
  background: #0c0f1a;
  opacity: 0.65;
}
.tl-weekend-header {
  background: #1a2233 !important;
}
.tl-weekend-header .tl-day-name {
  color: #475569 !important;
}
.tl-day-header {
  padding: 8px 10px;
  background: #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
}
.tl-day-name {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
}
.tl-day-count {
  font-size: 11px;
  background: #2563eb;
  color: #fff;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 700;
}
.tl-day-count.zero {
  background: #33415555;
  color: #475569;
}
.tl-day-body {
  padding: 6px;
  max-height: 400px;
  overflow-y: auto;
}
.tl-empty {
  text-align: center;
  color: #334155;
  padding: 20px 0;
  font-size: 18px;
}
.tl-item {
  padding: 6px 6px;
  border-bottom: 1px solid #1e293b88;
  font-size: 11px;
  border-left: 3px solid transparent;
  margin-bottom: 2px;
  border-radius: 2px;
}
.tl-item.tl-src-jira {
  border-left-color: #3b82f6;
  background: #3b82f608;
}
.tl-item.tl-src-github {
  border-left-color: #22c55e;
  background: #22c55e08;
}
.tl-item.tl-src-confluence {
  border-left-color: #06b6d4;
  background: #06b6d408;
}
.tl-item:last-child {
  border-bottom: none;
}
.tl-time {
  color: #475569;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 2px;
}
.tl-content {
  margin-left: 2px;
}
.tl-type {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 2px;
}
.tl-module {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #8b5cf622;
  color: #a78bfa;
  margin-left: 4px;
  vertical-align: middle;
}
.tl-link {
  margin: 2px 0;
}
.tl-link a {
  color: #38bdf8;
  text-decoration: none;
  font-size: 11px;
}
.tl-link a:hover {
  text-decoration: underline;
}
.tl-snippet {
  color: #64748b;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.detail-section {
  margin-bottom: 16px;
}
.detail-section:last-child { margin-bottom: 0; }
.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
.breakdown-chip {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  margin: 0 4px 4px 0;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}
.breakdown-chip.chip-disabled {
  opacity: 0.3;
  text-decoration: line-through;
}
.chip-status_change { background: #fb923c22; color: #fb923c; }
.chip-field_change { background: #94a3b822; color: #94a3b8; }
.chip-comment { background: #4ade8022; color: #4ade80; }
.chip-commit { background: #38bdf822; color: #38bdf8; }
.chip-pr_opened { background: #a78bfa22; color: #a78bfa; }
.chip-pr_merged { background: #8b5cf622; color: #8b5cf6; }
.chip-pr_reviewed { background: #c084fc22; color: #c084fc; }
.chip-pr_comment { background: #ddd6fe22; color: #ddd6fe; }
.chip-confluence_edit { background: #06b6d422; color: #22d3ee; }
.chip-confluence_create { background: #0891b222; color: #67e8f9; border: 1px solid #06b6d444; }

.card-projects {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 10px;
}
.card-projects .label {
  color: #64748b;
  margin-right: 4px;
}
.project-chip {
  display: inline-block;
  background: #334155;
  padding: 2px 8px;
  border-radius: 6px;
  margin: 2px 4px 2px 0;
  color: #e2e8f0;
  cursor: default;
}
.project-chip .count {
  color: #38bdf8;
  font-weight: 600;
  margin-left: 4px;
}

.card-recent-toggle {
  color: #64748b;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  padding-top: 8px;
  border-top: 1px solid #33415544;
}
.card-recent-toggle:hover {
  color: #38bdf8;
}
.card-recent {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #33415544;
  max-height: 300px;
  overflow-y: auto;
}
.card-recent.expanded {
  display: block;
}
.recent-item {
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px solid #1e293b44;
  color: #94a3b8;
}
.recent-item:last-child {
  border-bottom: none;
}
.recent-item .type {
  display: inline-block;
  font-weight: 600;
  min-width: 60px;
}
.recent-item .issue {
  color: #38bdf8;
  text-decoration: none;
  margin: 0 4px;
}
.recent-item .issue:hover {
  text-decoration: underline;
}
.recent-item .time {
  color: #475569;
  float: right;
}

.tooltip {
  position: fixed;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #e2e8f0;
  max-width: 400px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  line-height: 1.5;
}

/* Roster section */
.roster-section {
  max-width: 1400px;
  margin: 0 auto;
}
.roster-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.roster-controls input[type="text"],
.roster-controls select {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.roster-controls input[type="text"] { width: 220px; }
.roster-controls input[type="text"]:focus,
.roster-controls select:focus { border-color: #38bdf8; }
.roster-controls select[multiple] {
  display: none; /* hidden — replaced by custom dropdown */
  scrollbar-color: #475569 #1e293b;
}
.roster-controls select[multiple] option {
  padding: 3px 8px;
  border-radius: 4px;
}
.roster-controls select[multiple] option:checked {
  background: #2563eb;
  color: #fff;
}

/* Position custom dropdown */
.position-dropdown {
  position: relative;
}
.position-trigger {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  min-width: 160px;
  user-select: none;
}
.position-trigger:hover { border-color: #38bdf8; }
.position-arrow { font-size: 11px; color: #64748b; margin-left: auto; }
.position-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 6px 0;
  z-index: 100;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.position-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  color: #cbd5e1;
  cursor: pointer;
}
.position-option:hover { background: #334155; }
.position-option input[type="checkbox"] { accent-color: #38bdf8; cursor: pointer; }
.position-option.selected { color: #38bdf8; }
.position-count {
  margin-left: auto;
  font-size: 11px;
  color: #475569;
}

/* Person cards */
.person-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}
.person-card-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}
.person-card-header:hover { background: #334155; }
.person-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.person-name { font-weight: 600; color: #e2e8f0; font-size: 14px; }
.person-position { color: #64748b; font-size: 12px; }
.person-mod-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.sortable-col { cursor: pointer; user-select: none; }
.sortable-col:hover { color: #38bdf8; }
.col-active { color: #38bdf8; }
.person-stats { display: flex; align-items: center; gap: 12px; }
.ticket-count-badge {
  background: #38bdf822;
  color: #38bdf8;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.person-card-body { display: none; padding: 0 16px 16px; }
.person-card.expanded .person-card-body { display: block; }

/* Ticket table inside cards */
.ticket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ticket-table th {
  text-align: left;
  padding: 6px 10px;
  color: #64748b;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #334155;
}
.ticket-table td {
  padding: 6px 10px;
  border-top: 1px solid #1e293b44;
  vertical-align: middle;
}
.ticket-table tr:hover td { background: #33415544; }
.ticket-link {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.ticket-link:hover { text-decoration: underline; }
.ticket-summary {
  color: #cbd5e1;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.cai-chip {
  background: #22d3ee22;
  color: #22d3ee;
  text-decoration: none;
  font-size: 11px;
}
.cai-chip:hover { text-decoration: underline; }

/* Age color coding */
.age-ok { color: #4ade80; }
.age-mid { color: #fbbf24; }
.age-warn { color: #fb923c; }
.age-critical { color: #f87171; }

.last-update { color: #64748b; white-space: nowrap; }

.roster-meta {
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .charts { grid-template-columns: 1fr; }
  .refresh-btn { position: static; margin-bottom: 12px; }
  .activity-grid { grid-template-columns: 1fr; }
  .activity-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
