/* ==========================================================================
   ProjectSync AI - Design System
   Dark enterprise project-control theme.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
  /* --- Color tokens --- */
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-raised: #1a2333;
  --border: #253449;
  --border-strong: #324863;

  --text: #edf1f7;
  --text-muted: #8a96a8;
  --text-faint: #56637a;

  --cyan: #00e5ff;
  --cyan-dim: #0891b2;
  --cyan-wash: rgba(0, 229, 255, 0.1);

  --amber: #ffb020;
  --amber-wash: rgba(255, 176, 32, 0.12);

  --red: #ff4757;
  --red-wash: rgba(255, 71, 87, 0.12);

  --green: #2ed573;
  --green-wash: rgba(46, 213, 115, 0.12);

  /* --- Type --- */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* --- Layout --- */
  --content-width: 1180px;
  --radius: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 8px 0;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 { font-size: 34px; line-height: 1.2; }
h2 { font-size: 22px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.35; }

p { margin: 0 0 12px 0; color: var(--text-muted); }

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

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* --- Focus visibility (accessibility) --- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 28px;
}

.page-content {
  padding: 40px 0 80px 0;
}

.section {
  margin-bottom: 40px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
  padding-top: 20px;
}

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4, .hero-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 28px;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--cyan-dim) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #041014;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--surface-raised);
}

.nav-link.active {
  color: var(--cyan);
  background: var(--cyan-wash);
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-title {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-value.cyan { color: var(--cyan); }
.stat-value.amber { color: var(--amber); }
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }

.stat-sub {
  font-size: 13px;
  color: var(--text-faint);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--cyan);
  color: #041014;
}
.btn-primary:hover { background: #33ecff; text-decoration: none; }
.btn-primary:disabled { background: var(--border-strong); color: var(--text-faint); cursor: not-allowed; }

.btn-secondary {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--cyan); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); text-decoration: none; }

/* ==========================================================================
   Badges (status)
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  border-left: 2px solid currentColor;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-green   { color: var(--green);  background: var(--green-wash); }
.badge-amber   { color: var(--amber);  background: var(--amber-wash); }
.badge-red     { color: var(--red);    background: var(--red-wash); }
.badge-cyan    { color: var(--cyan);   background: var(--cyan-wash); }
.badge-neutral { color: var(--text-muted); background: var(--surface-raised); }

/* ==========================================================================
   Dual progress bar - planned (outline) vs actual (fill)
   The product's signature visual: schedule vs. site reality, at a glance.
   ========================================================================== */

.progress-dual {
  position: relative;
  height: 8px;
  background: var(--surface-raised);
  border-radius: 4px;
  overflow: visible;
  margin: 10px 0 6px 0;
}

.progress-dual .actual-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 4px;
  background: var(--cyan);
  transition: width 0.4s ease;
}

.progress-dual.status-atrisk .actual-fill { background: var(--amber); }
.progress-dual.status-delayed .actual-fill { background: var(--red); }
.progress-dual.status-ontrack .actual-fill { background: var(--green); }

.progress-dual .planned-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--text);
  opacity: 0.55;
}

.progress-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-raised); }

.activity-id {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--cyan);
}

/* ==========================================================================
   State messages: loading / error / empty
   Treated as real content per spec section 16 - never silent zeros.
   ========================================================================== */

.state-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 32px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.state-message.is-error {
  border-color: var(--red);
  background: var(--red-wash);
  color: var(--text);
}

.state-message.is-error .state-title { color: var(--red); }

.state-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 60px;
}

.footer-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: 13px;
}

/* ==========================================================================
   Utility
   ========================================================================== */

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mt-0 { margin-top: 0; }
.hidden { display: none !important; }
