:root {
  --bg: #e8f2ee;
  --surface: #ffffff;
  --ink: #14352c;
  --muted: #5c7a70;
  --line: rgba(20, 53, 44, 0.12);
  --accent: #0f7a5f;
  --accent-2: #0b5c48;
  --accent-soft: #d8f3ea;
  --best: #dcfce7;
  --best-border: #16a34a;
  --best-text: #14532d;
  --danger: #b42318;
  --shadow: 0 8px 22px rgba(15, 61, 50, 0.07);
  --radius: 14px;
  --font: "Outfit", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 50% at 10% -10%, rgba(15, 122, 95, 0.16), transparent 55%),
    linear-gradient(180deg, #eef7f3 0%, var(--bg) 45%, #ddeee7 100%);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100dvh; }

.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 12px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
}
.top-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}
.back-link {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-2);
  text-decoration: none;
}
.back-link:active { opacity: 0.75; }
.brand {
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}
.brand span { color: var(--accent); }
.link-btn {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
}

.field {
  display: block;
  margin-bottom: 10px;
}
.field > span, .cell > span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}
.field em {
  font-style: normal;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.8;
}

.input, .select {
  width: 100%;
  border: 1px solid var(--line);
  background: #f7fbf9;
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  outline: none;
  min-height: 40px;
}
.input:focus, .select:focus {
  border-color: rgba(15, 122, 95, 0.45);
  background: #fff;
}

.opts {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.opt-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f4faf7;
  padding: 8px;
}

.opt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.opt-num {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}
.btn-x {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: #fee4e2;
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
  font-size: 0.75rem;
}

.opt-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.85fr;
  gap: 6px;
}
.cell { display: block; min-width: 0; }
.cell-full { grid-column: 1 / -1; }

.actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
}
.actions-3 {
  grid-template-columns: 1fr 1fr 1.3fr;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 11px 12px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(180deg, #12936f, var(--accent));
  color: #fff;
}
.btn-ghost {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.result-title {
  margin: 0 0 8px;
  font-size: 0.98rem;
  font-weight: 800;
}
.result-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
  background: #f7fbf9;
}
.result-row.best {
  background: var(--best);
  border-color: var(--best-border);
}
.result-row.best .per { color: var(--best-text); }
.badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #16a34a;
  color: #fff;
  border-radius: 999px;
  padding: 2px 7px;
  vertical-align: middle;
}
.meta {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.per {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent-2);
  white-space: nowrap;
}

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px 14px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px 16px;
}
.login-card h1 {
  font-family: var(--display);
  margin: 0 0 4px;
  font-size: 1.7rem;
}
.login-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}
.login-card .btn-primary { width: 100%; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 60;
  text-align: center;
}

.hidden { display: none !important; }

@media (min-width: 640px) {
  .shell { padding: 18px 16px 36px; }
  .brand { font-size: 1.8rem; }
  .opt-grid { grid-template-columns: 1.2fr 0.9fr 0.85fr 1.3fr; }
  .cell-full { grid-column: auto; }
}
