:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7788;
  --border: #e3e7ee;
  --primary: #2f6fed;
  --primary-dark: #1f4fc4;
  --gray: #9aa4b2;
  --blue: #2f6fed;
  --green: #1fa971;
  --red: #e0483f;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.xsmall { font-size: 11px; }

/* ---------- Flash messages ---------- */
.flash-wrap { position: fixed; top: 12px; right: 12px; z-index: 50; }
.flash { padding: 10px 16px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; box-shadow: var(--shadow); }
.flash-error { background: #fdeceb; color: var(--red); border: 1px solid #f6c7c3; }
.flash-ok { background: #e5f7ee; color: var(--green); border: 1px solid #bfe9d3; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 4px 8px; font-size: 12px; }
.btn-danger { color: var(--red); border-color: #f3c9c5; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box {
  background: var(--card); padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow);
  width: 320px; display: flex; flex-direction: column; gap: 6px;
}
.login-box h1 { font-size: 20px; margin: 0 0 2px; }
.login-box label { font-size: 13px; margin-top: 10px; color: var(--muted); }
.login-box input {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px;
}
.login-box button { margin-top: 18px; }

/* ---------- Admin layout ---------- */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 18px 28px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar-actions { display: flex; gap: 8px; }
.container { max-width: 1000px; margin: 0 auto; padding: 28px; }
.container.narrow { max-width: 560px; }

.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}
.project-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.project-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.project-card-head h3 { margin: 0; font-size: 16px; }
.tag {
  font-size: 11px; background: #eef2fc; color: var(--primary);
  padding: 3px 8px; border-radius: 20px; font-weight: 600;
}
.progress-bar-mini { background: #eceff4; height: 6px; border-radius: 4px; overflow: hidden; margin: 10px 0 4px; }
.progress-bar-mini-fill { background: var(--green); height: 100%; }
.project-card-actions { display: flex; gap: 8px; margin-top: 12px; }

.form-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.form-card label { font-size: 13px; color: var(--muted); margin-top: 12px; }
.form-card input[type=text] {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px;
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 16px; color: var(--text); }
.checkbox-row input { width: auto; }
.default-stages-preview {
  background: #f7f9fc; border-radius: 8px; padding: 12px 16px; margin-top: 14px;
}
.default-stages-preview ol { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.form-card button { margin-top: 20px; }

.section-title { font-size: 15px; margin: 28px 0 12px; color: var(--text); }

.share-box {
  background: #eef2fc; border: 1px solid #d7e2fb; border-radius: var(--radius);
  padding: 16px 18px; font-size: 13px; color: var(--primary-dark);
}
.share-link-row { display: flex; gap: 8px; margin-top: 8px; }
.share-link-row input {
  flex: 1; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); font-size: 13px;
  background: #fff;
}

.notify-box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-top: 14px;
}
.notify-fields-row { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.notify-fields-row > div { flex: 1; min-width: 220px; }
.notify-fields-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.notify-fields-row input {
  width: 100%; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border); font-size: 13px;
}
.notify-actions { margin-top: 12px; }
.notify-fields { background: #f7f9fc; border-radius: 8px; padding: 12px 16px; margin-top: 10px; }
.notify-fields label { font-size: 13px; color: var(--muted); margin-top: 10px; display: block; }
.notify-fields input[type=email], .notify-fields input[type=text] {
  padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border); font-size: 13px; width: 100%;
}

.stage-list { display: flex; flex-direction: column; gap: 10px; }
.stage-row {
  background: var(--card); border: 1px solid var(--border); border-left: 5px solid var(--gray);
  border-radius: 10px; padding: 14px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.stage-row.status-concluido { border-left-color: var(--green); }
.stage-row.status-em_andamento { border-left-color: var(--blue); }
.stage-row.status-bloqueado { border-left-color: var(--red); }

.stage-row-main { display: flex; align-items: center; gap: 12px; min-width: 220px; flex: 1; }
.stage-icon { font-size: 22px; }
.stage-info strong { font-size: 14px; }

.stage-row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stage-row-form select, .stage-row-form input[type=text] {
  padding: 7px 10px; border-radius: 7px; border: 1px solid var(--border); font-size: 13px;
}
.stage-row-form input[type=text] { min-width: 180px; }

.stage-row-actions { display: flex; gap: 4px; }

.add-stage-form { display: flex; gap: 8px; }
.add-stage-form input[type=text] {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px; flex: 1;
}

/* ---------- Client-facing view ---------- */
.client-body { background: #f7f9fc; }
.client-header {
  background: linear-gradient(135deg, #1f2a44, #2f6fed);
  color: #fff; padding: 32px 28px 24px;
}
.client-header-inner {
  max-width: 1100px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px;
}
.client-header h1 { margin: 0 0 4px; font-size: 24px; }
.client-header p { margin: 0; opacity: .85; }
.progress-summary { text-align: right; }
.progress-ring-label { font-size: 30px; font-weight: 700; }
.progress-bar-big {
  max-width: 1100px; margin: 18px auto 0; background: rgba(255,255,255,.25); height: 8px; border-radius: 6px; overflow: hidden;
}
.progress-bar-big-fill { background: #fff; height: 100%; transition: width .4s ease; }

.timeline-wrap { max-width: 1200px; margin: 0 auto; padding: 60px 28px 40px; }

/* Desktop horizontal timeline */
.timeline {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 100px 10px;
}
.timeline-line {
  position: absolute; left: 0; right: 0; top: 50%; height: 3px;
  background: var(--border); transform: translateY(-50%); z-index: 0;
}
.timeline-node {
  position: relative; flex: 1; display: flex; justify-content: center; z-index: 1;
}
.timeline-node.pos-top .timeline-content { bottom: 38px; }
.timeline-node.pos-bottom .timeline-content { top: 38px; }
.timeline-content {
  position: absolute; width: 150px; text-align: center;
}
.timeline-icon { font-size: 26px; margin-bottom: 6px; }
.timeline-icon.small { font-size: 18px; margin: 0; }
.timeline-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.timeline-note { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.timeline-status-pill {
  display: inline-block; margin-top: 6px; font-size: 10.5px; font-weight: 700;
  padding: 2px 9px; border-radius: 20px; letter-spacing: .02em; text-transform: uppercase;
  background: #eceff4; color: var(--gray);
}
.timeline-dot {
  width: 18px; height: 18px; border-radius: 50%; background: var(--gray);
  border: 4px solid #f7f9fc; box-shadow: 0 0 0 2px var(--gray);
}

.status-concluido .timeline-dot { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.status-concluido .timeline-status-pill { background: #e5f7ee; color: var(--green); }
.status-em_andamento .timeline-dot { background: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.status-em_andamento .timeline-status-pill { background: #e9f0fe; color: var(--blue); }
.status-bloqueado .timeline-dot { background: var(--red); box-shadow: 0 0 0 2px var(--red); }
.status-bloqueado .timeline-status-pill { background: #fdeceb; color: var(--red); }

.timeline-node.is-current .timeline-dot {
  animation: pulse 1.8s infinite;
}
.timeline-node.is-current .timeline-name { color: var(--primary); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47,111,237,.5); }
  70% { box-shadow: 0 0 0 12px rgba(47,111,237,0); }
  100% { box-shadow: 0 0 0 0 rgba(47,111,237,0); }
}

/* Mobile stacked timeline */
.timeline-stacked { display: none; flex-direction: column; gap: 0; }
.stacked-row { display: flex; gap: 14px; position: relative; padding-bottom: 26px; }
.stacked-row::before {
  content: ""; position: absolute; left: 8px; top: 22px; bottom: 0; width: 2px; background: var(--border);
}
.stacked-row:last-child::before { display: none; }
.stacked-dot {
  width: 18px; height: 18px; border-radius: 50%; background: var(--gray);
  border: 3px solid #f7f9fc; box-shadow: 0 0 0 2px var(--gray); flex-shrink: 0; margin-top: 2px;
}
.stacked-row.status-concluido .stacked-dot { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.stacked-row.status-em_andamento .stacked-dot { background: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.stacked-row.status-bloqueado .stacked-dot { background: var(--red); box-shadow: 0 0 0 2px var(--red); }
.stacked-row.is-current .stacked-dot { animation: pulse 1.8s infinite; }
.stacked-head { display: flex; align-items: center; gap: 8px; }
.stacked-body strong { font-size: 14px; }

.client-footer { text-align: center; padding: 20px; }

@media (max-width: 820px) {
  .timeline { display: none; }
  .timeline-stacked { display: flex; }
  .client-header-inner { align-items: flex-start; }
  .progress-summary { text-align: left; }
}
