:root {
  --ink: #1c1c1c;
  --muted: #6b7280;
  --line: #ece8f4;
  --purple: #7b6cff;
  --purple-2: #9b7dff;
  --mint: #67c2a3;
  --mint-dark: #4fb08f;
  --card: #ffffff;
  --danger: #c2413b;
  --shadow: 0 18px 50px rgba(123, 108, 255, .12);
  --radius: 32px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: hidden; }

html, body, input, button, select, textarea, output {
  font-family: "Bai Jamjuree", "Noto Sans Thai", "Segoe UI", sans-serif;
}

body.site {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #f7f4fb;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

.bg-wash {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 8% 0%, rgba(255, 186, 214, .55), transparent 60%),
    radial-gradient(820px 520px at 100% 8%, rgba(186, 214, 255, .55), transparent 58%),
    radial-gradient(720px 480px at 50% 100%, rgba(216, 196, 255, .45), transparent 55%),
    linear-gradient(180deg, #fff7fb 0%, #f4f6ff 48%, #f7fbff 100%);
}

.topbar {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font-weight: 700;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  background: #efe8ff;
  display: grid;
  place-items: center;
}

.brand-mark img {
  width: 150%;
  height: 150%;
  object-fit: cover;
  object-position: center 52%;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-user {
  margin-right: 4px;
  color: #4b5563;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: var(--ink);
}

.pill.outline-dark { border-color: #111; background: #fff; }
.pill.solid-dark { background: #111; color: #fff; }
.pill.outline-purple { border-color: var(--purple); color: var(--purple); background: #fff; }
.pill.gradient {
  color: #fff;
  background: linear-gradient(90deg, #7b6cff, #9b7dff);
  box-shadow: 0 10px 22px rgba(123, 108, 255, .28);
}
.pill.ghost { background: rgba(255,255,255,.7); border-color: #ddd6fe; color: var(--purple); }
.pill.danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.pill:hover { filter: brightness(.98); transform: translateY(-1px); }
.pill:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-label-short { display: none; }

.glass-card {
  background: rgba(255,255,255,.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
}

.home-dash { padding: 28px 32px 26px; }

.home-dash-top {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 36px;
  align-items: start;
}

.home-progress.progress-track {
  position: relative;
  height: 32px;
  margin-top: 14px;
  background: #e8eef3;
}

.home-progress .progress-fill { position: absolute; inset: 0 auto 0 0; }

.home-progress span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: max(72px, var(--pct, 0%));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #0f6e56;
}

.home-dash-chart h2 small {
  margin-left: 6px;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
}

.home-progress-caption,
.home-hero-kicker,
.home-hero-note {
  margin: 8px 0 0;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
}

.home-hero-kicker { margin-top: 18px; color: #374151; }

.home-hero-number {
  margin: 2px 0 0;
  font-size: clamp(40px, 5vw, 56px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}

.home-glance,
.home-chip-grid,
.home-ship-grid {
  display: grid;
  gap: 12px;
}

.home-glance { grid-template-columns: 1fr 1fr; margin-top: 18px; }
.home-chip-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.home-ship-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.glance-card {
  min-height: 96px;
  padding: 14px 16px 12px;
  border-radius: 16px;
  border: 1.5px solid #e7e5ef;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.glance-card span {
  font-size: 14px;
  font-weight: 700;
  color: #374151;
}

.glance-card strong {
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.1;
  color: var(--mint-dark);
}

.glance-card small {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.glance-card.tone-mint { border-color: #8ed4bf; }
.glance-card.tone-mint strong { color: #0f9f78; }
.glance-card.tone-purple { border-color: #d4c7ff; }
.glance-card.tone-purple strong { color: #7c3aed; }
.glance-card.tone-amber { border-color: #f3d48a; }
.glance-card.tone-amber strong { color: #d97706; }
.glance-card.tone-rose { border-color: #f6c1bc; }
.glance-card.tone-rose strong { color: #e11d48; }
.glance-card.is-future { background: #fafafa; border-color: #ece8f4; }
.glance-card.is-future strong { color: #9ca3af; }

.home-dash-chart h2,
.home-dash-block h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.home-dash-block { margin-top: 26px; }

.home-chart {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  min-height: 210px;
}

.home-chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 24px;
  color: #9ca3af;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.home-chart-plot {
  height: 186px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0 4px;
  border-bottom: 1px solid #ece8f4;
  background: repeating-linear-gradient(to top, transparent 0 36px, #eef2f6 36px 37px);
}

.home-chart-col { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }

.home-chart-pair {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

.home-chart-pair i {
  display: block;
  width: 14px;
  height: var(--h, 0%);
  border-radius: 6px 6px 2px 2px;
}

.home-chart-pair i.good { background: #67c2a3; }
.home-chart-pair i.other { background: #9b8cff; }

.home-chart-x {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.home-legend {
  margin: 12px 0 0;
  display: flex;
  justify-content: center;
  gap: 18px;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
}

.home-legend span { display: inline-flex; align-items: center; gap: 6px; }

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.swatch.good { background: #67c2a3; }
.swatch.other { background: #9b8cff; }

.home-chart-empty {
  grid-column: 1 / -1;
  align-self: center;
  text-align: center;
  color: #6b7280;
  font-weight: 600;
}

.hero-card {
  text-align: center;
  padding: 36px 32px 28px;
}

.hero-card h1 {
  margin: 0;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 1.05;
  letter-spacing: -1px;
}

.hero-ctas {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-ctas .pill { min-width: 168px; min-height: 48px; }

.stats-card {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 28px;
  padding: 28px 32px;
}

.stat-success {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.check-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mint);
  color: #fff;
  font-size: 13px;
}

.progress-track {
  margin-top: 16px;
  height: 18px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5fd4b0, #67c2a3);
  transition: width .4s ease;
}

.progress-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}

.progress-meta strong { color: var(--ink); font-size: 18px; }

.member-row {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #374151;
}

.stat-chart h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.chart-grid {
  height: 150px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 16px;
  padding: 12px 8px 0;
  background:
    repeating-linear-gradient(to top, #edf1f6 0 1px, transparent 1px 28px);
  border-radius: 16px;
}

.chart-bar {
  height: var(--h, 18%);
  border-radius: 8px 8px 4px 4px;
  background: var(--bar, var(--purple));
}

.chart-bar.mint { --bar: var(--mint); }

.chart-labels {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.feature-card,
.info-card { padding: 26px 28px; }

.feature-card h2,
.info-card h2,
.saved-days h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.feature-card p,
.info-card p,
.info-card li {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.info-card ol {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.login-wrap {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
  padding: 24px 0 72px;
}

.login-card {
  width: min(440px, calc(100% - 40px));
  padding: 40px 36px 32px;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 36px);
  letter-spacing: -0.6px;
}

.login-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 28px;
  font-weight: 600;
}

.login-field input {
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  font: inherit;
  background: #fff;
}

.login-field input:focus {
  outline: 0;
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(123, 108, 255, .14);
}

.login-error {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

.login-card .pill {
  width: 100%;
  margin-top: 8px;
  min-height: 48px;
}

.site-nav {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: #4b5563;
  font-weight: 600;
  font-size: 14px;
  background: rgba(255,255,255,.72);
}

.site-nav a[aria-current="page"],
.site-nav a:hover {
  color: #fff;
  background: linear-gradient(90deg, #7b6cff, #9b7dff);
}

.embedded-summary {
  margin-top: 28px;
}

.embedded-summary > h2 {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 700;
}

.summary-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.period-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.period-toggle {
  display: flex;
  gap: 8px;
}

.period-toggle .pill[aria-pressed="true"] {
  background: linear-gradient(90deg, #7b6cff, #9b7dff);
  color: #fff;
  border-color: transparent;
}

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

.kpi-grid .summary-card small {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ship-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}

.ship-head h2,
.ship-head p {
  margin: 0;
}

.ship-head h2 { font-size: 18px; }

.ship-head p {
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
}

.ship-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ship-grid .summary-card { min-height: 118px; }

.ship-grid .summary-card strong {
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.1;
  color: var(--mint-dark);
}

.ship-grid .summary-card small {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.ship-grid .summary-card.is-future strong { color: #9ca3af; }

.kpi-grid .summary-card strong {
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.1;
  color: var(--mint-dark);
}

.table-card {
  padding: 18px 18px 8px;
}

.table-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.table-head h2 { margin: 0; }

.table-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.cell-input {
  width: 72px;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  background: #fff;
  text-align: center;
  font: inherit;
}

.cell-pair {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cell-pair .cell-input { width: 64px; }

.cell-unit {
  color: #6b7280;
  font-size: 12px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  font-size: 14px;
}

.result-table th,
.result-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.result-table th {
  color: #4b5563;
  font-weight: 700;
}

.result-table tbody tr:last-child td { border-bottom: 0; }

.result-table tfoot td {
  background: #ecfdf5;
  font-weight: 700;
  color: #047857;
  border-bottom: 0;
}

.result-table tfoot .sticky-date {
  background: #ecfdf5;
}

.result-table .sticky-date {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}

.result-table thead .sticky-date {
  background: #f8f6ff;
  z-index: 2;
}

.date-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}

.date-cell small {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}

.stock-entry-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  background: #f8f6ff;
  border-radius: 20px;
  overflow: hidden;
}

.stock-entry-table th,
.stock-entry-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.stock-entry-table thead th {
  font-size: 13px;
  font-weight: 700;
  color: #4b5563;
  line-height: 1.35;
}

.stock-entry-table tbody th {
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  white-space: normal;
  line-height: 1.3;
  min-width: 108px;
  max-width: 132px;
  padding-left: 12px;
}

.stock-entry-table .field-input {
  width: 100%;
  min-width: 0;
}

.mix-sacks-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 280px;
  margin: 0 0 16px;
  font-weight: 600;
  color: #374151;
}

.stock-entry-single {
  min-width: 0;
}

.stock-entry-table output {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  font-weight: 700;
  color: var(--mint-dark);
  font-size: 18px;
  background: #eefbf6;
  border-radius: 14px;
}

.stock-entry-table .total-row th,
.stock-entry-table .total-row td {
  background: #eefbf6;
  border-bottom: 0;
  font-weight: 700;
}

.page-shell {
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 64px;
}

.form-layout {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 64px;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.form-layout .page-shell {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
}

.form-rail {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 24px;
}

.form-rail a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 16px;
  text-decoration: none;
  color: #4b5563;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
}

.form-rail a:hover {
  background: #f4f0ff;
  color: var(--purple);
}

.form-rail a[aria-current="page"] {
  color: #fff;
  background: linear-gradient(90deg, #7b6cff, #9b7dff);
}

.form-panel[hidden] {
  display: none;
}

.form-panel .embedded-summary,
.embedded-summary {
  margin-top: 0;
}

.summary-page .page-shell {
  width: min(1180px, calc(100% - 40px));
}

.page-header h1 {
  margin: 8px 0 22px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.2;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(340px, 1.6fr);
  gap: 16px;
}

.summary-card {
  min-height: 104px;
  border-radius: 24px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-weight: 600;
  font-size: 16px;
}

.summary-card input {
  width: min(100%, 250px);
  border: 0;
  border-bottom: 1.5px solid #d9d6e5;
  outline: 0;
  background: transparent;
  font: inherit;
  padding: 3px 0 5px;
}

.summary-card input.computed {
  background: transparent;
  font-weight: 700;
  color: var(--mint-dark);
  cursor: default;
}

.health-card .health-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-top: 8px;
}

.health-fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.summary-input {
  width: 100%;
  height: 38px;
  border: 0;
  border-bottom: 1.5px solid #d9d6e5;
  outline: 0;
  background: transparent;
  font: inherit;
  padding: 3px 0 5px;
}

.summary-input:focus {
  border-color: var(--purple);
}

.day-bar {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 18px;
}

.date-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}

.date-picker input,
.date-picker select {
  min-width: 190px;
  height: 42px;
  border: 1px solid #ddd6fe;
  border-radius: 999px;
  padding: 0 14px;
  font: inherit;
  background: #fff;
}

.toolbar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.save-bar {
  margin-top: 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  background: none;
  box-shadow: none;
  border: 0;
}

.save-btn {
  width: 100%;
  min-height: 72px;
  border: 0;
  border-radius: 24px;
  color: #fff;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(90deg, #7b6cff, #9b7dff);
  box-shadow: 0 10px 22px rgba(123, 108, 255, .28);
}

.save-btn:hover { filter: brightness(.98); }
.save-btn:disabled { opacity: .55; cursor: not-allowed; }

.status { color: var(--muted); font-size: 14px; margin: 0; }
.toolbar-actions { display: flex; gap: 10px; }

.daily-form {
  margin-top: 16px;
  display: grid;
  gap: 16px;
}

fieldset {
  margin: 0;
  border: 0;
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
}

legend {
  padding: 0 8px;
  font-weight: 700;
  font-size: 18px;
}

.food-combined {
  display: grid;
  gap: 22px;
}

.food-block-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
}

.food-block-title small {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
}

.unit-note {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: #4b5563;
}

.sack-kg {
  font-size: 13px;
  font-weight: 600;
  color: #4b5563;
}

.sack-kg output {
  display: inline;
  font-size: inherit;
  color: inherit;
}

.field-grid,
.meal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.field-grid.two-col,
.meal-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid label,
.meal-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: #374151;
}

.field-input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  font: inherit;
  background: #fff;
}

.field-input:focus {
  outline: 0;
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(123, 108, 255, .14);
}

.meal-card,
.total-card {
  border-radius: 20px;
  background: #f8f6ff;
  padding: 14px;
}

.meal-card h2,
.meal-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.meal-card label + label { margin-top: 10px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}

.field-row label {
  margin-top: 0;
  min-width: 0;
  font-size: 14px;
}

.field-row label + label { margin-top: 0; }

.field-row.kg-row { grid-template-columns: minmax(0, 180px); }

.stock-entry-table .unit-note {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
}

.field-row .field-input {
  width: 100%;
  min-width: 0;
}

.nested-fields {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.72);
}

.nested-fields h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
}

.egg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.egg-field + .egg-field {
  margin-top: 12px;
}

.egg-field > span {
  font-weight: 600;
  color: #374151;
}

.egg-field .unit-note {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.total-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: #eefbf6;
  font-weight: 700;
}

.total-card output {
  font-size: 32px;
  line-height: 1;
  color: var(--mint-dark);
}

.total-card .sack-kg output {
  font-size: 13px;
  line-height: 1.3;
  color: #4b5563;
}

.food-grand-total {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 16px;
  flex-wrap: wrap;
}

.food-grand-total .total-card {
  flex: 1 1 240px;
  max-width: 360px;
  min-height: 120px;
  text-align: center;
}

.total-card .unit {
  font-size: 13px;
  font-weight: 600;
  color: #4b5563;
}

.feed-per-duck span {
  font-size: 15px;
  line-height: 1.35;
}

.egg-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
}

.egg-summary-row .total-card {
  flex: 1 1 180px;
  min-height: 110px;
}

.egg-percent-field {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  color: #374151;
  border-radius: 20px;
  background: #eefbf6;
  padding: 14px;
}

.field-input.computed {
  background: #eefbf6;
  font-weight: 700;
  color: var(--mint-dark);
  cursor: default;
}

.saved-days {
  margin-top: 22px;
  padding: 22px 24px;
}

.saved-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
}

.date-chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.date-chip.active {
  background: linear-gradient(90deg, #7b6cff, #9b7dff);
  border-color: transparent;
  color: white;
}

@media (hover: none) {
  .pill:hover { transform: none; filter: none; }
}

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .form-layout {
    width: min(100% - 32px, 1180px);
    grid-template-columns: 1fr;
    gap: 16px;
    padding-top: 12px;
  }

  .form-rail {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px;
  }

  .form-rail a {
    flex: 1 1 180px;
    justify-content: center;
    text-align: center;
    white-space: normal;
  }

  .summary-row,
  .field-grid,
  .field-grid.two-col,
  .meal-grid.two-col {
    grid-template-columns: 1fr;
  }

  .meal-grid {
    grid-template-columns: 1fr 1fr;
  }

  .meal-grid > .total-card {
    grid-column: 1 / -1;
  }

  .field-input,
  .summary-input,
  .date-picker input,
  .date-picker select,
  .login-field input,
  .summary-card input {
    font-size: 16px;
    min-height: 46px;
  }

  .daily-form { gap: 18px; }
  .food-combined { gap: 20px; }
  .meal-grid,
  .meal-grid.two-col { gap: 16px; }
  .field-row { gap: 12px; }
  .egg-field + .egg-field { margin-top: 16px; }
  .nested-fields { margin-top: 14px; padding: 14px; }
}

@media (max-width: 860px) {
  .topbar,
  .stats-card,
  .feature-row,
  .summary-row,
  .field-grid,
  .field-grid.two-col,
  .meal-grid,
  .meal-grid.two-col { grid-template-columns: 1fr; }

  .topbar {
    width: min(100% - 20px, 1180px);
    padding: 14px 0 8px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
  }

  .auth-user {
    width: 100%;
    margin: 0;
    white-space: normal;
    font-size: 13px;
    line-height: 1.4;
    order: -1;
  }

  .hero-card { padding: 42px 22px; }
  .home-main,
  .page-shell,
  .summary-page .page-shell,
  .form-layout {
    width: min(100% - 20px, 1180px);
    padding: 10px 0 88px;
  }
  .form-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .form-rail {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px;
  }
  .form-rail a {
    flex: 1 1 160px;
    white-space: normal;
    text-align: center;
    font-size: 14px;
    padding: 12px 14px;
  }
  .site-nav { width: min(100% - 20px, 1180px); }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .ship-grid { grid-template-columns: 1fr 1fr; }
  .home-dash { padding: 22px 16px 18px; }
  .home-dash-top { grid-template-columns: 1fr; gap: 22px; }
  .home-chip-grid,
  .home-ship-grid { grid-template-columns: 1fr 1fr; }
  .home-hero-number { font-size: 40px; }

  .page-header h1 {
    margin: 4px 0 12px;
    font-size: clamp(24px, 7vw, 32px);
  }

  .daily-form { margin-top: 0; gap: 16px; }

  .summary-card,
  fieldset {
    border-radius: 20px;
    padding: 16px;
  }

  .meal-card {
    padding: 16px;
  }

  .summary-card input {
    width: 100%;
  }

  .egg-summary-row {
    flex-direction: column;
  }

  .egg-summary-row .total-card,
  .egg-percent-field {
    flex: 1 1 auto;
    width: 100%;
  }

  .unit-note {
    font-size: 13px;
  }

  .day-bar {
    margin-top: 0;
    padding: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "date date"
      "prev next"
      "today today";
    align-items: stretch;
    gap: 8px;
  }

  .date-picker { grid-area: date; }
  .day-prev { grid-area: prev; }
  .day-next { grid-area: next; }
  .day-today { grid-area: today; }

  .day-bar .pill { width: 100%; }
  .date-picker input,
  .date-picker select {
    width: 100%;
    min-width: 0;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-top: 0;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .pill {
    flex: 1;
  }

  .save-btn {
    min-height: 64px;
    font-size: 20px;
    border-radius: 20px;
  }

  .field-input,
  .summary-input,
  .date-picker input,
  .date-picker select,
  .login-field input,
  .summary-card input {
    font-size: 16px;
    min-height: 48px;
  }

  .food-combined { gap: 16px; }
  .food-block-title { font-size: 16px; }

  .food-grand-total .total-card {
    max-width: none;
    min-height: 96px;
  }

  .stock-entry-table {
    min-width: 0;
  }

  .stock-entry-table thead th {
    font-size: 12px;
    padding: 8px 4px;
  }

  .stock-entry-table th,
  .stock-entry-table td {
    padding: 8px 4px;
  }

  .egg-summary-row .total-card,
  .egg-percent-field { min-height: 96px; }

  .total-card output { font-size: 28px; }
}

@media (max-width: 640px) {
  .btn-label-full { display: none; }
  .btn-label-short { display: inline; }

  .brand-text { font-size: 15px; }
  .brand-mark { width: 38px; height: 38px; }

  .login-wrap { padding: 12px 0 40px; min-height: auto; }
  .login-card {
    width: min(440px, calc(100% - 20px));
    padding: 24px 18px 20px;
  }

  .pill {
    padding: 8px 12px;
    font-size: 14px;
  }

  .health-fields {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .form-rail a {
    flex: 1 1 100%;
  }
}

@media print {
  .bg-wash, .topbar, .toolbar, .day-bar .pill { display: none; }
  body.site { background: #fff; }
  @page { margin: 8mm; }
}
