*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Background ────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  min-height: 100vh;
  background: linear-gradient(135deg, #04090f 0%, #071526 40%, #0d2a4a 75%, #143d66 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 14px 180px;
  position: relative;
  overflow-x: hidden;
}

/* ── Grass / crop silhouette ───────────────────────────────────────────── */
#grassScene {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Card ──────────────────────────────────────────────────────────────── */
.card {
  position: relative;
  z-index: 1;
  background: rgba(6, 16, 36, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 100, 100, .55);
  width: 100%;
  max-width: 520px;
  padding: 32px 32px 36px;
  color: #e8eef6;
}

/* ── App header ────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 12px;
}

.app-name {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .4px;
  line-height: 1.2;
}

.app-name span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #7aa8d0;
  letter-spacing: .3px;
  margin-top: 2px;
}

.app-logo {
  height: 54px;
  width: 54px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
}

/* Logo fallback (shown when img fails to load) */
.logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, #1a5c35, #2ea855);
  border-radius: 10px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -1px;
}

/* ── Step indicator ────────────────────────────────────────────────────── */
.steps {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
  gap: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .3s, color .3s;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
}

.step-dot.active {
  background: #2ea855;
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 10px rgba(46, 168, 85, 0.5);
}

.step-dot.done {
  background: #1a5c35;
  color: #7fd89a;
  border-color: transparent;
}

.step-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .3s;
}

.step-label.active {
  color: #5dcc7f;
  font-weight: 600;
}

.step-connector {
  flex: 1;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 6px;
  transition: background .3s;
  flex-shrink: 0;
  min-width: 12px;
}

.step-connector.done {
  background: linear-gradient(90deg, #1a5c35, #2ea855);
}

/* ── Typography ────────────────────────────────────────────────────────── */
h2 {
  font-size: 18px;
  color: #fff;
  margin-bottom: 4px;
  font-weight: 700;
}

.subtitle {
  font-size: 13px;
  color: #7aa8d0;
  margin-bottom: 22px;
}

h3 {
  font-size: 14px;
  font-weight: 700;
  color: #a8d4f0;
  margin: 18px 0 10px;
}

.divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 16px 0;
}

/* ── Form fields ────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #c4daf0;
  margin-bottom: 5px;
  letter-spacing: .2px;
}

label .req {
  color: #e05050;
  margin-left: 3px;
}

label .opt {
  font-size: 11px;
  font-weight: 400;
  color: #5a7a9a;
  margin-left: 4px;
}

input,
textarea {
  width: 100%;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-size: 14px;
  color: #e8eef6;
  outline: none;
  transition: border-color .2s, background .2s;
}

input::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.22);
}

input:focus,
textarea:focus {
  border-color: #2ea855;
  background: rgba(255, 255, 255, 0.09);
}

input.error {
  border-color: #e05050;
  background: rgba(224, 80, 80, 0.07);
}

input[readonly] {
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.4);
  cursor: default;
}

textarea {
  resize: vertical;
}

/* Auto-fill highlight */
input.autofilled {
  border-color: #2ea855;
  background: rgba(46, 168, 85, 0.1);
}

.field-error {
  font-size: 12px;
  color: #f08080;
  margin-top: 4px;
  display: none;
}

.field-error.visible {
  display: block;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-row {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  letter-spacing: .2px;
}

.btn:active {
  transform: scale(.97);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #c4daf0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-primary {
  background: linear-gradient(135deg, #2ea855 0%, #1a5c35 100%);
  color: #fff;
  box-shadow: 0 3px 12px rgba(46, 168, 85, 0.35);
}

.btn-primary:hover {
  opacity: .88;
}

.btn-danger {
  background: rgba(224, 80, 80, 0.15);
  color: #f09090;
  border: 1px solid rgba(224, 80, 80, 0.25);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
  line-height: 1.4;
}

.alert.visible {
  display: block;
}

.alert-error {
  background: rgba(224, 80, 80, 0.15);
  color: #f5aaaa;
  border: 1px solid rgba(224, 80, 80, 0.3);
}

.alert-success {
  background: rgba(46, 168, 85, 0.15);
  color: #7fd89a;
  border: 1px solid rgba(46, 168, 85, 0.3);
}

.alert-warn {
  background: rgba(210, 160, 40, 0.15);
  color: #f0c96a;
  border: 1px solid rgba(210, 160, 40, 0.35);
}

.alert-info {
  background: rgba(41, 121, 255, 0.13);
  color: #90c0f0;
  border: 1px solid rgba(41, 121, 255, 0.25);
}

/* ── Catalog cards ───────────────────────────────────────────────────────── */
.farm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.farm-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.farm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  cursor: pointer;
  transition: background .2s;
}

.farm-card-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.farm-card-title {
  font-size: 14px;
  font-weight: 700;
  color: #e8eef6;
}

.farm-card-sub {
  font-size: 12px;
  color: #6a9abf;
  margin-top: 2px;
}

.farm-card-body {
  padding: 12px 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: none;
}

.farm-card-body.open {
  display: block;
}

/* ── Farm inline form ────────────────────────────────────────────────────── */
.farm-form-box {
  border: 1.5px dashed rgba(46, 168, 85, 0.4);
  border-radius: 10px;
  padding: 16px;
  margin-top: 8px;
  background: rgba(46, 168, 85, 0.04);
  display: none;
}

.farm-form-box.open {
  display: block;
}

.farm-form-title {
  font-size: 14px;
  font-weight: 700;
  color: #5dcc7f;
  margin-bottom: 14px;
}

/* ── Producer info box ───────────────────────────────────────────────────── */
.producer-info-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 18px;
}

.producer-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.producer-info-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.producer-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 14px;
  font-size: 13px;
  color: #c4daf0;
}

@media (max-width: 400px) {
  .producer-info-grid {
    grid-template-columns: 1fr;
  }
}

.producer-info-grid span {
  color: #5a8aaa;
}

.producer-edit-form {
  margin-top: 14px;
  display: none;
}

.producer-edit-form.open {
  display: block;
}

/* ── Success screen ──────────────────────────────────────────────────────── */
#successScreen {
  display: none;
  text-align: center;
  padding: 20px 0;
}

#successScreen.visible {
  display: block;
}

.success-icon {
  font-size: 52px;
  margin-bottom: 14px;
}

.success-title {
  font-size: 20px;
  font-weight: 700;
  color: #5dcc7f;
  margin-bottom: 8px;
}

.success-sub {
  font-size: 14px;
  color: #7aa8d0;
}

/* ── Sending modal ───────────────────────────────────────────────────────── */
.sending-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.sending-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.sending-modal-card {
  background: rgba(6, 22, 46, 0.95);
  border: 1px solid rgba(46, 168, 85, 0.35);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 100, 80, .5);
  padding: 36px 40px;
  text-align: center;
  max-width: 320px;
  width: 90%;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(46, 168, 85, 0.2);
  border-top-color: #2ea855;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 20px;
}

.sending-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.sending-modal-hint {
  font-size: 13px;
  color: #7aa8d0;
  line-height: 1.5;
}

/* ── Select & date inputs — match navy theme ─────────────────────────────── */
select,
input[type="date"] {
  width: 100%;
  padding: 10px 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-size: 14px;
  color: #e8eef6;
  outline: none;
  transition: border-color .2s, background .2s;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237aa8d0' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}

select option {
  background: #0d1f3a;
  color: #e8eef6;
}

select:focus,
input[type="date"]:focus {
  border-color: #2ea855;
  background: rgba(255, 255, 255, 0.09);
}

/* Force date picker popup to dark — Chromium only, best-effort */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(0.7);
  cursor: pointer;
}

input[type="date"]::-webkit-datetime-edit {
  color: #e8eef6;
}

input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  background: transparent;
}

/* Disable context menu cursor hint */
* {
  -webkit-user-select: none;
  user-select: text; /* allow text selection; context menu blocked via JS */
}

/* ── Form section separators ─────────────────────────────────────────────── */
.form-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 14px;
}

.form-section-header hr {
  flex: 1;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #5dcc7f;
  text-transform: uppercase;
  letter-spacing: .8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.form-section-note {
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 12px;
  color: #90c0f0;
  background: rgba(41, 121, 255, 0.1);
  border: 1px solid rgba(41, 121, 255, 0.22);
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── Field hint ──────────────────────────────────────────────────────────── */
.field-hint {
  font-size: 11px;
  color: #5a7a9a;
  margin-top: 4px;
}

/* ── MST read-only display ───────────────────────────────────────────────── */
.mst-readonly {
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: #8aaccc;
  font-size: 14px;
  letter-spacing: 0.5px;
  user-select: text;
}

/* ── farm-form-title centered ────────────────────────────────────────────── */
.farm-form-title {
  text-align: center;
}

/* ── Validation modal ────────────────────────────────────────────────────── */
.validation-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.validation-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.validation-modal-card {
  background: rgba(6, 22, 46, 0.97);
  border: 1px solid rgba(224, 80, 80, 0.4);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(180, 40, 40, .35);
  padding: 32px 36px;
  text-align: center;
  max-width: 320px;
  width: 90%;
}

.validation-modal-icon {
  font-size: 36px;
  margin-bottom: 14px;
}

.validation-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.validation-modal-hint {
  font-size: 13px;
  color: #f0a0a0;
  line-height: 1.5;
  margin-bottom: 22px;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .card {
    padding: 22px 18px 28px;
  }

  .app-name {
    font-size: 15px;
  }
}
