:root {
  --ink: #14231c;
  --ink-soft: #3d5348;
  --paper: #f3f6f1;
  --paper-2: #e7eee6;
  --panel: #ffffff;
  --line: rgba(20, 35, 28, 0.12);
  --leaf: #2f6b45;
  --leaf-deep: #1d4a30;
  --mist: #dce8df;
  --accent: var(--leaf-deep);
  --accent-ink: #f7faf6;
  --warn: #9a6b12;
  --danger: #b1422f;
  --info: #1f5f8b;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(20, 35, 28, 0.12);
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "IBM Plex Sans Thai", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.eyebrow {
  margin: 0 0 0.35rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--leaf);
  font-weight: 600;
}
.lede { color: var(--ink-soft); line-height: 1.6; max-width: 36rem; }
.brand {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  margin: 0.2rem 0 0.8rem;
  letter-spacing: -0.03em;
}
.stack { display: grid; gap: 0.85rem; }
.stack label { display: grid; gap: 0.35rem; font-size: 0.9rem; color: var(--ink-soft); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(47, 107, 69, 0.35);
  border-color: var(--leaf);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.15s ease, opacity 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--leaf-deep); color: var(--accent-ink); }
.btn--primary:hover { background: var(--leaf); }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn--sm { padding: 0.45rem 0.8rem; font-size: 0.85rem; }
.btn--warn { background: #f0c36a; color: #2a1c00; }

/* ── Auth: photo + form ── */
.view--auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
}
.auth-visual {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  color: #f7faf6;
}
.auth-visual__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  transform: scale(1.04);
  animation: drift 18s var(--ease) infinite alternate;
}
.auth-visual__veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 22, 16, 0.28) 0%, rgba(10, 22, 16, 0.12) 40%, rgba(10, 22, 16, 0.72) 100%),
    linear-gradient(90deg, rgba(10, 22, 16, 0.2), transparent 55%);
}
.auth-visual__copy {
  position: absolute;
  left: clamp(1.4rem, 4vw, 3rem);
  right: clamp(1.4rem, 4vw, 3rem);
  bottom: clamp(1.8rem, 5vw, 3.2rem);
  z-index: 1;
  max-width: 28rem;
  animation: rise 0.8s var(--ease) both;
}
.auth-visual__mark {
  margin: 0 0 0.55rem;
  font-size: 0.92rem;
  opacity: 0.88;
}
.auth-visual__brand {
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.95;
}
.auth-visual__lede {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.45;
  color: rgba(247, 250, 246, 0.86);
  max-width: 22ch;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1.4rem, 3.5vw, 2.6rem);
  background: var(--paper);
  max-height: 100vh;
  overflow: auto;
  animation: rise 0.7s var(--ease) 0.06s both;
}
.auth-panel__head {
  margin-bottom: 1.1rem;
}
.auth-panel__head h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}
.auth-panel__head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.auth-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.25rem;
  background: var(--paper-2);
  border-radius: 999px;
}
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.auth-tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(20, 35, 28, 0.08);
}
.demo-accounts {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.demo-accounts__title {
  margin: 0 0 0.6rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.demo-accounts code {
  font-family: ui-monospace, monospace;
  font-size: 0.82em;
  background: var(--mist);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.demo-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.demo-chips button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}
.demo-chips button:hover {
  border-color: var(--leaf);
  color: var(--leaf-deep);
}
.auth-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.45;
}
.auth-check input {
  width: auto;
  margin-top: 0.2rem;
  accent-color: var(--leaf-deep);
}
.auth-check a {
  color: var(--leaf-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-panel__foot {
  margin: 1.25rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.auth-panel__foot a { color: inherit; text-decoration: none; }
.auth-panel__foot a:hover { color: var(--ink); }

/* ── App shell ── */
.view--app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  background: var(--paper);
}
.rail {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 1.15rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.rail__brand { display: flex; gap: 0.75rem; align-items: center; }
.rail__mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--leaf-deep);
  color: #f7faf6;
  font-weight: 700;
  font-size: 0.85rem;
}
.rail__brand strong {
  display: block;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.rail__brand small, .rail__user small { color: var(--ink-soft); display: block; font-size: 0.78rem; }
.rail__nav { display: grid; gap: 0.25rem; flex: 1; }
.rail__nav button {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.rail__nav button.is-active,
.rail__nav button:hover {
  background: var(--mist);
  color: var(--ink);
}
.rail__user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.stage { padding: 1.25rem 1.5rem 2rem; overflow: auto; }
.stage__top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stage__top h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2.05rem);
  letter-spacing: -0.02em;
}
.stage__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}
.kpi {
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  animation: rise 0.45s var(--ease) both;
}
.kpi span { display: block; color: var(--ink-soft); font-size: 0.82rem; margin-bottom: 0.35rem; }
.kpi strong {
  font-family: var(--font-display);
  font-size: 1.65rem;
  letter-spacing: -0.02em;
  color: var(--leaf-deep);
}

.layout-split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
  min-height: 520px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel__head {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(180deg, #fafcfa, #fff);
}
.panel__head h3 { margin: 0; font-size: 1rem; }
.panel__body { padding: 1rem; overflow: auto; flex: 1; }
.map {
  height: 100%;
  min-height: 420px;
  background: var(--mist);
}
.leaflet-container { background: var(--mist); font: inherit; }

.list { display: grid; gap: 0.65rem; }
.list-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: #fff;
}
.list-item:hover, .list-item.is-active {
  border-color: rgba(47, 107, 69, 0.45);
  background: rgba(47, 107, 69, 0.05);
}
.list-item strong { display: block; margin-bottom: 0.2rem; }
.list-item small { color: var(--ink-soft); }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  background: var(--mist);
  color: var(--leaf-deep);
}
.badge--warn { background: rgba(240, 195, 106, 0.28); color: var(--warn); }
.badge--danger { background: rgba(255, 143, 122, 0.22); color: var(--danger); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.form-grid .full { grid-column: 1 / -1; }

.species-filter {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  min-width: 0;
}
.species-filter select,
.species-filter input,
#species-q {
  font: inherit;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.species-filter--group { width: 100%; margin-top: 0.55rem; }
.species-filter--group select { width: 100%; }

.g-pill {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.table th, .table td {
  text-align: left;
  padding: 0.65rem 0.45rem;
  vertical-align: top;
  border-bottom: 1px solid rgba(20, 35, 28, 0.10);
  border-right: 1px solid rgba(20, 35, 28, 0.08);
}
.table th:last-child, .table td:last-child { border-right: 0; }
.table th { color: var(--ink-soft); font-weight: 500; background: #eef4ef; }
.table td.col-group { background-image: linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.35)); }
.table td.col-mult { background-image: linear-gradient(rgba(20,35,28,.03), rgba(20,35,28,.03)); }
.table td.col-co2 { background-image: linear-gradient(rgba(47,107,69,.045), rgba(47,107,69,.045)); }
.table td.col-mid { background-image: linear-gradient(rgba(47,107,69,.05), rgba(47,107,69,.05)); }
.table td.col-range { background-image: linear-gradient(rgba(20,35,28,.02), rgba(20,35,28,.02)); }
.table td.col-otc { background-image: linear-gradient(rgba(110,88,58,.05), rgba(110,88,58,.05)); }
.table td.col-year { background-image: linear-gradient(rgba(47,107,69,.04), rgba(47,107,69,.04)); }
.table td.col-rai { background-image: linear-gradient(rgba(29,74,48,.055), rgba(29,74,48,.055)); }
.table tr.sec-1 td { background-color: rgba(168,148,98,.055); }
.table tr.sec-2 td { background-color: rgba(90,118,98,.05); }
.table tr.sec-3 td { background-color: rgba(110,122,120,.05); }
.table tr.sec-4 td { background-color: rgba(130,116,100,.05); }
.table tr.sec-5 td { background-color: rgba(140,112,92,.05); }
.table tr.sec-6 td { background-color: rgba(118,122,88,.05); }
.table tr.sec-7 td { background-color: rgba(132,116,116,.05); }
.table tr.sec-8 td { background-color: rgba(96,118,112,.05); }
.table tr.sec-9 td { background-color: rgba(122,128,96,.05); }
.table tr.sec-10 td { background-color: rgba(108,114,110,.05); }
.table tr.sec-1 td:first-child { box-shadow: inset 3px 0 0 rgba(150,132,88,.4); }
.table tr.sec-2 td:first-child { box-shadow: inset 3px 0 0 rgba(80,108,90,.38); }
.table tr.sec-3 td:first-child { box-shadow: inset 3px 0 0 rgba(100,112,110,.36); }
.table tr.sec-4 td:first-child { box-shadow: inset 3px 0 0 rgba(120,106,90,.38); }
.table tr.sec-5 td:first-child { box-shadow: inset 3px 0 0 rgba(128,100,82,.38); }
.table tr.sec-6 td:first-child { box-shadow: inset 3px 0 0 rgba(108,112,78,.38); }
.table tr.sec-7 td:first-child { box-shadow: inset 3px 0 0 rgba(122,106,106,.36); }
.table tr.sec-8 td:first-child { box-shadow: inset 3px 0 0 rgba(86,108,102,.38); }
.table tr.sec-9 td:first-child { box-shadow: inset 3px 0 0 rgba(112,118,86,.38); }
.table tr.sec-10 td:first-child { box-shadow: inset 3px 0 0 rgba(98,104,100,.34); }
.g-pill.sec-1 { background: #ebe4d4; color: #5a4e32; }
.g-pill.sec-2 { background: #dde4de; color: #3d5348; }
.g-pill.sec-3 { background: #e0e4e3; color: #3d4a4c; }
.g-pill.sec-4 { background: #e6e0d6; color: #4a4238; }
.g-pill.sec-5 { background: #e8dfd6; color: #534538; }
.g-pill.sec-6 { background: #e3e4d6; color: #454a32; }
.g-pill.sec-7 { background: #e6dedf; color: #4e4246; }
.g-pill.sec-8 { background: #dde4e1; color: #3d4e4a; }
.g-pill.sec-9 { background: #e3e5d8; color: #454a36; }
.g-pill.sec-10 { background: #e2e4e2; color: #3d4548; }
.sec-legend { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.75rem; }

.cert {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  background:
    linear-gradient(135deg, rgba(47, 107, 69, 0.08), transparent 42%),
    #fff;
}
.cert h3 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0.2rem 0 0.8rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  background: var(--ink);
  border: 1px solid transparent;
  color: #f7faf6;
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: min(360px, 90vw);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to { transform: scale(1.1) translate3d(-1.2%, -0.8%, 0); }
}

@media (max-width: 980px) {
  .view--auth { grid-template-columns: 1fr; }
  .auth-visual { min-height: 38vh; }
  .auth-panel { max-height: none; }
  .view--app { grid-template-columns: 1fr; }
  .rail {
    position: sticky;
    top: 0;
    z-index: 5;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail__nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .kpi-grid, .layout-split, .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .kpi-grid, .form-grid { grid-template-columns: 1fr; }
  .layout-split { grid-template-columns: 1fr; }
  .auth-visual__lede { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-visual__img { animation: none; transform: none; }
}
