:root {
  --grain-green: #00482b;
  --grain-green-deep: #002f1d;
  --grain-green-soft: #e2efe8;
  --grain-gold: #b78f16;
  --grain-gold-soft: #f4ead0;
  --paper: #fffefa;
  --ink: #17231b;
  --muted: #68756d;
  --line: #d7dfd8;
  --danger: #a43d32;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(0, 72, 43, 0.74), rgba(220, 235, 240, 0.86) 34%, rgba(255, 254, 250, 0.98) 68%),
    url("https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=1600&q=80");
  background-attachment: fixed;
  background-position: center top;
  background-size: cover;
  color: var(--ink);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(0, 72, 43, 0.82), rgba(0, 47, 29, 0.72)),
    url("https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=1600&q=80");
  background-position: center;
  background-size: cover;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.98);
  box-shadow: 0 24px 80px rgba(0, 31, 19, 0.35);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
}

.shell {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: none;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 12px;
  padding: 8px 0 14px;
}

body.is-home-view .topbar {
  display: grid;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.94);
  color: var(--grain-green);
  box-shadow: 0 14px 42px rgba(0, 47, 29, 0.22);
}

.logo-mark {
  width: 70px;
  height: 50px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 6px;
  background: white;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-lockup span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
  line-height: 1.22;
}

.eyebrow {
  margin: 0 0 4px;
  color: inherit;
  font-size: 0.76rem;
  font-weight: 840;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.76;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  color: white;
  font-size: 1.28rem;
  font-weight: 840;
  text-shadow: none;
}

h2 {
  font-size: 1.35rem;
}

.mission-panel,
.capture-panel,
.plan-panel,
.dataset-panel {
  background: rgba(255, 254, 250, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(0, 47, 29, 0.18);
}

.view-panel {
  animation: viewIn 160ms ease-out;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mission-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 0;
  background: linear-gradient(135deg, rgba(0, 72, 43, 0.96), rgba(0, 47, 29, 0.9));
}

.mission-copy .eyebrow {
  color: var(--grain-gold);
}

.mission-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mission-stats div,
.stats-box {
  min-height: 54px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border-radius: 6px;
  background: rgba(255, 254, 250, 0.12);
  color: white;
}

.mission-stats strong {
  font-size: 1.05rem;
}

.mission-stats span {
  font-size: 0.7rem;
  opacity: 0.82;
  text-align: center;
}

.home-screen {
  display: grid;
  gap: 14px;
}

.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.tile-group {
  display: grid;
  gap: 10px;
}

.tile-group h2 {
  margin: 2px 2px 0;
  color: var(--grain-green-deep);
  font-size: 1rem;
}

.home-tile {
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  min-height: 88px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.98);
  color: var(--grain-green-deep);
  text-align: left;
  box-shadow: 0 16px 46px rgba(0, 47, 29, 0.16);
}

.home-tile svg {
  grid-row: 1 / 3;
  width: 28px;
  height: 28px;
  color: var(--grain-green);
}

.home-tile span {
  font-size: 1.12rem;
  font-weight: 860;
}

.home-tile small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

.primary-tile {
  background: linear-gradient(135deg, var(--grain-green), var(--grain-green-deep));
  color: white;
}

.primary-tile svg,
.primary-tile small {
  color: rgba(255, 255, 255, 0.82);
}

.capture-panel {
  overflow: hidden;
}

.capture-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 0;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--grain-green-soft);
  color: var(--grain-green-deep);
  font-size: 0.84rem;
  font-weight: 820;
}

.capture-head .eyebrow,
.section-head .eyebrow {
  color: var(--grain-green);
}

.series-pill,
.review-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--grain-gold-soft);
  color: var(--grain-green-deep);
  font-size: 0.78rem;
  font-weight: 820;
  white-space: nowrap;
}

.photo-stage {
  position: relative;
  min-height: 320px;
  aspect-ratio: 3 / 4;
  margin-top: 14px;
  background:
    linear-gradient(135deg, rgba(0, 72, 43, 0.9), rgba(0, 47, 29, 0.88)),
    repeating-linear-gradient(90deg, transparent 0 44px, rgba(255, 255, 255, 0.08) 44px 46px);
  color: white;
  cursor: pointer;
  overflow: hidden;
}

.photo-stage input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.photo-stage.file-fallback input {
  pointer-events: auto;
}

.photo-stage.capture-busy {
  cursor: wait;
}

.photo-stage.capture-busy::after {
  content: "Обработка фото...";
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(0, 47, 29, 0.58);
  color: white;
  font-weight: 840;
}

.camera-preview,
.captured-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.captured-preview {
  z-index: 2;
}

.photo-empty {
  position: relative;
  z-index: 1;
  min-height: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 26px;
  text-align: center;
  background: rgba(0, 47, 29, 0.18);
  pointer-events: none;
}

.photo-empty svg {
  width: 48px;
  height: 48px;
  color: var(--grain-gold);
}

.photo-empty strong {
  font-size: 1.35rem;
}

.photo-empty span {
  max-width: 300px;
  color: rgba(255, 255, 255, 0.78);
}

.capture-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.two {
  grid-template-columns: 1fr;
}

label {
  color: var(--grain-green-deep);
  font-size: 0.88rem;
  font-weight: 760;
}

input,
select {
  width: 100%;
  min-height: 48px;
  margin-top: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--grain-green);
  box-shadow: 0 0 0 3px rgba(0, 72, 43, 0.16);
}

input:disabled,
select:disabled {
  color: var(--muted);
  background: #f3f6f2;
}

.server-check-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.server-check-row .secondary {
  min-height: 44px;
}

.login-server-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  background: #f3f6f2;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.login-server-status.server-online {
  background: #e6f3d7;
  color: var(--grain-green-deep);
}

.login-server-status.server-offline {
  background: #fae5e1;
  color: var(--danger);
}

.login-server-status.server-checking {
  background: var(--grain-gold-soft);
  color: var(--grain-green-deep);
}

.gps-strip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--grain-green-soft);
  color: var(--grain-green-deep);
  font-size: 0.86rem;
  font-weight: 720;
}

.gps-strip svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.gps-strip.gps-error {
  background: #fae5e1;
  color: var(--danger);
}

.gps-strip.gps-ok {
  background: #e6f3d7;
}

.actions,
.export-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.plan-export-actions {
  justify-content: flex-end;
  padding: 14px 16px 16px;
}

.series-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--grain-green-soft);
  color: var(--grain-green-deep);
  font-size: 0.9rem;
  font-weight: 840;
  white-space: nowrap;
}

.series-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--grain-gold-soft);
  color: var(--grain-green-deep);
  font-size: 0.88rem;
  font-weight: 840;
}

.switch-control {
  position: relative;
  width: 52px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(0, 47, 29, 0.28);
  transition: background 120ms ease;
}

.switch-control::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: white;
  box-shadow: 0 2px 7px rgba(0, 47, 29, 0.24);
  transition: transform 120ms ease;
}

.switch-control.series-active {
  background: var(--grain-green);
}

.switch-control.series-active::after {
  transform: translateX(22px);
}

.primary,
.secondary,
.ghost,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 840;
}

.primary {
  flex: 1 1 190px;
  background: var(--grain-green);
  color: white;
}

.camera-button {
  min-height: 54px;
  font-size: 1.04rem;
}

.primary:disabled {
  opacity: 0.72;
}

.secondary:disabled,
.switch-control:disabled {
  opacity: 0.62;
}

.secondary {
  background: var(--grain-gold-soft);
  color: var(--grain-green-deep);
}

.secondary.series-active {
  background: var(--grain-green);
  color: white;
  box-shadow: 0 10px 24px rgba(0, 72, 43, 0.22);
}

.ghost {
  background: transparent;
  color: var(--grain-green-deep);
}

.danger {
  color: var(--danger);
}

.icon-button {
  width: 46px;
  padding: 0;
  background: rgba(255, 254, 250, 0.92);
  color: var(--grain-green);
  box-shadow: 0 12px 34px rgba(0, 47, 29, 0.2);
}

.scout-chip,
.server-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  max-width: 160px;
  padding: 0 12px;
  border-radius: 6px;
  background: rgba(255, 254, 250, 0.92);
  color: var(--grain-green);
  font-weight: 840;
  box-shadow: 0 12px 34px rgba(0, 47, 29, 0.2);
}

.server-chip {
  max-width: 210px;
}

.server-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #a8b0a4;
  box-shadow: 0 0 0 3px rgba(168, 176, 164, 0.18);
}

.server-chip.server-online .server-dot {
  background: #219653;
  box-shadow: 0 0 0 3px rgba(33, 150, 83, 0.18);
}

.server-chip.server-offline .server-dot {
  background: #c83d2e;
  box-shadow: 0 0 0 3px rgba(200, 61, 46, 0.18);
}

.scout-chip span,
.server-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.plan-panel,
.dataset-panel,
.local-queue-panel {
  padding-bottom: 16px;
}

.section-summary {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 720;
}

.plan-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px 16px 0;
}

.plan-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-align: left;
}

.plan-card strong {
  display: block;
  font-size: 0.98rem;
}

.plan-card span,
.plan-card small {
  color: var(--muted);
  font-weight: 720;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ec;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--grain-green), var(--grain-gold));
}

.sample-list {
  display: grid;
  gap: 10px;
  padding: 14px 16px 0;
}

.sample-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.sample-card img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
}

.sample-photo-placeholder {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f5f7f2;
  color: var(--muted);
  text-align: center;
}

.sample-photo-placeholder svg {
  width: 20px;
  height: 20px;
  color: var(--green);
}

.sample-photo-placeholder span {
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.1;
}

.sample-card h3 {
  margin: 0 0 5px;
  font-size: 0.98rem;
}

.sample-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 140px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  color: var(--grain-green);
}

.local-queue-list {
  display: grid;
  gap: 10px;
  padding: 14px 16px 0;
}

.local-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.local-card > img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 6px;
  background: #edf1ec;
}

.local-card-body {
  display: grid;
  gap: 8px;
}

.local-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.local-card-head strong {
  display: block;
  font-size: 0.98rem;
}

.local-card-head span,
.local-card p {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.local-card p {
  margin: 0;
}

.local-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.local-card-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 6px;
}

.local-card-form .primary {
  grid-column: 1 / -1;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf1ec;
  color: var(--grain-green-deep);
  font-size: 0.74rem;
  font-weight: 840;
  white-space: nowrap;
}

.upload-status-uploading {
  background: var(--grain-gold-soft);
}

.upload-status-failed,
.upload-error {
  color: var(--danger);
}

.upload-status-failed {
  background: #fae5e1;
}

.upload-button {
  flex: 0 1 260px;
}

.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 31, 19, 0.54);
}

.app-dialog-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.99);
  color: var(--ink);
  box-shadow: 0 24px 86px rgba(0, 31, 19, 0.36);
}

.app-dialog-card h2 {
  color: var(--grain-green-deep);
  font-size: 1.12rem;
}

.app-dialog-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.36;
}

.app-dialog-input {
  display: grid;
  gap: 7px;
}

.app-dialog-input input {
  margin-top: 0;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.app-dialog-actions .primary.danger {
  background: var(--danger);
  color: white;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 30;
  width: min(420px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.98);
  color: var(--grain-green-deep);
  box-shadow: 0 18px 54px rgba(0, 47, 29, 0.24);
  font-size: 0.9rem;
  font-weight: 780;
}

.app-toast-success {
  border-color: #b8d9ba;
}

.app-toast-error {
  border-color: #efb8b0;
  color: var(--danger);
}

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

  .mission-panel {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: end;
  }

  .tile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .capture-panel {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
  }

  .capture-head {
    grid-column: 1 / -1;
  }

  .photo-stage {
    margin-top: 16px;
    min-height: auto;
  }

  .photo-empty {
    min-height: 100%;
  }

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

  .plan-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .brand-lockup {
    gap: 10px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar .brand-lockup {
    grid-column: 1 / -1;
  }

  .logo-mark {
    width: 64px;
    height: 48px;
  }

  .mission-stats {
    grid-template-columns: 1fr 1fr;
  }

  .mission-stats div:first-child {
    grid-column: 1 / -1;
  }

  .section-head {
    display: grid;
  }

  .capture-head {
    display: grid;
  }

  .export-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .export-actions .secondary {
    padding: 0 8px;
  }

  .sample-card {
    grid-template-columns: 64px 1fr;
  }

  .local-card {
    grid-template-columns: 72px 1fr;
  }

  .local-card > img {
    width: 72px;
    height: 72px;
  }

  .local-card-head {
    display: grid;
  }

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

  .sample-card img {
    width: 64px;
    height: 64px;
  }

  .sample-photo-placeholder {
    width: 64px;
    height: 64px;
    padding: 6px;
  }

  .review-badge {
    grid-column: 2;
    width: fit-content;
  }
}
