:root {
  --bg: #0e1512;
  --bg-panel: #151f1a;
  --bg-card: #1a2620;
  --border: #2a3830;
  --text: #eef2ef;
  --text-dim: #9fb3a8;
  --accent: #4caf7d;
  --accent-strong: #6fe3a4;
  --concrete: #8a95a1;
  --timber: #c98b4a;
  --danger: #e07856;
  --debt-red: #df5b4e;
  --avoided-orange: #e0a23c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

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

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-strong); text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: nowrap;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.brand .mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  min-width: 0;
}
.user-chip .user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 15px; }
  .topbar-actions .projects-link { display: none; }
  .user-chip .user-name { display: none; }
  .topbar-actions .btn { padding: 8px 10px; font-size: 13px; }
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #08150e;
  border: none;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Login screen */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card .mark-big {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 18px;
}
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card p { color: var(--text-dim); font-size: 14px; margin: 0 0 28px; }

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: #fff;
  color: #1f1f1f;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.google-btn:hover { background: #f4f4f4; }

.login-foot {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-dim);
}

.session-notice {
  background: rgba(224,120,86,0.12);
  border: 1px solid rgba(224,120,86,0.35);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}

/* Project list */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 24px; margin: 0; }
.page-head p.sub { color: var(--text-dim); margin: 4px 0 0; font-size: 14px; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.project-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.project-card h3 { margin: 0; font-size: 16px; }
.project-card .meta { color: var(--text-dim); font-size: 13px; }
.project-card .stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}
.project-card .stat-row strong { color: var(--accent-strong); }
.project-card .project-photo { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 4px; }

.field-photo-preview { display: none; width: 100%; max-height: 220px; object-fit: cover; border-radius: 8px; margin-top: 10px; }
.detail-photo { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--radius); margin-bottom: 24px; display: block; }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state h3 { color: var(--text); margin: 0 0 8px; }

/* Forms */
.form-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 640px;
}
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field label .unit { font-style: italic; font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.hint, .field .hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.calc-btn-row { text-align: center; margin: 24px 0 32px; }
.calc-btn-row .btn { padding: 12px 32px; }

/* Carbon Summary results */
.results-section {
  animation: fadeIn 0.35s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.results-section h2 {
  font-size: 16px;
  margin: 24px 0 14px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  margin-top: 20px;
  position: relative;
}
.chart-caption {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}
.chart-canvas-wrap { height: 280px; position: relative; max-width: 100%; }
.chart-canvas-wrap canvas { max-width: 100%; }

.toggle-group {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid var(--border);
}
.toggle-group button {
  flex: 1;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.toggle-group button.active {
  background: var(--accent);
  color: #08150e;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 26px 0 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

/* Pitch page */
.pitch-head { text-align: center; margin-bottom: 28px; }
.pitch-head h1 { font-size: 28px; margin: 0 0 6px; }
.pitch-head p { color: var(--text-dim); margin: 0; }

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}
@media (max-width: 640px) { .compare-grid { grid-template-columns: 1fr; } }

.compare-card {
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.compare-card.concrete { background: linear-gradient(160deg, #23272c, #171a1d); }
.compare-card.timber { background: linear-gradient(160deg, #2b2115, #1c160f); border-color: #4a3620; }
.compare-card .tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.compare-card.concrete .tag { background: rgba(138,149,161,0.18); color: var(--concrete); }
.compare-card.timber .tag { background: rgba(201,139,74,0.18); color: var(--timber); }
.compare-card .building-icon { font-size: 40px; margin-bottom: 10px; display:block; }
.compare-card .big-num { font-size: 30px; font-weight: 800; margin: 6px 0 2px; }
.compare-card .big-num-label { font-size: 12px; color: var(--text-dim); }
.compare-card .detail-list { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 6px; }
.compare-card .detail-list li { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); }
.compare-card .detail-list li strong { color: var(--text); }

.headline-stat {
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  margin-bottom: 24px;
}
.headline-stat .num {
  font-size: 52px;
  font-weight: 800;
  color: var(--accent-strong);
  line-height: 1;
}
.headline-stat .label {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 8px;
}
.headline-stat .lede {
  max-width: 480px;
  margin: 16px auto 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.equiv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.equiv-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.equiv-card .icon { font-size: 28px; margin-bottom: 8px; display: block; }
.equiv-card .num { font-size: 22px; font-weight: 800; }
.equiv-card .label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.metric-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.metric-card .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.metric-card .value { font-size: 24px; font-weight: 800; margin-top: 6px; }
.metric-card .value.good { color: var(--accent-strong); }
.metric-card .sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.center-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 30px;
}

.info-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.info-card .icon { font-size: 24px; margin-bottom: 8px; display: block; }
.info-card h3 { margin: 0 0 6px; font-size: 15px; }
.info-card p { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.about-intro { max-width: 720px; font-size: 15px; line-height: 1.6; color: var(--text); margin-bottom: 28px; }

.loading, .error-box {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.error-box { color: var(--danger); }

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; color: #111; }
  main { max-width: 100%; }
}
