html {
  font-size: 90%;
}

:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #647067;
  --line: #dfe7df;
  --paper: #f6f7f2;
  --panel: #ffffff;
  --green: #1f6b4e;
  --green-dark: #164834;
  --lime: #a8c75a;
  --gold: #d69a2d;
  --red: #bd4a3d;
  --teal: #1e7b7b;
  --shadow: 0 16px 45px rgba(33, 45, 37, 0.1);

  /* Aliases for JS inline-style compatibility */
  --text: var(--ink);
  --muted-text: var(--muted);
  --surface: var(--panel);
  --surface-raised: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

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

button,
input,
select {
  font: inherit;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
  background: #122218;
}

.login-visual {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.login-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(10, 31, 21, 0.88), rgba(10, 31, 21, 0.5) 58%, rgba(10, 31, 21, 0.2));
}

.login-visual-copy {
  position: relative;
  z-index: 1;
  max-width: 680px;
  padding: 56px;
  color: white;
  display: grid;
  align-content: end;
  min-height: 100vh;
}

.login-visual-copy .brand-mark {
  margin-bottom: 22px;
}

.login-panel {
  min-height: 100vh;
  padding: 34px;
  background: var(--paper);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 440px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.login-card .brand-mark {
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  outline: 0;
}

.field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(31, 107, 78, 0.12);
}

.login-submit {
  width: 100%;
  min-height: 46px;
}

.login-error {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-success {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 600;
}

.password-wrap {
  position: relative;
  display: flex;
}
.password-wrap input {
  flex: 1;
  padding-right: 44px;
}
.pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  display: flex;
  align-items: center;
}
.pw-toggle:hover { color: var(--ink); }

.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -4px 0;
}
.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}
.remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  cursor: pointer;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-button:hover { opacity: 0.75; }

.login-footer {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  margin-top: -4px;
}
.login-footer .link-button { font-size: 0.82rem; }

.privacy-modal-box {
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.privacy-content {
  overflow-y: auto;
  flex: 1;
  padding: 0 2px;
  font-size: 0.93rem;
  line-height: 1.65;
}
.privacy-content h4 {
  margin: 20px 0 6px;
  font-size: 0.95rem;
  color: var(--ink);
}
.privacy-content p  { margin: 0 0 10px; color: var(--muted); }
.privacy-content ul { margin: 0 0 10px; padding-left: 20px; color: var(--muted); }
.privacy-content li { margin-bottom: 4px; }
.privacy-content .eyebrow { margin-bottom: 16px; }

.default-account {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 0.86rem;
}

.default-account span {
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  transition: grid-template-columns 0.2s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 200;
  padding: 18px 12px;
  background: #0f241a;
  color: #edf5e6;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
}

.brand,
.nav-list a {
  color: inherit;
  text-decoration: none;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  min-width: 0;
  flex: 1;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--lime);
  color: #102318;
  font-weight: 800;
  font-size: 0.86rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.95rem;
}

.brand small {
  font-size: 0.72rem;
}

.sync-copy {
  transition: opacity 0.18s ease;
}

.brand small,
.sync-card small {
  color: #b8cbbf;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-list a {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #c8d9cd;
  font-size: 0.88rem;
  font-weight: 600;
}

.sidebar-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #edf5e6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  flex: 0 0 auto;
}

.nav-list a:hover,
.nav-list a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-list svg,
.topbar svg,
button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sync-card {
  margin-top: auto;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  display: flex;
  gap: 9px;
  background: rgba(255, 255, 255, 0.06);
}

.sync-card strong {
  font-size: 0.86rem;
}

.sync-card small {
  font-size: 0.72rem;
}

.app-shell.sidebar-collapsed .sidebar {
  padding-inline: 9px;
  align-items: center;
}

.app-shell.sidebar-collapsed .brand-row {
  flex-direction: column;
  gap: 12px;
}

.app-shell.sidebar-collapsed .brand,
.app-shell.sidebar-collapsed .nav-list a,
.app-shell.sidebar-collapsed .sync-card {
  width: 54px;
  justify-content: center;
  padding-inline: 0;
}

.app-shell.sidebar-collapsed .brand > span:last-child,
.app-shell.sidebar-collapsed .nav-list a {
  font-size: 0;
}

.app-shell.sidebar-collapsed .sync-card > div,
.app-shell.sidebar-collapsed .brand > span:last-child {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.app-shell.sidebar-collapsed .sync-card {
  min-height: 48px;
}

.app-shell.sidebar-collapsed .status-dot {
  margin-top: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 999px;
  background: #8bcf63;
  box-shadow: 0 0 0 5px rgba(139, 207, 99, 0.14);
}

.main {
  min-width: 0;
  padding: 20px 28px 42px;
}

.main-tight {
  padding-top: 0;
}

.page-section-tight {
  padding-top: 0;
}

.sticky-page-head {
  position: sticky;
  top: 0;
  z-index: 150;
  padding: 8px 0 4px;
  margin-bottom: 2px;
  background: var(--paper);
}

.compact-header {
  margin-bottom: 10px;
}

.compact-toolbar {
  margin-bottom: 0;
}

.detail-sticky-head {
  padding-bottom: 8px;
}

.topbar {
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-button {
  display: none;
}

.search {
  flex: 1;
  min-width: 160px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 10px;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

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

.header-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
  padding: 0 4px;
}

.header-user-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--green-dark);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-user-role {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted-text, #888);
}

.icon-button,
.primary-button,
.ghost-button,
.period-control button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.icon-button {
  width: 42px;
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.primary-button {
  padding: 0 16px;
  background: var(--green);
  color: white;
}

.ghost-button,
.period-control button {
  padding: 0 13px;
  background: #edf4ed;
  color: var(--green-dark);
}

.hero {
  position: relative;
  min-height: 280px;
  margin: 10px 0 28px;
  overflow: hidden;
  border-radius: 8px;
  background: #122218;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(10, 31, 21, 0.86) 0%, rgba(10, 31, 21, 0.58) 42%, rgba(10, 31, 21, 0.12) 100%);
}

.hero-overlay {
  position: relative;
  z-index: 1;
  max-width: 720px;
  padding: 34px;
  color: white;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #d5ee8f;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 650px;
  margin-bottom: 22px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.55rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-metrics span {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.11);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-header,
.panel-head,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.period-control {
  display: flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.period-control button.active {
  background: var(--green);
  color: white;
}

.kpi-grid,
.content-grid {
  display: grid;
  gap: 16px;
}

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

.two-col {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

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

.map-layout,
.trace-layout {
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
}

.panel,
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.kpi-card {
  padding: 18px;
}

.kpi-card .icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #edf4ed;
  color: var(--green);
}

.kpi-card strong {
  display: block;
  margin: 14px 0 4px;
  font-size: 1.8rem;
  letter-spacing: 0;
}

.kpi-card small,
.muted {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.success {
  background: #e4f4e9;
  color: #1a6d43;
}

.warning {
  background: #fff0ce;
  color: #8a5a00;
}

.danger {
  background: #ffe6e0;
  color: #9b342b;
}

.neutral {
  background: #e9f1f4;
  color: #225b67;
}

.timeline,
.risk-list,
.trace-chain,
.lot-breakdown,
.farm-detail {
  display: grid;
  gap: 12px;
}

.activity,
.risk-item,
.trace-step,
.breakdown-row,
.detail-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
}

.activity {
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
}

.activity-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f1f5ec;
  color: var(--green);
}

.risk-item {
  border-left: 4px solid var(--gold);
}

.toolbar {
  justify-content: flex-start;
}

.table-link {
  color: var(--green-dark);
  text-decoration: none;
}

.table-link:hover {
  color: var(--green);
  text-decoration: underline;
}

.tabbar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--green-dark);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.tab-button.active {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.detail-subtitle {
  margin: 4px 0 0;
  font-size: 0.82rem;
}

.detail-summary {
  display: grid;
  grid-template-columns: 1.3fr repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 10px 0 12px;
}

.detail-summary:empty {
  display: none;
}

.profile-head-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-meta-chips {
  display: flex;
  gap: 20px;
  align-items: flex-end;
}

.profile-meta-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.profile-meta-chip .muted {
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-meta-chip strong {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.profile-meta-chip--row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.profile-year-select {
  height: 26px;
  padding: 0 4px 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  cursor: pointer;
}

.profile-year-select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 107, 78, 0.1);
}

/* ── Farmer detail edit modal ── */
.fd-edit-modal {
  width: min(680px, 95vw);
}

.fd-edit-body {
  overflow-y: auto;
  max-height: 62vh;
  padding: 2px 4px;
}

.fd-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.fd-section-title:first-child {
  margin-top: 4px;
}

/* ── Family yes/no question ── */
.family-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.family-top-row .family-question-block {
  flex: 1;
}

.family-question-block {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.88rem;
}

.fd-question-block {
  margin-bottom: 4px;
}

.yesno-toggle {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.yesno-btn {
  padding: 5px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--panel);
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.yesno-btn + .yesno-btn {
  border-left: 1px solid var(--line);
}

.yesno-btn.active {
  background: var(--green);
  color: #fff;
}

/* ── Family member card in edit modal ── */
.fd-family-member,
.fd-worker-member {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
}

.fd-family-member-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.fd-family-member-head strong {
  font-size: 0.84rem;
}

.fd-add-member-btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 9px;
  font-size: 0.84rem;
}

.profile-identity-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.38fr) minmax(420px, 0.62fr);
  gap: 10px;
  align-items: stretch;
}

.profile-quick-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.farmer-photo-card {
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 8px 12px;
  align-items: center;
}

.farmer-photo-card strong,
.farmer-photo-card small {
  display: block;
}

.farmer-photo-card strong {
  font-size: 0.9rem;
}

.farmer-photo-card small {
  color: var(--muted);
  font-size: 0.74rem;
}

.farmer-photo-placeholder {
  grid-row: span 2;
  width: 68px;
  height: 74px;
  border: 1px dashed #b9c8b8;
  border-radius: 8px;
  background: #f3f7ee;
  color: var(--green);
  display: grid;
  place-items: center;
}

.farmer-photo-placeholder svg {
  width: 30px;
  height: 30px;
}

.identity-section {
  display: grid;
  grid-template-columns: minmax(240px, 0.42fr) minmax(320px, 0.58fr);
  gap: 10px;
  align-items: stretch;
}

.family-card-section {
  max-width: 760px;
}

.identity-photo-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: #fbfcf8;
}

.identity-photo-card strong,
.identity-photo-card small {
  display: block;
}

.identity-photo-card strong {
  font-size: 0.86rem;
}

.identity-photo-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.identity-photo-placeholder {
  width: 94px;
  height: 60px;
  border: 1px dashed #b9c8b8;
  border-radius: 8px;
  background: #f3f7ee;
  color: var(--green);
  display: grid;
  place-items: center;
}

.identity-photo-placeholder svg {
  width: 28px;
  height: 28px;
}

.photo-upload-button {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 0.78rem;
  justify-self: start;
}

.detail-summary .kpi-card {
  padding: 12px;
}

.detail-summary .kpi-card strong {
  margin: 8px 0 3px;
  font-size: 1.1rem;
}

.detail-summary .kpi-card small {
  font-size: 0.72rem;
}

.detail-panel {
  display: grid;
  gap: 14px;
  font-size: 0.86rem;
}

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

.detail-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.garden-map-card {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(220px, 0.34fr);
  gap: 12px;
  align-items: stretch;
}

.garden-map {
  position: relative;
  min-height: 240px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31, 107, 78, 0.18), transparent 48%),
    repeating-linear-gradient(32deg, rgba(31, 107, 78, 0.09) 0 10px, rgba(168, 199, 90, 0.1) 10px 22px),
    #dfead5;
}

.garden-map-polygon {
  position: absolute;
  left: 25%;
  top: 16%;
  width: 48%;
  height: 62%;
  border: 3px solid rgba(22, 72, 52, 0.9);
  background: rgba(168, 199, 90, 0.38);
  clip-path: polygon(12% 20%, 72% 6%, 95% 38%, 80% 86%, 32% 94%, 4% 58%);
}

.garden-map-pin {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 4px solid white;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
}

.map-boundary {
  position: absolute;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.map-boundary.north {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.map-boundary.east {
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
}

.map-boundary.south {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.map-boundary.west {
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
}

.garden-map-info {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  display: grid;
  align-content: center;
  gap: 8px;
}

.garden-map-info strong,
.garden-map-info span {
  display: block;
}

.detail-table {
  min-width: 1040px;
}

.detail-table th,
.detail-table td {
  padding: 9px 11px;
  font-size: 0.8rem;
}

.detail-panel .detail-row {
  padding: 10px;
}

.detail-panel .detail-row span {
  font-size: 0.74rem;
}

.detail-panel .detail-row strong {
  font-size: 0.84rem;
}

.detail-panel h3 {
  font-size: 0.94rem;
}

.tab-button {
  font-size: 0.82rem;
}

.compact-toolbar {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(190px, 0.28fr) minmax(170px, 0.24fr) auto auto;
  align-items: center;
  gap: 12px;
}

.toolbar-search {
  max-width: none;
  position: relative;
}

/* ─── Search dropdown ─────────────────────────────────────────────────────── */
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(23, 33, 27, 0.14);
  z-index: 1200;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.sd-empty {
  padding: 14px 16px;
  font-size: 0.82rem;
  color: var(--muted);
}

.sd-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  outline: none;
}

.sd-item:last-child { border-bottom: none; }

.sd-item:hover,
.sd-item:focus {
  background: var(--paper);
}

.sd-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.sd-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}

.sd-name mark,
.sd-id mark,
.sd-gid mark {
  background: #ffe066;
  color: var(--ink);
  border-radius: 2px;
  padding: 0 1px;
}

.sd-item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  color: var(--muted);
}

.sd-sep { opacity: 0.4; }

.sd-badge {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sd-badge-base   { background: #e8f5e9; color: #1f6b4e; }
.sd-badge-import { background: #e3f0ff; color: #1d5fa6; }

.farms-page {
  font-size: 0.86rem;
}

.farms-page h2 {
  font-size: 1.28rem;
}

.farms-page h3 {
  font-size: 0.92rem;
}

.farms-page .eyebrow {
  font-size: 0.7rem;
}

.farms-page .search {
  height: 40px;
}

.farms-page .top-actions .primary-button,
.farms-page .top-actions .ghost-button,
.farms-page .top-actions .icon-button {
  min-height: 38px;
  font-size: 0.82rem;
}

.farms-page .top-actions .ghost-button,
.farms-page .top-actions .primary-button {
  padding-inline: 11px;
}

.farms-page .panel {
  padding: 14px;
}

.farms-page .mock-map {
  min-height: 390px;
}

.map-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  isolation: isolate;
}

.farms-page .map-panel {
  padding: 0;
  overflow: hidden;
  flex: 1;
}

.import-layers-panel {
  padding: 0;
  flex-shrink: 0;
}

.import-layers-head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.import-layers-head .ghost-button {
  font-size: 0.78rem;
  padding: 5px 10px;
  color: var(--red, #c0392b);
  border-color: #f5c6c2;
}

.import-layers-head .ghost-button:hover {
  background: #fef2f2;
  border-color: #e57373;
}

.import-layers-list {
  display: grid;
  gap: 6px;
  padding: 10px 12px 12px;
  max-height: 200px;
  overflow-y: auto;
}

.il-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.il-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #d8f2ee;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #0f766e;
}

.il-icon i { width: 14px; height: 14px; }

.il-info {
  flex: 1;
  min-width: 0;
}

.il-name {
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.il-meta {
  font-size: 0.71rem;
  color: var(--muted);
  margin-top: 2px;
}

.il-del-btn {
  background: none;
  border: 1px solid #f5c6c2;
  color: #c0392b;
  border-radius: 8px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.14s, border-color 0.14s;
  padding: 0;
}

.il-del-btn i { width: 13px; height: 13px; }
.il-del-btn:hover { background: #fef2f2; border-color: #e57373; }

/* ─── Forest Overlay Results Panel ──────────────────────────────────────────── */

.overlay-result-panel {
  padding: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 420px;
}

.overlay-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  gap: 10px;
}

.overlay-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.overlay-head-actions .ghost-button {
  font-size: 0.78rem;
  padding: 5px 10px;
}

.overlay-summary {
  padding: 10px 14px 6px;
  flex-shrink: 0;
}

.overlay-summary-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.overlay-pill {
  font-size: 0.73rem;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
}

.overlay-pill strong { color: var(--ink); margin-left: 4px; }

.overlay-pill.danger {
  background: #fef2f2;
  border-color: #f5c6c2;
  color: #9b2226;
}

.overlay-pill.danger strong { color: #9b2226; }

.overlay-pill.success {
  background: #f0faf4;
  border-color: #b7dcca;
  color: #1a5e3a;
}

.overlay-pill.success strong { color: #1a5e3a; }

.overlay-pill.neutral {
  background: var(--paper);
  border-color: var(--line);
}

.overlay-result-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.overlay-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.overlay-table thead th {
  position: sticky;
  top: 0;
  background: var(--paper);
  padding: 7px 10px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.overlay-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overlay-table tbody tr:last-child td { border-bottom: none; }

.overlay-table tbody tr:hover td { background: var(--paper); }

.overlay-table tbody tr.ot-row-alert td { background: #fff8f7; }

.overlay-table tbody tr.ot-row-alert:hover td { background: #fff0ee; }

.overlay-progress {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overlay-progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.overlay-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.overlay-progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.overlay-error {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
}

.overlay-error p { color: var(--red); margin: 0 0 6px; font-size: 0.82rem; }
.overlay-error small { font-size: 0.73rem; }

.overlay-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.real-map {
  min-height: 430px;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

.map-north-arrow {
  width: 40px;
  height: 56px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(23, 33, 27, 0.14);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(23, 33, 27, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.map-north-arrow svg {
  width: 32px;
  height: 52px;
}

.map-layer-switcher {
  padding: 6px;
  border: 1px solid rgba(23, 33, 27, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(23, 33, 27, 0.14);
  display: grid;
  gap: 5px;
}

.map-layer-switcher button {
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--green-dark);
  font-size: 0.74rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.map-layer-switcher button.active {
  background: var(--green);
  color: white;
}

.forest-legend,
.tree-loss-legend,
.ra-deforestation-legend {
  width: 230px;
  padding: 10px;
  border: 1px solid rgba(23, 33, 27, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(23, 33, 27, 0.14);
  color: var(--ink);
  display: grid;
  gap: 6px;
}

.forest-legend strong,
.tree-loss-legend strong,
.ra-deforestation-legend strong {
  font-size: 0.8rem;
}

.forest-legend div,
.tree-loss-legend div,
.ra-deforestation-legend div {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 700;
}

.forest-legend span,
.tree-loss-legend span,
.ra-deforestation-legend span {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(23, 33, 27, 0.18);
  border-radius: 3px;
  flex: 0 0 auto;
}

.tree-loss-legend span {
  background: #ff3b30;
}

.forest-legend small,
.tree-loss-legend small,
.ra-deforestation-legend small {
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.35;
}

.ra-legend-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.ra-badge {
  background: #00a651;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.03em;
}

.map-fallback {
  min-height: 430px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

/* ─── Farm detail panel (right side) ──────────────────────────────────────── */

.farms-page .panel:not(.map-panel) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.farms-page .panel:not(.map-panel) .panel-head {
  padding: 14px 16px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}

.farm-detail-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  display: grid;
  gap: 0;
  align-content: start;
}

/* Header */
.fd-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.fd-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

.fd-header-info {
  flex: 1;
  min-width: 0;
}

.fd-name {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fd-code {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: monospace;
  margin-top: 1px;
}

/* Sections */
.fd-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.fd-section:last-of-type { border-bottom: none; }

.fd-id-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  margin-bottom: 4px;
  padding: 4px 0;
}

.fd-id-row span { color: var(--muted); }
.fd-id-row strong { font-family: monospace; font-size: 0.76rem; }

.fd-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 6px;
}

.fd-location {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.fd-group {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Stat grid */
.fd-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.fd-stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
}

.fd-stat strong {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--green-dark);
  line-height: 1.2;
}

.fd-stat strong span {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 2px;
}

.fd-stat small {
  font-size: 0.7rem;
  color: var(--muted);
  display: block;
  margin-top: 1px;
}

/* GPS */
.fd-gps {
  display: grid;
  gap: 5px;
}

.fd-gps-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f0f5f0;
  border: 1px solid #d9e8da;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  min-width: 0;
  overflow: hidden;
}

.fd-gps-row span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fd-gps-row strong {
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--green-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.fd-gps-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--green-dark);
  background: none;
  border: 1px solid #c5dece;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  margin-top: 2px;
  transition: background 0.12s;
  width: 100%;
  justify-content: center;
}

.fd-gps-copy:hover { background: #e8f4ef; }

/* Score bar */
.fd-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fd-score-bar {
  flex: 1;
  height: 7px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.fd-score-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.fd-score-row > strong {
  font-size: 0.95rem;
  font-weight: 800;
  min-width: 26px;
  text-align: right;
}

/* Polygon status */
.fd-polygon-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Actions */
.fd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 0 6px;
}

.fd-actions .ghost-button {
  flex: 1;
  justify-content: center;
  font-size: 0.78rem;
  padding: 6px 8px;
}

/* Farm mini list */
.fd-list-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 10px 0 6px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.fd-mini-list {
  display: grid;
  gap: 4px;
}

.fd-mini-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.fd-mini-item:hover {
  background: var(--paper);
  border-color: var(--line);
}

.fd-mini-item.active {
  background: #e8f4ef;
  border-color: #b5d9c2;
}

.fd-mini-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.fd-mini-dot.dot-success { background: #3aae6e; }
.fd-mini-dot.dot-warning { background: var(--gold); }
.fd-mini-dot.dot-danger  { background: var(--red); }
.fd-mini-dot.dot-teal    { background: #0f766e; }

.fd-mini-body {
  flex: 1;
  min-width: 0;
}

.fd-mini-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fd-mini-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1px;
}

/* ─── Imported Layer Manager ────────────────────────────────────────────────── */
.fd-import-layers {
  display: grid;
  gap: 6px;
  padding-bottom: 10px;
}

.fd-import-layer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.fd-import-layer-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #d8f2ee;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #0f766e;
}

.fd-import-layer-icon i { width: 14px; height: 14px; }

.fd-import-layer-info {
  flex: 1;
  min-width: 0;
}

.fd-import-layer-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fd-import-layer-meta {
  font-size: 0.71rem;
  color: var(--muted);
  margin-top: 2px;
}

.fd-import-layer-del {
  background: none;
  border: 1px solid #f5c6c2;
  color: #c0392b;
  border-radius: 8px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.14s, border-color 0.14s;
  padding: 0;
}

.fd-import-layer-del i { width: 13px; height: 13px; }
.fd-import-layer-del:hover { background: #fef2f2; border-color: #e57373; }

/* ─── Selected polygon ring (Leaflet adds this class) ──────────────────────── */
.leaflet-interactive.farm-selected {
  animation: polygonPulse 0.3s ease;
}

@keyframes polygonPulse {
  from { stroke-opacity: 0; fill-opacity: 0.1; }
  to   { stroke-opacity: 1; fill-opacity: 0.5; }
}

/* Legacy detail-row inside farm detail — keep for compatibility */
.farms-page .farm-detail {
  gap: 8px;
}

.farms-page .detail-row {
  padding: 10px;
}

.farms-page .detail-row span {
  font-size: 0.72rem;
}

.farms-page .detail-row strong {
  font-size: 0.82rem;
}

.farms-toolbar {
  position: relative;
  z-index: 1100;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.farms-toolbar .ghost-button,
.farms-toolbar .export-dropdown .ghost-button {
  min-height: 40px;
  padding-inline: 14px;
  font-size: 0.82rem;
}

.export-dropdown {
  position: relative;
  flex: 0 0 auto;
}

.export-menu {
  position: absolute;
  z-index: 1800;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 36px rgba(23, 33, 27, 0.16);
  display: grid;
  gap: 4px;
}

.export-menu button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.export-menu button:hover {
  background: #edf4ed;
}

.settings-page {
  font-size: 0.82rem;
}

.settings-page h2 {
  font-size: 1.22rem;
}

.settings-page h3 {
  font-size: 0.88rem;
}

.settings-page .eyebrow {
  font-size: 0.68rem;
}

.settings-page .search {
  height: 38px;
}

.settings-page .search input {
  font-size: 0.78rem;
}

.settings-page .top-actions .primary-button,
.settings-page .top-actions .ghost-button,
.settings-page .top-actions .icon-button {
  min-height: 36px;
  font-size: 0.78rem;
}

.settings-page .tab-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.76rem;
}

.settings-page .topbar {
  justify-content: flex-end;
  min-height: 0;
  margin-bottom: 4px;
}

.settings-page .topbar:empty {
  display: none;
}

.settings-page .page-section {
  padding-top: 0;
}

.settings-page .section-header {
  margin-bottom: 8px;
}

.settings-page .section-header h2 {
  margin: 2px 0 0;
}

.settings-header {
  align-items: center;
}

.settings-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.settings-header-actions .badge {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.settings-tabbar {
  margin-bottom: 0;
}

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

.setting-mini-card {
  padding: 11px;
  display: grid;
  gap: 6px;
}

.setting-mini-card span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.setting-mini-card strong {
  color: var(--green-dark);
  font-size: 0.98rem;
}

.settings-grid {
  grid-template-columns: minmax(320px, 0.42fr) minmax(0, 0.58fr);
}

.setting-form-panel {
  padding: 14px;
}

.setting-form-panel .panel-head,
.setting-table-head {
  margin-bottom: 12px;
}

.setting-fields {
  display: grid;
  gap: 8px;
}

.setting-fields .detail-row {
  padding: 9px;
}

.setting-fields .detail-row span {
  font-size: 0.68rem;
}

.setting-fields .detail-row strong {
  font-size: 0.78rem;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.settings-form input,
.settings-form select {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.settings-form input:focus,
.settings-form select:focus {
  border-color: var(--green);
  outline: 2px solid rgba(31, 107, 78, 0.14);
}

.checkbox-field {
  grid-column: 1 / -1;
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf3;
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  color: var(--green-dark) !important;
  cursor: pointer;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.wide-field {
  grid-column: 1 / -1;
}

.code-preview {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf3;
  display: grid;
  gap: 6px;
}

.code-preview span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.code-preview strong {
  color: var(--green-dark);
  font-size: 1rem;
  letter-spacing: 0;
}

.code-token-help {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  display: grid;
  gap: 5px;
}

.code-token-help strong {
  color: var(--green-dark);
  font-size: 0.74rem;
}

.code-token-help span {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.date-field.is-disabled {
  opacity: 0.58;
}

.date-field.is-disabled input {
  background: #edf4ed;
  color: var(--muted);
  cursor: not-allowed;
}

.setting-table-panel {
  overflow: hidden;
}

.setting-table-head {
  padding: 14px 14px 0;
}

.setting-table-panel table {
  font-size: 0.74rem;
}

.setting-table-panel th,
.setting-table-panel td {
  padding: 10px 12px;
}

.table-action-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf4ed;
  color: var(--green-dark);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
}

.table-action-button:hover {
  border-color: var(--green);
}

.table-action-button svg {
  width: 15px;
  height: 15px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  padding: 24px;
  background: rgba(8, 28, 20, 0.38);
  display: grid;
  place-items: center;
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(8, 28, 20, 0.28);
}

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

.modal-head h3 {
  margin-top: 4px;
  font-size: 1rem;
}

.map-import-modal {
  font-size: 0.86rem;
}

.import-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.import-choice {
  min-height: 96px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdf8;
  display: flex;
  gap: 10px;
  cursor: pointer;
}

.import-choice input {
  margin-top: 4px;
  accent-color: var(--green);
}

.import-choice span,
.file-drop span {
  display: grid;
  gap: 5px;
}

.import-choice strong,
.file-drop strong,
.import-template-grid strong {
  color: var(--green-dark);
}

.import-choice small,
.file-drop small,
.import-template-grid small {
  color: var(--muted);
  line-height: 1.35;
}

.file-drop {
  margin-top: 12px;
  min-height: 96px;
  padding: 16px;
  border: 1px dashed #a8b9a6;
  border-radius: 8px;
  background: #f7fbf3;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
}

.file-drop > svg {
  width: 32px;
  height: 32px;
  color: var(--green);
}

.file-drop input {
  display: none;
}

.import-template-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.import-template-grid div,
.config-block {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  display: grid;
  gap: 5px;
}

.import-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 4px 0 12px;
}

.import-step {
  display: flex;
  gap: 14px;
  padding-bottom: 16px;
  position: relative;
  align-items: flex-start;
}

.import-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 26px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.import-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  margin-top: 1px;
}

.import-step-body {
  flex: 1;
  min-width: 0;
}

.import-step-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  line-height: 1.3;
}

.import-step-desc {
  font-size: 0.77rem;
  color: var(--muted);
  margin: 0 0 8px;
  line-height: 1.5;
}

.import-step-desc em {
  font-style: normal;
  color: var(--ink);
  font-weight: 500;
}

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

.config-block {
  align-content: start;
}

.config-block strong {
  color: var(--green-dark);
}

.config-block label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

.config-block input {
  margin-top: 2px;
  accent-color: var(--green);
}

.import-feedback {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf4ed;
  color: var(--green-dark);
  font-weight: 700;
  line-height: 1.45;
}

.import-fail-list {
  margin: 8px 0 0;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  background: #fff8f8;
  overflow: hidden;
}

.import-fail-list.is-hidden { display: none; }

.import-fail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fee2e2;
  border-bottom: 1px solid #fca5a5;
  font-weight: 700;
  font-size: 0.84rem;
  color: #b91c1c;
}

.import-fail-header svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.import-fail-scroll {
  max-height: 180px;
  overflow-y: auto;
  padding: 6px 0;
}

.import-fail-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 6px;
  padding: 6px 14px;
  border-bottom: 1px solid #fee2e2;
  font-size: 0.78rem;
}

.import-fail-item:last-child { border-bottom: none; }

.import-fail-ids {
  font-family: monospace;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-fail-reason {
  color: #b91c1c;
  font-size: 0.73rem;
  text-align: right;
  white-space: nowrap;
}

.import-fail-export {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #b91c1c;
  background: #fff;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.import-fail-export:hover { background: #fef2f2; }
.import-fail-export svg { width: 13px; height: 13px; flex-shrink: 0; }

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.excel-button {
  min-height: 42px;
  padding-inline: 13px;
}

select {
  min-height: 42px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.table-panel {
  padding: 0;
  overflow: auto;
}

.compact-table-panel {
  margin-top: 0;
  max-height: calc(100vh - 230px);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.92rem;
}

.compact-table-panel table {
  min-width: 1180px;
}

.compact-table-panel th,
.compact-table-panel td {
  padding: 10px 12px;
  font-size: 0.82rem;
}

.compact-table-panel th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 0.7rem;
  background: #fbfcf8;
  box-shadow: inset 0 -1px 0 var(--line);
}

.compact-table-panel .badge {
  min-height: 24px;
  padding-inline: 9px;
  font-size: 0.72rem;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fbfcf8;
}

tr:last-child td {
  border-bottom: 0;
}

.mock-map {
  position: relative;
  min-height: 420px;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(115deg, rgba(31, 107, 78, 0.2), transparent 45%),
    repeating-linear-gradient(35deg, rgba(31, 107, 78, 0.1) 0 8px, rgba(168, 199, 90, 0.08) 8px 18px),
    #dfead5;
}

.map-marker {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 4px solid white;
  background: var(--red);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.map-polygon {
  position: absolute;
  border: 2px solid rgba(22, 72, 52, 0.86);
  background: rgba(168, 199, 90, 0.36);
  clip-path: polygon(12% 22%, 84% 8%, 96% 68%, 44% 92%, 6% 66%);
}

.trace-step {
  position: relative;
  padding-left: 46px;
}

.trace-step::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 15px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px #e7f3ea;
}

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

.progress span {
  display: block;
  height: 100%;
  background: var(--green);
}

@media (max-width: 1020px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-visual {
    display: none;
  }

  .login-panel {
    padding: 22px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 5;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 270px;
    align-items: stretch;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .app-shell.sidebar-collapsed .sidebar {
    padding: 18px 12px;
    align-items: stretch;
  }

  .app-shell.sidebar-collapsed .brand-row {
    flex-direction: row;
    gap: 10px;
  }

  .app-shell.sidebar-collapsed .brand,
  .app-shell.sidebar-collapsed .nav-list a,
  .app-shell.sidebar-collapsed .sync-card {
    width: auto;
    justify-content: flex-start;
    padding-inline: 12px;
  }

  .app-shell.sidebar-collapsed .brand > span:last-child,
  .app-shell.sidebar-collapsed .nav-list a {
    font-size: inherit;
  }

  .app-shell.sidebar-collapsed .sync-card > div,
  .app-shell.sidebar-collapsed .brand > span:last-child {
    position: static;
    opacity: 1;
    pointer-events: auto;
  }

  .menu-button {
    display: inline-flex;
  }

  .kpi-grid,
  .settings-summary,
  .two-col,
  .three-col,
  .map-layout,
  .trace-layout,
  .detail-summary,
  .detail-grid,
  .identity-section,
  .profile-identity-grid,
  .profile-quick-fields,
  .garden-map-card {
    grid-template-columns: 1fr 1fr;
  }

  .compact-toolbar {
    grid-template-columns: 1fr 1fr;
  }

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

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

@media (max-width: 720px) {
  .login-card {
    padding: 22px;
  }

  .default-account {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .section-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    min-height: 0;
  }

  .menu-button {
    align-self: flex-start;
  }

  .top-actions,
  .period-control,
  .toolbar select,
  .excel-button {
    width: 100%;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .primary-button,
  .ghost-button,
  .period-control button,
  .toolbar select,
  .excel-button {
    flex: 1;
  }

  .export-dropdown {
    flex: 1;
  }

  .export-dropdown .ghost-button {
    width: 100%;
  }

  .export-menu {
    left: 0;
    right: auto;
    width: 100%;
  }

  .import-choice-grid,
  .import-template-grid,
  .export-config-grid {
    grid-template-columns: 1fr;
  }

  .compact-toolbar {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 360px;
  }

  .hero-overlay {
    padding: 24px;
  }

  .kpi-grid,
  .settings-summary,
  .two-col,
  .three-col,
  .map-layout,
  .trace-layout,
  .detail-summary,
  .detail-grid,
  .identity-section,
  .profile-identity-grid,
  .profile-quick-fields,
  .garden-map-card {
    grid-template-columns: 1fr;
  }

  .identity-photo-card,
  .farmer-photo-card {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL SYSTEM
═══════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 16, 0.55);
  backdrop-filter: blur(3px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-dialog {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(10, 25, 16, 0.25);
  width: min(100%, 560px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.18s ease;
}

.modal-dialog.modal-lg {
  width: min(100%, 720px);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.modal-header .eyebrow {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin: 0 0 2px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
  background: var(--line);
  color: var(--ink);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Modal Form Layouts ───────────────────────────────────────────────────── */

.modal-form {
  display: grid;
  gap: 14px;
}

.modal-form .form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
}

.modal-form .form-row.single {
  grid-template-columns: 1fr;
}

.modal-form .form-row.triple {
  grid-template-columns: 1fr 1fr 1fr;
}

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.modal-form label > span,
.modal-form .field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-form input[type="text"],
.modal-form input[type="email"],
.modal-form input[type="number"],
.modal-form input[type="date"],
.modal-form input[type="password"],
.modal-form select,
.modal-form textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 107, 78, 0.12);
}

.modal-form textarea {
  resize: vertical;
  min-height: 72px;
}

.modal-form .pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.modal-form .pw-wrap input[type="password"],
.modal-form .pw-wrap input[type="text"] {
  width: 100%;
  padding-right: 38px;
}

.modal-form .pw-eye {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted-text);
  display: flex;
  align-items: center;
  padding: 0;
  line-height: 1;
}

.modal-form .pw-eye:hover { color: var(--green); }
.modal-form .pw-eye svg { pointer-events: none; }

.modal-form .checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.modal-form .checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  cursor: pointer;
}

.modal-form .checkbox-row span {
  font-size: 0.875rem;
}

/* ─── User Access Checklist ────────────────────────────────────────────────── */

/* Legacy pill styles — masih dipakai di tempat lain */
.access-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: opacity 0.2s;
}

.access-group-label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.access-group-label i { width: 13px; height: 13px; }

.access-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
}

.access-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--ink);
  transition: border-color 0.14s, background 0.14s;
  user-select: none;
}

.access-pill:hover { border-color: var(--green); background: #f0faf4; }

.access-pill input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--green);
  cursor: pointer; flex-shrink: 0;
}

.access-pill:has(input:checked) {
  border-color: var(--green);
  background: #e8f5ed;
  color: var(--green-dark);
  font-weight: 500;
}

/* ─── Access Columns (User modal 2-col layout) ──────────────────────────── */

.access-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

/* Kolom kanan — Trace + Setting stacked vertikal */
.access-col-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.access-col {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: opacity 0.2s;
}

.access-col-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.access-col-header i { width: 13px; height: 13px; flex-shrink: 0; }

.access-item-list {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}

.access-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--ink);
  user-select: none;
  transition: background 0.1s;
}

.access-item:hover { background: #f5faf7; }

.access-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.access-item:has(input:checked) {
  background: #eef7f2;
  color: var(--green-dark);
  font-weight: 500;
}

.access-item:has(input:checked) + .access-item { border-top: 1px solid #d5eddf; }

@media (max-width: 600px) {
  .access-columns { grid-template-columns: 1fr; }
}

.modal-form .field-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.modal-form .code-preview-box {
  background: #122218;
  color: #a8c75a;
  font-family: "Courier New", monospace;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 7px;
  letter-spacing: 0.05em;
}

.modal-form .section-divider {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════════════════════ */

.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 9px;
  background: #1a2e22;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
  min-width: 240px;
  max-width: 380px;
}

.toast.toast-success { background: #1a3d29; border-left: 4px solid #4caf50; }
.toast.toast-error   { background: #3d1a1a; border-left: 4px solid #ef5350; }
.toast.toast-warning { background: #3d2f1a; border-left: 4px solid #ffa726; }
.toast.toast-info    { background: #1a2e3d; border-left: 4px solid #42a5f5; }

@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(40px); opacity: 0; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.toast.removing {
  animation: toastOut 0.2s ease forwards;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS PAGE — ENHANCED
═══════════════════════════════════════════════════════════════════════════ */

.settings-tabbar-sticky {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  margin: 0 -28px;
  padding: 8px 28px 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
}

.settings-tabbar {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.settings-tabbar::-webkit-scrollbar { display: none; }

.tab-scroll-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
  transition: opacity 0.15s, background 0.15s;
  padding: 0;
}

.tab-scroll-btn:hover { background: var(--line); }

.tab-scroll-btn:disabled {
  opacity: 0.25;
  pointer-events: none;
}

/* ─── Supply Chain Flow ────────────────────────────────────────────────────── */

.chain-flow-builder {
  display: grid;
  gap: 10px;
}

.chain-step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  position: relative;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.chain-step-item:hover {
  border-color: #b5cfbb;
  box-shadow: 0 2px 10px rgba(31, 107, 78, 0.08);
}

.chain-step-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.chain-step-connector {
  position: absolute;
  left: 27px;
  bottom: -11px;
  width: 2px;
  height: 11px;
  background: var(--line);
  z-index: 0;
}

.chain-step-item:last-child .chain-step-connector { display: none; }

.chain-step-body {
  flex: 1;
}

.chain-step-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.chain-step-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.chain-step-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.chain-step-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.step-action-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.step-action-btn:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: #b5cfbb;
}

.step-action-btn.danger:hover {
  background: #fdf0ef;
  color: var(--red);
  border-color: var(--red);
}

.step-action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chain-commodity-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.chain-commodity-selector label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.chain-commodity-selector select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  font-size: 0.875rem;
  color: var(--ink);
  outline: none;
}

/* ─── Commodity Grade Table ────────────────────────────────────────────────── */

.grade-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e8f4ef;
  color: var(--green-dark);
}

/* ─── Quality Standards ────────────────────────────────────────────────────── */

.quality-standard-grid {
  display: grid;
  gap: 12px;
}

.quality-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  background: var(--paper);
}

.quality-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.quality-card-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.quality-params {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.quality-param {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quality-param-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--muted);
}

.quality-param-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

/* ─── Compliance Indicators ────────────────────────────────────────────────── */

.indicator-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.indicator-order {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--line);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.indicator-body {
  flex: 1;
}

.indicator-title {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.indicator-desc {
  font-size: 0.77rem;
  color: var(--muted);
  line-height: 1.5;
}

.indicator-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.indicator-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ─── Enhanced Settings Table Actions ──────────────────────────────────────── */

.table-action-group {
  display: flex;
  gap: 4px;
}

.tbl-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.tbl-btn-edit {
  background: #e8f4ef;
  color: var(--green-dark);
  border-color: #c5dece;
}

.tbl-btn-edit:hover {
  background: #d1eade;
  border-color: var(--green);
}

.tbl-btn-delete {
  background: #fdf0ef;
  color: var(--red);
  border-color: #f3c9c7;
}

.tbl-btn-delete:hover {
  background: #fad9d7;
  border-color: var(--red);
}

.tbl-btn-toggle {
  background: var(--paper);
  color: var(--muted);
  border-color: var(--line);
}

.tbl-btn-toggle:hover {
  background: var(--line);
  color: var(--ink);
}

/* ─── Settings Summary Stats ───────────────────────────────────────────────── */

.settings-stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
}

.stat-chip strong {
  font-size: 1rem;
  font-weight: 800;
  color: var(--green-dark);
}

.stat-chip span {
  color: var(--muted);
}

/* ─── Empty State ──────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state svg {
  opacity: 0.3;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.9rem;
  margin: 0 0 16px;
}

/* ─── Badge variants ───────────────────────────────────────────────────────── */

.badge.active   { background: #e8f4ef; color: #164834; }
.badge.inactive { background: #f2f2f2; color: #888;    }
.badge.required { background: #e8f4ef; color: var(--green-dark); }
.badge.optional { background: #f2f7ff; color: #1a5bb5; }

/* ─── Danger button ────────────────────────────────────────────────────────── */

.danger-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--red);
  background: #fdf0ef;
  color: var(--red);
  transition: background 0.12s;
}

.danger-button:hover { background: #fad9d7; }

/* ─── Confirm dialog (danger action) ──────────────────────────────────────── */

.confirm-dialog {
  padding: 12px 0 4px;
}

.confirm-dialog p {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.6;
}

.confirm-dialog strong {
  color: var(--red);
}

/* ─── Settings page commodity tab ─────────────────────────────────────────── */

.commodity-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}

.commodity-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.commodity-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.commodity-card-title strong {
  font-size: 0.95rem;
}

.commodity-card-title code {
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--line);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--muted);
}

.commodity-card-body {
  padding: 14px 18px;
  display: grid;
  gap: 10px;
}

.grade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.grade-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.grade-code {
  font-family: monospace;
  font-size: 0.75rem;
  background: #e8f4ef;
  color: var(--green-dark);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
}

.grade-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.grade-moisture {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ─── Price tag colors ─────────────────────────────────────────────────────── */

.price-active   { color: var(--green-dark); font-weight: 700; }
.price-inactive { color: var(--muted);      text-decoration: line-through; }

/* ─── Export/Import config ─────────────────────────────────────────────────── */

.config-io-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.config-io-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 18px;
  background: var(--paper);
}

.config-io-card h4 {
  margin: 0 0 6px;
  font-size: 0.875rem;
}

.config-io-card p {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .modal-form .form-row {
    grid-template-columns: 1fr;
  }
  .modal-form .form-row.triple {
    grid-template-columns: 1fr 1fr;
  }
  .config-io-panel {
    grid-template-columns: 1fr;
  }
  .toast-stack {
    right: 12px;
    bottom: 16px;
    left: 12px;
  }
}

/* ─── Survey Builder ────────────────────────────────────────────────────────── */

.sv-editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 5;
}

.sv-editor-head > div {
  flex: 1;
}

.sv-editor-head p.eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sv-editor-head h3 {
  margin: 2px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.sv-meta-panel {
  margin-bottom: 20px;
}

.sv-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 14px;
  align-items: start;
}

.sv-meta-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sv-meta-field > span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.sv-meta-field input,
.sv-meta-field select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.875rem;
  width: 100%;
}

.sv-meta-field input:focus,
.sv-meta-field select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 107, 78, 0.1);
}

.sv-section-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sv-section-panel {
  padding: 0;
  overflow: hidden;
}

.sv-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.sv-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sv-section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sv-section-title > div {
  min-width: 0;
}

.sv-section-title strong {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-section-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sv-fields-list {
  padding: 8px 0;
}

.sv-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  min-height: 42px;
}

.sv-field-row:last-child {
  border-bottom: none;
}

.sv-field-row:hover {
  background: var(--paper);
}

.sv-field-type {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--green);
  background: rgba(31, 107, 78, 0.08);
  border-radius: 5px;
  padding: 3px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sv-field-label {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-field-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.sv-add-field-row {
  padding: 8px 12px;
  border-top: 1px dashed var(--line);
}

.sv-fields-empty {
  padding: 14px 16px;
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

.sv-empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.sv-empty-state strong {
  color: var(--ink);
}

@media (max-width: 900px) {
  .sv-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .sv-meta-grid {
    grid-template-columns: 1fr;
  }
  .sv-editor-head {
    flex-wrap: wrap;
    gap: 8px;
  }
  .sv-section-head {
    flex-wrap: wrap;
  }
  .sv-section-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ─── Survey Builder: Conditional Logic ─────────────────────────────────────── */

.sv-cond-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--teal);
  background: rgba(30, 123, 123, 0.09);
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.sv-cond-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}

.sv-cond-toggle {
  margin-bottom: 10px;
}

.sv-cond-body {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.sv-cond-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sv-cond-row #fldCondField {
  flex: 2;
  min-width: 0;
}

.sv-cond-row #fldCondOp {
  flex: 1;
  min-width: 0;
}

.sv-cond-row #fldCondValueWrap {
  flex: 1;
  min-width: 0;
}

.sv-cond-row select,
.sv-cond-row input {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.84rem;
  background: var(--panel);
  color: var(--ink);
  width: 100%;
}

.sv-cond-row select:focus,
.sv-cond-row input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(30, 123, 123, 0.12);
}

.sv-cond-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  font-style: italic;
}

/* ─── Survey Builder: Preview ────────────────────────────────────────────────── */

.sv-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 16px 0 48px;
}

.sv-preview-device {
  width: 375px;
  background: var(--panel);
  border-radius: 38px;
  border: 7px solid #1c1c1e;
  box-shadow: 0 0 0 1px #3a3a3c, 0 28px 64px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.sv-preview-device-bar {
  background: var(--green);
  color: #fff;
  padding: 14px 18px 12px;
  flex-shrink: 0;
}

.sv-preview-device-name {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.sv-preview-device-cat {
  display: block;
  font-size: 0.72rem;
  opacity: 0.75;
  margin-top: 2px;
}

.sv-preview-form {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sv-preview-device-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
}

.sv-preview-submit {
  width: 100%;
  height: 44px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.sv-preview-submit:hover {
  background: var(--green-dark);
}

.sv-preview-section {
  border-bottom: 8px solid var(--paper);
  padding: 16px 16px 12px;
  background: var(--panel);
}

.sv-preview-section:last-child {
  border-bottom: none;
}

.sv-preview-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.sv-preview-section-desc {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 6px 0 10px;
  line-height: 1.4;
}

.sv-preview-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 12px;
}

.sv-prev-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: opacity 0.2s, transform 0.2s;
}

.sv-prev-hidden {
  display: none !important;
}

.sv-prev-field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.sv-prev-required {
  color: var(--red);
  font-weight: 700;
}

.sv-prev-cond-tag {
  display: inline-flex;
  align-items: center;
  color: var(--teal);
  font-size: 0.7rem;
}

.sv-prev-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-size: 0.84rem;
  color: var(--ink);
}

.sv-prev-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 107, 78, 0.1);
}

textarea.sv-prev-input {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}

.sv-prev-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sv-prev-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  user-select: none;
}

.sv-prev-option input {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--green);
}

.sv-prev-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  background: var(--paper);
}

.sv-prev-sig-area {
  min-height: 72px;
  justify-content: center;
  border-color: var(--ink);
  opacity: 0.35;
}

@media (max-width: 480px) {
  .sv-preview-device {
    width: 100%;
    border-radius: 16px;
    border-width: 4px;
  }
  .sv-cond-row {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PROFESSIONAL POLISH
═══════════════════════════════════════════════════════════════════════════ */

/* ─── Button transitions & hover / active ───────────────────────────────── */

.icon-button,
.primary-button,
.ghost-button,
.period-control button {
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease,
              box-shadow 0.14s ease, transform 0.1s ease;
}

.primary-button:hover  {
  background: var(--green-dark);
  box-shadow: 0 4px 14px rgba(31, 107, 78, 0.28);
}
.primary-button:active {
  background: #112d20;
  transform: translateY(1px);
  box-shadow: none;
}

.ghost-button:hover  { background: #d8e9d8; border-color: #b5cfbb; }
.ghost-button:active { background: #c6dac6; }

.icon-button:hover  { background: #edf4ed; border-color: #b5cfbb; }
.icon-button:active { background: #d8e9d8; }

/* ─── Tab button transitions ─────────────────────────────────────────────── */

.tab-button { transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease; }
.tab-button:not(.active):hover { background: #edf4ed; border-color: #b5cfbb; }

/* ─── Nav: transitions + active accent bar ───────────────────────────────── */

.nav-list a { transition: background 0.14s ease, color 0.14s ease; }

.nav-list a.active {
  background: rgba(168, 199, 90, 0.15);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--lime);
}

/* ─── Table row hover (all data tables) ─────────────────────────────────── */

tbody td { transition: background 0.12s ease; }
tbody tr:hover td { background: #f7fbf6; }

/* ─── KPI card: micro-lift ───────────────────────────────────────────────── */

.kpi-card { transition: box-shadow 0.18s ease, transform 0.18s ease; }
.kpi-card:hover {
  box-shadow: 0 8px 28px rgba(23, 33, 27, 0.13);
  transform: translateY(-2px);
}

/* ─── Search bar focus glow ──────────────────────────────────────────────── */

.search { transition: border-color 0.14s ease, box-shadow 0.14s ease; }
.search:focus-within {
  border-color: #a0c8a8;
  box-shadow: 0 0 0 3px rgba(31, 107, 78, 0.1);
}

/* ─── Focus: ring on keyboard, none on mouse ─────────────────────────────── */

*:focus { outline: none; }
*:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* Form controls keep visible ring even on mouse (user is typing) */
.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus,
.settings-form input:focus,
.settings-form select:focus,
.field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 107, 78, 0.12);
  outline: none;
}

/* ─── Thin custom scrollbars ─────────────────────────────────────────────── */

::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: #ccd9cc; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #b0c4b0; }

* { scrollbar-width: thin; scrollbar-color: #ccd9cc transparent; }

/* ─── Sticky page head: subtle depth when content scrolls under ─────────── */

.sticky-page-head {
  box-shadow: 0 2px 0 var(--line);
}

/* ─── Panel: border-radius boost for modern feel ─────────────────────────── */

.panel,
.kpi-card,
.modal-dialog {
  border-radius: 10px;
}

/* ─── Badge: slightly rounder for modern look ────────────────────────────── */

.badge { border-radius: 6px; }

/* ─── Table header: cleaner separation ───────────────────────────────────── */

th {
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ─── Eyebrow label refinement ───────────────────────────────────────────── */

.eyebrow { letter-spacing: 0.08em; }

/* ─── Ghost button used as a link (e.g. back arrow) ─────────────────────── */

a.ghost-button {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
