:root {
  --orange: #e96e16;
  --ink: #243247;
  --muted: #66758a;
  --line: #e5e9ef;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #f5f7fa;
  color: var(--ink);
  font-family: system-ui,sans-serif;
}
header {
  background: linear-gradient(110deg,#d9570b,#f48a29);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px max(20px,calc((100vw - 1400px)/2));
  gap: 12px;
}
.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}
.logo {
  font-weight: 900;
  border: 2px solid white;
  border-radius: 10px;
  padding: 8px;
  font-size: 22px;
}
.brand small {
  font-size: 10px;
  letter-spacing: 2px;
}
.brand h1 {
  font-size: 23px;
  margin: 0;
  font-weight: 750;
}
nav {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 0 max(12px,calc((100vw - 1400px)/2));
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 5;
}
nav button {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 15px 20px;
  color: var(--muted);
  font-weight: 650;
}
nav button.active {
  color: var(--orange);
  border-color: var(--orange);
}
main {
  max-width: 1440px;
  padding: 22px!important;
  min-height: 76vh;
}
.panel,.metric {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 2px 7px #27374908;
}
.filters {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr)) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 20px;
}
.filters[hidden] {
  display: none;
}
label,.muted {
  font-size: 12px;
  color: var(--muted);
}
label {
  margin-bottom: 4px;
  font-weight: 600;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 12px;
  margin: 12px 0 20px;
}
.metric strong {
  font-size: clamp(20px,2.2vw,32px);
  display: block;
  letter-spacing: -.6px;
  color: var(--orange);
}
.metric small {
  font-size: 12px;
  color: var(--muted);
}
h2 {
  font-size: 21px;
  font-weight: 750;
  margin: 0 0 12px;
}
h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}
.chartbox {
  height: 280px;
  position: relative;
}
.twocol {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.panel {
  margin-bottom: 14px;
}
.twocol .panel {
  margin: 0;
}
.table {
  font-size: 13px;
  white-space: nowrap;
}
.table th {
  background: #fff3e8;
  color: #8e430d;
}
.table-responsive {
  max-height: 530px;
  overflow: auto;
}
.table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 20px;
  background: #eaf0f5;
  color: #42536b;
}
.good {
  color: #198754;
}
.bad {
  color: #c33;
}
.warn {
  color: #a15c00;
}
footer {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar input {
  max-width: 340px;
}
.detail {
  background: #fff9f2;
  border-radius: 8px;
  padding: 15px;
  margin: 12px 0;
}
button:focus-visible {
  outline: 2px solid #1663ae;
  outline-offset: 2px;
}
@media(max-width:760px) {
  header {
    padding: 12px;
  }
  main {
    padding: 12px!important;
    padding-bottom: 75px!important;
  }
  nav {
    position: fixed;
    bottom: 0;
    top: auto;
    width: 100%;
    justify-content: space-around;
    padding: 0;
    border-top: 1px solid var(--line);
  }
  nav button {
    flex: 1;
    font-size: 12px;
    padding: 16px 3px;
    border-bottom: 0;
    border-top: 3px solid transparent;
  }
  nav button.active {
    border-top-color: var(--orange);
  }
  .filters {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .metric,.panel {
    padding: 12px;
  }
  .twocol {
    grid-template-columns: 1fr;
  }
  .chartbox {
    height: 240px;
  }
  footer {
    display: none;
  }
}
/* V1 UI refinement: presentation only; no data or API changes. */
:root {
  --orange: #c94e08;
  --ink: #172b45;
  --muted: #536579;
  --line: #dce4ed;
  --surface: #f2f5f9;
  --radius: 16px;
}
body {
  background: var(--surface);
  font-size: 15px;
  font-feature-settings: "tnum";
  line-height: 1.55;
}
header {
  background: linear-gradient(108deg,#b53e05 0%,#df6412 62%,#ef8127 100%);
  padding-block: 20px;
  box-shadow: 0 3px 12px #9c40051a;
}
.brand small {
  font-weight: 700;
  letter-spacing: 2px;
  color: #fff;
}
.brand h1 {
  font-size: 26px;
  letter-spacing: -.55px;
  line-height: 1.2;
}
.logo {
  display: grid;
  place-items: center;
  min-width: 58px;
  min-height: 58px;
  background: #ffffff12;
  border: 1px solid #ffffffb0;
  border-radius: 15px;
  font-size: 21px;
  letter-spacing: -.5px;
}
#refresh {
  font-weight: 650;
  border: 1px solid #ffffffc9;
  border-radius: 9px;
  padding: 9px 15px;
  color: #853401;
  background: #fff;
  white-space: nowrap;
}
#refresh:disabled {
  opacity: .7;
}
nav {
  gap: 6px;
  box-shadow: 0 3px 10px #172b4508;
}
nav button {
  min-height: 58px;
  transition: background .15s,color .15s;
}
nav button:hover {
  background: #fff5ec;
  color: var(--orange);
}
nav button.active {
  background: #fff7ef;
  border-color: #df6412;
  color: #ad4006;
}
main {
  max-width: 1500px;
  padding: 24px!important;
}
#status {
  background: #eaf0f7;
  border: 1px solid #dbe5ef;
  border-radius: 9px;
  padding: 10px 14px;
  color: #44586e;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.panel,.metric {
  border-radius: var(--radius);
  box-shadow: 0 3px 14px #172b4507;
  min-width: 0;
  padding: 20px;
}
.filters {
  gap: 14px;
  margin-bottom: 24px;
  padding: 17px 20px;
}
.filters>div {
  min-width: 0;
}
label {
  font-size: 12px;
  font-weight: 700;
  color: #40536b;
}
.form-select,.form-control {
  border-color: #cdd7e3;
  border-radius: 9px;
  color: var(--ink);
  min-height: 42px;
  font-size: 14px;
}
.form-select:focus,.form-control:focus {
  border-color: #df6412;
  box-shadow: 0 0 0 .2rem #e8752026;
}
.btn-outline-secondary {
  color: #43586f;
  border-color: #bdcad9;
  border-radius: 9px;
}
.btn-outline-secondary:hover {
  color: #fff;
  background: #43586f;
  border-color: #43586f;
}
#reset {
  min-height: 42px;
  padding-inline: 17px;
}
h2 {
  font-size: 23px;
  letter-spacing: -.4px;
  margin-bottom: 14px;
}
h3 {
  font-size: 16px;
  letter-spacing: -.15px;
  margin-bottom: 15px;
}
.metrics {
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 15px;
  margin: 12px 0 22px;
}
.metric {
  position: relative;
  overflow: hidden;
  border-top: 3px solid #e87520;
  min-height: 124px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.metric strong {
  font-size: clamp(20px,2.05vw,30px);
  font-weight: 800;
  line-height: 1.28;
  letter-spacing: -.65px;
  overflow-wrap: anywhere;
  color: #bd4c0b;
}
.metric small:first-child {
  font-size: 13px;
  font-weight: 650;
  color: #4d6077;
}
.metric small:not(:first-child) {
  font-size: 12px;
}
.metric .good,.metric .bad {
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 650;
}
.metric .good {
  background: #e7f5ec;
  color: #137044;
}
.metric .bad {
  background: #fbe9e8;
  color: #a92525;
}
.twocol {
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 16px;
}
.chartbox {
  height: 300px;
}
.panel:has(.chartbox) {
  padding-bottom: 16px;
}
.table {
  font-size: 13px;
  margin-bottom: 8px;
  --bs-table-color: var(--ink);
  --bs-table-hover-bg: #fff6ee;
}
.table th {
  background: #f8eee4;
  color: #81400c;
  font-size: 12px;
  font-weight: 750;
  border-bottom: 1px solid #e8d8c7;
}
.table td,.table th {
  padding: 11px 12px;
  vertical-align: middle;
}
.table tbody tr:nth-child(even) {
  --bs-table-bg: #f8fafc;
}
.table-responsive {
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 100%;
  scrollbar-width: thin;
}
.table td {
  border-bottom-color: #e8edf2;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.toolbar {
  gap: 12px;
}
.toolbar small {
  color: var(--muted);
  font-weight: 600;
}
.detail {
  border: 1px solid #f0d9c5;
  border-left: 4px solid #e87520;
  border-radius: 12px;
  background: #fffaf5;
}
.muted {
  line-height: 1.65;
  font-size: 12px;
}
.pill {
  font-weight: 600;
}
footer {
  color: #536579;
  padding: 22px;
}
button:focus-visible {
  outline: 3px solid #266ba7;
  outline-offset: 3px;
}
button {
  touch-action: manipulation;
}
@media(min-width:761px) and (max-width:1050px) {
  .metrics {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .filters {
    grid-template-columns: repeat(2,minmax(0,1fr)) auto;
  }
  .chartbox {
    height: 265px;
  }
}
@media(max-width:760px) {
  header {
    padding: 13px 14px;
  }
  .brand {
    gap: 10px;
  }
  .brand h1 {
    font-size: 20px;
  }
  .brand small {
    font-size: 9px;
    letter-spacing: 1.2px;
  }
  .logo {
    min-width: 44px;
    min-height: 44px;
    font-size: 17px;
    padding: 5px;
    border-radius: 11px;
  }
  #refresh {
    padding: 8px 10px;
    font-size: 12px;
  }
  main {
    padding: 13px!important;
    padding-bottom: calc(85px + env(safe-area-inset-bottom))!important;
  }
  nav {
    gap: 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -3px 18px #172b4512;
  }
  nav button {
    min-height: 57px;
    padding: 12px 2px;
    font-size: 12px;
  }
  nav button.active {
    border-top-color: #df6412;
  }
  .filters {
    grid-template-columns: repeat(2,minmax(0,1fr));
    padding: 13px;
    gap: 10px;
    margin-bottom: 18px;
  }
  #reset {
    grid-column: 1/-1;
    min-height: 38px;
  }
  .metrics {
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 9px;
    margin-bottom: 16px;
  }
  .metric,.panel {
    padding: 13px;
    border-radius: 12px;
  }
  .metric {
    min-height: 112px;
  }
  .metric strong {
    font-size: clamp(19px,5vw,25px);
  }
  .metric small:first-child {
    font-size: 12px;
  }
  .metric small:not(:first-child) {
    font-size: 11px;
  }
  .twocol {
    grid-template-columns: minmax(0,1fr);
    gap: 12px;
  }
  .chartbox {
    height: 255px;
  }
  h2 {
    font-size: 20px;
  }
  h3 {
    font-size: 15px;
  }
  .toolbar input {
    max-width: none;
  }
  .table th,.table td {
    padding: 10px;
  }
  .form-select,.form-control {
    font-size: 16px;
  }
  #status {
    font-size: 11px;
    padding: 9px 11px;
  }
}
@media(prefers-reduced-motion:reduce) {
  * {
    scroll-behavior: auto!important;
    transition: none!important;
  }
}
/* STEP 01: fixed-in-view header + navigation, dashboard only layout */
.app-top {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: white;
}
.app-top nav {
  position: static;
  top: auto;
  bottom: auto;
  width: auto;
}
.app-top header {
  position: static;
}
[hidden] {
  display: none!important;
}
.dashboard-metrics {
  grid-template-columns: repeat(3,minmax(0,1fr));
}
.trend-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.trend-heading h3 {
  margin-bottom: 4px;
}
.trend-ranges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.range-active {
  background: #c94e08;
  color: white;
  border: 1px solid #c94e08;
  border-radius: 9px;
}
.range-active:hover {
  background: #ad4006;
  color: white;
}
.dashboard-trend .chartbox {
  height: 340px;
}
.dashboard-trend {
  min-width: 0;
}
@media(max-width:760px) {
  .app-top nav {
    justify-content: space-around;
    border-top: 0;
    box-shadow: none;
    padding: 0;
  }
  .app-top nav button {
    border-top: 0;
    border-bottom: 3px solid transparent;
    min-height: 44px;
    padding: 9px 2px;
  }
  .app-top nav button.active {
    border-bottom-color: #df6412;
  }
  main {
    padding-bottom: 20px!important;
  }
  .dashboard-metrics {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .dashboard-metrics .metric:last-child {
    grid-column: 1/-1;
  }
  .dashboard-trend .chartbox {
    height: 260px;
  }
  .trend-heading {
    align-items: flex-start;
  }
  .trend-ranges {
    width: 100%;
  }
  .trend-ranges button {
    flex: 1;
    white-space: nowrap;
    padding-inline: 5px;
  }
}
/* STEP 01 REV03: shared filter and four dashboard metrics */
.dashboard-metrics {
  grid-template-columns: repeat(4,minmax(0,1fr));
}
.page-period {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
}
.page-period label {
  margin: 0;
  white-space: nowrap;
}
.page-period select {
  max-width: 230px;
}
.dashboard-metrics .metric:last-child {
  grid-column: auto;
}
@media(max-width:1050px) {
  .dashboard-metrics {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
}
@media(max-width:760px) {
  .page-period {
    padding: 12px;
  }
  .page-period select {
    max-width: none;
    min-width: 0;
  }
  .dashboard-metrics .metric:last-child {
    grid-column: auto;
  }
}
/* STEP 01 REV04: Dashboard-only cosmetic refinement. */
.dashboard-metrics .dashboard-kpi {
  display: grid;
  grid-template-rows: 36px auto minmax(2.8em,auto);
  align-content: start;
  gap: 7px;
  min-height: 154px;
  justify-content: stretch;
}
.dashboard-kpi .kpi-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.dashboard-kpi .kpi-icon {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff0e3;
  color: #c94e08;
}
.dashboard-kpi .kpi-icon svg {
  width: 21px;
  height: 21px;
}
.dashboard-kpi .kpi-caption {
  line-height: 1.4;
  color: var(--muted);
  font-size: 12px;
}
.dashboard-kpi strong {
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
  word-break: normal;
  font-size: clamp(19px,1.9vw,29px);
}
@media(max-width:760px) {
  .dashboard-metrics .dashboard-kpi {
    grid-template-rows: 34px auto minmax(2.8em,auto);
    min-height: 140px;
    gap: 6px;
  }
  .dashboard-kpi .kpi-icon {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }
  .dashboard-kpi .kpi-icon svg {
    width: 18px;
    height: 18px;
  }
  .dashboard-kpi strong {
    font-size: clamp(16px,4.6vw,24px);
    overflow-wrap: anywhere;
  }
  .dashboard-kpi .kpi-caption {
    font-size: 11px;
  }
}
/* REV05: Global year and average KPI */
@media(min-width:1051px) {
  .filters {
    grid-template-columns: repeat(5,minmax(0,1fr)) auto;
  }
}
.dashboard-kpi .kpi-heading small {
  line-height: 1.25;
}
.dashboard-kpi strong {
  overflow-wrap: anywhere;
}
/* REV06 */
@media(min-width:1051px) {
  .filters {
    grid-template-columns: repeat(6,minmax(0,1fr)) auto;
  }
}
.region-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(180px,1fr));
  gap: 12px;
  margin: 12px 0 18px;
}
.region-card {
  border: 1px solid #e1e7ee;
  border-radius: 12px;
  padding: 15px;
  display: grid;
  gap: 6px;
}
.region-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}
.region-title span {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.region-card strong {
  font-size: 28px;
  color: #172b45;
}
.region-card small {
  color: #536579;
}
.region-track {
  height: 8px;
  background: #edf0f4;
  border-radius: 5px;
  overflow: hidden;
}
.region-track div {
  height: 100%;
  border-radius: 5px;
}
.region-panel table {
  white-space: nowrap;
}

/* STEP 02 — Peternak only */
.farmer-select { width: auto; max-width: 100%; }
.farmer-donut { position: relative; height: 300px; max-width: 680px; margin: 0 auto 18px; }
.farmer-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }
.farmer-bar { margin: 12px 0; }
.farmer-bar-label { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; font-size: 13px; }
.farmer-bar .region-track > div { background: #e87520; }
.farmer-quality-card { text-align: left; cursor: pointer; color: var(--ink); }
.farmer-quality-card strong { color: #a96516; }
.farmer-quality-card:hover { background: #fff8ef; }
.farmer-address { min-width: 135px; display: grid; gap: 2px; }
.farmer-address small { color: var(--muted); }
.farmer-toolbar { flex-wrap: wrap; }
.farmer-toolbar input { flex: 1 1 280px; }
.farmer-pagination { flex-wrap: wrap; justify-content: space-between; }
#farmerListPanel { scroll-margin-top: 170px; }
@media (max-width: 760px) {
    .farmer-donut { height: 250px; }
    .farmer-toolbar input { flex-basis: 100%; }
    .farmer-toolbar .farmer-select { flex: 1 1 auto; }
}

/* STEP 02 REV02 — responsive layout, scoped exclusively to Peternak. */
.farmer-page .farmer-kpis .dashboard-kpi {
  min-height: 0;
  padding: 14px 17px;
  grid-template-rows: auto auto auto;
  gap: 8px;
  align-content: start;
}
.farmer-page .farmer-note {
  font-size: 12px;
  line-height: 1.55;
  padding: 10px 12px;
  border-left: 3px solid #e87520;
  background: #fffaf5;
  border-radius: 5px;
  margin-bottom: 16px;
}
.farmer-page .farmer-panel-heading {
  justify-content: space-between;
  align-items: center;
}
.farmer-page .farmer-panel-heading h3 { margin: 0; }
.farmer-page .farmer-population-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}
.farmer-page .farmer-donut {
  width: 100%;
  max-width: 300px;
  height: 260px;
  margin: 0 auto;
}
.farmer-page .farmer-donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
  color: var(--ink);
}
.farmer-page .farmer-donut-center strong { font-size: clamp(16px, 1.5vw, 24px); }
.farmer-page .farmer-donut-center small { color: var(--muted); font-size: 11px; }
.farmer-page #populationLegend { min-width: 0; }
.farmer-page #populationLegend .table-responsive { max-height: 275px; }
.farmer-page .farmer-network-grid { display: grid; gap: 16px; margin-bottom: 18px; }
.farmer-page .farmer-network-grid .panel { margin: 0; min-width: 0; }
.farmer-page #farmerNetwork { max-height: 390px; overflow: auto; padding-right: 5px; }
.farmer-page .farmer-bar { margin: 9px 0; }
.farmer-page .farmer-bar-label { font-size: 12px; margin-bottom: 4px; }
.farmer-page .farmer-bar-label span { color: var(--muted); font-variant-numeric: tabular-nums; }
.farmer-page .farmer-bar .region-track { height: 9px; }
.farmer-page #farmerNetworkTable .table-responsive { max-height: 390px; }
.farmer-page #farmerNetworkTable .table th,
.farmer-page #farmerNetworkTable .table td { padding: 8px 9px; }
.farmer-page .farmer-quality .farmer-quality-card {
  min-height: 0;
  padding: 13px 16px;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 5px;
  align-content: start;
}
.farmer-page .farmer-quality-card strong { font-size: 25px; }
.farmer-page .farmer-quality-card small { line-height: 1.35; }
.farmer-page .farmer-toolbar input { max-width: none; }
.farmer-page .farmer-toolbar #farmerPageSize { min-width: 76px; }
.farmer-page #farmerListPanel .table-responsive { max-height: 540px; }
.farmer-page .farmer-pagination { margin: 10px 0 0; }
@media (min-width: 761px) {
  .farmer-page .farmer-population-body { grid-template-columns: minmax(230px, 0.85fr) minmax(0, 1.65fr); }
  .farmer-page .farmer-network-grid { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.35fr); }
}
@media (min-width: 1100px) {
  .farmer-page .farmer-network-grid { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.3fr); }
}
@media (max-width: 760px) {
  .farmer-page .farmer-donut { max-width: 260px; height: 230px; }
  .farmer-page .farmer-kpis .dashboard-kpi,
  .farmer-page .farmer-quality .farmer-quality-card { padding: 12px; }
  .farmer-page .farmer-toolbar input { flex-basis: 100%; }
  .farmer-page .farmer-toolbar .farmer-select { flex: 1 1 auto; }
}

/* STEP 02 REV03 — dedicated farmer detail dialog; no shared layout changes. */
.farmer-detail-dialog { width: min(90vw, 1120px); max-width: none; max-height: 92dvh; padding: 0; border: 1px solid #dce4ed; border-radius: 16px; color: var(--ink); background: white; overflow: hidden; box-shadow: 0 24px 80px #14294255; }
.farmer-detail-dialog[open] { display: flex; flex-direction: column; }
.farmer-detail-dialog::backdrop { background: #172b4599; }
.farmer-detail-dialog .fd-head { position: static; display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 18px 24px; color: white; background: linear-gradient(108deg,#b53e05,#ef8127); flex-shrink: 0; }
.farmer-detail-dialog .fd-head h2 { margin: 3px 0; color: white; font-size: 23px; }
.farmer-detail-dialog .fd-head small { color: white; }
.farmer-detail-dialog .fd-close { border: 1px solid #ffffff88; border-radius: 8px; background: transparent; color: white; font-size: 26px; width: 40px; height: 40px; line-height: 1; }
.farmer-detail-dialog .fd-body { padding: 20px 24px; overflow: auto; min-height: 0; display: grid; gap: 16px; background: #f7f9fc; }
.farmer-detail-dialog .fd-profile, .farmer-detail-dialog .fd-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.farmer-detail-dialog .fd-kpis { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.farmer-detail-dialog .fd-box { border: 1px solid #dce4ed; border-radius: 10px; background: white; padding: 14px; display: grid; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.farmer-detail-dialog .fd-box small, .farmer-detail-dialog .fd-section-title small { color: var(--muted); font-size: 12px; }
.farmer-detail-dialog .fd-number { color: #bf4e05; font-size: clamp(20px,2vw,29px); line-height: 1.2; }
.farmer-detail-dialog .fd-fields > div { display: grid; gap: 3px; min-width: 0; }
.farmer-detail-dialog .fd-products { display: flex; gap: 6px; flex-wrap: wrap; }
.farmer-detail-dialog .fd-products span { background: #fff0e3; border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.farmer-detail-dialog h3 { margin: 0; font-size: 16px; }
.farmer-detail-dialog .fd-section-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.farmer-detail-dialog .fd-status { background: #fff0dd; color: #86500c; border-radius: 6px; padding: 6px 10px; font-size: 12px; }
.farmer-detail-dialog .fd-positive { color: #14623e; background: #e4f4ea; }
.farmer-detail-dialog .fd-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.farmer-detail-dialog .fd-tabs button { border: 1px solid #bdcbdc; background: white; color: var(--ink); padding: 7px 12px; border-radius: 7px; font-size: 13px; }
.farmer-detail-dialog .fd-tabs button[aria-pressed="true"] { background: #bf4e05; border-color: #bf4e05; color: white; }
.farmer-detail-dialog .fd-chart-panel, .farmer-detail-dialog .fd-table-panel { background: white; border: 1px solid #dce4ed; border-radius: 10px; padding: 14px; min-width: 0; }
.farmer-detail-dialog .fd-chart { position: relative; height: 300px; margin-top: 12px; }
.farmer-detail-dialog .fd-hint, .farmer-detail-dialog .fd-notice { margin: 0; font-size: 12px; color: var(--muted); }
.farmer-detail-dialog .fd-notice { background: #fff0dd; color: #86500c; padding: 12px; border-radius: 8px; }
.farmer-detail-dialog .fd-footer { padding: 12px 24px; display: flex; justify-content: flex-end; background: white; border-top: 1px solid #dce4ed; flex-shrink: 0; }
@media (max-width: 1050px) { .farmer-detail-dialog { width: 95vw; } }
@media (max-width: 760px) { .farmer-detail-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; } .farmer-detail-dialog .fd-body { padding: 12px; } .farmer-detail-dialog .fd-head, .farmer-detail-dialog .fd-footer { padding: 12px; } .farmer-detail-dialog .fd-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); } .farmer-detail-dialog .fd-chart { height: 240px; } .farmer-detail-dialog .fd-tabs button { padding: 6px 8px; } }

/* STEP 03 — Keaktifan only */
.activity-page .ac-kpis { display:grid; gap:12px; margin-bottom:12px; }
.activity-page .ac-two { grid-template-columns:repeat(2,minmax(0,1fr)); }
.activity-page .ac-five { grid-template-columns:repeat(5,minmax(0,1fr)); }
.activity-page .ac-kpi { text-align:left; border-top:3px solid var(--ac-color); display:grid; gap:6px; cursor:pointer; min-width:0; }
.activity-page .ac-kpi strong { color:var(--ac-color); }
.activity-page .ac-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.5fr); gap:14px; margin:14px 0; }
.activity-page .ac-grid .panel { min-width:0; margin:0; }
.activity-page .ac-chart { height:280px; position:relative; }
.activity-page .ac-scroll { max-height:390px; overflow:auto; }
.activity-page .ac-select { width:auto; max-width:100%; }
.activity-page .ac-tools { flex-wrap:wrap; }
.activity-page .ac-tools input { flex:1 1 240px; min-width:0; }
.activity-page .ac-staff { display:grid; gap:4px; padding:9px 0; border-bottom:1px solid var(--line); }
.activity-page .ac-stack { display:flex; height:15px; border-radius:5px; overflow:hidden; }
.activity-page .ac-stack span { height:100%; }
.activity-page .ac-sub { display:block; color:var(--muted); }
.activity-page .ac-pattern { display:flex; gap:4px; }
.activity-page .ac-pattern span { border-radius:4px; padding:3px 6px; background:#eef1f5; color:#536579; font-size:11px; }
.activity-page .ac-pattern .on { background:#198754; color:white; }
.activity-page #acList .table-responsive { max-height:540px; overflow:auto; }
.activity-page .ac-pagination { justify-content:space-between; flex-wrap:wrap; }
.activity-page #acListPanel { scroll-margin-top:170px; }
@media(max-width:1050px) { .activity-page .ac-five { grid-template-columns:repeat(3,minmax(0,1fr)); } .activity-page .ac-grid { grid-template-columns:1fr 1fr; } }
@media(max-width:760px) { .activity-page .ac-five { grid-template-columns:repeat(2,minmax(0,1fr)); } .activity-page .ac-grid { grid-template-columns:1fr; } .activity-page .ac-chart { height:240px; } .activity-page .ac-kpi { padding:12px; } }

/* STEP 04 — Omset: scoped responsive layout */
.sales-page .sales-kpis {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-bottom:18px;}
.sales-page .sales-kpi {display:flex;flex-direction:column;gap:8px;min-height:118px;border-top:3px solid var(--orange);}
.sales-page .sales-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;}
.sales-page .sales-chart {height:280px;position:relative;}
.sales-page .sales-scroll {max-height:380px;overflow:auto;}
.sales-page .toolbar {flex-wrap:wrap;gap:8px;}
.sales-page .sales-grid .panel {min-width:0;}
.sales-page .sales-kpi strong {overflow-wrap:anywhere;}
@media(max-width:900px){.sales-page .sales-kpis {grid-template-columns:repeat(2,minmax(0,1fr));}.sales-page .sales-grid {grid-template-columns:1fr;}}
@media(max-width:480px){.sales-page .sales-kpis {gap:8px;}.sales-page .sales-kpi {padding:12px;}.sales-page .sales-kpi strong {font-size:20px;}.sales-page .sales-chart {height:235px;}}

/* STEP 04 REV02 — scoped presentation refinements */
.farmer-page .farmer-address-inline { white-space: nowrap; }
.activity-page .ac-pagination,
.sales-page .ac-pagination { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.sales-page .sales-kpis { grid-template-columns: repeat(6,minmax(0,1fr)); gap: 10px; }
.sales-page .sales-kpi { min-height: 0; padding: 12px; gap: 6px; justify-content: flex-start; }
.sales-page .sales-kpi strong { font-size: clamp(15px,1.5vw,23px); line-height: 1.25; }
.sales-page .sales-kpi small { font-size: 11px; line-height: 1.35; }
.sales-page .sales-section-head { justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sales-page .sales-section-head select { width: auto; min-width: 155px; max-width: 100%; }
.sales-page .sales-contribution-layout { display: grid; grid-template-columns: minmax(180px,0.8fr) minmax(0,1.6fr); gap: 18px; align-items: center; }
.sales-page .sales-donut { position: relative; height: 245px; width: 100%; max-width: 340px; margin: auto; }
.sales-page .sales-contribution-details { min-width: 0; }
.sales-page #salesContributionTable .table-responsive { max-height: 340px; overflow: auto; }
.sales-page .sales-network-label { display: flex; align-items: center; gap: 7px; }
.sales-page .sales-network-label i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.sales-page #salesContributionTable td:nth-child(n+2),
.sales-page #salesContributionTable th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.sales-page .sales-performance-tools { display: grid; grid-template-columns: minmax(110px,1fr) minmax(150px,2fr) minmax(140px,1.4fr) 76px; gap: 8px; align-items: center; margin: 10px 0; }
.sales-page .sales-performance-tools > * { min-width: 0; width: 100%; max-width: none; }
.sales-page .sales-scroll { overflow: visible; max-height: none; }
.sales-page .sales-scroll .table-responsive { max-height: 380px; overflow: auto; }
.sales-page .ac-sub { display: block; color: var(--muted); line-height: 1.4; margin-top: 3px; }
.sales-page #salesUp td:nth-child(2), .sales-page #salesDown td:nth-child(2) { white-space: nowrap; text-align: right; }
@media (max-width: 1100px) {
  .sales-page .sales-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .sales-page .sales-kpis { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
  .sales-page .sales-kpi { padding: 8px 6px; gap: 4px; }
  .sales-page .sales-kpi strong { font-size: clamp(12px,3.4vw,18px); overflow-wrap: anywhere; }
  .sales-page .sales-kpi small { font-size: 10px; }
  .sales-page .sales-contribution-layout { grid-template-columns: 1fr; gap: 12px; }
  .sales-page .sales-donut { height: 210px; }
  .sales-page .sales-performance-tools { grid-template-columns: repeat(2,minmax(0,1fr)); }
}


/* REV02A — Shared mobile filter disclosure, desktop layout unchanged. */
.mobile-filter-toggle { display: none; }
.unmapped-link { border: 0; background: none; padding: 2px 0; color: #98500b; text-decoration: underline; text-underline-offset: 3px; font: inherit; cursor: pointer; text-align: left; }
.unmapped-link:focus-visible { outline: 2px solid #c45108; outline-offset: 3px; }
.unmapped-dialog .unmapped-table { min-width: 0; }
.unmapped-dialog .unmapped-table .table-responsive { max-height: 52vh; overflow: auto; }
@media (max-width: 760px) {
  #filters:not([hidden]) { padding: 9px 11px; gap: 8px; margin-bottom: 12px; }
  #filters .mobile-filter-toggle { display: flex; grid-column: 1 / -1; width: 100%; align-items: center; gap: 9px; text-align: left; border: 0; background: transparent; color: var(--ink); padding: 3px 0; min-height: 40px; }
  .mobile-filter-icon { color: var(--orange); font-size: 23px; }
  .mobile-filter-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
  .mobile-filter-text strong { font-size: 13px; }
  .mobile-filter-text small { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
  .mobile-filter-chevron { font-size: 20px; transition: transform .15s; }
  #filterToggle[aria-expanded="true"] .mobile-filter-chevron { transform: rotate(180deg); }
  #filters:not(.mobile-filters-open) > :not(.mobile-filter-toggle) { display: none; }
  #filters .form-select { min-height: 36px; padding: 6px 28px 6px 9px; font-size: 13px; }
  #filters label { font-size: 11px; margin-bottom: 3px; }
  #filters #reset { min-height: 34px; padding: 5px 10px; font-size: 13px; }
  #periodField:not([hidden]) { padding: 8px 11px; gap: 8px; }
  #periodField .form-select { min-height: 36px; padding-block: 5px; font-size: 13px; }
  #periodField label { font-size: 11px; }
}

/* UI FINAL A — Corporate brand and initial loading */
.app-top header { background:#fff; color:#172b45; border-top:3px solid #e87520; box-shadow:none; padding-block:14px; }
.app-top .brand { min-width:0; }
.app-top .brand small { color:#536579; }
.app-top .brand h1 { color:#172b45; }
.fr-brand-logo { width:58px; height:58px; flex:none; object-fit:contain; }
.japfa-brand-logo { width:150px; height:auto; max-height:44px; object-fit:contain; flex:none; }
.loading-shell { display:grid; gap:16px; }
.loading-metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.loading-shell .placeholder-block { background:linear-gradient(100deg,#edf1f5 25%,#f8fafc 50%,#edf1f5 75%); background-size:220% 100%; animation:jrc-skeleton 1.5s ease-in-out infinite; border-radius:10px; min-height:90px; }
.loading-shell .placeholder-chart { min-height:240px; }
@keyframes jrc-skeleton { to { background-position:-220% 0; } }
.data-freshness { color:var(--muted); font-size:11px; margin-top:8px; }
@media(max-width:760px) { .app-top header { padding:10px 12px; gap:8px; } .fr-brand-logo {width:40px;height:40px;} .japfa-brand-logo {width:94px;max-height:30px;} .app-top .brand {gap:7px;} .app-top .brand h1 {font-size:17px;} .app-top .brand small {font-size:8px;letter-spacing:.6px;} .loading-metrics {grid-template-columns:repeat(2,minmax(0,1fr));} }
@media(max-width:340px) { .japfa-brand-logo {width:72px;} .app-top .brand h1 {font-size:15px;} }
@media(prefers-reduced-motion:reduce) { .loading-shell .placeholder-block {animation:none;} }

/* UI FINAL C — Compact & fluid layout. Presentation only. */
:root {
  --jrc-gutter: 24px;
  --jrc-header-height: 64px;
  --jrc-nav-height: 42px;
}
.app-top > header {
  min-height: var(--jrc-header-height);
  padding: 6px var(--jrc-gutter);
  border-bottom: 1px solid #dce4ed;
  gap: 12px;
}
.app-top .brand { gap: 10px; }
.app-top .brand small { display: block; line-height: 1.25; }
.app-top .brand h1 { line-height: 1.2; font-size: 23px; }
.app-top .fr-brand-logo { width: 48px; height: 48px; }
.app-top .japfa-brand-logo { width: 136px; max-height: 38px; }
.app-top > nav {
  padding: 0 var(--jrc-gutter);
  min-height: var(--jrc-nav-height);
  gap: 4px;
  border-bottom: 1px solid #dce4ed;
}
.app-top > nav button {
  min-height: calc(var(--jrc-nav-height) - 1px);
  padding: 8px 18px;
  line-height: 1.3;
}
main.container-fluid {
  max-width: none;
  width: 100%;
  padding: 16px var(--jrc-gutter) 20px !important;
}
main .panel { padding: 16px; margin-bottom: 12px; }
main .twocol .panel,
main .farmer-network-grid .panel,
main .ac-grid .panel { margin-bottom: 0; }
main #filters { padding: 12px 16px; margin-bottom: 16px; gap: 12px; }
main #periodField { padding: 10px 16px; }
main h2 { margin-bottom: 10px; }
main .metrics { margin: 10px 0 14px; gap: 12px; }
main .dashboard-metrics .dashboard-kpi,
main .farmer-page .farmer-kpis .dashboard-kpi {
  min-height: 0;
  padding: 12px 16px;
  grid-template-rows: auto auto auto;
  gap: 5px;
  align-content: start;
}
main .dashboard-kpi .kpi-icon { width: 32px; height: 32px; flex-basis: 32px; }
main .dashboard-kpi .kpi-icon svg { width: 19px; height: 19px; }
main .dashboard-kpi strong { line-height: 1.2; }
main .dashboard-kpi .kpi-caption { line-height: 1.35; }
main .activity-page .ac-kpi,
main .farmer-page .farmer-quality .farmer-quality-card { padding: 12px 14px; gap: 4px; }
main .sales-page .sales-kpi { min-height: 0; padding: 10px 12px; gap: 5px; }
main .trend-heading { margin-bottom: 12px; }
main .twocol { gap: 12px; margin-bottom: 14px; }
#farmerListPanel, .activity-page #acListPanel {
  scroll-margin-top: calc(var(--jrc-header-height) + var(--jrc-nav-height) + 16px);
}
@media (min-width: 761px) and (max-width: 1050px) {
  :root { --jrc-gutter: 16px; }
}
@media (max-width: 760px) {
  :root { --jrc-gutter: 12px; --jrc-header-height: 56px; --jrc-nav-height: 40px; }
  .app-top > header { padding: 6px var(--jrc-gutter); gap: 8px; }
  .app-top .brand { gap: 7px; }
  .app-top .brand h1 { font-size: 17px; }
  .app-top .fr-brand-logo { width: 40px; height: 40px; }
  .app-top .japfa-brand-logo { width: 94px; max-height: 30px; }
  .app-top > nav { padding: 0; gap: 0; }
  .app-top > nav button { flex: 1 1 0; min-width: 0; padding: 8px 2px; }
  main.container-fluid { padding-top: 12px !important; }
  main .panel { padding: 12px; }
  main #filters:not([hidden]) { padding: 8px 10px; gap: 8px; margin-bottom: 12px; }
  main #periodField:not([hidden]) { padding: 8px 10px; }
  main .metrics { gap: 8px; }
  main .dashboard-metrics .dashboard-kpi,
  main .farmer-page .farmer-kpis .dashboard-kpi,
  main .activity-page .ac-kpi,
  main .farmer-page .farmer-quality .farmer-quality-card { padding: 10px; gap: 4px; }
  main .dashboard-kpi .kpi-icon { width: 28px; height: 28px; flex-basis: 28px; }
  main .dashboard-kpi .kpi-icon svg { width: 17px; height: 17px; }
  main .sales-page .sales-kpi { padding: 8px 6px; gap: 4px; }
}
@media (max-width: 340px) {
  .app-top .japfa-brand-logo { width: 72px; }
  .app-top .brand h1 { font-size: 15px; }
}
