* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: #1f2933;
  background: #f4f1e8;
}

a { color: inherit; }

.topbar {
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  padding: 10px 26px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid #d8d1bf;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: #31522b;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a,
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid #7a8b50;
  border-radius: 6px;
  background: #456b35;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.nav a {
  background: transparent;
  color: #31522b;
}

.button.secondary {
  background: #fff;
  color: #31522b;
}

.hero {
  min-height: calc(100vh - 58px);
  background-image: url("../img/hero-wheat-acros.png");
  background-size: cover;
  background-position: center;
}

.hero-overlay {
  min-height: calc(100vh - 58px);
  display: flex;
  align-items: center;
  padding: 44px 7vw;
  background: linear-gradient(90deg, rgba(25, 34, 21, 0.72), rgba(25, 34, 21, 0.30), rgba(25, 34, 21, 0.08));
}

.hero-content {
  width: min(620px, 100%);
  color: #fff;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f2d77e;
}

h1, h2 { margin: 0 0 12px; }

.hero h1 {
  font-size: clamp(36px, 6vw, 72px);
  line-height: 1;
}

.lead {
  margin: 16px 0 24px;
  max-width: 560px;
  font-size: 20px;
  line-height: 1.45;
}

.login-panel,
.panel {
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 34px rgba(41, 35, 18, 0.12);
}

.login-panel {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  padding: 12px;
  color: #1f2933;
}

label span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #57606a;
}

.form-field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #57606a;
}

input, select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #cfc7b6;
  border-radius: 6px;
  background: #fff;
  color: #1f2933;
  font: inherit;
}

textarea { resize: vertical; }

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 52px;
}

.page.wide { width: min(1600px, calc(100% - 24px)); }
.page.admin-page { width: calc(100% - 16px); }
.page.narrow { width: min(520px, calc(100% - 32px)); }
.page-title { margin-bottom: 18px; }
.page-title h1 { color: #284623; }

.row-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel.compact { padding: 12px; }

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

.inline-form,
.filters,
.admin-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.ximiya-modal {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fffdf8;
  color: #1f2933;
  box-shadow: 0 22px 70px rgba(31, 41, 51, 0.32);
}

.ximiya-modal::backdrop {
  background: rgba(24, 31, 22, 0.42);
}

.ximiya-modal-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.ximiya-modal-form h2 {
  margin-bottom: 4px;
}

.ximiya-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.ximiya-hidden-frame {
  display: none;
}

.ximiya-treatment-products-editor {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d8d1bf;
  border-radius: 6px;
  background: #f8f5ec;
}

.ximiya-treatment-products-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.ximiya-treatment-product-rows {
  display: grid;
  gap: 8px;
}

.ximiya-treatment-product-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(90px, 120px) minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.ximiya-treatment-product-row label {
  display: grid;
  gap: 4px;
}

.ximiya-treatment-product-meta {
  display: grid;
  gap: 2px;
  min-height: 38px;
  color: #5d6657;
  font-size: 12px;
  line-height: 1.25;
}

.ximiya-treatment-hectares {
  display: inline-flex;
  width: fit-content;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #eef4df;
  color: #31431f;
  font-weight: 700;
  font-size: 12px;
}

@media (max-width: 700px) {
  .ximiya-treatment-product-row {
    grid-template-columns: 1fr;
  }
}

.inline-form input,
.filters label,
.filters .ximiya-filter-control,
.admin-form input,
.admin-form select {
  min-width: 170px;
}

.admin-form select[name="ai_access_level"] {
  min-width: 150px;
}

.ximiya-filter-control {
  position: relative;
  display: grid;
  gap: 5px;
}

.ximiya-filter-control > span {
  font-weight: 700;
}

.ximiya-check-dropdown {
  position: relative;
}

.ximiya-check-dropdown summary {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 34px 8px 12px;
  border: 1px solid #d8d1bf;
  border-radius: 6px;
  background: #fffdf8;
  color: #203a1c;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.ximiya-check-dropdown summary::-webkit-details-marker {
  display: none;
}

.ximiya-check-dropdown summary::after {
  content: "";
  position: absolute;
  right: 12px;
  width: 7px;
  height: 7px;
  border-right: 2px solid #49683f;
  border-bottom: 2px solid #49683f;
  transform: rotate(45deg);
}

.ximiya-check-dropdown[open] summary::after {
  transform: rotate(225deg);
}

.ximiya-check-filter {
  position: absolute;
  z-index: 2000;
  top: calc(100% + 4px);
  left: 0;
  display: grid;
  gap: 2px;
  max-height: 240px;
  width: 260px;
  min-width: 220px;
  max-width: 320px;
  overflow: auto;
  padding: 6px;
  border: 1px solid #d8d1bf;
  border-radius: 6px;
  background: #fffdf8;
  box-shadow: 0 10px 24px rgba(39, 57, 29, 0.16);
}

.ximiya-check-apply {
  position: sticky;
  top: 0;
  z-index: 1;
  width: 100%;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 5px;
  background: #49683f;
  color: #fff;
}

.filters .ximiya-check-filter label,
.ximiya-modal .ximiya-check-filter label {
  display: flex;
  align-items: center;
  gap: 7px;
  width: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 4px 6px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.filters .ximiya-check-filter label:hover,
.ximiya-modal .ximiya-check-filter label:hover {
  background: #f3f0e6;
}

.filters .ximiya-check-filter input[type="checkbox"],
.ximiya-modal .ximiya-check-filter input[type="checkbox"] {
  display: inline-block !important;
  flex: 0 0 14px !important;
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  max-width: 14px !important;
  min-height: 14px !important;
  max-height: 14px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 2px;
}

.filters .ximiya-check-filter label span,
.ximiya-modal .ximiya-check-filter label span {
  display: inline !important;
  margin: 0 !important;
  color: #1f2933 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  white-space: normal;
}

.ximiya-movement-filters {
  display: grid;
  grid-template-columns: minmax(78px, .65fr) minmax(110px, .9fr) minmax(120px, .95fr) minmax(108px, .85fr) minmax(108px, .85fr) minmax(118px, .9fr) minmax(104px, .78fr) minmax(104px, .78fr) auto auto;
  gap: 6px;
  align-items: end;
}

.ximiya-movement-filters label {
  min-width: 0;
}

.ximiya-movement-filters input,
.ximiya-movement-filters select {
  width: 100%;
  min-width: 0;
}

.ximiya-movement-filters .ximiya-filter-product {
  max-width: 190px;
}

.ximiya-movement-type-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ximiya-movement-modal {
  width: min(720px, calc(100% - 28px));
}

.ximiya-movement-products-editor,
.ximiya-movement-product-rows {
  display: grid;
  gap: 8px;
}

.ximiya-movement-product-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(90px, 130px) auto;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid #ded6c2;
  border-radius: 6px;
  background: #fffdf8;
}

.ximiya-movement-product-row label {
  display: grid;
  gap: 4px;
}

.ximiya-movement-table {
  font-size: 80%;
  table-layout: fixed;
  min-width: 1040px;
}

.ximiya-movement-table th,
.ximiya-movement-table td {
  padding: 5px 6px;
  overflow-wrap: anywhere;
}

.ximiya-movement-product-col,
.ximiya-movement-supplier-col,
.ximiya-movement-customer-col {
  width: 10%;
}

.ximiya-sortable-header {
  position: relative;
  cursor: pointer;
  user-select: none;
  padding-right: 18px !important;
}

.ximiya-sortable-header::after {
  content: "↕";
  position: absolute;
  right: 6px;
  color: #8b7d65;
  font-size: 0.82em;
}

.ximiya-sortable-header.ximiya-sort-asc::after {
  content: "↑";
  color: #31431f;
}

.ximiya-sortable-header.ximiya-sort-desc::after {
  content: "↓";
  color: #31431f;
}

.ximiya-movement-row {
  cursor: context-menu;
}

.ximiya-movement-row:hover {
  background: #f3f0e6;
}

.ximiya-movement-context-menu {
  position: absolute;
  z-index: 5000;
  display: grid;
  min-width: 150px;
  padding: 5px;
  border: 1px solid #cfc6ad;
  border-radius: 6px;
  background: #fffdf8;
  box-shadow: 0 12px 28px rgba(32, 42, 28, 0.22);
}

.ximiya-movement-context-menu[hidden] {
  display: none;
}

.ximiya-movement-context-menu button {
  width: 100%;
  min-height: 30px;
  padding: 6px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #1f2933;
  text-align: left;
}

.ximiya-movement-context-menu button:hover {
  background: #e8efd9;
}

@media (max-width: 1100px) {
  .ximiya-movement-filters {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .ximiya-movement-filters .ximiya-filter-product {
    max-width: none;
  }
}

@media (max-width: 700px) {
  .ximiya-movement-product-row {
    grid-template-columns: 1fr;
  }
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.timesheet-day-picker {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.timesheet-day-picker label {
  display: grid;
  gap: 4px;
  margin: 0;
}

.timesheet-day-picker input[type="date"] {
  min-width: 150px;
}

.grid-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.action-card {
  display: grid;
  gap: 8px;
  min-height: 124px;
  padding: 18px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
}

.action-card strong { color: #31522b; }
.action-card span { color: #57606a; }

.table-wrap {
  overflow: auto;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fff;
}

.table-wrap.massive { max-height: 72vh; }

.ximiya-map {
  width: 100%;
  height: min(80vh, 806px);
  min-height: 546px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #e9ecef;
  overflow: hidden;
}

.ximiya-map-panel {
  position: relative;
}

.ximiya-map-fullscreen-toggle {
  position: absolute;
  right: 18px;
  bottom: 54px;
  z-index: 700;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(31, 41, 55, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: #1f2937;
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(31, 41, 55, 0.22);
}

.ximiya-map-fullscreen-toggle:hover {
  background: #ffffff;
}

body.ximiya-map-fullscreen-active {
  overflow: hidden;
}

body.ximiya-map-fullscreen-active .ximiya-map-pane {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #f7f3e8;
  padding: 10px;
}

body.ximiya-map-fullscreen-active .ximiya-map-panel {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border-radius: 0;
}

body.ximiya-map-fullscreen-active .ximiya-map {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 0;
}

body.ximiya-map-fullscreen-active .ximiya-map-empty {
  position: absolute;
  left: 18px;
  bottom: 12px;
  z-index: 700;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
}

body.ximiya-map-fullscreen-active .ximiya-map-fullscreen-toggle {
  right: 22px;
  bottom: 22px;
}

.ximiya-map-workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 1fr);
  gap: 16px;
  align-items: stretch;
  width: 100%;
  margin: 18px 0;
}

.ximiya-map-pane,
.ximiya-map-table-pane {
  min-width: 0;
}

.ximiya-map-table-pane.ximiya-loading {
  opacity: 0.55;
  pointer-events: none;
}

.ximiya-map-source-table {
  display: none;
}

.ximiya-map-table-pane .ximiya-map-source-table {
  display: block;
}

.ximiya-map-table-wrap {
  max-height: min(80vh, 806px);
  overflow: auto;
}

.ximiya-map-table {
  font-size: 13px;
}

.ximiya-map-table th,
.ximiya-map-table td {
  padding: 7px 8px;
}

.ximiya-map-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.ximiya-map-table tfoot th {
  border-top: 2px solid #49683f;
  background: #f5f8ef;
  font-weight: 800;
  text-align: right;
}

.ximiya-sort-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.ximiya-sort-button[data-sort-active="asc"]::after {
  content: " ^";
}

.ximiya-sort-button[data-sort-active="desc"]::after {
  content: " v";
}

.ximiya-map-table td:nth-child(2) span {
  display: block;
  white-space: nowrap;
}

.page.field-work-page {
  width: calc(100% - 24px);
}

.field-work-page .ximiya-map-workspace {
  grid-template-columns: 1fr;
}

.field-work-page .ximiya-map-pane,
.field-work-page .ximiya-map-table-pane {
  width: 100%;
}

.field-work-page .ximiya-map {
  height: min(50vh, 532px);
  min-height: 364px;
}

.field-work-page .ximiya-map-table-wrap {
  max-height: none;
}

.field-work-page .button.active {
  background: #31522b;
  color: #fff;
}

.field-work-tech-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.field-work-tech-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.field-work-tech-form h2 {
  grid-column: 1 / -1;
  margin-bottom: 0;
  font-size: 18px;
}

.field-work-recalc-action {
  display: grid;
  gap: 10px;
  align-content: end;
}

.field-work-recalc-action h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.field-work-tech-grid {
  display: grid;
  gap: 16px;
  margin: 18px 0;
}

.field-work-tech-table {
  width: 100%;
  min-width: 920px;
}

.field-work-tech-table tr[data-tractor-row] {
  cursor: context-menu;
}

.field-work-tech-table tr[data-tractor-row]:hover {
  background: #f8f4ea;
}

.ximiya-row-credited {
  background: #e3f4dd;
}

.ximiya-row-uncredited {
  background: #ffe3dd;
}

.ximiya-row-credited.ximiya-selected-row,
.ximiya-row-uncredited.ximiya-selected-row {
  outline: 2px solid #c48a22;
  outline-offset: -2px;
}

.ximiya-field-cell {
  min-width: 92px;
}

.ximiya-field-focus {
  padding: 0;
  border: 0;
  background: transparent;
  color: #173f82;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.ximiya-field-focus:hover {
  text-decoration: underline;
}

.ximiya-row-select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ximiya-hidden-form {
  display: none;
}

.ximiya-map-empty {
  padding: 12px 0;
  color: #6b7280;
}

.ximiya-transport-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.ximiya-transport-map-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin: 18px 0;
}

.ximiya-transport-sidebar {
  align-self: stretch;
  max-height: min(96vh, 968px);
  overflow: auto;
}

.ximiya-transport-sidebar label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  font-size: 12px;
  line-height: 1.25;
}

.ximiya-transport-sidebar input[type="checkbox"] {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
}

.ximiya-transport-map-panel {
  min-width: 0;
}

.ximiya-transport-map {
  height: min(96vh, 968px);
  min-height: 655px;
}

.ximiya-transport-modal {
  width: min(1080px, calc(100% - 28px));
}

.ximiya-transport-edit-list {
  display: grid;
  gap: 8px;
  max-height: 54vh;
  overflow: auto;
  padding: 0 18px 18px;
}

.ximiya-transport-edit-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) 52px minmax(160px, 1.2fr) auto;
  gap: 8px;
  align-items: center;
}

.ximiya-transport-delete-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -6px;
}

.ximiya-field-label {
  padding: 2px 6px;
  border: 1px solid rgba(49, 82, 43, 0.35);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.82);
  color: #203a1c;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  white-space: pre-line;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
  pointer-events: none;
}

.ximiya-track-tooltip {
  color: #172033;
  font-size: 12px;
  line-height: 1.35;
}

.ximiya-color-chip {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border: 1px solid #b8b09d;
  border-radius: 4px;
  vertical-align: middle;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid #e8e0cf;
  border-right: 1px solid #eee7d8;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8f4ea;
  color: #31522b;
  font-weight: 700;
}

.timesheet-edit th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.employee {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 220px;
  background: #f8f4ea;
}

.employee span {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
}

.day-cell { min-width: 190px; }
.hours-input { max-width: 76px; }

.day-block {
  margin: 0 0 22px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.day-block-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #f8f4ea;
  border-bottom: 1px solid #d8d1bf;
}

.day-block-head h2 {
  margin: 0;
  color: #284623;
}

.day-block-head span,
.muted {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
}

.add-worker {
  width: min(360px, 100%);
}

.day-actions {
  padding: 12px 16px;
  border-top: 1px solid #e8e0cf;
}

.add-worker-panel {
  padding: 12px 16px;
  border-top: 1px solid #e8e0cf;
  background: #fffdf8;
}

.add-worker-panel label {
  display: block;
  width: min(420px, 100%);
}

.daily-timesheet th:first-child,
.daily-timesheet td:first-child {
  width: 158px;
  min-width: 158px;
  max-width: 158px;
  text-align: left;
}

.daily-timesheet th:nth-child(2),
.daily-timesheet td:nth-child(2) {
  width: 106px;
  min-width: 106px;
  max-width: 106px;
}

.daily-timesheet th:nth-child(3),
.daily-timesheet td:nth-child(3) {
  width: 103px;
  min-width: 103px;
  max-width: 103px;
}

.daily-timesheet th:nth-child(4),
.daily-timesheet td:nth-child(4) {
  width: 180px;
  min-width: 180px;
}

.management-timesheet-page {
  width: min(760px, calc(100% - 8px));
  margin-left: 4px;
  margin-right: auto;
}

.management-timesheet-wrap {
  width: max-content;
  max-width: 100%;
}

.daily-timesheet {
  width: auto;
  min-width: 547px;
  font-size: 11px;
  table-layout: fixed;
}

.daily-timesheet th,
.daily-timesheet td {
  padding: 2px 4px;
  line-height: 1.1;
}

.daily-timesheet tbody tr {
  cursor: pointer;
}

.daily-timesheet tbody tr:hover,
.daily-timesheet tbody tr.timesheet-selected-row {
  background: #e5e7eb;
}

.daily-timesheet strong {
  display: block;
  font-size: 11px;
  line-height: 1.1;
  font-weight: 600;
}

.daily-timesheet select,
.daily-timesheet input,
.daily-timesheet textarea {
  min-height: 22px;
  padding: 2px 4px;
  font-size: 11px;
  line-height: 1.1;
}

.daily-timesheet textarea {
  height: 24px;
  min-height: 24px;
  resize: vertical;
}

.accounting-table th:nth-child(2) { min-width: 220px; }
.accounting-table th:nth-child(3),
.accounting-table th:nth-child(4) { min-width: 170px; }
.accounting-table th:nth-child(5) { min-width: 150px; }
.accounting-table th:nth-child(8) { min-width: 170px; }
.accounting-table th:nth-child(9) { min-width: 220px; }

.accounting-summary-row {
  cursor: pointer;
}

.accounting-summary-row:hover {
  background: #e5e7eb;
}

.accounting-detail-modal {
  width: min(900px, calc(100% - 28px));
}

.work-type-row-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 170px) minmax(130px, 170px) minmax(80px, auto) auto;
  gap: 8px;
  align-items: center;
}

.work-type-row-form input,
.work-type-row-form select {
  width: 100%;
  min-width: 0;
}

.work-types-table input,
.work-types-table select {
  width: 100%;
  min-width: 0;
}

.work-type-row {
  cursor: context-menu;
}

.work-type-row:hover {
  background: #f8f4ea;
}

.work-type-context-menu {
  position: absolute;
  z-index: 5000;
  min-width: 150px;
  padding: 4px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
}

.work-type-context-menu[hidden] {
  display: none;
}

.work-type-context-menu button {
  width: 100%;
  justify-content: flex-start;
}

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.check-line input {
  width: auto;
  min-height: 0;
}

.admin-users-wrap table {
  font-size: 14px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  min-width: 1080px;
}

.admin-users-wrap th,
.admin-users-wrap td {
  height: 38px;
  padding: 6px 7px;
  border: 0;
  border-right: 1px solid #eee7d8;
  border-bottom: 1px solid #e8e0cf;
  overflow: hidden;
  vertical-align: middle;
  line-height: 1.2;
}

.admin-users-wrap th:last-child,
.admin-users-wrap td:last-child {
  border-right: 0;
}

.admin-users-wrap thead th {
  height: 40px;
  white-space: nowrap;
}

.admin-users-wrap tbody td {
  white-space: nowrap;
  text-overflow: ellipsis;
}

.admin-users-wrap .admin-col-name {
  width: auto;
}

.admin-users-wrap .admin-col-login {
  width: 170px;
}

.admin-users-wrap .admin-col-password {
  width: 150px;
}

.admin-users-wrap .admin-col-permission {
  width: 96px;
}

.admin-users-wrap .admin-col-permission-wide {
  width: 130px;
}

.admin-users-wrap .admin-col-edit {
  width: 150px;
}

.admin-users-wrap td button {
  display: inline-block;
  min-height: 0;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.admin-permission-mark {
  text-align: center;
  white-space: nowrap;
}

.admin-users-actions {
  display: flex;
  justify-content: flex-start;
}

.admin-users-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-users-filter-title {
  font-weight: 700;
}

.admin-users-filter-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-user-modal {
  width: min(760px, calc(100% - 28px));
}

.admin-user-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-user-form h2,
.admin-user-form .ximiya-modal-actions,
.admin-user-permissions {
  grid-column: 1 / -1;
}

.admin-user-form label span {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.admin-user-form input,
.admin-user-form select {
  width: 100%;
  min-width: 0;
}

.admin-user-permissions {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fbfaf6;
}

.admin-user-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 600;
}

.admin-user-check input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
}

.sklad-page {
  width: calc(100% - 18px);
}

.sklad-topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sklad-status {
  margin-left: auto;
  color: #667085;
  font-size: 12px;
}

.sklad-topbar .active {
  background: #456b35;
  color: #fff;
}

.sklad-ref-dropdown {
  position: relative;
  display: inline-flex;
}

.sklad-ref-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 170px;
  padding: 6px;
  display: grid;
  gap: 4px;
  border: 1px solid #d8cdb8;
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 10px 26px rgba(34, 28, 16, 0.14);
}

.sklad-ref-menu[hidden] {
  display: none;
}

.sklad-ref-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 30px;
  padding: 5px 8px;
}

.sklad-filters {
  display: grid;
  grid-template-columns: repeat(10, minmax(86px, 1fr));
  gap: 6px;
  align-items: end;
}

.sklad-filters label {
  min-width: 0;
}

.sklad-filters input,
.sklad-filters select {
  min-height: 32px;
  padding: 5px 7px;
  font-size: 12px;
}

.sklad-layout {
  display: block;
}

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

.sklad-table {
  font-size: 12px;
}

.sklad-table th,
.sklad-table td {
  padding: 7px 8px;
  vertical-align: top;
}

.sklad-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8f4ea;
}

.sklad-table .num {
  text-align: right;
  white-space: nowrap;
}

.sklad-table .sklad-summary-row td {
  background: #f8f4ea;
  border-top: 2px solid #d9cfbd;
}

.sklad-movements-wrap,
.sklad-balances-wrap {
  max-height: calc(100vh - 210px);
}

.sklad-row {
  cursor: pointer;
}

.sklad-row:hover,
.sklad-selected-row {
  background: #fff1d6;
}

.sklad-select {
  width: 16px;
  min-height: 16px;
}

.sklad-modal {
  width: min(780px, calc(100% - 28px));
}

.sklad-modal .ximiya-modal-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sklad-modal h2,
.sklad-modal .ximiya-modal-actions,
.sklad-modal label:last-of-type {
  grid-column: 1 / -1;
}

.sklad-transfer-balance {
  grid-column: 1 / -1;
  padding: 8px 10px;
  border: 1px solid #b7d7c0;
  border-radius: 6px;
  background: #f1fbf3;
  color: #17633a;
  font-size: 13px;
}

.sklad-transfer-balance.is-error {
  border-color: #f4a6a6;
  background: #fff1f1;
  color: #9f1d1d;
}

.sklad-transfer-balance[hidden] {
  display: none;
}

.sklad-refs-modal {
  width: min(900px, calc(100% - 28px));
}

.sklad-ref-editor {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(320px, 1.1fr);
  gap: 12px;
  align-items: start;
}

.sklad-ref-editor-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sklad-ref-editor-form .ximiya-modal-actions,
.sklad-ref-editor-form .check-line {
  grid-column: 1 / -1;
}

.sklad-ref-editor-form input,
.sklad-ref-editor-form select {
  min-height: 32px;
  padding: 5px 7px;
}

.sklad-ref-list {
  display: grid;
  gap: 6px;
  max-height: 340px;
  overflow: auto;
}

.sklad-ref-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, auto) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #e1dac7;
  border-radius: 6px;
  background: #fff;
  cursor: context-menu;
}

.sklad-ref-row:hover {
  background: #fff7e6;
}

.sklad-ref-row strong,
.sklad-ref-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sklad-ref-row span {
  color: #667085;
  font-size: 12px;
}

.sklad-ref-row em {
  color: #9a3412;
  font-size: 12px;
  font-style: normal;
}

.sklad-ref-row.is-inactive {
  opacity: 0.62;
}

.sklad-ref-context {
  position: fixed;
  z-index: 1000;
  min-width: 150px;
  padding: 5px;
  display: grid;
  gap: 4px;
  border: 1px solid #d8cdb8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(34, 28, 16, 0.18);
}

.sklad-ref-context[hidden] {
  display: none;
}

.sklad-ref-context button {
  width: 100%;
  justify-content: flex-start;
  min-height: 30px;
  padding: 5px 8px;
}

@media (max-width: 820px) {
  .sklad-ref-editor {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sklad-no-print,
  .ximiya-no-print,
  .topbar,
  .flash {
    display: none !important;
  }
  .ximiya-print-page,
  .sklad-page {
    width: 100%;
    margin: 0;
  }
  .ximiya-print-page {
    page-break-inside: auto;
  }
  .ximiya-print-page .panel,
  .ximiya-print-page .table-wrap {
    border: 0;
    box-shadow: none;
  }
  .ximiya-print-page .table-wrap {
    max-height: none;
    overflow: visible;
  }
  .ximiya-print-table {
    width: 100%;
    border-collapse: collapse;
    page-break-inside: auto;
  }
  .ximiya-print-table thead {
    display: table-header-group;
  }
  .ximiya-print-table tfoot {
    display: table-footer-group;
  }
  .ximiya-print-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .sklad-layout {
    display: block;
  }
  .sklad-movements-wrap,
  .sklad-balances-wrap {
    max-height: none;
    overflow: visible;
    margin-bottom: 18px;
  }
}

.summary,
.summary-list {
  margin-top: 16px;
  font-size: 18px;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #e8e0cf;
}

.summary-list .ximiya-total-hectares {
  padding: 12px 0;
  color: #203a1c;
  font-size: 20px;
}

.summary-list .ximiya-total-hectares strong {
  font-size: 24px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0;
  background: linear-gradient(180deg, rgba(244, 241, 232, 0), #f4f1e8 35%);
}

.flash {
  width: min(900px, calc(100% - 32px));
  margin: 14px auto;
  padding: 12px 14px;
  border-radius: 6px;
  font-weight: 700;
}

.flash-success { background: #e7f4df; color: #31522b; }
.flash-error { background: #ffe5df; color: #8a2d1b; }
.error-box { white-space: pre-wrap; color: #8a2d1b; }
.print-page { background: #fff; }
.ximiya-field-done { color: #b42318; font-weight: 700; }
.ximiya-field-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.25;
}

.ximiya-selected-row {
  background: #fff1d6;
}

.ximiya-treatment-row {
  cursor: pointer;
}

.ximiya-treatment-row:hover {
  background: #f8f4ea;
}

.ximiya-context-menu {
  position: absolute;
  z-index: 1000;
  min-width: 210px;
  padding: 6px;
  border: 1px solid #c9bea7;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(39, 54, 31, 0.18);
}

.ximiya-context-menu button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #24351f;
  text-align: left;
  font-weight: 600;
}

.ximiya-context-menu button:hover {
  background: #f8f4ea;
}

.ximiya-context-menu button:disabled {
  color: #9ca3af;
  cursor: not-allowed;
}

.land-layer-context-menu {
  position: fixed;
  min-width: 170px;
}

.ximiya-map-treatment-popup {
  margin-top: 8px;
  max-width: 100%;
  overflow-x: auto;
}

.ximiya-field-treatments-modal {
  width: min(920px, calc(100% - 28px));
}

.ximiya-field-treatment-filters {
  margin: 0;
}

.ximiya-field-treatments-table td {
  vertical-align: top;
}

.ximiya-map-treatment-products {
  width: 100%;
  min-width: 260px;
  margin-top: 6px;
  border-collapse: collapse;
  font-size: 12px;
}

.ximiya-map-treatment-products th,
.ximiya-map-treatment-products td {
  padding: 4px 5px;
  border: 1px solid #d6c98a;
  text-align: left;
}

.ximiya-map-treatment-products th {
  background: #fff4b8;
}

.ximiya-map .leaflet-popup,
.ximiya-map-view .leaflet-popup {
  max-width: calc(100vw - 28px) !important;
}

.ximiya-map .leaflet-popup-content-wrapper,
.ximiya-map-view .leaflet-popup-content-wrapper {
  max-width: calc(100vw - 28px);
}

.ximiya-map .leaflet-popup-content,
.ximiya-map-view .leaflet-popup-content {
  width: auto !important;
  min-width: min(420px, calc(100vw - 60px));
  max-width: min(720px, calc(100vw - 60px));
  margin: 10px 12px;
  overflow-x: auto;
}

@media (max-width: 560px) {
  .ximiya-map-treatment-products {
    min-width: 0;
    font-size: 11px;
  }

  .ximiya-map-treatment-products th,
  .ximiya-map-treatment-products td {
    padding: 3px 4px;
    overflow-wrap: anywhere;
  }
}

.ximiya-map-view-page {
  width: 100%;
  max-width: none;
  margin: 12px 0 0;
  padding: 0 12px 12px;
}

.ximiya-map-view-filter {
  margin-left: auto;
}

.ximiya-map-view-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 150px);
  min-height: 520px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  overflow: hidden;
  background: #eef1e8;
}

.ximiya-map-view {
  width: 100%;
  height: 100%;
}

.land-page {
  width: 100%;
  max-width: none;
  margin: 12px 0 0;
  padding: 0 12px 12px;
}

.land-layout {
  --land-layers-width: 160px;
  display: grid;
  grid-template-columns: minmax(420px, 0.88fr) minmax(620px, 0.72fr);
  gap: 12px;
  height: calc(100vh - 150px);
  min-height: 560px;
}

.land-layout-no-details {
  grid-template-columns: minmax(0, 1fr);
}

.land-layout-one-detail {
  grid-template-columns: minmax(420px, 1fr) minmax(300px, 360px);
}

.land-layout-two-details {
  grid-template-columns: minmax(420px, 1fr) minmax(620px, 720px);
}

.land-layout-with-layers.land-layout-no-details {
  grid-template-columns: var(--land-layers-width) minmax(0, 1fr);
}

.land-layout-with-layers.land-layout-one-detail {
  grid-template-columns: var(--land-layers-width) minmax(420px, 1fr) minmax(300px, 360px);
}

.land-layout-with-layers.land-layout-two-details {
  grid-template-columns: var(--land-layers-width) minmax(420px, 1fr) minmax(620px, 720px);
}

.land-layout-no-details .land-map-wrap {
  height: 100%;
  min-height: 560px;
}

.land-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  align-items: center;
}

.land-tabs-search {
  display: flex;
  flex: 0 1 650px;
  align-items: end;
  gap: 8px;
  margin-left: 4px;
}

.land-tabs-search label {
  display: grid;
  flex: 0 1 304px;
  min-width: 270px;
  gap: 4px;
}

.land-tabs-search .land-search-field {
  flex-basis: 304px;
}

.land-tabs-search .land-view-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 0;
  align-items: center;
  gap: 6px;
  padding-bottom: 7px;
  white-space: nowrap;
}

.land-tabs-search .land-view-toggle span {
  font-size: 13px;
}

.land-tabs-search .land-view-toggle input {
  width: auto;
  margin: 0;
}

.land-tabs-search label span {
  color: #6b665b;
  font-size: 12px;
  font-weight: 700;
}

.land-tabs-search input {
  width: 100%;
}

.land-search-field {
  position: relative;
}

.land-search-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 900;
  max-height: 320px;
  overflow: auto;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 12px 28px rgba(31, 42, 29, 0.16);
}

.land-search-suggestions button {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 9px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #1f2a1d;
  text-align: left;
  cursor: pointer;
}

.land-search-suggestions button:hover,
.land-search-suggestions button:focus {
  background: #eef2ea;
}

.land-search-suggestions span {
  color: #6b665b;
  font-size: 12px;
}

.land-map-wrap {
  position: relative;
  z-index: 0;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  overflow: hidden;
  background: #eef1e8;
}

.land-map-fullscreen-button,
.land-map-print-button {
  position: absolute;
  z-index: 900;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid rgba(31, 41, 55, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: #1f2937;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.2);
}

.land-map-fullscreen-button {
  right: 12px;
  bottom: 58px;
}

.land-map-print-button {
  top: 12px;
  right: 12px;
}

.land-map-fullscreen-button:hover,
.land-map-print-button:hover {
  background: #ffffff;
}

body.land-map-fullscreen-active {
  overflow: hidden;
}

body.land-map-fullscreen-active .land-map-wrap {
  position: fixed;
  inset: 0;
  z-index: 4000;
  border: 0;
  border-radius: 0;
}

body.land-map-fullscreen-active .land-map {
  width: 100%;
  height: 100%;
}

.land-layers-panel {
  position: relative;
  min-width: 0;
  padding: 8px;
  padding-right: 14px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  overflow: auto;
  background: #fffdf8;
}

.land-layers-panel button:not(.land-layers-resizer) {
  width: 100%;
  min-height: 32px;
  padding: 5px 6px;
  font-size: 12px;
}

.land-layers-resizer {
  position: absolute;
  top: 0;
  right: -7px;
  z-index: 20;
  width: 14px;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: col-resize;
}

.land-layers-resizer::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 6px;
  width: 2px;
  border-radius: 999px;
  background: rgba(91, 111, 82, 0.28);
}

.land-layers-resizer:hover::before,
.land-layout-resizing .land-layers-resizer::before {
  background: rgba(64, 98, 52, 0.7);
}

.land-layer-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.land-layer-list label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 5px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.land-layer-list label.active {
  background: #dbeafe;
  outline: 2px solid #2563eb;
}

.land-layer-list input {
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  margin: 0;
}

.land-layer-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.land-map {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
}

.land-map,
.land-map .leaflet-container,
.land-map .leaflet-grab,
.land-map .leaflet-dragging,
.land-map .leaflet-interactive {
  cursor: default !important;
}

.land-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.land-details-grid-one {
  grid-template-columns: minmax(300px, 1fr);
}

.land-cadastre-image {
  position: absolute;
  z-index: 450;
  pointer-events: none;
  opacity: 0.78;
}

.land-cadastre-debug {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 470;
  max-width: calc(100% - 20px);
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  font-size: 12px;
  pointer-events: none;
}

.land-details {
  min-width: 0;
  padding: 14px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  overflow: auto;
  background: #fffdf8;
}

.land-details h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.land-details h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.land-details dl {
  display: grid;
  grid-template-columns: 135px minmax(0, 1fr);
  gap: 7px 10px;
  margin: 0;
}

.land-details dt {
  color: #6b665b;
  font-size: 13px;
}

.land-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.land-doc-list,
.land-history-list {
  margin: 0;
  padding-left: 18px;
}

.land-doc-list li,
.land-history-list li {
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.land-context-menu {
  left: 0;
  top: 0;
}

.land-color-select {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 36px;
}

.land-color-select span {
  width: 20px;
  height: 20px;
  border: 1px solid #6b665b;
  border-radius: 4px;
  background: #3b82f6;
}

.land-color-dialog {
  width: min(360px, calc(100% - 28px));
}

.land-color-palette {
  display: grid;
  grid-template-columns: repeat(5, 34px);
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}

.land-color-palette button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #9ca3af;
  border-radius: 4px;
  cursor: pointer;
}

.land-color-palette button.selected {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

.land-shareholders-panel {
  margin-bottom: 12px;
}

.land-shareholders-table-wrap {
  max-height: calc(100vh - 240px);
}

.land-shareholders-table {
  min-width: 1260px;
  font-size: 13px;
}

.land-shareholders-table th,
.land-shareholders-table td {
  vertical-align: top;
}

.land-shareholders-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f4ea;
  box-shadow: 0 1px 0 #d8d1bf;
}

.land-shareholders-table th:first-child,
.land-shareholders-table td:first-child {
  min-width: 240px;
}

.land-shareholders-table th:nth-child(2),
.land-shareholders-table td:nth-child(2) {
  min-width: 220px;
}

.land-shareholders-table th:nth-child(4),
.land-shareholders-table td:nth-child(4),
.land-shareholders-table th:nth-child(5),
.land-shareholders-table td:nth-child(5),
.land-shareholders-table th:nth-child(6),
.land-shareholders-table td:nth-child(6),
.land-shareholders-table th:nth-child(7),
.land-shareholders-table td:nth-child(7),
.land-shareholders-table th:nth-child(9),
.land-shareholders-table td:nth-child(9) {
  min-width: 140px;
  white-space: nowrap;
}

.land-shareholders-table th:nth-child(8),
.land-shareholders-table td:nth-child(8) {
  min-width: 180px;
  max-width: 220px;
}

.land-shareholder-comment-cell {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.35;
}

.table-sort-link {
  color: inherit;
  text-decoration: none;
}

.table-sort-link:hover {
  color: #0f5f7a;
  text-decoration: underline;
}

.link-button.land-shareholder-change-date {
  padding: 0;
  border: 0;
  background: transparent;
  color: #0f5f7a;
  font: inherit;
  text-decoration: underline;
  box-shadow: none;
}

.link-button.land-shareholder-change-date:hover {
  color: #0a3f52;
}

.land-shareholder-row {
  cursor: context-menu;
}

.land-shareholder-row:hover,
.land-shareholder-selected-row {
  background: #fff1d6;
}

.land-shareholder-context-menu {
  position: absolute;
  z-index: 5000;
}

.land-shareholder-modal textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
}

.land-shareholders-table-compact {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

.land-shareholders-table-compact th,
.land-shareholders-table-compact td {
  min-width: 0 !important;
  overflow-wrap: anywhere;
}

.land-modal {
  width: min(920px, calc(100% - 28px));
}

.land-form {
  display: block;
}

.land-existing-documents {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #e1dac8;
  border-radius: 8px;
  background: #fffaf0;
}

.land-existing-documents h3 {
  margin: 0 0 10px;
}

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

.land-form label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.land-form input,
.land-form select,
.land-form textarea {
  width: 100%;
}

.ai-page {
  min-height: calc(100vh - 118px);
}

.ai-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 680px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  overflow: hidden;
  background: #fffdf8;
  box-shadow: 0 12px 34px rgba(41, 35, 18, 0.10);
}

.ai-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-right: 1px solid #d8d1bf;
  background: #f8f4ea;
}

.ai-new-chat {
  width: 100%;
}

.ai-model-switch {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 6px;
}

.ai-model-switch button,
.ai-model-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #7a8b50;
  border-radius: 6px;
  background: #fffdf8;
  color: #31522b;
  font-weight: 700;
  text-decoration: none;
}

.ai-model-switch .active {
  background: #456b35;
  color: #fff;
}

.ai-model-note {
  padding: 8px 10px;
  border: 1px solid #e1dac7;
  border-radius: 6px;
  background: #fffdf8;
  color: #5f685d;
  font-size: 12px;
  line-height: 1.35;
}

.ai-model-note-hidden {
  display: none;
}

.ai-balance {
  display: grid;
  gap: 6px;
}

.ai-balance button {
  width: 100%;
}

.ai-key-form {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #d8d1bf;
  border-radius: 6px;
  background: #fffaf0;
}

.ai-key-form label,
.ai-key-form small {
  color: #5f685d;
  font-size: 12px;
}

.ai-key-form div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.ai-key-form input,
.ai-key-form select {
  min-width: 0;
  height: 36px;
  padding: 8px 10px;
  border: 1px solid #cfc5ad;
  border-radius: 6px;
  background: #fff;
}

.ai-key-form select {
  width: 100%;
}

.ai-chat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
}

.ai-chat-item {
  display: grid;
  justify-content: stretch;
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border-color: #d8d1bf;
  background: #fffdf8;
  color: #203a1c;
  text-align: left;
}

.ai-chat-item.active,
.ai-chat-item:hover {
  border-color: #7a8b50;
  background: #edf4e5;
}

.ai-chat-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-item small {
  color: #68736d;
  font-weight: 400;
}

.ai-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
}

.ai-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: auto;
}

.ai-empty {
  margin: auto;
  color: #68736d;
  text-align: center;
}

.ai-message {
  width: min(820px, 88%);
  padding: 12px 14px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  line-height: 1.45;
  white-space: normal;
}

.ai-message-user {
  align-self: flex-end;
  background: #e7f4df;
  border-color: #b7cfa7;
}

.ai-message-assistant {
  align-self: flex-start;
  background: #fff;
}

.ai-message time {
  display: block;
  margin-top: 8px;
  color: #68736d;
  font-size: 12px;
}

.ai-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid #d8d1bf;
  background: #f8f4ea;
}

.ai-form textarea {
  min-height: 58px;
  max-height: 180px;
}

.ai-file-input {
  display: none;
}

.ai-attach {
  min-width: 112px;
}

.ai-attach-status {
  grid-column: 1 / -1;
  min-height: 18px;
  color: #68736d;
  font-size: 13px;
  line-height: 1.35;
}

.ai-workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  min-height: 720px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  overflow: hidden;
  background: #fffdf8;
}

.ai-workspace-side,
.ai-workspace-context {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: #f8f4ea;
}

.ai-workspace-side {
  border-right: 1px solid #d8d1bf;
}

.ai-workspace-context {
  border-left: 1px solid #d8d1bf;
}

.ai-project-form {
  display: grid;
  gap: 8px;
}

.ai-project-form input,
.ai-project-form select,
.ai-workspace-context select,
.ai-workspace-context textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfc5ad;
  border-radius: 6px;
  background: #fff;
}

.ai-project-form input,
.ai-project-form select,
.ai-workspace-context select {
  height: 36px;
  padding: 8px 10px;
}

.ai-file-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: #5f685d;
  font-size: 13px;
}

.ai-file-toolbar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  min-height: 360px;
}

.ai-file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #e1dac7;
  border-radius: 6px;
  background: #fffdf8;
  color: #2f3b2d;
  text-align: left;
}

.ai-file-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-file-item small {
  color: #7b8177;
  font-size: 11px;
}

.ai-workspace-chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
}

.ai-open-file {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid #e1dac7;
  border-radius: 6px;
  background: #fffdf8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #33402f;
}

#aiFilePreview {
  min-height: 260px;
  resize: vertical;
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.ai-proposal {
  display: grid;
  gap: 8px;
}

.ai-proposal span {
  color: #5f685d;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ai-agent-page {
  width: calc(100% - 18px);
  min-height: calc(100vh - 110px);
}

.codex-embed {
  display: grid;
  grid-template-rows: auto minmax(640px, calc(100vh - 170px));
  gap: 12px;
}

.codex-embed-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.codex-embed-head h1 {
  margin: 0 0 4px;
  color: #284623;
}

.codex-embed-head p {
  margin: 0;
  color: #5f685d;
}

.codex-embed iframe {
  width: 100%;
  height: 100%;
  min-height: 640px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fff;
}

.codex-agent-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #d9ddce;
  border-radius: 8px;
  background: #f8faf3;
}

.codex-agent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.codex-agent-head h2 {
  margin: 0 0 3px;
  font-size: 18px;
  color: #284623;
}

.codex-agent-head p {
  margin: 0;
  color: #5f685d;
  font-size: 13px;
}

.codex-agent-status {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid #cbd6bf;
  border-radius: 999px;
  background: #fff;
  color: #33502b;
  font-size: 12px;
  font-weight: 700;
}

.codex-agent-grid {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(160px, 1fr) minmax(150px, 0.9fr) minmax(260px, 2fr);
  gap: 8px;
}

.codex-agent-grid label,
.codex-agent-prompt {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: #5f685d;
  font-size: 12px;
  font-weight: 700;
}

.codex-agent-grid input,
.codex-agent-grid select,
.codex-agent-prompt textarea {
  width: 100%;
  min-width: 0;
}

.codex-agent-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.codex-agent-log {
  margin: 0;
  min-height: 160px;
  max-height: 320px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #d8ddcd;
  border-radius: 6px;
  background: #151a16;
  color: #eaf1e6;
  font-size: 12px;
  white-space: pre-wrap;
}

.ai-agent-shell {
  display: grid;
  grid-template-columns: 300px minmax(460px, 1fr) 420px;
  grid-template-rows: minmax(520px, calc(100vh - 360px)) 260px;
  border: 1px solid #d8d1bf;
  border-radius: 8px;
  background: #fffdf8;
  overflow: hidden;
}

.ai-agent-files,
.ai-agent-editor,
.ai-agent-chat,
.ai-agent-bottom {
  min-width: 0;
  min-height: 0;
}

.ai-agent-files {
  display: grid;
  grid-template-rows: auto auto auto auto auto auto auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border-right: 1px solid #d8d1bf;
}

.ai-agent-editor {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
}

.ai-agent-chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border-left: 1px solid #d8d1bf;
}

.ai-agent-bottom {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-top: 1px solid #d8d1bf;
  background: #fff;
}

.ai-agent-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-agent-toolbar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: auto;
}

.ai-agent-path,
.ai-agent-key {
  padding: 7px 9px;
  border: 1px solid #e1dac7;
  border-radius: 6px;
  background: #f8f4ea;
  color: #5f685d;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-agent-label {
  color: #5f685d;
  font-size: 12px;
  font-weight: 700;
}

#agentProjectRoot,
#agentMode {
  width: 100%;
  min-width: 0;
}

.ai-agent-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: auto;
}

.ai-agent-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  justify-content: stretch;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  background: #fff;
  color: #1f2933;
  border: 1px solid #e1dac7;
}

.ai-agent-file span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.ai-agent-file small {
  color: #68736d;
  font-weight: 400;
}

#agentEditor,
#agentProposalContent {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
}

.ai-agent-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.ai-agent-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: end;
}

.ai-agent-form textarea {
  min-height: 82px;
  max-height: 180px;
}

.ai-agent-tabs {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid #e1dac7;
}

.ai-agent-tabs button {
  min-height: 30px;
  padding: 5px 10px;
}

.ai-agent-tabs .active {
  background: #456b35;
  color: #fff;
}

.ai-agent-bottom pre,
.ai-agent-proposal {
  margin: 0;
  padding: 10px;
  overflow: auto;
  min-height: 0;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.ai-agent-proposal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

#aiProposalContent {
  min-height: 220px;
  font-family: Consolas, monospace;
  font-size: 12px;
}

@media print {
  .topbar, .nav, .button, button { display: none !important; }
  .page { width: 100%; margin: 0; }
  .table-wrap { border: 0; }

  body.land-map-printing .topbar,
  body.land-map-printing .nav,
  body.land-map-printing .page-title,
  body.land-map-printing .land-tabs,
  body.land-map-printing .land-layers-panel,
  body.land-map-printing .land-details-grid,
  body.land-map-printing .ximiya-context-menu,
  body.land-map-printing .land-map-fullscreen-button,
  body.land-map-printing .land-map-print-button {
    display: none !important;
  }

  body.land-map-printing .page,
  body.land-map-printing .land-page,
  body.land-map-printing .land-layout {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.land-map-printing .land-map-wrap {
    position: fixed !important;
    inset: 0 !important;
    display: block !important;
    width: 100vw !important;
    height: 100vh !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
  }

  body.land-map-printing .land-map {
    width: 100vw !important;
    height: 100vh !important;
  }

  body.land-map-printing,
  body.land-map-printing *,
  body.land-map-printing .land-map-wrap,
  body.land-map-printing .land-map,
  body.land-map-printing .leaflet-container,
  body.land-map-printing .leaflet-pane,
  body.land-map-printing .leaflet-layer,
  body.land-map-printing .leaflet-tile,
  body.land-map-printing .leaflet-image-layer,
  body.land-map-printing .leaflet-marker-icon,
  body.land-map-printing .leaflet-tooltip,
  body.land-map-printing canvas,
  body.land-map-printing svg,
  body.land-map-printing path {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
    filter: none !important;
    -webkit-filter: none !important;
    mix-blend-mode: normal !important;
  }

  body.land-map-printing .leaflet-tile,
  body.land-map-printing .leaflet-image-layer,
  body.land-map-printing canvas,
  body.land-map-printing svg {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  body.ximiya-printing-map-table .topbar,
  body.ximiya-printing-map-table .nav,
  body.ximiya-printing-map-table .filters,
  body.ximiya-printing-map-table .ximiya-map-pane,
  body.ximiya-printing-map-table .ximiya-map-summary-panel,
  body.ximiya-printing-map-table .ximiya-context-menu,
  body.ximiya-printing-map-table .ximiya-map-empty,
  body.ximiya-printing-map-table .ximiya-row-select,
  body.ximiya-printing-map-table .ximiya-hidden-form {
    display: none !important;
  }

  body.ximiya-printing-map-table .page {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  body.ximiya-printing-map-table .ximiya-map-workspace {
    display: block;
    margin: 0;
  }

  body.ximiya-printing-map-table .ximiya-map-table-pane,
  body.ximiya-printing-map-table .ximiya-map-source-table {
    display: block !important;
  }

  body.ximiya-printing-map-table .ximiya-map-table-wrap {
    max-height: none;
    overflow: visible;
  }

  body.ximiya-printing-map-table .ximiya-map-table {
    width: 100%;
    font-size: 11px;
  }

  body.ximiya-printing-map-table .ximiya-map-table button {
    display: inline !important;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
  }
}

@media (max-width: 760px) {
  .topbar,
  .row-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .ximiya-map-workspace {
    grid-template-columns: 1fr;
  }

  .field-work-tech-actions,
  .field-work-tech-form {
    grid-template-columns: 1fr;
  }

  .land-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .land-map-wrap {
    height: 62vh;
    min-height: 420px;
  }

  .land-details-grid {
    grid-template-columns: 1fr;
  }

  .land-tabs-search {
    flex-basis: 100%;
    margin-left: 0;
  }

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

  .ximiya-transport-map-layout {
    grid-template-columns: 1fr;
  }

  .ximiya-transport-sidebar {
    max-height: 220px;
  }

  .ximiya-transport-edit-row {
    grid-template-columns: 1fr;
  }

  .ximiya-map {
    height: 560px;
  }

  .login-panel { grid-template-columns: 1fr; }

  .hero-overlay {
    align-items: flex-end;
    padding: 28px 16px;
  }

  .ai-shell {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 180px);
  }

  .ai-workspace {
    grid-template-columns: 1fr;
  }

  .ai-workspace-side,
  .ai-workspace-context {
    border: 0;
    border-bottom: 1px solid #d8d1bf;
  }

  .codex-agent-head {
    flex-direction: column;
  }

  .codex-agent-grid {
    grid-template-columns: 1fr;
  }

  .ai-sidebar {
    max-height: 230px;
    border-right: 0;
    border-bottom: 1px solid #d8d1bf;
  }

  .ai-message {
    width: 100%;
  }

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

  .ai-attach-status {
    grid-column: auto;
  }

}
