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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}

/* ── Header ── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #16213e;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
header h1 { font-size: 1.2rem; }

.header-actions { display: flex; gap: 8px; align-items: center; }

.upload-btn, .export-btn {
  background: #e94560;
  color: white;
  border: none;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}
.upload-btn:hover { background: #c73650; }
.export-btn { background: #0f3460; }
.export-btn:hover { background: #1a4a8a; }

/* ── Sheet Tabs ── */
.sheet-tabs {
  display: flex;
  background: #16213e;
  padding: 0 24px;
  border-bottom: 1px solid #0f3460;
  overflow-x: auto;
}
.sheet-tab {
  padding: 8px 18px;
  cursor: pointer;
  color: #888;
  border-bottom: 3px solid transparent;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}
.sheet-tab:hover { color: #ccc; }
.sheet-tab.active { color: #e94560; border-bottom-color: #e94560; }

/* ── Customer Filter ── */
.customer-filter {
  display: flex;
  gap: 6px;
  padding: 8px 24px;
  background: #1a1a2e;
  flex-wrap: wrap;
  border-bottom: 1px solid #0f3460;
}
.filter-btn {
  padding: 4px 14px;
  border: 1px solid #0f3460;
  border-radius: 20px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.filter-btn:hover { border-color: #e94560; color: #eee; }
.filter-btn.active { background: #e94560; border-color: #e94560; color: white; }

/* ── Board ── */
.board { padding: 16px 24px; }

.empty-state {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 160px);
}
.upload-prompt { text-align: center; color: #666; }
.upload-icon { font-size: 3rem; margin-bottom: 12px; }
.upload-prompt p { font-size: 1rem; margin-bottom: 16px; }
.upload-btn-large {
  background: #e94560;
  color: white;
  padding: 10px 26px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  display: inline-block;
  transition: background 0.2s;
}
.upload-btn-large:hover { background: #c73650; }

/* ── Sheet Section (collapsible) ── */
.sheet-section { margin-bottom: 10px; }

.sheet-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #0f3460;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.sheet-section-header:hover { background: #1a4a8a; }

.sheet-toggle { font-size: 0.75rem; color: #e94560; width: 12px; }
.sheet-section-name { font-size: 0.95rem; font-weight: 600; flex: 1; }
.sheet-section-count { font-size: 0.78rem; color: #888; }

.sheet-section-body { padding: 12px 4px 4px; }

/* ── Customer Group ── */
.customer-group { margin-bottom: 24px; }
.customer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #0f3460;
}
.customer-header h2 { font-size: 1rem; color: #e94560; }
.customer-header .project-count { color: #555; font-size: 0.8rem; }

/* ── Cards Grid ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 10px;
}

/* ── Project Card ── */
.project-card {
  background: #16213e;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #0f3460;
  transition: box-shadow 0.2s;
}
.project-card:hover { box-shadow: 0 2px 16px rgba(0,0,0,0.4); }

/* Completed (100%) card */
.project-card.completed { background: #1e1e1e; border-color: #333; opacity: 0.6; }
.project-card.completed .card-header { background: #2a2a2a; }
.project-card.completed .stage-label,
.project-card.completed .progress-text,
.project-card.completed .date-chip,
.project-card.completed .project-name span,
.project-card.completed .por-exit-badge,
.project-card.completed .avg-pct { color: #555; }
.project-card.completed .progress-fill { background: #444 !important; }
.project-card.completed .avg-bar-fill  { background: #444 !important; }
.project-card.completed .progress-bar  { background: #2a2a2a; }
.project-card.completed .stage-item    { background: #222; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #0f3460;
}
.project-name { font-size: 0.9rem; font-weight: 600; flex: 1; min-width: 0; }
.project-name span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.por-exit-badge {
  font-size: 0.72rem;
  color: #888;
  white-space: nowrap;
  margin-left: 10px;
}

.avg-block {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  white-space: nowrap;
}
.avg-bar-container {
  width: 70px;
  height: 6px;
  background: #1a1a2e;
  border-radius: 3px;
  overflow: hidden;
}
.avg-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.avg-pct { font-size: 0.75rem; color: #aaa; min-width: 28px; text-align: right; }

/* ── Stage Rows ── */
.stage-rows { padding: 6px 0; }

.stage-row {
  display: grid;
  grid-template-columns: 148px 1fr 80px 80px;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.stage-row:last-child { border-bottom: none; }

.stage-label {
  font-size: 0.72rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Compact Progress Bar ── */
.progress-bar {
  position: relative;
  height: 14px;
  background: #0a1628;
  border-radius: 4px;
  cursor: ew-resize;
  user-select: none;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.1s;
  min-width: 0;
}
.progress-text {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  pointer-events: none;
}
.progress-bar:hover { box-shadow: 0 0 0 2px rgba(233,69,96,0.4); }

/* ── Clickable Date ── */
.date-chip {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #0a1628;
  color: #888;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1.3;
}
.date-chip-label {
  font-size: 0.6rem;
  color: #555;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.date-chip:hover { background: #1a2a4a; border-color: #e94560; color: #eee; }
.date-chip:hover .date-chip-label { color: #e94560; }
.date-chip.late-warning { color: #e9a045; }
.date-chip.late-danger  { color: #e94560; }
.date-chip.no-date      { color: #444; font-style: italic; }

/* ── Date Picker Popup ── */
.date-popup {
  position: fixed;
  z-index: 999;
  background: #16213e;
  border: 1px solid #e94560;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.date-popup label { font-size: 0.75rem; color: #aaa; }
.date-popup input[type="date"] {
  background: #0f3460;
  color: #eee;
  border: 1px solid #e94560;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.date-popup input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}
.date-popup-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.date-popup-actions button {
  padding: 4px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.78rem;
}
.btn-clear  { background: #333; color: #aaa; }
.btn-apply  { background: #e94560; color: white; }

/* ── Progress Colors ── */
.progress-green  { background: #45e980; }
.progress-yellow { background: #e9a045; }
.progress-red    { background: #e94560; }

/* ── RWD ── */
@media (max-width: 768px) {
  header { padding: 10px 14px; }
  .board { padding: 12px 14px; }
  .cards-grid { grid-template-columns: 1fr; }
  .stage-row { grid-template-columns: 110px 1fr 70px 70px; }
  .sheet-tabs, .customer-filter { padding-left: 14px; padding-right: 14px; }
}
