/* ═══════════════════════════════════════════════════════════════
   WRIGHTSAI CLIENT PORTAL — portal.css
   Brand-matched to wrightsai.com (Manrope / Space Grotesk, blue accents)
   ═══════════════════════════════════════════════════════════════ */
@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0b1220;
  --muted: #5b6b81;
  --faint: #8fa0b5;
  --accent: #1d4ed8;
  --accent-2: #4d8ef7;
  --accent-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --cyan: #0e7490;
  --cyan-soft: #cffafe;
  --border: rgba(148, 163, 184, 0.30);
  --border-strong: rgba(148, 163, 184, 0.5);
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 30px rgba(15, 23, 42, 0.07);
  --shadow-strong: 0 2px 4px rgba(15, 23, 42, 0.06), 0 20px 50px rgba(15, 23, 42, 0.14);
  --radius: 16px;
  --radius-lg: 22px;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --sidebar-w: 264px;
}

[data-theme="dark"] {
  --bg: #090e1a;
  --surface: #101827;
  --surface-2: #16203a;
  --text: #eef2f9;
  --muted: #9aabc4;
  --faint: #64748b;
  --accent: #4d8ef7;
  --accent-2: #7db0ff;
  --accent-soft: rgba(77, 142, 247, 0.16);
  --green: #4ade80;
  --green-soft: rgba(34, 197, 94, 0.15);
  --amber: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --red: #f87171;
  --red-soft: rgba(239, 68, 68, 0.15);
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.12);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.32);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-strong: 0 2px 4px rgba(0, 0, 0, 0.4), 0 20px 50px rgba(0, 0, 0, 0.5);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 1rem; color: inherit; }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; letter-spacing: -0.01em; }

svg.icon { width: 20px; height: 20px; flex-shrink: 0; }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--accent-soft); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Brand wordmark ─────────────────────────────── */
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 1.1rem;
  color: var(--text);
  white-space: nowrap;
}
.wordmark span { color: var(--accent); }
.wordmark small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--faint);
  text-transform: uppercase;
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════ */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.login-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 15%, rgba(77, 142, 247, 0.28), transparent 55%),
    radial-gradient(ellipse at 85% 80%, rgba(34, 211, 238, 0.14), transparent 50%),
    linear-gradient(160deg, #060b18 0%, #0a1428 55%, #0d1b38 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px 64px;
}
.login-hero .wordmark { color: #fff; }
.login-hero .wordmark span { color: var(--accent-2); }
.login-hero .wordmark small { color: rgba(255, 255, 255, 0.45); }

.login-hero-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 30% 40%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 30%, transparent 75%);
}

.login-hero-copy { position: relative; max-width: 480px; }
.login-hero-copy h1 {
  font-size: clamp(1.9rem, 3.2vw, 2.7rem);
  font-weight: 600;
  line-height: 1.18;
  margin-bottom: 18px;
}
.login-hero-copy h1 em { font-style: normal; color: var(--accent-2); }
.login-hero-copy p { color: rgba(255, 255, 255, 0.68); font-size: 1.02rem; max-width: 42ch; }

.login-hero-points { position: relative; display: grid; gap: 14px; }
.login-point { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,0.82); font-size: 0.95rem; font-weight: 500; }
.login-point svg.icon { width: 18px; height: 18px; color: var(--accent-2); }

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 28px;
  background: var(--bg);
}
.login-card { width: 100%; max-width: 420px; }
.login-card > .wordmark { display: none; margin-bottom: 28px; }
.login-card h2 { font-size: 1.65rem; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin-bottom: 30px; }

.demo-creds {
  margin-top: 26px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
}
.demo-creds strong { color: var(--text); font-weight: 700; display: block; margin-bottom: 6px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.demo-creds code {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
}
.demo-creds .cred-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; flex-wrap: wrap; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-card > .wordmark { display: block; }
}

/* ═══════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════ */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 7px;
  color: var(--text);
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 48px;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.field .hint { font-size: 0.8rem; color: var(--faint); margin-top: 5px; }
.form-error {
  display: none;
  background: var(--red-soft);
  color: var(--red);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.form-error.show { display: block; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ═══════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.94rem;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn svg.icon { width: 17px; height: 17px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.28);
}
.btn-primary:hover { box-shadow: 0 8px 24px rgba(29, 78, 216, 0.4); filter: brightness(1.06); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent-2); color: var(--accent); }

.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { filter: brightness(0.97); }

.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { filter: brightness(0.96); }

.btn-sm { padding: 7px 14px; min-height: 36px; font-size: 0.84rem; border-radius: 10px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-2); }

/* ═══════════════════════════════════════════════════
   APP SHELL (sidebar + main)
   ═══════════════════════════════════════════════════ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: transform 0.28s ease;
}
.sidebar-head { padding: 26px 24px 20px; border-bottom: 1px solid var(--border); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--faint);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 11px;
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--muted);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg.icon { width: 19px; height: 19px; }
.nav-item .count {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.nav-item .count[hidden] { display: none; }

.sidebar-foot { padding: 16px 14px; border-top: 1px solid var(--border); display: grid; gap: 4px; }

.user-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 6px;
}
.user-chip .avatar { width: 38px; height: 38px; font-size: 0.85rem; }
.user-chip .u-name { font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
.user-chip .u-role { font-size: 0.75rem; color: var(--muted); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.avatar.alt { background: linear-gradient(135deg, #0e7490, #22d3ee); }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px 64px;
  max-width: 1220px;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 1.55rem; font-weight: 600; }
.topbar .crumb { color: var(--muted); font-size: 0.88rem; font-weight: 600; margin-bottom: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.menu-btn { display: none; }

.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(5, 10, 20, 0.45);
  z-index: 55;
  border: none;
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-strong); }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; }
  .main { margin-left: 0; padding: 22px 18px 56px; }
  .menu-btn { display: inline-flex; }
}

/* ═══════════════════════════════════════════════════
   CARDS / STATS / GRIDS
   ═══════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 26px 28px;
}
.card + .card { margin-top: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 18px; flex-wrap: wrap;
}
.card-head h3 { font-size: 1.12rem; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.card-head h3 svg.icon { color: var(--accent); }
.card-head .sub { color: var(--muted); font-size: 0.87rem; margin-top: 2px; width: 100%; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr 1fr; } .card { padding: 20px; } }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}
.stat-ico {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.stat-ico.green { background: var(--green-soft); color: var(--green); }
.stat-ico.amber { background: var(--amber-soft); color: var(--amber); }
.stat-ico.cyan { background: var(--cyan-soft); color: var(--cyan); }
.stat .s-val { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; line-height: 1.15; }
.stat .s-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.stat > div { min-width: 0; }

/* ═══════════════════════════════════════════════════
   BADGES / TAGS
   ═══════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.plain::before { display: none; }

/* ═══════════════════════════════════════════════════
   PROGRESS
   ═══════════════════════════════════════════════════ */
.progress-track {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  min-width: 0;
}
.progress-fill.thin { background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%); }
.progress-fill.done { background: linear-gradient(90deg, #16a34a, #4ade80); }
.progress-track.thin { height: 8px; }

.progress-hero { display: flex; align-items: center; gap: 32px; }
.progress-hero .ph-meta { flex: 1; min-width: 0; }
.progress-hero .ph-pct {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
}
.progress-hero .ph-pct small { font-size: 1.2rem; color: var(--muted); font-weight: 600; }

/* progress ring */
.ring-wrap { position: relative; width: 148px; height: 148px; flex-shrink: 0; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 11; }
.ring-val {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 11;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-center .r-pct { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; line-height: 1; }
.ring-center .r-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

@media (max-width: 640px) {
  .progress-hero { flex-direction: column; align-items: flex-start; gap: 20px; }
}

/* ═══════════════════════════════════════════════════
   TIMELINE / PHASES
   ═══════════════════════════════════════════════════ */
.timeline { position: relative; padding-left: 6px; }
.phase {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 16px;
  padding-bottom: 30px;
}
.phase:last-child { padding-bottom: 4px; }
.phase::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 36px;
  bottom: 2px;
  width: 2px;
  background: var(--border);
}
.phase:last-child::before { display: none; }
.phase-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  color: var(--faint);
  border: 2px solid var(--border);
  z-index: 1;
  transition: background 0.2s ease, color 0.2s ease;
}
.phase-dot svg.icon { width: 16px; height: 16px; }
.phase.is-complete .phase-dot { background: var(--green-soft); color: var(--green); border-color: transparent; }
.phase.is-active .phase-dot {
  background: var(--accent-soft); color: var(--accent); border-color: var(--accent-2);
  box-shadow: 0 0 0 5px var(--accent-soft);
}
.phase-body { min-width: 0; }
.phase-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.phase-top h4 { font-size: 1.02rem; font-weight: 600; }
.phase-desc { color: var(--muted); font-size: 0.9rem; margin-bottom: 10px; max-width: 62ch; }
.phase-meta { display: flex; gap: 16px; align-items: center; font-size: 0.8rem; color: var(--faint); font-weight: 600; margin-top: 8px; flex-wrap: wrap; }
.phase-bar { display: flex; align-items: center; gap: 12px; }
.phase-bar .progress-track { flex: 1; }
.phase-bar .pct { font-weight: 800; font-size: 0.85rem; min-width: 42px; text-align: right; font-family: var(--font-display); }

/* ═══════════════════════════════════════════════════
   FEED (build log)
   ═══════════════════════════════════════════════════ */
.feed { display: grid; gap: 14px; }
.feed-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.feed-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-soft); }
.feed-ico {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.feed-body { min-width: 0; }
.feed-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.feed-top h4 { font-size: 0.99rem; font-weight: 600; }
.feed-time { font-size: 0.78rem; color: var(--faint); font-weight: 600; white-space: nowrap; }
.feed-text { color: var(--muted); font-size: 0.92rem; margin-top: 3px; max-width: 70ch; white-space: pre-line; }
.feed-tags { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════
   NOTES
   ═══════════════════════════════════════════════════ */
.note {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--surface);
  position: relative;
}
.note.pinned { border-color: var(--accent-2); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 82%); }
.note-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.note-head .avatar { width: 34px; height: 34px; font-size: 0.75rem; }
.note-head .n-name { font-weight: 700; font-size: 0.92rem; }
.note-head .n-time { font-size: 0.77rem; color: var(--faint); font-weight: 600; }
.note-body { color: var(--muted); font-size: 0.94rem; white-space: pre-line; }
.note-actions { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }
.notes-list { display: grid; gap: 14px; }

/* ═══════════════════════════════════════════════════
   QUESTIONS (Q&A)
   ═══════════════════════════════════════════════════ */
.qa { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.qa + .qa { margin-top: 14px; }
.qa.unanswered { border-left: 4px solid var(--amber); }
.qa.answered { border-left: 4px solid var(--green); }
.qa-q { padding: 18px 20px; }
.qa-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.qa-head .avatar { width: 34px; height: 34px; font-size: 0.75rem; }
.qa-text { color: var(--text); font-weight: 600; font-size: 0.97rem; white-space: pre-line; }
.qa-a {
  margin: 0 20px 18px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.qa-a .qa-text { font-weight: 500; color: var(--muted); }
.qa-reply { margin: 0 20px 18px; }
.qa-meta { font-size: 0.77rem; color: var(--faint); font-weight: 600; }

/* ═══════════════════════════════════════════════════
   FILES
   ═══════════════════════════════════════════════════ */
.file-row {
  display: flex; align-items: center; gap: 16px;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.file-row:hover { border-color: var(--accent-2); box-shadow: var(--shadow-soft); }
.file-row + .file-row { margin-top: 12px; }
/* The client's file list uses buttons, not links, because opening a stored
   file means minting a signed URL first. */
button.file-row {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.file-ico {
  width: 44px; height: 44px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--accent);
  flex-shrink: 0;
}
.file-row .f-name { font-weight: 700; font-size: 0.95rem; }
.file-row .f-meta { font-size: 0.78rem; color: var(--faint); font-weight: 600; }
.file-row > div { min-width: 0; flex: 1; }

/* ═══════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; min-width: 560px; }
.tbl th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tbl td { padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.tbl tr:last-child td { border-bottom: none; }
.tbl td .strong { font-weight: 700; }

/* ═══════════════════════════════════════════════════
   PROJECT CARDS (admin)
   ═══════════════════════════════════════════════════ */
.proj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  text-align: left;
  width: 100%;
}
.proj-card:hover { border-color: var(--accent-2); box-shadow: var(--shadow-strong); }
.proj-card .p-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.proj-card h3 { font-size: 1.08rem; font-weight: 600; }
.proj-card .p-client { color: var(--muted); font-size: 0.85rem; font-weight: 600; margin-bottom: 16px; }
.proj-card .p-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 0.8rem; color: var(--faint); font-weight: 700; }

/* ═══════════════════════════════════════════════════
   SLIDERS (admin phase %)
   ═══════════════════════════════════════════════════ */
input[type="range"].pct-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) var(--val, 0%), var(--surface-2) var(--val, 0%));
  outline-offset: 4px;
  cursor: pointer;
}
input[type="range"].pct-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
  cursor: grab;
}
input[type="range"].pct-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
  cursor: grab;
}

.admin-phase {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--surface);
}
.admin-phase + .admin-phase { margin-top: 14px; }
.admin-phase .ap-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-phase .ap-top h4 { font-size: 0.99rem; }
.admin-phase .ap-controls { display: grid; grid-template-columns: 1fr 130px 64px; gap: 14px; align-items: center; }
.admin-phase select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); min-height: 40px; }
.admin-phase .ap-pct { font-family: var(--font-display); font-weight: 700; text-align: right; }
@media (max-width: 640px) { .admin-phase .ap-controls { grid-template-columns: 1fr; } .admin-phase .ap-pct { text-align: left; } }

/* ═══════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════ */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(5, 10, 20, 0.5);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}
.modal-scrim.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-strong);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 30px 32px;
  animation: modalIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal h3 { font-size: 1.25rem; margin-bottom: 4px; }
.modal .m-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
@media (max-width: 560px) { .modal { padding: 24px 20px; } }

/* ═══════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════ */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: grid;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--text);
  color: var(--bg);
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow-strong);
  font-weight: 600;
  font-size: 0.92rem;
  animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-theme="dark"] .toast { background: #1e293b; color: #eef2f9; border: 1px solid var(--border-strong); }
.toast svg.icon { color: var(--accent-2); }
.toast.success svg.icon { color: #4ade80; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.toast.hide { opacity: 0; transform: translateY(8px); transition: opacity 0.3s ease, transform 0.3s ease; }

/* ═══════════════════════════════════════════════════
   MISC
   ═══════════════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty svg.icon { width: 44px; height: 44px; color: var(--faint); margin-bottom: 12px; }
.empty h4 { font-size: 1.05rem; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 0.9rem; max-width: 40ch; margin: 0 auto; }

.divider { height: 1px; background: var(--border); margin: 22px 0; border: none; }

.select-inline {
  padding: 10px 38px 10px 14px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 700;
  font-size: 0.9rem;
  min-height: 44px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235b6b81' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.pill-tabs { display: inline-flex; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 5px; flex-wrap: wrap; }
.pill-tabs button {
  border: none; background: transparent;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
  min-height: 38px;
}
.pill-tabs button:hover { color: var(--text); }
.pill-tabs button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-soft); }

.fade-in { animation: fadeUp 0.35s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.mt-0 { margin-top: 0 !important; }
.mb-18 { margin-bottom: 18px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ═══════════════════════════════════════════════════
   BOOT / LOADING STATES
   The portal now waits on the network before it can draw anything,
   so there is a real gap to fill instead of instant localStorage.
   ═══════════════════════════════════════════════════ */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.boot-inner { text-align: center; max-width: 46ch; display: grid; gap: 14px; justify-items: center; }
.boot-inner p { color: var(--muted); font-size: 0.95rem; }
.boot-inner h3 { font-size: 1.15rem; }
.boot-ico svg.icon { width: 40px; height: 40px; color: var(--amber); }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  flex: none;
}
.spinner.big { width: 34px; height: 34px; border-width: 3px; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .fade-in { animation: none; }
}

/* ═══════════════════════════════════════════════════
   LOGIN EXTRAS
   ═══════════════════════════════════════════════════ */
.form-ok {
  display: none;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 18px;
  line-height: 1.5;
}
.form-ok.show { display: block; }

.login-alt { margin-top: 18px; text-align: center; }
.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.linkish:hover { text-decoration: underline; }

.login-foot {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--faint);
  text-align: center;
  line-height: 1.6;
}
.login-foot a { color: var(--accent); font-weight: 600; }

/* ═══════════════════════════════════════════════════
   PHASE (BUILD PLAN) EDITOR
   ═══════════════════════════════════════════════════ */
.plan-editor { display: grid; gap: 16px; }
.plan-row {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px 4px;
  background: var(--surface-2);
}
.plan-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.plan-num {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 0.78rem;
  flex: none;
}
.plan-order { display: flex; gap: 4px; margin-right: auto; }
.plan-row .field { margin-bottom: 14px; }
.plan-row .field input,
.plan-row .field select { background: var(--surface); }

.plan-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.plan-foot-right { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.icon-btn.tiny { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn.tiny svg.icon { width: 15px; height: 15px; }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn:disabled:hover { color: inherit; border-color: var(--border); }

/* ═══════════════════════════════════════════════════
   FORMS: CHECKBOX ROW + FILE INPUT
   ═══════════════════════════════════════════════════ */
.check-line {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.check-line input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.field input[type="file"] {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.88rem;
}
.field input[type="file"]::file-selector-button {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 14px;
  margin-right: 12px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}
.field input[type="file"]::file-selector-button:hover {
  border-color: var(--accent-2);
  color: var(--accent);
}

/* ═══════════════════════════════════════════════════
   DANGER ZONE
   ═══════════════════════════════════════════════════ */
.danger-zone { border-color: var(--red); }
.danger-zone .card-head h3 svg.icon { color: var(--red); }

/* Busy buttons keep their footprint so the layout doesn't jump. */
.btn .spinner { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.65; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════
   CAPTCHA + TWO-FACTOR
   ═══════════════════════════════════════════════════ */
/* Collapses to nothing when Turnstile isn't configured, so the form keeps
   its spacing either way. */
.captcha-slot:not(:empty) { margin-bottom: 18px; }

.code-input {
  font-family: var(--font-display), monospace;
  font-size: 1.5rem !important;
  letter-spacing: 0.4em;
  text-align: center;
  font-weight: 700;
  padding-left: 0.4em !important;
}

.mfa-steps {
  margin: 0 0 20px 18px;
  padding: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}
.mfa-steps li { margin-bottom: 4px; }
.mfa-steps strong { color: var(--text); }

.mfa-qr {
  display: grid;
  place-items: center;
  padding: 18px;
  background: #fff;            /* QR codes need a white quiet zone to scan */
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.mfa-qr img { display: block; width: 200px; height: 200px; }

.mfa-manual summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
}
.mfa-secret {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: monospace;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  word-break: break-all;
  user-select: all;
}

/* Invite sharing — WhatsApp first, since email delivery can't be relied on. */
.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}
.share-row a.btn { text-decoration: none; }
