:root {
  --green-50:  #ecfdf5;
  --green-100: #d1fae5;
  --green-200: #a7f3d0;
  --green-300: #6ee7b7;
  --green-400: #34d399;
  --green-500: #10b981;
  --green-600: #059669;
  --green-700: #047857;
  --green-800: #065f46;
  --green-900: #064e3b;

  --ink-900: #0b1f17;
  --ink-700: #1f3a2e;
  --ink-500: #3d574a;
  --ink-300: #6b8479;
  --ink-100: #e8efe9;

  --bg: #f4faf6;
  --card: #ffffff;
  --border: #e2ece5;

  --warn: #f59e0b;
  --danger: #ef4444;

  --shadow-sm: 0 2px 6px rgba(6, 78, 59, 0.06);
  --shadow-md: 0 10px 30px rgba(6, 78, 59, 0.10);
  --shadow-lg: 0 24px 60px rgba(6, 78, 59, 0.14);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink-900);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 90% -10%, #d1fae570 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #a7f3d066 0%, transparent 60%),
    var(--bg);
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ========== Brand ========== */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  color: white;
  box-shadow: var(--shadow-md);
}
.brand-name {
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink-900);
}
.brand-tag {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--ink-300);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ========== Header ========== */
.site-header {
  background: rgba(255,255,255,0.7);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: white;
  border: 1px solid var(--border);
  padding: 6px 8px 6px 6px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--green-400), var(--green-700));
  color: white;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.user-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-700);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  background: transparent;
  border: 0;
  color: var(--ink-300);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 999px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.logout-btn:hover { background: var(--green-50); color: var(--green-700); }

/* ========== Footer ========== */
.site-footer {
  margin-top: auto;
  padding: 22px 20px 28px;
  text-align: center;
  color: var(--ink-300);
  font-size: 0.85rem;
}

/* ========== Login page ========== */
.login-page {
  position: relative;
  overflow: hidden;
}
.bg-blobs {
  position: fixed; inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: float 14s var(--ease) infinite alternate;
}
.blob-1 { width: 360px; height: 360px; background: var(--green-300); top: -80px; left: -60px; }
.blob-2 { width: 420px; height: 420px; background: var(--green-200); bottom: -120px; right: -100px; animation-duration: 18s; }
.blob-3 { width: 240px; height: 240px; background: var(--green-400); top: 40%; right: 30%; animation-duration: 22s; opacity: 0.35; }

@keyframes float {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(30px,-20px,0) scale(1.08); }
}

.login-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}
.login-title {
  margin: 18px 0 6px;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}
.login-sub {
  margin: 0 0 18px;
  color: var(--ink-500);
  font-size: 0.95rem;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }

.input-wrap {
  position: relative;
}
.input-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.7;
}
.login-form input,
.calc-form input,
.calc-form select {
  width: 100%;
  padding: 14px 14px 14px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink-900);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.calc-form input,
.calc-form select {
  padding-left: 14px;
}
.login-form input:focus,
.calc-form input:focus,
.calc-form select:focus {
  outline: none;
  border-color: var(--green-500);
  background: white;
  box-shadow: 0 0 0 4px var(--green-100);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.features {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--ink-500);
}
.features li span {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 10px;
  background: var(--green-50);
}

/* ========== Buttons ========== */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease), color .2s var(--ease);
  letter-spacing: 0.01em;
}
.btn-primary {
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  color: white;
  box-shadow: 0 10px 24px rgba(5, 150, 105, .28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(5, 150, 105, .34); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: transparent;
  color: var(--ink-500);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--green-50); color: var(--green-700); border-color: var(--green-200); }
.btn-arrow { transition: transform .25s var(--ease); }
.btn:hover .btn-arrow { transform: translateX(4px); }

/* ========== Dashboard ========== */
.dashboard { padding: 28px 20px 40px; }
.hero { margin-bottom: 22px; }
.hero-title {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -0.02em;
}
.hero-sub {
  margin: 0;
  color: var(--ink-500);
  font-size: 1rem;
}

.grid {
  display: grid;
  gap: 22px;
  grid-template-columns: 1fr;
}
@media (min-width: 880px) {
  .grid { grid-template-columns: 1fr 1.05fr; align-items: start; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-head h3 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.muted { color: var(--ink-300); margin: 0 0 16px; font-size: 0.9rem; }

.calc-form { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; }
.field label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-700);
}
.field-icon {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--green-50);
}

.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill {
  position: relative;
  flex: 1 1 140px;
  cursor: pointer;
}
.radio-pill input {
  position: absolute; opacity: 0; inset: 0;
}
.radio-pill span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-700);
  transition: all .2s var(--ease);
}
.radio-pill input:checked + span {
  border-color: var(--green-500);
  background: var(--green-50);
  color: var(--green-700);
  box-shadow: 0 0 0 4px var(--green-100);
}

.actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 160px; }

/* Result card */
.result-card { position: relative; overflow: hidden; }
.result-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 200px at 100% 0%, var(--green-100), transparent 60%);
  pointer-events: none;
}
.result-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  position: relative;
}
.result-number .number {
  font-size: clamp(2.4rem, 7vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--green-700);
  line-height: 1;
}
.result-number .unit {
  display: inline-block;
  margin-left: 8px;
  font-weight: 600;
  color: var(--ink-500);
}
.badge {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-800);
}
.badge.level-low    { background: #d1fae5; color: #065f46; }
.badge.level-medium { background: #fef3c7; color: #92400e; }
.badge.level-high   { background: #fee2e2; color: #991b1b; }

.message {
  margin: 12px 0 16px;
  padding: 12px 14px;
  background: var(--green-50);
  border: 1px solid var(--green-100);
  color: var(--green-800);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
}

.chart-wrap {
  position: relative;
  margin: 8px auto 14px;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
  margin-bottom: 18px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink-700);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.suggestions h4 {
  margin: 6px 0 8px;
  font-size: 1rem;
  color: var(--ink-700);
}
.suggestions ul {
  list-style: none;
  margin: 0; padding: 0;
  display: grid; gap: 8px;
}
.suggestions li {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  color: var(--ink-700);
  animation: slide-in .35s var(--ease) both;
}
.suggestions li::before {
  content: "✓";
  color: var(--green-600);
  font-weight: 800;
}

/* ========== Animations ========== */
.fade-in {
  animation: fade-up .55s var(--ease) both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

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

/* ========== Mobile tweaks ========== */
@media (max-width: 520px) {
  .login-card { padding: 22px; border-radius: var(--radius-lg); }
  .header-inner { flex-direction: column; gap: 12px; align-items: flex-start; }
  .user-chip { align-self: stretch; justify-content: space-between; }
  .actions .btn { flex: 1 1 100%; }
}
