:root {
  --field-sidebar-w: 260px;
  --field-topbar-h: 48px;
  --field-bottom-nav-h: 60px;
  --field-bg: #f4f6f3;
  --field-surface: #fff;
  --field-icon-wash: #e8f2ec;
}

body.field-app {
  background: var(--field-bg);
}

/* Sidebar */
body.field-app .sidebar {
  width: var(--field-sidebar-w);
  padding: 20px 16px;
  box-shadow: 2px 0 24px rgba(12, 36, 28, 0.12);
}

body.field-app .sidebar nav {
  margin-top: 20px;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 2px;
}

body.field-app .sidebar nav a {
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
}

body.field-app .sidebar nav a.active {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  border-left: 3px solid var(--lime);
  padding-left: 11px;
}

body.field-app .nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

body.field-app .nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.field-app .sidebar-foot {
  padding-top: 16px;
}

/* Main shell */
body.field-app .main {
  margin-left: var(--field-sidebar-w);
  min-height: 100vh;
  padding: 0;
  display: flex;
  flex-direction: column;
}

body.field-app .field-topbar {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--field-topbar-h);
  padding: 10px 20px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #0f2d22 0%, #163b2d 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px rgba(12, 36, 28, 0.2);
}

body.field-app .field-topbar .topbar-title {
  min-width: 0;
  flex: 1;
}

body.field-app .field-topbar .topbar-title h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

body.field-app .field-topbar .eyebrow {
  margin: 0 0 2px !important;
  font-size: 10px !important;
  letter-spacing: 0.12em !important;
  color: var(--green) !important;
}

body.field-app .field-topbar .head-meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

body.field-app .topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

body.field-app .topbar-actions .btn {
  padding: 8px 14px;
  font-size: 12px;
  white-space: nowrap;
}

body.field-app .field-page-body {
  flex: 1;
  padding: 16px 20px 28px;
}

body.field-app.has-bottom-nav .field-page-body {
  padding-bottom: calc(var(--field-bottom-nav-h) + 20px + env(safe-area-inset-bottom, 0px));
}

/* Hide duplicate in-page headers when topbar is active */
body.field-app.has-field-topbar .page-head > div:first-child,
body.field-app.has-field-topbar .form-top > div:not(.steps):first-child,
body.field-app.has-field-topbar .form-top > a:first-child + div {
  display: none;
}

body.field-app.has-field-topbar .page-head,
body.field-app.has-field-topbar .form-top {
  margin-bottom: 12px;
}

body.field-app.has-field-topbar .page-head:empty,
body.field-app.has-field-topbar .page-head:not(:has(.btn)) {
  display: none;
}

/* Bottom nav base — mobile styles in field-mobile.css */
.field-bottom-nav {
  display: none;
}

@media (max-width: 850px) {
  body.field-app .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 200;
  }

  body.field-app .sidebar.open {
    transform: none;
  }

  body.field-app .sidebar.open::before {
    display: none;
  }

  body.field-app .mobile-head {
    display: none;
  }

  body.field-app .main {
    margin-left: 0;
  }
}

@media (min-width: 851px) {
  body.field-app .field-bottom-nav {
    display: none !important;
  }
}

/* Back link in top bar */
body.field-app .page-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #edf4ee;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

body.field-app .page-back-link:hover {
  background: #e3efe5;
}

/* Sidebar brand logo */
body.field-app .sidebar-logo {
  display: block;
  padding: 4px 0 8px;
}

body.field-app .sidebar-logo img {
  display: block;
  width: 132px;
  max-width: 100%;
  height: auto;
}

/* Mobile form polish */
@media (max-width: 850px) {
  body.field-app .registration-form {
    border-radius: 14px;
    margin-left: -2px;
    margin-right: -2px;
  }

  body.field-app .steps {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 14px 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  body.field-app .steps::-webkit-scrollbar {
    display: none;
  }

  body.field-app .steps i {
    flex: 0 0 24px;
    min-width: 24px;
  }

  body.field-app .steps button {
    flex: 0 0 auto;
    min-width: 44px;
  }

  body.field-app .form-actions {
    position: sticky;
    bottom: calc(var(--field-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    z-index: 110;
    padding: 12px 16px;
    box-shadow: 0 -4px 16px rgba(20, 53, 42, 0.08);
  }

  body.field-app .form-actions .btn {
    min-height: 44px;
  }

  body.field-app .toast {
    top: auto;
    right: 16px;
    left: 16px;
    bottom: calc(var(--field-bottom-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  }

  body.field-app .panel {
    border-radius: 14px;
  }

  body.field-app .search {
    margin: 14px;
    max-width: none;
  }

  body.field-app .topbar-actions .btn {
    padding: 8px 12px;
  }

  body.field-app .field-topbar .topbar-title h1 {
    font-size: 18px;
  }
}

@media (max-width: 520px) {
  body.field-app .topbar-actions {
    gap: 6px;
  }

  body.field-app .topbar-actions .btn:not(.page-back-link) {
    padding: 8px 10px;
    font-size: 11px;
  }

  body.field-app .field-topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  body.field-app .field-topbar .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Auth — mobile-first */
@media (max-width: 850px) {
  .auth-panel,
  .simple-auth {
    padding: 24px 20px 32px;
    align-items: flex-start;
  }

  .auth-card {
    width: 100%;
    max-width: 420px;
  }

  .auth-card h2 {
    font-size: 24px;
  }

  .auth-shell {
    background: linear-gradient(180deg, #f4f6f3 0%, #fff 28%);
  }
}

/* 404 */
.not-found {
  text-align: center;
  padding: 48px 20px 64px;
}

.not-found span {
  display: inline-grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: #eef4ee;
  color: var(--green);
  font: 800 22px 'Plus Jakarta Sans', sans-serif;
}

.not-found h1 {
  margin: 18px 0 8px;
  font-size: 24px;
}

.not-found p {
  color: var(--muted);
  margin: 0 0 24px;
}

.not-found .btn {
  display: none;
}

body.field-app.has-field-topbar .not-found .btn {
  display: none;
}
