:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e3e6ec;
  --text: #1c2333;
  --muted: #667085;
  --accent: #2f6fed;
  --green: #12925c;
  --amber: #b97d10;
  --red: #d43a4c;
  --grey: #7a869e;
}

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

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

header {
  padding: 28px 32px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

h1 { font-size: 24px; font-weight: 650; letter-spacing: 0.2px; }
.subtitle { color: var(--muted); margin-top: 4px; font-size: 14px; }

.header-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

.back-link {
  color: var(--accent); text-decoration: none; font-size: 13.5px; font-weight: 600;
  display: inline-block; margin-bottom: 10px;
}
.back-link:hover { text-decoration: underline; }

.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(18, 146, 92, 0.5);
  animation: pulse 2.5s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(18, 146, 92, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(18, 146, 92, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 146, 92, 0); }
}

.stats { display: flex; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  min-width: 130px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.warn .num { color: var(--red); }

main { padding: 24px 32px 48px; max-width: 1400px; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  border-top: 3px solid var(--accent);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  color: inherit;
  text-decoration: none;
}
.card:hover { box-shadow: 0 6px 18px rgba(16, 24, 40, 0.1); transform: translateY(-2px); }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pid {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  padding: 3px 8px; border-radius: 6px; color: #fff;
}
.card h3 { font-size: 16px; margin-top: 8px; font-weight: 620; }
.card .desc { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; min-height: 36px; }

.badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}
.badge.on-track { background: rgba(18,146,92,.1); color: var(--green); }
.badge.completed { background: rgba(18,146,92,.18); color: var(--green); }
.badge.at-risk { background: rgba(185,125,16,.12); color: var(--amber); }
.badge.delayed { background: rgba(212,58,76,.1); color: var(--red); }
.badge.on-hold { background: rgba(122,134,158,.12); color: var(--grey); }
.badge.not-started { background: rgba(122,134,158,.12); color: var(--grey); }

.progress-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.bar { flex: 1; height: 8px; background: #edf0f4; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width 0.4s; }
.pct { font-size: 13px; font-weight: 700; min-width: 38px; text-align: right; }

.card-meta {
  display: flex; justify-content: space-between; margin-top: 12px;
  font-size: 12px; color: var(--muted);
}
.next-ms { margin-top: 10px; font-size: 12px; color: var(--muted); }
.next-ms b { color: var(--text); font-weight: 600; }
.next-ms .overdue { color: var(--red); font-weight: 700; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.panel h2 { font-size: 15px; margin-bottom: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }

.ms-row, .feed-row {
  display: flex; gap: 12px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.ms-row:last-child, .feed-row:last-child { border-bottom: none; }
.ms-date { color: var(--muted); min-width: 84px; font-variant-numeric: tabular-nums; }
.ms-date.overdue { color: var(--red); font-weight: 700; }
.ms-pid, .feed-pid {
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; color: #fff;
  min-width: 30px; text-align: center;
}
.gate-tag { font-size: 10px; color: var(--amber); border: 1px solid var(--amber); padding: 1px 6px; border-radius: 4px; margin-left: 8px; }
.feed-time { color: var(--muted); font-size: 12px; min-width: 130px; }
.feed-author { color: var(--accent); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; }
td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.st { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.st.completed { background: rgba(18,146,92,.12); color: var(--green); }
.st.in-progress { background: rgba(47,111,237,.1); color: var(--accent); }
.st.delayed { background: rgba(212,58,76,.1); color: var(--red); }
.st.on-hold { background: rgba(122,134,158,.12); color: var(--grey); }
.st.not-started { background: rgba(122,134,158,.1); color: var(--grey); }
.ms-done { color: var(--green); font-weight: 600; }
.ms-open { color: var(--muted); }

/* ---------- project page ---------- */

.project-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.project-title-row h1 { font-size: 22px; }
.project-sub { color: var(--muted); font-size: 13.5px; margin-top: 6px; }

.gantt-wrap { overflow-x: auto; }
.gantt { min-width: 720px; position: relative; }

.gantt-months {
  position: relative; height: 26px; margin-left: var(--gantt-label-w, 260px);
  border-bottom: 1px solid var(--border);
}
.gantt-month {
  position: absolute; top: 0; height: 100%;
  font-size: 11px; color: var(--muted); font-weight: 600;
  border-left: 1px solid var(--border); padding: 5px 0 0 6px;
  white-space: nowrap; overflow: hidden;
}

.gantt-row { display: flex; align-items: center; height: 34px; }
.gantt-row:nth-child(even) { background: var(--surface-2); }
.gantt-label {
  width: var(--gantt-label-w, 260px); min-width: var(--gantt-label-w, 260px);
  font-size: 12px; padding: 0 10px 0 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gantt-label .tid { font-weight: 700; color: var(--muted); margin-right: 6px; font-size: 11px; }

.gantt-track { position: relative; flex: 1; height: 100%; }
.gantt-gridline { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border); }
.gantt-bar {
  position: absolute; top: 8px; height: 18px; border-radius: 5px;
  min-width: 4px; overflow: hidden;
}
.gantt-bar .fill { position: absolute; inset: 0; width: 0; background: rgba(255,255,255,0.45); right: auto; }
.gantt-bar.overdue { outline: 2px solid var(--red); }
.gantt-bar .bar-pct {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

.gantt-today { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--red); z-index: 2; }
.gantt-today-label {
  position: absolute; top: -2px; font-size: 10px; color: var(--red); font-weight: 700;
  transform: translateX(3px);
}

.gantt-legend { display: flex; gap: 18px; margin-top: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.gantt-legend .chip { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: baseline; }

@media (max-width: 640px) {
  header, main { padding-left: 16px; padding-right: 16px; }
  .stats { gap: 8px; }
  .stat { min-width: 100px; padding: 10px 14px; }
  :root { --gantt-label-w: 170px; }
}
