/* ════════════════════════════════════════════════════════════════════════
   RRS Dev Performance Dashboard — Dark Theme Stylesheet
   ════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0d0f14;
  --bg-card:   #161b27;
  --bg-card2:  #1e2538;
  --border:    #2a3148;
  --text:      #e2e8f0;
  --text-muted:#8892a4;
  --accent:    #6366f1;
  --accent2:   #818cf8;
  --red:       #ef4444;
  --red-dim:   #7f1d1d;
  --green:     #22c55e;
  --green-dim: #14532d;
  --yellow:    #eab308;
  --orange:    #f97316;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 1.8rem; }
.brand-title { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.brand-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }

.header-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.update-label { font-size: 0.78rem; color: var(--text-muted); }

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.2s;
}
.btn-secondary:hover { background: var(--accent); border-color: var(--accent); }
.btn-secondary i { margin-right: 6px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}
.back-btn:hover { color: var(--text); text-decoration: none; }

/* ─── Deadline Banner ────────────────────────────────────────────────────── */
.deadline-banner {
  background: linear-gradient(135deg, #1a0000, #3b0000);
  border-bottom: 3px solid var(--red);
  padding: 20px 24px;
  text-align: center;
}

.deadline-inner { max-width: 900px; margin: 0 auto; }

.deadline-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fca5a5;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.deadline-counter {
  font-size: clamp(2rem, 5vw, 3.8rem);
  font-weight: 900;
  color: var(--red);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-shadow: 0 0 30px rgba(239,68,68,0.6);
  margin-bottom: 8px;
}

.deadline-sub {
  font-size: 0.82rem;
  color: #fca5a5;
  opacity: 0.8;
}

/* ─── Loading Overlay ────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,15,20,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.loading-box {
  text-align: center;
  max-width: 380px;
  padding: 32px;
}

.loading-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.loading-percent {
  display: inline-block;
  min-width: 68px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card2);
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
}

.loading-tip {
  font-size: 0.74rem;
  color: var(--text-muted);
  min-height: 1.2rem;
  opacity: 0.95;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar-wrap {
  background: var(--border);
  border-radius: 100px;
  height: 6px;
  overflow: hidden;
  margin: 12px 0 8px;
}

.progress-bar {
  background: var(--accent);
  height: 100%;
  border-radius: 100px;
  transition: width 0.4s ease;
  width: 0%;
}

.loading-detail { font-size: 0.75rem; color: var(--text-muted); }

/* ─── Main Layout ────────────────────────────────────────────────────────── */
main { max-width: 1400px; margin: 0 auto; padding: 24px 20px 40px; }

.section { margin-bottom: 32px; }

.section-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ─── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.chart-card { min-height: 320px; }

/* ─── Phase Cards ────────────────────────────────────────────────────────── */
.phase-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 700px) { .phase-grid { grid-template-columns: 1fr; } }

.phase-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.phase-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.phase-1::before { background: #22c55e; }
.phase-2::before { background: #6366f1; }
.phase-3::before { background: #ef4444; }
.phase-3.completed::before { background: #22c55e; }

.phase-number { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.phase-name   { font-size: 1.05rem; font-weight: 700; margin: 4px 0 2px; }
.phase-dates  { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 12px; }
.phase-stat   { display: flex; justify-content: space-between; font-size: 0.82rem; margin-top: 6px; }
.phase-stat-label { color: var(--text-muted); }
.phase-stat-val   { font-weight: 700; }

.phase-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-done    { background: var(--green-dim); color: var(--green); }
.badge-ongoing { background: #4c1d19; color: #fca5a5; animation: pulse-red 2s infinite; }
@keyframes pulse-red { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ─── Developer Grid ─────────────────────────────────────────────────────── */
.dev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.dev-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  display: block;
  color: var(--text);
}
.dev-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(99,102,241,0.2);
  text-decoration: none;
}

.dev-card-accent {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
}

.dev-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

.dev-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}

.dev-meta { flex: 1; min-width: 0; }
.dev-name { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-role { font-size: 0.75rem; color: var(--text-muted); }

.dev-score-wrap  { text-align: right; flex-shrink: 0; }
.dev-score-num   { font-size: 1.5rem; font-weight: 900; }
.dev-score-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; display: block; }

.dev-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.dev-stat  { background: var(--bg-card2); border-radius: var(--radius-sm); padding: 8px 10px; }
.dev-stat-val   { font-size: 1rem; font-weight: 700; }
.dev-stat-label { font-size: 0.7rem; color: var(--text-muted); }

.dev-tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tag-active   { background: var(--green-dim); color: var(--green); }
.tag-inactive { background: var(--red-dim); color: var(--red); }
.tag-info     { background: #1e2e4a; color: #60a5fa; }
.tag-warn     { background: #3d2800; color: var(--yellow); }

.tag i,
.phase-status-badge i,
.type-note i,
.deadline-label i {
  margin-right: 6px;
}

/* ─── Stat Strip (developer page) ─────────────────────────────────────────── */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-tile-val   { font-size: 1.6rem; font-weight: 900; }
.stat-tile-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

/* ─── Activity Heatmap ───────────────────────────────────────────────────── */
.heatmap {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px;
}

.heatmap-cell {
  width: 12px; height: 12px;
  border-radius: 2px;
  cursor: default;
  transition: transform 0.1s;
  position: relative;
}
.heatmap-cell:hover { transform: scale(1.8); z-index: 10; }

.hm-0  { background: var(--bg-card2); }
.hm-1  { background: #1a4731; }
.hm-2  { background: #166534; }
.hm-3  { background: #15803d; }
.hm-4  { background: #16a34a; }
.hm-5p { background: var(--green); }

/* ─── Inactive Days List ─────────────────────────────────────────────────── */
.inactive-list {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}
.inactive-list::-webkit-scrollbar { width: 4px; }
.inactive-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.inactive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.8rem;
}

.inactive-date  { font-weight: 700; font-variant-numeric: tabular-nums; }
.inactive-phase { font-size: 0.7rem; color: var(--text-muted); }
.inactive-bad   { border-left: 3px solid var(--red); }
.inactive-title { display: flex; align-items: center; gap: 8px; }
.inactive-title i { color: var(--red); }

.badge-red {
  background: var(--red-dim);
  color: var(--red);
  padding: 1px 8px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ─── Rework Section ─────────────────────────────────────────────────────── */
.rework-big {
  text-align: center;
  margin: 12px 0 16px;
}
.rework-pct {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}
.rework-pct.high { color: var(--red); }
.rework-pct.mid  { color: var(--yellow); }
.rework-pct.low  { color: var(--green); }
.rework-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Type Note ──────────────────────────────────────────────────────────── */
.type-note {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-card2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.insights-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card2);
  border: 1px solid rgba(255,255,255,0.03);
}

.insight-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

.insight-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.insight-value {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--accent2);
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

.profile-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.profile-table thead th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
}

.profile-table tbody td {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  padding: 8px 6px;
  color: var(--text);
}

.file-cell {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #c7d2fe;
}

.commit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}

.commit-item {
  background: var(--bg-card2);
  border: 1px solid rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.commit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.commit-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.commit-phase {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #1e2e4a;
  color: #93c5fd;
}

.commit-msg {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.commit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ─── Score Badge ────────────────────────────────────────────────────────── */
.score-badge {
  font-size: 1rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 100px;
}
.rating-Excellent     { background: #14532d; color: var(--green); }
.rating-Good          { background: #1e2e4a; color: #60a5fa; }
.rating-Average       { background: #3d2d00; color: var(--yellow); }
.rating-Below-Average { background: #3d1a00; color: var(--orange); }
.rating-Poor          { background: var(--red-dim); color: var(--red); }
.rating-No-Data       { background: var(--bg-card2); color: var(--text-muted); }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

canvas {
  width: 100% !important;
  display: block;
}

@media (max-width: 1024px) {
  .site-header { padding: 12px 14px; }
  main { padding: 16px 14px 28px; }
  .card { padding: 16px; }
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .header-brand {
    width: 100%;
    gap: 10px;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .brand-title { font-size: 1.02rem; }
  .brand-sub { font-size: 0.74rem; }
  .dev-grid { grid-template-columns: 1fr; }
  .dev-stats { grid-template-columns: 1fr 1fr; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .deadline-counter { font-size: clamp(1.55rem, 8vw, 2.6rem); }
  .section { margin-bottom: 20px; }
}

@media (max-width: 480px) {
  html { font-size: 15px; }
  .site-header { padding: 10px 10px; }
  main { padding: 12px 10px 22px; }
  .card { padding: 12px; border-radius: 8px; }
  .phase-card { padding: 12px; }
  .dev-card { padding: 12px 12px 12px 14px; }
  .dev-card-header { gap: 8px; }
  .dev-avatar { width: 34px; height: 34px; font-size: 0.95rem; }
  .dev-score-num { font-size: 1.2rem; }
  .dev-score-label { font-size: 0.64rem; }
  .dev-stats { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: 1fr; gap: 8px; }
  .inactive-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .btn-secondary { font-size: 0.78rem; padding: 6px 10px; }
  .update-label { font-size: 0.7rem; }
  .brand-icon { font-size: 1.15rem; }
  .insight-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .insight-value { white-space: normal; }
  .file-cell { max-width: 170px; }
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
