:root {
  --green: #1c8a4d;
  --green-dark: #126b3a;
  --green-deep: #0b4c29;
  --green-soft: #e8f6ed;
  --green-line: #c8e6d2;
  --lime: #b9e27f;
  --ink: #15241b;
  --muted: #65766b;
  --line: #dce8df;
  --paper: #ffffff;
  --bg: #eef5ef;
  --amber: #f2a51f;
  --red: #c14a3d;
  --shadow: 0 10px 30px rgba(18, 74, 42, 0.08);
  --radius: 20px;
  --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(185, 226, 127, 0.24), transparent 34%),
    radial-gradient(circle at 100% 18%, rgba(28, 138, 77, 0.1), transparent 32%),
    var(--bg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(100%, 540px);
  margin: 0 auto;
  padding: 14px 14px calc(150px + env(safe-area-inset-bottom));
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 20px 22px 26px;
  border-radius: 26px;
  color: #fff;
  background:
    linear-gradient(150deg, #176f40 0%, #1c8a4d 52%, #2fa566 100%);
  box-shadow: 0 18px 40px rgba(15, 84, 46, 0.24);
}

.hero::after {
  position: absolute;
  right: -60px;
  bottom: -80px;
  width: 250px;
  height: 250px;
  border: 34px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  content: "";
}

.hero-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  color: var(--lime);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
}

.brand-text b {
  display: block;
  font-size: 12px;
  letter-spacing: 0.15em;
}

.brand-text small {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.version {
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.hero h1 {
  position: relative;
  z-index: 2;
  margin: 20px 0 8px;
  font-size: clamp(32px, 8vw, 40px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.hero h1 em {
  color: var(--lime);
  font-style: normal;
}

.hero-sub {
  position: relative;
  z-index: 2;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 500;
}

.hero-art {
  position: absolute;
  right: -6px;
  bottom: -6px;
  z-index: 1;
  width: 148px;
  height: 148px;
  color: #fff;
  opacity: 0.17;
  transform: rotate(-8deg);
}

.hero-art svg {
  width: 100%;
  height: 100%;
}

/* ---------- cards ---------- */

.card {
  margin-bottom: 14px;
  padding: 20px;
  border: 1px solid rgba(200, 222, 207, 0.7);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.step {
  position: relative;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.step-no {
  display: grid;
  flex: none;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 16px;
  font-weight: 900;
}

.step-head h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.step-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

/* ---------- mapped flower ---------- */

.mapped {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--green-line);
  border-radius: 16px;
  background: linear-gradient(150deg, #f4fbf6, #ebf7ef);
}

.mapped-label {
  color: #6f8578;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.mapped-flower {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 4px 0 2px;
}

.mapped-flower strong {
  color: var(--green-deep);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.mapped-flower span {
  color: #547160;
  font-size: 12px;
  font-weight: 700;
}

.mapped-note {
  display: inline-block;
  margin-top: 2px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff2d9;
  color: #9b6811;
  font-size: 10px;
  font-weight: 800;
}

.select-label {
  display: block;
  margin: 11px 0 5px;
  color: #7a8d80;
  font-size: 10px;
  font-weight: 700;
}

.big-select {
  width: 100%;
  min-height: 52px;
  padding: 0 13px;
  border: 1.5px solid var(--green-line);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.big-select:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(28, 138, 77, 0.12);
}

.market-label {
  margin-top: 0;
}

.market-select + .market-label {
  margin-top: 14px;
}

.market-select {
  min-height: 64px;
  font-size: 15px;
  font-weight: 800;
}

/* ---------- mode tabs ---------- */

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 5px;
  border-radius: 15px;
  background: #edf3ee;
}

.mode-tabs button {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #6c7d71;
  font-size: 13px;
  font-weight: 800;
}

.mode-tabs button[aria-selected="true"] {
  background: #fff;
  color: var(--green-dark);
  box-shadow: 0 3px 10px rgba(20, 70, 40, 0.1);
}

.mode-icon {
  font-size: 15px;
}

/* ---------- fields ---------- */

.field {
  margin-top: 15px;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #5d6f63;
  font-size: 12px;
  font-weight: 800;
}

.field-label small {
  color: #93a198;
  font-size: 10px;
  font-weight: 600;
}

.stepper {
  display: grid;
  grid-template-columns: 62px 1fr 62px;
  gap: 8px;
}

.stepbtn {
  display: grid;
  width: 62px;
  height: 64px;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #f8fbf8;
  color: var(--green-dark);
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
  transition: background 0.12s, transform 0.1s;
}

.stepbtn:active {
  transform: scale(0.95);
  background: var(--green-soft);
}

.stepbtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stepval {
  display: flex;
  min-height: 64px;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  border: 1.5px solid var(--green-line);
  border-radius: 16px;
  background: #fff;
}

.stepval strong {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.stepval span {
  color: #7b8d80;
  font-size: 12px;
  font-weight: 700;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.choice {
  display: flex;
  min-height: 64px;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  border: 1.5px solid var(--line);
  border-radius: 15px;
  background: #f8fbf8;
  color: #52675a;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.choice small {
  color: #8a998f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.choice:active {
  transform: scale(0.985);
}

.choice.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px var(--green);
}

.choice.active small {
  color: var(--green-dark);
}

/* ---------- switch ---------- */

.switch {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdfb;
  color: #5c6f62;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch .knob {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #d7e2d9;
  transition: background 0.18s;
}

.switch .knob::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  content: "";
  transition: transform 0.18s;
}

.switch input:checked + .knob {
  background: var(--green);
}

.switch input:checked + .knob::after {
  transform: translateX(20px);
}

.switch input:focus-visible + .knob {
  box-shadow: 0 0 0 4px rgba(28, 138, 77, 0.16);
}

.field-hint {
  margin: 8px 2px 0;
  color: #8b9c90;
  font-size: 10.5px;
  line-height: 1.45;
}

/* ---------- bunches mode ---------- */

.big-input {
  display: flex;
  min-height: 78px;
  align-items: center;
  padding: 0 18px;
  border: 1.5px solid var(--green-line);
  border-radius: 18px;
  background: #f8fcf9;
}

.big-input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 38px;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.big-input span {
  flex: none;
  color: #7c8f82;
  font-size: 14px;
  font-weight: 800;
}

.quick-row {
  display: flex;
  gap: 7px;
  margin-top: 9px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.quick-row button {
  flex: none;
  min-width: 66px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #5e7164;
  font-size: 13px;
  font-weight: 800;
}

.quick-row button.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
}

/* ---------- result ---------- */

.result {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  background:
    linear-gradient(140deg, #eef9f1, #e1f3e7);
  border: 1px solid var(--green-line);
  text-align: center;
}

.result-formula {
  color: #60816c;
  font-size: 12px;
  font-weight: 700;
}

.result-total {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  margin-top: 2px;
}

.result-total strong {
  color: var(--green-deep);
  font-size: clamp(46px, 13vw, 58px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.result-total span {
  color: var(--green-dark);
  font-size: 17px;
  font-weight: 800;
}

.result-total.pop strong {
  animation: pop 0.22s ease-out;
}

@keyframes pop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* ---------- packing plan ---------- */

.plan {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--green-line);
  border-radius: 18px;
  background: #f7fcf8;
}

.plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.plan-badge {
  display: inline-block;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.plan-badge.warn {
  background: var(--amber);
  color: #4b3303;
}

.plan-hint {
  color: #7c8f82;
  font-size: 10.5px;
  font-weight: 700;
  text-align: right;
}

.plan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 13px 0 7px;
}

.plan-chips span {
  display: grid;
  min-width: 48px;
  min-height: 44px;
  padding: 0 10px;
  place-items: center;
  border: 1px solid #cbe7d3;
  border-radius: 11px;
  background: #fff;
  color: var(--green-deep);
  font-size: 19px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.plan-chips span.over {
  border-color: #a8d8b6;
  background: #e8f7ed;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px #a8d8b6;
}

.plan-meta {
  color: #6e8275;
  font-size: 11.5px;
  font-weight: 700;
}

.plan-alt {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px dashed #d5e8db;
  color: #7c8f82;
  font-size: 11px;
  line-height: 1.5;
}

.plan-empty {
  margin-top: 14px;
  padding: 23px;
  border: 1px dashed var(--green-line);
  border-radius: 16px;
  color: #7b8e81;
  font-size: 12px;
  text-align: center;
}

/* ---------- summary ---------- */

.inline-field {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdfb;
}

.inline-field span {
  color: #6a7d70;
  font-size: 12px;
  font-weight: 800;
}

.inline-field input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.summary {
  margin: 14px 0 0;
}

.summary div {
  display: flex;
  min-height: 39px;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px dashed #e5eee7;
}

.summary dt {
  flex: none;
  color: #7d8e82;
  font-size: 11.5px;
  font-weight: 700;
}

.summary dd {
  margin: 0;
  color: #253b2c;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.summary dd .muted {
  color: #829487;
  font-size: 10.5px;
  font-weight: 600;
}

.summary .grand {
  margin-top: 4px;
  padding-top: 12px;
  border-bottom: 0;
}

.summary .grand dt {
  font-size: 13px;
  font-weight: 900;
}

.summary .grand dd {
  color: var(--green-deep);
  font-size: 25px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.note-field {
  display: block;
  margin-top: 14px;
}

.note-field span {
  display: block;
  margin-bottom: 6px;
  color: #6a7d70;
  font-size: 11.5px;
  font-weight: 800;
}

.note-field input {
  width: 100%;
  min-height: 52px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: #fbfdfb;
  color: var(--ink);
  font-size: 14px;
}

.note-field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(28, 138, 77, 0.1);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 0;
  border-radius: 15px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.01em;
  transition: transform 0.1s, filter 0.12s;
}

.btn:active {
  transform: scale(0.985);
}

.btn.primary {
  background: linear-gradient(140deg, #219357, #157041);
  color: #fff;
  box-shadow: 0 7px 18px rgba(16, 105, 61, 0.28);
}

.btn.primary:disabled {
  background: #a9bbae;
  box-shadow: none;
  cursor: not-allowed;
}

.btn.ghost {
  border: 1.5px solid var(--green-line);
  background: #f8fcf9;
  color: var(--green-dark);
}

.btn.wide {
  width: 100%;
  margin-top: 14px;
}

/* ---------- recent ---------- */

.recent {
  margin-bottom: 0;
}

.recent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.recent-head h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.recent-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10.5px;
}

.text-btn {
  padding: 6px;
  border: 0;
  background: transparent;
  color: #9a6a60;
  font-size: 11px;
  font-weight: 700;
}

.order-group {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e4eee7;
}

.order-group:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.order-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.order-group-title {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.order-group-title time {
  color: var(--green-deep);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.order-group-title span {
  color: #8a9b8f;
  font-size: 10px;
  font-weight: 700;
}

.day-copy {
  flex: none;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--green-line);
  border-radius: 10px;
  background: #f4fbf6;
  color: var(--green-dark);
  font-size: 10.5px;
  font-weight: 800;
}

.day-copy:active {
  transform: scale(0.97);
}

.order {
  padding: 10px 0;
  border-top: 1px dashed #e5eee7;
}

.order-group-head + .order {
  border-top: 0;
}

.order-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.order-top b {
  font-size: 13px;
  line-height: 1.3;
  text-transform: uppercase;
}

.order-amount {
  flex: none;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.order-country {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eef6f0;
  color: #4c6b57;
  font-size: 9.5px;
  font-weight: 800;
}

.order-detail {
  margin-top: 3px;
  color: #607367;
  font-size: 11.5px;
  line-height: 1.45;
}

.order-detail strong {
  color: var(--green-dark);
}

.order-note {
  margin-top: 5px;
  color: #9b6811;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.4;
}

.order-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.order-actions button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfb;
  color: #5e7164;
  font-size: 11px;
  font-weight: 800;
}

.order-actions button.danger {
  border-color: #f0d8d4;
  background: #fff9f8;
  color: #a8554a;
}

.empty {
  padding: 20px 0 8px;
  color: #8b9c90;
  font-size: 12px;
  text-align: center;
}

/* ---------- save bar ---------- */

.savebar {
  position: fixed;
  z-index: 20;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  width: min(calc(100% - 28px), 512px);
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px 12px 20px;
  border: 1px solid rgba(200, 222, 207, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 40px rgba(15, 68, 39, 0.2);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
}

.savebar-total {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  white-space: nowrap;
}

.sb-label {
  color: #7c8f82;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.sb-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.sb-value strong {
  color: var(--green-deep);
  font-size: 30px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.savebar-total em {
  color: var(--green-dark);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.savebar-total small {
  color: #8a9b8f;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.1;
}

.savebar .btn {
  flex: none;
  min-width: 150px;
  min-height: 58px;
  padding: 0 15px;
  font-size: 14px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  z-index: 40;
  bottom: 108px;
  left: 50%;
  max-width: calc(100% - 40px);
  padding: 11px 16px;
  border-radius: 999px;
  background: #173226;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.2s;
}

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

/* ---------- desktop ---------- */

@media (min-width: 700px) {
  .app {
    padding-top: 26px;
  }

  .hero {
    padding: 24px 28px 30px;
  }

  .card {
    padding: 24px;
  }

  .savebar {
    bottom: 20px;
  }
}

@media (max-width: 380px) {
  .app {
    padding-left: 10px;
    padding-right: 10px;
  }

  .card {
    padding: 16px;
  }

  .market-select {
    font-size: 14px;
  }

  .savebar {
    gap: 8px;
    padding-left: 14px;
  }

  .sb-value strong {
    font-size: 27px;
  }

  .savebar .btn {
    min-width: 132px;
    padding: 0 10px;
    font-size: 13px;
  }
}

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