:root {
  color-scheme: light;
  --bg: #eef1e7;
  --surface: #fffdf8;
  --surface-strong: #f8f4ea;
  --ink: #13211b;
  --muted: #617168;
  --line: #d7d0c1;
  --leaf: #2b7350;
  --leaf-dark: #173d2b;
  --soil: #76563d;
  --amber: #c9882c;
  --blue: #2c6a78;
  --danger: #9a3b32;
  --shadow: 0 18px 50px rgba(42, 35, 24, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  background: #eef1e7;
  place-items: center;
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
  width: min(960px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-visual {
  min-height: 560px;
  background: var(--soil);
}

.auth-visual img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 560px;
  object-fit: cover;
}

.auth-content {
  display: grid;
  align-content: center;
  gap: 20px;
  padding: 30px;
}

.auth-topline {
  display: grid;
  gap: 16px;
}

.auth-title {
  margin: 0;
  color: var(--ink);
  font-size: 1.7rem;
  line-height: 1.12;
  letter-spacing: 0;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 780;
}

.auth-submit {
  min-height: 46px;
  border: 1px solid var(--leaf-dark);
  border-radius: var(--radius);
  background: #246b49;
  color: #ffffff;
  padding: 10px 16px;
  font-weight: 840;
}

.auth-submit:hover,
.auth-submit:focus-visible {
  background: var(--leaf-dark);
  outline: none;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
}

.auth-message.is-error {
  color: var(--danger);
}

.auth-switch {
  justify-self: start;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-weight: 820;
}

.auth-switch:hover,
.auth-switch:focus-visible {
  color: var(--leaf-dark);
  outline: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.side-panel {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-right: 1px solid rgba(23, 61, 43, 0.16);
  background: #fbf7ee;
  backdrop-filter: blur(12px);
}

.brand-visual {
  overflow: hidden;
  min-height: 174px;
  border-radius: var(--radius);
  background: var(--soil);
  box-shadow: 0 12px 30px rgba(38, 31, 22, 0.14);
}

.brand-visual img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 174px;
  object-fit: cover;
}

.brand-block {
  padding: 2px 2px 4px;
}

.brand-name {
  margin: 0;
  color: #173d2b;
  font-size: 1.42rem;
  font-weight: 880;
  line-height: 1.08;
  letter-spacing: 0;
}

.brand-name::after {
  display: block;
  width: 56px;
  height: 3px;
  margin-top: 10px;
  border-radius: 999px;
  background: #2c6a78;
  content: "";
}

.language-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f3eee3;
}

.language-button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 7px 8px;
  font-size: 0.86rem;
  font-weight: 820;
}

.language-button:hover,
.language-button:focus-visible {
  color: var(--leaf-dark);
  outline: none;
}

.language-button.is-active {
  border-color: rgba(43, 115, 80, 0.22);
  background: #ffffff;
  color: var(--leaf-dark);
  box-shadow: 0 2px 8px rgba(42, 35, 24, 0.08);
}

.user-panel {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid rgba(44, 106, 120, 0.18);
  border-radius: var(--radius);
  background: #eef6f5;
}

.user-panel span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 780;
  text-transform: uppercase;
}

.user-panel strong {
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.logout-button {
  justify-self: start;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-size: 0.86rem;
  font-weight: 820;
}

.logout-button:hover,
.logout-button:focus-visible {
  color: var(--leaf-dark);
  outline: none;
}

.plan-panel {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(43, 115, 80, 0.22);
  border-radius: var(--radius);
  background: #eaf3ed;
}

.plan-panel span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 780;
  text-transform: uppercase;
}

.plan-panel strong {
  color: var(--leaf-dark);
  font-size: 1.08rem;
  line-height: 1.15;
}

.plan-panel p {
  margin: 0;
  color: #40534a;
  font-size: 0.84rem;
  line-height: 1.35;
}

.plan-button {
  min-height: 38px;
  border: 1px solid var(--leaf-dark);
  border-radius: var(--radius);
  background: #246b49;
  color: #ffffff;
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 820;
  line-height: 1.2;
}

.plan-button:hover,
.plan-button:focus-visible {
  background: var(--leaf-dark);
  outline: none;
}

.plan-button:disabled {
  border-color: rgba(43, 115, 80, 0.22);
  background: #ffffff;
  color: var(--leaf-dark);
  cursor: default;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--leaf);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-heading h3 {
  margin: 0;
  color: var(--ink);
  line-height: 1.05;
  letter-spacing: 0;
}

.tool-nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 780;
  text-align: left;
}

.nav-button:hover,
.nav-button:focus-visible {
  border-color: rgba(47, 111, 78, 0.24);
  background: rgba(47, 111, 78, 0.08);
  outline: none;
}

.nav-button.is-active {
  border-color: rgba(43, 115, 80, 0.34);
  background: #e5efe7;
  color: var(--leaf-dark);
  box-shadow: inset 3px 0 0 var(--leaf);
}

.nav-mark {
  display: inline-grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--soil);
  font-size: 0.72rem;
  font-weight: 850;
  box-shadow: inset 0 0 0 1px rgba(114, 82, 58, 0.14);
}

.workspace {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 22px;
  min-width: 0;
}

.calc-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
  min-width: 0;
}

.form-grid label {
  display: grid;
  position: relative;
  gap: 7px;
  min-width: 0;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 780;
}

input,
select {
  width: 100%;
  min-height: 46px;
  min-width: 0;
  border: 1px solid #cfc7b8;
  border-radius: var(--radius);
  background: #fffefa;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

input:focus,
select:focus {
  border-color: var(--leaf);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(43, 115, 80, 0.15);
}

input::placeholder {
  color: #92998f;
}

.ghost-button {
  border: 1px solid var(--line);
  min-height: 44px;
  border-radius: var(--radius);
  background: #fffefa;
  color: var(--ink);
  padding: 9px 12px;
  font-weight: 820;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: rgba(47, 111, 78, 0.38);
  background: #eef5ef;
  outline: none;
}

.is-hidden {
  display: none !important;
}

.calc-panel {
  display: none;
  padding: 20px 22px 24px;
}

.calc-panel.is-active {
  display: grid;
  gap: 16px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h3 {
  font-size: 1.36rem;
  line-height: 1.18;
}

.copy-button {
  flex: 0 0 auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 13px 16px;
}

.field-unit {
  position: absolute;
  right: 10px;
  top: 0;
  max-width: 48%;
  overflow: hidden;
  color: #748078;
  font-size: 0.76rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 106px;
  gap: 8px;
}

.quality-panel,
.nutrient-panel {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f3eee3;
}

.sub-tab {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 7px 11px;
  font-size: 0.88rem;
  font-weight: 820;
}

.sub-tab:hover,
.sub-tab:focus-visible {
  color: var(--leaf-dark);
  outline: none;
}

.sub-tab.is-active {
  border-color: rgba(43, 115, 80, 0.22);
  background: #ffffff;
  color: var(--leaf-dark);
  box-shadow: 0 2px 8px rgba(42, 35, 24, 0.08);
}

.quality-fields {
  padding-top: 2px;
}

.info-strip {
  border: 1px solid rgba(44, 106, 120, 0.16);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: #eef6f5;
  color: #21434d;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 690;
  line-height: 1.45;
}

.warning-strip {
  border: 1px solid rgba(154, 59, 50, 0.12);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  background: #fff4ef;
  color: #52312b;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 690;
  line-height: 1.45;
}

.result-box {
  display: grid;
  gap: 14px;
  min-height: 160px;
  min-width: 0;
  padding: 16px 18px 18px;
  border: 1px solid #d8d0c0;
  border-radius: var(--radius);
  background: #f8f3e8;
}

.result-box.is-empty {
  align-content: center;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(148px, 1fr));
  gap: 11px;
}

.metric {
  display: grid;
  align-content: space-between;
  gap: 10px;
  min-height: 94px;
  padding: 13px 14px;
  border: 1px solid rgba(40, 76, 64, 0.14);
  border-radius: var(--radius);
  background: #fffefa;
  box-shadow: 0 5px 16px rgba(42, 35, 24, 0.05);
}

.metric span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 780;
  line-height: 1.25;
}

.metric strong {
  align-self: end;
  color: var(--ink);
  font-size: 1.24rem;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.metric.is-accent {
  border-color: rgba(43, 115, 80, 0.26);
  background: #eaf3ed;
}

.steps {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 12px 12px 12px 34px;
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.72);
  color: #34433b;
  font-size: 0.9rem;
  line-height: 1.48;
}

.notes {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.notes li {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(201, 136, 44, 0.12);
  background: #f7ead3;
  color: #563d1d;
  font-size: 0.88rem;
  line-height: 1.38;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, 24px);
  border-radius: var(--radius);
  background: #1f2a26;
  color: #ffffff;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 720;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 286px minmax(0, 1fr);
  }

  .form-grid,
  .metrics {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 860px) {
  .auth-screen {
    padding: 16px;
  }

  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-visual,
  .auth-visual img {
    min-height: 180px;
  }

  .auth-content {
    padding: 22px;
  }

  .app-shell {
    display: block;
  }

  .side-panel {
    position: relative;
    gap: 12px;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-visual {
    min-height: 150px;
  }

  .brand-visual img {
    min-height: 150px;
  }

  .brand-name {
    font-size: 1.34rem;
  }

  .tool-nav {
    grid-template-columns: repeat(5, minmax(132px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }

  .nav-button {
    min-width: 132px;
    scroll-snap-align: start;
  }

  .workspace {
    padding: 16px;
  }

}

@media (max-width: 620px) {
  .auth-screen {
    padding: 12px;
  }

  .auth-content {
    gap: 16px;
    padding: 18px;
  }

  .auth-title {
    font-size: 1.42rem;
  }

  .side-panel {
    padding: 12px;
    gap: 14px;
  }

  .workspace {
    padding: 12px;
  }

  .calc-panel {
    padding: 14px;
  }

  .calc-panel.is-active {
    gap: 14px;
  }

  .brand-visual,
  .brand-visual img {
    min-height: 122px;
  }

  .panel-heading {
    display: grid;
  }

  .copy-button {
    width: 100%;
  }

  .form-grid,
  .metrics,
  .inline-field {
    grid-template-columns: 1fr;
  }

  .metrics {
    gap: 9px;
  }

  .result-box {
    padding: 12px;
  }

  .metric {
    min-height: 82px;
  }

  .metric strong {
    font-size: 1.12rem;
  }

  .steps {
    padding-left: 28px;
  }

  .info-strip,
  .warning-strip {
    font-size: 0.84rem;
  }

  .sub-tabs {
    width: 100%;
  }

  .sub-tab {
    flex: 1 1 auto;
  }

  .field-unit {
    position: static;
    max-width: none;
    white-space: normal;
  }

  .ghost-button {
    width: 100%;
    white-space: normal;
  }
}

@media (max-width: 420px) {
  .auth-screen {
    padding: 10px;
  }

  .auth-content {
    padding: 14px;
  }

  .auth-title {
    font-size: 1.25rem;
  }

  .side-panel {
    padding: 10px;
  }

  .workspace {
    padding: 10px;
  }

  .brand-name {
    font-size: 1.2rem;
  }

  .nav-button {
    min-width: 118px;
    font-size: 0.88rem;
  }

  .nav-mark {
    flex-basis: 28px;
    width: 28px;
    height: 28px;
  }

  .panel-heading h3 {
    font-size: 1.12rem;
  }
}
