:root {
  --ink: #15171a;
  --muted: #62666d;
  --paper: #ffffff;
  --surface: #f5f6f7;
  --surface-2: #eceff1;
  --line: #d9dee3;
  --primary: #07875f;
  --primary-dark: #046146;
  --primary-soft: #e7f8f0;
  --black: #171a20;
  --danger: #c4161c;
  --warning: #b76100;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(21, 23, 26, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: auto;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(7, 135, 95, 0.13), transparent 32rem),
    linear-gradient(180deg, #ffffff 0%, #f6f7f8 34%, #f1f3f4 100%);
  font-family: "Noto Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-nav {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(21, 23, 26, 0.08);
  backdrop-filter: blur(18px);
}

.site-logo,
.nav-links a,
.nav-menu {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-weight: 800;
}

.site-logo {
  justify-self: start;
  padding-left: 0;
}

.site-logo::after {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 8px;
  background: var(--primary);
  border-radius: 50%;
  content: "";
}

.nav-links {
  display: none;
}

.nav-menu {
  justify-self: end;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 72px 0 calc(92px + env(safe-area-inset-bottom));
}

#product-selector,
#decision-card,
#forecast,
#signal,
#reasons,
#calculator,
#confidence {
  scroll-margin-top: 70px;
}

.home-screen,
.detail-stack {
  display: grid;
  gap: 14px;
}

.home-topline,
.section-heading,
.card-heading,
.decision-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow,
.section-kicker,
.card-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 560px;
  margin-bottom: 8px;
  font-size: clamp(2.15rem, 10vw, 4.8rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.1rem, 5vw, 1.55rem);
  line-height: 1.22;
  letter-spacing: 0;
}

.subtitle {
  max-width: 440px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.data-pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.data-pill {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.card,
.product-panel,
.context-note,
.quick-nav {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(217, 222, 227, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.product-panel,
.card,
.context-note {
  padding: 18px;
}

.product-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid rgba(217, 222, 227, 0.88);
  border-radius: var(--radius);
}

.product-tab {
  min-height: 46px;
  padding: 9px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.product-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.product-tab[aria-selected="true"] {
  color: #ffffff;
  background: var(--black);
  box-shadow: 0 8px 18px rgba(21, 23, 26, 0.12);
}

.surface-dark {
  color: #ffffff;
  background:
    linear-gradient(145deg, rgba(7, 135, 95, 0.2), rgba(0, 0, 0, 0) 42%),
    var(--black);
  border-color: rgba(21, 23, 26, 0.84);
}

.surface-dark .card-label,
.surface-dark span {
  color: rgba(255, 255, 255, 0.7);
}

.status-chip {
  color: #ffffff;
}

.status-chip.high {
  background: var(--danger);
}

.status-chip.medium {
  background: var(--warning);
}

.status-chip.low {
  background: var(--primary);
}

.recommendation-panel {
  margin-top: 24px;
  padding: 18px;
  background: rgba(7, 135, 95, 0.18);
  border: 1px solid rgba(7, 135, 95, 0.38);
  border-radius: var(--radius);
}

.recommendation-panel strong {
  display: block;
  margin-top: 2px;
  color: #ffffff;
  font-size: clamp(2.15rem, 11vw, 4.1rem);
  line-height: 1.05;
}

.decision-metrics,
.confidence-metrics {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.decision-metrics div {
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
}

.decision-metrics div:nth-child(2) {
  background: rgba(7, 135, 95, 0.18);
  border-color: rgba(7, 135, 95, 0.34);
}

.decision-metrics strong,
.confidence-metrics strong {
  display: block;
  margin-top: 3px;
  font-size: 1.04rem;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  color: #ffffff;
  background: var(--primary);
  border-radius: var(--radius);
  font-weight: 800;
}

.quick-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
}

.quick-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  color: var(--muted);
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 800;
}

.quick-nav a:hover {
  color: var(--ink);
  background: var(--surface);
}

.timeline-list {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 52px 1fr 44px;
  align-items: center;
  gap: 9px;
}

.timeline-day {
  color: var(--muted);
  font-weight: 800;
}

.timeline-bar {
  height: 8px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 999px;
}

.timeline-fill {
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--black), var(--primary));
  border-radius: inherit;
}

.timeline-percent {
  text-align: right;
  font-weight: 800;
}

.signal-card {
  display: grid;
  gap: 16px;
}

.signal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.score-ring {
  --score: 72%;
  display: grid;
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  place-items: center;
  background:
    radial-gradient(circle, #ffffff 58%, transparent 60%),
    conic-gradient(var(--primary) var(--score), var(--surface-2) 0);
  border-radius: 50%;
}

.score-ring span {
  color: var(--primary-dark);
  font-size: 0.95rem;
  font-weight: 800;
}

.signal-summary {
  margin-bottom: 0;
  color: #30343a;
  font-weight: 800;
  line-height: 1.5;
}

.signal-grid {
  display: grid;
  gap: 10px;
}

.signal-grid div {
  display: grid;
  gap: 3px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid rgba(217, 222, 227, 0.86);
  border-radius: var(--radius);
}

.signal-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.signal-grid strong {
  color: var(--ink);
  line-height: 1.38;
}

.reason-card {
  color: #ffffff;
  background:
    linear-gradient(145deg, rgba(7, 135, 95, 0.2), rgba(0, 0, 0, 0) 40%),
    var(--black);
  border-color: rgba(21, 23, 26, 0.84);
}

.reason-card .card-label,
.reason-card h2 {
  color: #ffffff;
}

.reason-list {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: reason;
}

.reason-list li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: start;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.55;
}

.reason-list li::before {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  border-radius: 999px;
  content: counter(reason);
  counter-increment: reason;
  font-size: 0.88rem;
  font-weight: 800;
}

.calculator-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.input-group {
  display: grid;
  gap: 8px;
  color: #393c41;
  font-weight: 800;
}

.input-shell,
.range-row {
  display: grid;
  align-items: center;
  min-height: 50px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.input-shell:focus-within,
.range-row:focus-within {
  border-color: var(--primary);
}

.input-shell {
  grid-template-columns: 1fr auto;
  padding: 0 12px;
}

.input-shell input {
  width: 100%;
  min-width: 0;
  height: 48px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-weight: 800;
}

.input-shell span {
  color: var(--muted);
  font-size: 0.9rem;
}

.range-row {
  grid-template-columns: 1fr 52px;
  gap: 12px;
  padding: 0 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.saving-result {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 16px;
  color: #ffffff;
  background: var(--primary);
  border-radius: var(--radius);
}

.saving-result span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
  font-weight: 700;
}

.saving-result strong {
  font-size: 1.18rem;
}

.saving-result small {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.45;
}

.confidence-card {
  display: grid;
  gap: 16px;
}

.confidence-metrics div {
  padding: 14px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.confidence-metrics span {
  color: var(--muted);
}

.quality-note {
  margin-bottom: 0;
  padding: 14px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.5;
}

.context-note {
  display: grid;
  gap: 7px;
  color: #393c41;
}

.context-note strong {
  color: var(--ink);
}

.mobile-action-bar {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid rgba(7, 135, 95, 0.2);
  backdrop-filter: blur(18px);
}

.mobile-status {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.mobile-status span {
  overflow: hidden;
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-status strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 18px;
  color: #ffffff;
  background: var(--primary);
  border-radius: var(--radius);
  font-weight: 800;
}

.is-loading {
  opacity: 0.68;
  pointer-events: none;
}

.data-error {
  grid-column: 1 / -1;
  padding: 14px;
  color: #8a1f11;
  background: #fff1ed;
  border: 1px solid #ffc8ba;
  border-radius: var(--radius);
  font-weight: 700;
}

@media (min-width: 720px) {
  .site-nav {
    grid-template-columns: 1fr auto 1fr;
    min-height: 58px;
    padding: 0 clamp(22px, 3.4vw, 48px);
  }

  .nav-links {
    display: flex;
    gap: 6px;
    justify-self: center;
  }

  .nav-links a:hover,
  .nav-menu:hover {
    background: rgba(21, 23, 26, 0.07);
  }

  .app-shell {
    display: grid;
    grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
    gap: 18px;
    padding-top: 78px;
    padding-bottom: 42px;
  }

  .home-screen {
    position: sticky;
    top: 78px;
    align-self: start;
  }

  .detail-stack {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .timeline-card,
  .signal-card,
  .calculator-card,
  .context-note {
    grid-column: span 2;
  }

  .product-tabs {
    grid-template-columns: repeat(4, 1fr);
  }

  .decision-metrics,
  .confidence-metrics,
  .signal-grid {
    grid-template-columns: 1fr 1fr;
  }

  .decision-metrics div:first-child {
    grid-column: span 2;
  }

  .mobile-action-bar {
    display: none;
  }
}

@media (min-width: 1040px) {
  .app-shell {
    grid-template-columns: 440px minmax(0, 1fr);
  }

  .product-panel,
  .card,
  .context-note {
    padding: 22px;
  }
}
