
:root {
  --bg: #0b1220;
  --panel: #101a2e;
  --panel2: #17233b;
  --text: #e9f0ff;
  --muted: #8ea0bf;
  --accent: #38bdf8;
  --green: #22c55e;
  --blue: #2563eb;
  --yellow: #facc15;
  --red: #ef4444;
  --line: rgba(255,255,255,0.12);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
#app { display: grid; grid-template-columns: 420px 1fr; height: 100vh; overflow: hidden; }
#sidebar { background: linear-gradient(180deg, #101a2e, #0b1220); border-right: 1px solid var(--line); padding: 18px; overflow-y: auto; }
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.logo { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: rgba(56,189,248,0.16); font-size: 28px; box-shadow: 0 12px 30px rgba(0,0,0,0.25); }
h1 { margin: 0; font-size: 23px; letter-spacing: -0.04em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
h2 { font-size: 17px; margin: 18px 0 12px; }
h3 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,0.04); }
.tab, button, select, input { font: inherit; }
button { border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,0.06); padding: 10px 12px; border-radius: 12px; cursor: pointer; transition: 0.15s ease; }
button:hover { background: rgba(255,255,255,0.11); transform: translateY(-1px); }
button.primary { background: linear-gradient(135deg, #0284c7, #22c55e); border: 0; font-weight: 700; }
.tab.active, .mode.active { background: rgba(56,189,248,0.20); border-color: rgba(56,189,248,0.55); }
.panel { display: none; }
.panel.active { display: block; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
input, select { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); color: var(--text); outline: none; }
select option { background: #0b1220; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.hint { margin: 14px 0; padding: 12px; border: 1px solid rgba(56,189,248,0.22); background: rgba(56,189,248,0.08); border-radius: 14px; color: #cdeeff; font-size: 13px; line-height: 1.4; }
code { color: #bae6fd; }
.list { display: grid; gap: 8px; }
.item { padding: 10px; border-radius: 14px; background: rgba(255,255,255,0.055); border: 1px solid var(--line); }
.item b { display: block; font-size: 13px; }
.item span { color: var(--muted); font-size: 12px; }
.item .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.item button { padding: 6px 8px; border-radius: 9px; font-size: 12px; }
main { min-width: 0; position: relative; }
#toolbar { height: 58px; display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: rgba(11,18,32,0.90); border-bottom: 1px solid var(--line); }
#map { height: calc(100vh - 58px); width: 100%; background: #0e1726; }
.badge { margin-left: auto; color: var(--muted); font-size: 12px; border: 1px solid var(--line); padding: 8px 10px; border-radius: 999px; }
.status-card { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: rgba(255,255,255,0.06); border: 1px solid var(--line); }
.status-dot { width: 14px; height: 14px; border-radius: 50%; background: #64748b; box-shadow: 0 0 0 5px rgba(100,116,139,0.15); }
.status-dot.live { background: var(--green); box-shadow: 0 0 0 5px rgba(34,197,94,0.18); }
.status-card span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.metric-grid div { padding: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.055); border-radius: 16px; }
.metric-grid span { display: block; color: var(--muted); font-size: 12px; }
.metric-grid b { font-size: 20px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size: 12px; }
.rules { color: #dbeafe; line-height: 1.55; padding-left: 18px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #111827; color: white; }
.pull-label { color: #fff; text-shadow: 0 1px 5px #000; font-weight: 800; font-size: 12px; }
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 46vh 54vh; }
  #sidebar { order: 2; }
  main { order: 1; }
}

.coord-box {
  margin: 14px 0;
  padding: 12px;
  border-radius: 16px;
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.28);
}
.coord-box b { display:block; margin-bottom: 6px; }
.coord-box span {
  display: block;
  color: #d1fae5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  margin: 3px 0;
}
.coord-box button {
  margin-top: 8px;
  width: 100%;
}

.stand-preview-line {
  stroke-dasharray: 7 7;
}
.coverage-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(56,189,248,0.12);
  border: 1px solid rgba(56,189,248,0.35);
  color: #dff6ff;
  font-size: 12px;
  margin-top: 4px;
}

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

.moisture-label {
  color: white;
  font-weight: 900;
  font-size: 13px;
  text-align: center;
  text-shadow: 0 1px 6px #000, 0 0 3px #000;
}
.moisture-label .box {
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
}

.hint code {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 6px;
  line-height: 1.35;
}

.tabs { grid-template-columns: repeat(5, 1fr); }
.decision { border-left: 5px solid #64748b; }
.decision.now { border-left-color: #ef4444; background: rgba(239,68,68,0.10); }
.decision.watch { border-left-color: #f59e0b; background: rgba(245,158,11,0.10); }
.decision.wait { border-left-color: #22c55e; background: rgba(34,197,94,0.08); }
.decision-badge { display:inline-block; font-weight:900; padding:4px 8px; border-radius:999px; margin-bottom:5px; }
.decision-badge.now { background:#ef4444; color:white; }
.decision-badge.watch { background:#f59e0b; color:#111827; }
.decision-badge.wait { background:#22c55e; color:#052e16; }
.rainbar { height:8px; border-radius:999px; background:rgba(56,189,248,0.25); overflow:hidden; margin-top:5px; }
.rainbar > span { display:block; height:8px; background:#38bdf8; }

.compact-status { margin-top: 12px; padding: 10px; }
.plan-active-row { border-color: rgba(34,197,94,0.5); background: rgba(34,197,94,0.08); }
.plan-select-hint { color: #bae6fd; font-size: 12px; margin-top: 6px; }

.op-session-card { border-left: 5px solid #38bdf8; }
.op-session-card.running { border-left-color: #22c55e; background: rgba(34,197,94,0.08); }
.op-session-card.alarm { border-left-color: #ef4444; background: rgba(239,68,68,0.12); }
.progressbar { height: 10px; border-radius: 999px; background: rgba(255,255,255,0.12); overflow: hidden; margin-top: 8px; }
.progressbar span { display: block; height: 10px; background: #38bdf8; }
.alarm-text { color: #fecaca; font-weight: 800; }

.tabs { grid-template-columns: repeat(6, 1fr); }
.log-card { border-left: 5px solid #38bdf8; }
.log-card .meta { color: #bae6fd; display:block; margin-top:4px; }
.log-card .conditions { color:#d1fae5; display:block; margin-top:4px; }

.iot-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.iot-table th, .iot-table td { border-bottom: 1px solid rgba(255,255,255,.12); padding: 6px 8px; vertical-align: top; }
.iot-table th { text-align: left; color: #bae6fd; position: sticky; top: 0; background: rgba(15,23,42,.95); }
.table-wrap { overflow: auto; max-height: 520px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; }
.iot-raw { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #cbd5e1; }
.iot-card { border-left: 5px solid #64748b; }
.iot-card.soil { border-left-color: #84cc16; }
.iot-card.water_wagon, .iot-card.tracker { border-left-color: #38bdf8; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 850px) { .grid-two { grid-template-columns: 1fr; } }


.soil-monitor-box { margin-top: 16px; padding: 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: rgba(15,23,42,.35); }
.soil-monitor-card { border-left: 5px solid #84cc16; cursor: pointer; }
.soil-monitor-card.no-placement { border-left-color: #f59e0b; }
.soil-monitor-card b { display: block; }
.soil-monitor-card span { display: block; color: #cbd5e1; font-size: 12px; margin-top: 2px; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 850px) { .grid-two { grid-template-columns: 1fr; } }


.soil-placement-tools {
  margin: 14px 0;
  padding: 12px;
  border: 1px dashed rgba(132, 204, 22, .55);
  border-radius: 12px;
  background: rgba(132, 204, 22, .08);
}
.soil-placement-tools h4 { margin: 0 0 6px 0; }
.soil-placement-active {
  outline: 2px solid rgba(132, 204, 22, .9);
  box-shadow: 0 0 0 4px rgba(132, 204, 22, .16);
}
.soil-monitor-card.active-placement {
  background: rgba(132, 204, 22, .14);
  border-left-color: #22c55e;
}
.soil-placement-help-active {
  color: #bef264 !important;
  font-weight: 600;
}


.soil-adc-label {
  background: rgba(15, 23, 42, .88);
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}



/* patch23 safe styling only - do not alter layout */
.wagon-map-label {
  background: rgba(2, 132, 199, .90);
  border: 1px solid rgba(255,255,255,.45);
  color: white;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

/* neutralize broken patch workspaces if they remain in DOM from cached HTML */
#patch21Workspace,
#patch22Workspace {
  display: none !important;
}

/* do not hide normal app/sidebar/map elements */
aside,
.sidebar,
#sidebar,
.side-panel,
.sidebar-panel,
.controls-panel,
#controlsPanel {
  visibility: visible !important;
}


/* patch36: one clean top menu, no old patch menu/workspaces */
#patch21Workspace,
#patch22Workspace,
#patch24TopMenu,
#patch25TopActions,
#patch30OperationPanel,
#patch30MoisturePanel,
#patch31ModeViewport,
#patch32ModeViewport,
#patch32ModeParking,
#patch33ModeBox,
#patch35TopMenu,
#patch35ModeHost {
  display: none !important;
}

/* Hide original menu buttons after JS marks them. Content/forms remain visible. */
.patch36-hide-original-menu {
  display: none !important;
  visibility: hidden !important;
}

#patch36TopMenu {
  position: sticky;
  top: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin: 0;
  background: rgba(15, 23, 42, .96);
  border-bottom: 1px solid rgba(148, 163, 184, .24);
  backdrop-filter: blur(10px);
}

#patch36TopMenu button {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, .35);
  background: rgba(30, 41, 59, .88);
  color: #e5eefb;
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 40px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.1;
}

#patch36TopMenu button[data-action] {
  border-radius: 12px;
  border-color: rgba(56, 189, 248, .38);
}

#patch36TopMenu button.patch36-active {
  background: linear-gradient(135deg, #0ea5e9, #22c55e);
  color: #fff;
  border-color: transparent;
}

.patch36-separator {
  width: 1px;
  height: 34px;
  background: rgba(148, 163, 184, .32);
  margin: 0 2px;
}

/* Keep real left side functions visible. */
aside,
.sidebar,
#sidebar,
.side-panel,
.sidebar-panel,
.controls-panel,
#controlsPanel,
.left-menu,
#leftMenu {
  visibility: visible !important;
}

/* Mobile: single horizontal scrollable top bar */
@media (max-width: 900px) {
  #patch36TopMenu {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 8px;
  }

  #patch36TopMenu button {
    white-space: nowrap;
    padding: 9px 13px;
    font-size: 13px;
  }

  .patch36-separator {
    height: 30px;
  }
}


/* patch37: hide/remove only Plan mode, never Planlegging */
.patch37-remove-plan-mode {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}


/* patch38: operation wagon live/run UI */
.patch38-operation-box {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .28);
  border-radius: 14px;
  background: rgba(15, 23, 42, .38);
}

.patch38-operation-box h3 {
  margin: 0 0 4px 0;
  color: #e5eefb;
  font-size: 18px;
}

.patch38-muted {
  color: #94a3b8;
  font-size: 12px;
  margin: 0 0 10px 0;
}

.patch38-wagon-card {
  margin: 9px 0;
  padding: 11px;
  border-left: 5px solid #38bdf8;
  border-radius: 11px;
  background: rgba(30, 41, 59, .58);
}

.patch38-wagon-card.patch38-selected {
  outline: 2px solid rgba(34, 211, 238, .7);
}

.patch38-wagon-card b,
.patch38-wagon-card span {
  display: block;
}

.patch38-wagon-card span {
  color: #cbd5e1;
  font-size: 12px;
  margin-top: 2px;
}

.patch38-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.patch38-buttons button {
  border: 1px solid rgba(56, 189, 248, .35);
  background: rgba(30, 41, 59, .88);
  color: #e5eefb;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.patch38-buttons button:hover {
  border-color: rgba(34, 211, 238, .75);
  background: rgba(51, 65, 85, .96);
}

.patch38-run-info {
  margin-top: 8px;
  padding: 8px;
  border-radius: 9px;
  background: rgba(15, 23, 42, .48);
  color: #cbd5e1;
  font-size: 12px;
}

.patch38-wagon-label,
.patch38-point-label {
  background: rgba(2, 132, 199, .92);
  border: 1px solid rgba(255,255,255,.45);
  color: white;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

.patch38-point-label.finish {
  background: rgba(220, 38, 38, .92);
}

.patch38-point-label.start {
  background: rgba(22, 163, 74, .92);
}


/* patch40: simplified auto operation */
.patch40-hide-old-operation {
  display: none !important;
  visibility: hidden !important;
}

.patch40-operation-box {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .28);
  border-radius: 14px;
  background: rgba(15, 23, 42, .38);
}

.patch40-operation-box h3 {
  margin: 0 0 4px 0;
  color: #e5eefb;
  font-size: 18px;
}

.patch40-muted {
  color: #94a3b8;
  font-size: 12px;
  margin: 0 0 10px 0;
}

.patch40-card {
  margin: 9px 0;
  padding: 11px;
  border-left: 5px solid #38bdf8;
  border-radius: 11px;
  background: rgba(30, 41, 59, .58);
}

.patch40-card b,
.patch40-card span {
  display: block;
}

.patch40-card span {
  color: #cbd5e1;
  font-size: 12px;
  margin-top: 2px;
}

.patch40-status-badge {
  display: inline-block !important;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin: 4px 0;
  background: rgba(148, 163, 184, .25);
  color: #e5eefb;
}

.patch40-status-running {
  background: rgba(34, 197, 94, .25);
  color: #bbf7d0;
}

.patch40-status-completed {
  background: rgba(14, 165, 233, .25);
  color: #bae6fd;
}

.patch40-alarm {
  color: #fecaca !important;
  font-weight: 700;
}

.patch40-buttons,
.patch40-config-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.patch40-buttons button {
  border: 1px solid rgba(56, 189, 248, .35);
  background: rgba(30, 41, 59, .88);
  color: #e5eefb;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.patch40-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.patch40-config-grid label {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 3px;
}

.patch40-config-grid input {
  width: 100%;
  box-sizing: border-box;
}

.patch40-wagon-label,
.patch40-point-label {
  background: rgba(2, 132, 199, .92);
  border: 1px solid rgba(255,255,255,.45);
  color: white;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

.patch40-point-label.finish {
  background: rgba(220, 38, 38, .92);
}

.patch40-point-label.start {
  background: rgba(22, 163, 74, .92);
}



/* patch41 cleanup: old Operation artifacts must not appear */
#patch38OperationBox,
#patch39OperationBox,
#patch40OperationBox,
.patch38-operation-box,
.patch39-operation-box,
.patch40-operation-box {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.patch41-hide-old-operation {
  display: none !important;
  visibility: hidden !important;
}

.patch41-operation-box {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .28);
  border-radius: 14px;
  background: rgba(15, 23, 42, .38);
}

.patch41-operation-box h3 {
  margin: 0 0 4px 0;
  color: #e5eefb;
  font-size: 18px;
}

.patch41-muted {
  color: #94a3b8;
  font-size: 12px;
  margin: 0 0 10px 0;
}

.patch41-card {
  margin: 9px 0;
  padding: 11px;
  border-left: 5px solid #38bdf8;
  border-radius: 11px;
  background: rgba(30, 41, 59, .58);
}

.patch41-card b,
.patch41-card span {
  display: block;
}

.patch41-card span {
  color: #cbd5e1;
  font-size: 12px;
  margin-top: 2px;
}

.patch41-status-badge {
  display: inline-block !important;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin: 4px 0;
  background: rgba(148, 163, 184, .25);
  color: #e5eefb;
}

.patch41-status-running {
  background: rgba(34, 197, 94, .25);
  color: #bbf7d0;
}

.patch41-status-completed {
  background: rgba(14, 165, 233, .25);
  color: #bae6fd;
}

.patch41-alarm {
  color: #fecaca !important;
  font-weight: 700;
}

.patch41-buttons,
.patch41-config-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.patch41-buttons button {
  border: 1px solid rgba(56, 189, 248, .35);
  background: rgba(30, 41, 59, .88);
  color: #e5eefb;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.patch41-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.patch41-config-grid label {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 3px;
}

.patch41-config-grid input {
  width: 100%;
  box-sizing: border-box;
}

.patch41-wagon-label,
.patch41-point-label {
  background: rgba(2, 132, 199, .92);
  border: 1px solid rgba(255,255,255,.45);
  color: white;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

.patch41-point-label.finish {
  background: rgba(220, 38, 38, .92);
}

.patch41-point-label.start {
  background: rgba(22, 163, 74, .92);
}

/* patch43: precise hide of old legacy Operation block only */
.patch43-remove-exact-legacy-operation {
  display: none !important;
  visibility: hidden !important;
}


/* patch45: global one-mode-only rule */
.patch45-mode-hidden {
  display: none !important;
  visibility: hidden !important;
}

.patch45-mode-visible {
  display: block !important;
  visibility: visible !important;
}

.patch45-managed-left-child.patch45-mode-hidden {
  display: none !important;
  visibility: hidden !important;
}

.patch45-managed-left-child.patch45-mode-visible {
  display: block !important;
  visibility: visible !important;
}

/* Operation box is a mode, never extra content */
#patch41OperationBox.patch45-mode-hidden,
#patch38OperationBox,
#patch39OperationBox,
#patch40OperationBox,
#patch30OperationPanel,
#patch30MoisturePanel,
#patch32ModeViewport,
#patch32ModeParking,
#patch35ModeHost {
  display: none !important;
  visibility: hidden !important;
}

#patch41OperationBox.patch45-mode-visible {
  display: block !important;
  visibility: visible !important;
}


/* patch46: action buttons state */
#patch36TopMenu button.patch46-action-active {
  background: linear-gradient(135deg, #6366f1, #0ea5e9) !important;
  color: white !important;
  border-color: transparent !important;
}

.patch46-temp-visible {
  display: initial !important;
  visibility: visible !important;
}


/* patch47: Vanningsbehov/Data are real modes, visually same as other modes */
#patch36TopMenu button[data-mode="needs"],
#patch36TopMenu button[data-mode="data"] {
  border-radius: 999px !important;
  border-color: rgba(148, 163, 184, .35) !important;
}

#patch36TopMenu button.patch47-active {
  background: linear-gradient(135deg, #0ea5e9, #22c55e) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.patch47-mode-hidden {
  display: none !important;
  visibility: hidden !important;
}

.patch47-mode-visible {
  display: block !important;
  visibility: visible !important;
}

/* Internal marker only; keeps Vanningsbehov/Data using normal left content without stacking Operation */
.patch47-normal-mode-active #patch41OperationBox,
.patch47-normal-mode-active #patch38OperationBox,
.patch47-normal-mode-active #patch39OperationBox,
.patch47-normal-mode-active #patch40OperationBox {
  display: none !important;
  visibility: hidden !important;
}


/* patch49: recover from patch48 and keep original left UI */
#patch48ModeHost,
#patch48OriginalPanel,
#patch48OperationPanel,
#patch48NeedsPanel,
#patch48DataPanel {
  display: none !important;
  visibility: hidden !important;
}

.patch49-remove-duplicate-action {
  display: none !important;
  visibility: hidden !important;
}

#patch36TopMenu button[data-mode="needs"],
#patch36TopMenu button[data-mode="data"] {
  border-radius: 999px !important;
  border-color: rgba(148, 163, 184, .35) !important;
}

#patch36TopMenu button.patch49-active,
#topModeMenu button.patch49-active,
#patch24TopMenu button.patch49-active {
  background: linear-gradient(135deg, #0ea5e9, #22c55e) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* Operation must be a mode, not extra content below other modes */
#patch41OperationBox.patch49-operation-hidden {
  display: none !important;
  visibility: hidden !important;
}

#patch41OperationBox.patch49-operation-visible {
  display: block !important;
  visibility: visible !important;
}


/* patch50: strict exclusive modes */
.patch50-hidden-mode-block {
  display: none !important;
  visibility: hidden !important;
}

.patch50-visible-mode-block {
  display: block !important;
  visibility: visible !important;
}

#patch36TopMenu button.patch50-active,
#topModeMenu button.patch50-active,
#patch24TopMenu button.patch50-active {
  background: linear-gradient(135deg, #0ea5e9, #22c55e) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* Old/generated operation fragments should never reappear when not active */
body:not(.patch50-mode-operation) #patch41OperationBox,
body:not(.patch50-mode-operation) #patch40OperationBox,
body:not(.patch50-mode-operation) #patch39OperationBox,
body:not(.patch50-mode-operation) #patch38OperationBox {
  display: none !important;
  visibility: hidden !important;
}


/* patch51: stabilize after conflicting mode patches */
#patch48ModeHost,
#patch48OriginalPanel,
#patch48OperationPanel,
#patch48NeedsPanel,
#patch48DataPanel {
  display: none !important;
  visibility: hidden !important;
}

/* Keep removed-patch classes from hiding content forever */
.patch44-left-hidden,
.patch45-mode-hidden,
.patch46-temp-visible,
.patch47-mode-hidden,
.patch48-mode-panel,
.patch49-operation-hidden,
.patch50-hidden-mode-block {
}

/* Old generated Operation boxes should not show; patch41 owns Operation */
#patch38OperationBox,
#patch39OperationBox,
#patch40OperationBox {
  display: none !important;
  visibility: hidden !important;
}


/* patch52 stable panels */
#patch52Panel {
  display: none;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .30);
  border-radius: 14px;
  background: rgba(15, 23, 42, .42);
}

#patch52Panel.patch52-visible {
  display: block !important;
  visibility: visible !important;
}

.patch52-card {
  margin: 10px 0;
  padding: 12px;
  border-left: 5px solid #38bdf8;
  border-radius: 11px;
  background: rgba(30, 41, 59, .58);
}

.patch52-card h3 {
  margin: 0 0 6px 0;
  color: #e5eefb;
  font-size: 18px;
}

.patch52-card b,
.patch52-card span {
  display: block;
}

.patch52-card span,
.patch52-muted {
  color: #cbd5e1;
  font-size: 12px;
  margin-top: 2px;
}

.patch52-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.patch52-kv {
  padding: 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, .55);
}

.patch52-kv b {
  color: #e5eefb;
}

.patch52-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.patch52-buttons button {
  border: 1px solid rgba(56, 189, 248, .35);
  background: rgba(30, 41, 59, .88);
  color: #e5eefb;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.patch52-wagon-label,
.patch52-point-label {
  background: rgba(2, 132, 199, .92);
  border: 1px solid rgba(255,255,255,.45);
  color: white;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

.patch52-point-label.finish {
  background: rgba(220, 38, 38, .92);
}

.patch52-point-label.start {
  background: rgba(22, 163, 74, .92);
}

#patch36TopMenu button.patch52-active,
#topModeMenu button.patch52-active,
#patch24TopMenu button.patch52-active {
  background: linear-gradient(135deg, #0ea5e9, #22c55e) !important;
  color: #fff !important;
  border-color: transparent !important;
}

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


/* patch53 stable panels */
#patch52Panel {
  display: none !important;
  visibility: hidden !important;
}

#patch53Panel {
  display: none;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .30);
  border-radius: 14px;
  background: rgba(15, 23, 42, .42);
}

#patch53Panel.patch53-visible {
  display: block !important;
  visibility: visible !important;
}

.patch53-card {
  margin: 10px 0;
  padding: 12px;
  border-left: 5px solid #38bdf8;
  border-radius: 11px;
  background: rgba(30, 41, 59, .58);
}

.patch53-card h3 {
  margin: 0 0 6px 0;
  color: #e5eefb;
  font-size: 18px;
}

.patch53-card b,
.patch53-card span {
  display: block;
}

.patch53-card span,
.patch53-muted {
  color: #cbd5e1;
  font-size: 12px;
  margin-top: 2px;
}

.patch53-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.patch53-kv {
  padding: 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, .55);
}

.patch53-kv b {
  color: #e5eefb;
}

.patch53-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.patch53-buttons button {
  border: 1px solid rgba(56, 189, 248, .35);
  background: rgba(30, 41, 59, .88);
  color: #e5eefb;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.patch53-wagon-label,
.patch53-point-label {
  background: rgba(2, 132, 199, .92);
  border: 1px solid rgba(255,255,255,.45);
  color: white;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

.patch53-point-label.finish {
  background: rgba(220, 38, 38, .92);
}

.patch53-point-label.start {
  background: rgba(22, 163, 74, .92);
}

#patch36TopMenu button.patch53-active,
#topModeMenu button.patch53-active,
#patch24TopMenu button.patch53-active {
  background: linear-gradient(135deg, #0ea5e9, #22c55e) !important;
  color: #fff !important;
  border-color: transparent !important;
}

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


/* patch54: transactional single-mode left panel */
.patch54-hidden { display: none !important; visibility: hidden !important; }
.patch54-visible { display: block !important; visibility: visible !important; }
#patch52Panel, #patch53Panel { display: none !important; visibility: hidden !important; }

#patch54Panel {
  display: none;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .30);
  border-radius: 14px;
  background: rgba(15, 23, 42, .42);
}
#patch54Panel.patch54-visible { display: block !important; visibility: visible !important; }

.patch54-card {
  margin: 10px 0;
  padding: 12px;
  border-left: 5px solid #38bdf8;
  border-radius: 11px;
  background: rgba(30, 41, 59, .58);
}
.patch54-card h3 { margin: 0 0 6px 0; color: #e5eefb; font-size: 18px; }
.patch54-card b, .patch54-card span { display: block; }
.patch54-card span, .patch54-muted { color: #cbd5e1; font-size: 12px; margin-top: 2px; }

.patch54-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.patch54-kv { padding: 8px; border-radius: 8px; background: rgba(15, 23, 42, .55); }
.patch54-kv b { color: #e5eefb; }

.patch54-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.patch54-buttons button {
  border: 1px solid rgba(56, 189, 248, .35);
  background: rgba(30, 41, 59, .88);
  color: #e5eefb;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.patch54-wagon-label, .patch54-point-label {
  background: rgba(2, 132, 199, .92);
  border: 1px solid rgba(255,255,255,.45);
  color: white;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.patch54-point-label.finish { background: rgba(220, 38, 38, .92); }
.patch54-point-label.start { background: rgba(22, 163, 74, .92); }

#patch36TopMenu button.patch54-active,
#topModeMenu button.patch54-active,
#patch24TopMenu button.patch54-active {
  background: linear-gradient(135deg, #0ea5e9, #22c55e) !important;
  color: #fff !important;
  border-color: transparent !important;
}
@media (max-width: 850px) { .patch54-grid { grid-template-columns: 1fr; } }


/* patch55: transactional single-mode left panel with multi-field needs */
.patch55-hidden { display: none !important; visibility: hidden !important; }
.patch55-visible { display: block !important; visibility: visible !important; }
#patch52Panel, #patch53Panel, #patch54Panel { display: none !important; visibility: hidden !important; }

#patch55Panel {
  display: none;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, .30);
  border-radius: 14px;
  background: rgba(15, 23, 42, .42);
}
#patch55Panel.patch55-visible { display: block !important; visibility: visible !important; }

.patch55-card {
  margin: 10px 0;
  padding: 12px;
  border-left: 5px solid #38bdf8;
  border-radius: 11px;
  background: rgba(30, 41, 59, .58);
}
.patch55-card h3 { margin: 0 0 6px 0; color: #e5eefb; font-size: 18px; }
.patch55-card b, .patch55-card span { display: block; }
.patch55-card span, .patch55-muted { color: #cbd5e1; font-size: 12px; margin-top: 2px; }

.patch55-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.patch55-kv { padding: 8px; border-radius: 8px; background: rgba(15, 23, 42, .55); }
.patch55-kv b { color: #e5eefb; }

.patch55-field-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
.patch55-field-card {
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .50);
  border: 1px solid rgba(148, 163, 184, .25);
}
.patch55-field-card.patch55-need-high { border-left: 5px solid #f97316; }
.patch55-field-card.patch55-need-low { border-left: 5px solid #22c55e; }
.patch55-field-card.patch55-need-unknown { border-left: 5px solid #94a3b8; }

.patch55-sensor-row {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(2, 6, 23, .35);
  font-size: 12px;
  color: #cbd5e1;
}

.patch55-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.patch55-buttons button {
  border: 1px solid rgba(56, 189, 248, .35);
  background: rgba(30, 41, 59, .88);
  color: #e5eefb;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.patch55-wagon-label, .patch55-point-label {
  background: rgba(2, 132, 199, .92);
  border: 1px solid rgba(255,255,255,.45);
  color: white;
  font-weight: 700;
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.patch55-point-label.finish { background: rgba(220, 38, 38, .92); }
.patch55-point-label.start { background: rgba(22, 163, 74, .92); }

#patch36TopMenu button.patch55-active,
#topModeMenu button.patch55-active,
#patch24TopMenu button.patch55-active {
  background: linear-gradient(135deg, #0ea5e9, #22c55e) !important;
  color: #fff !important;
  border-color: transparent !important;
}
@media (max-width: 850px) { .patch55-grid { grid-template-columns: 1fr; } }


/* patch66: polygon SVG paths are click-through except in Operation mode */
body:not(.patch66-operation-mode) .leaflet-overlay-pane svg path.leaflet-interactive {
  pointer-events: none !important;
}

body.patch66-operation-mode .leaflet-overlay-pane svg path.leaflet-interactive {
  pointer-events: auto !important;
}


/* patch71 calibrated Soil map labels */
.patch71-soil-label {
  background: rgba(15, 23, 42, .92);
  border: 1px solid rgba(132, 204, 22, .85);
  color: #fff;
  border-radius: 8px;
  padding: 3px 7px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.patch71-soil-label .p71dev {
  display: block;
  color: #e5eefb;
  font-size: 12px;
  line-height: 1.1;
}

.patch71-soil-label .p71pct {
  display: block;
  color: #bef264;
  font-size: 13px;
  line-height: 1.1;
}



/* patch93: Historisk */
.patch93-card { background: rgba(15, 23, 42, .76); border: 1px solid rgba(148, 163, 184, .25); border-radius: 12px; padding: 12px; margin: 10px 0; color: #e5eefb; }
.patch93-card h3 { margin: 0 0 8px 0; color: #e5eefb; font-size: 18px; }
.patch93-muted { color: #cbd5e1; font-size: 12px; margin: 4px 0 8px 0; }
.patch93-buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.patch93-buttons button, .patch93-buttons select { background: rgba(30, 41, 59, .92); color: #e5eefb; border: 1px solid rgba(148, 163, 184, .35); border-radius: 8px; padding: 7px 10px; }
.patch93-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.patch93-grid div { background: rgba(15, 23, 42, .50); border-radius: 8px; padding: 8px; }
.patch93-grid b { display: block; color: #e5eefb; font-size: 12px; }
.patch93-grid span { display: block; color: #cbd5e1; font-size: 12px; margin-top: 2px; }
.patch93-table-wrap { max-height: 380px; overflow: auto; border-radius: 8px; border: 1px solid rgba(148, 163, 184, .18); }
.patch93-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.patch93-table th, .patch93-table td { padding: 6px 8px; border-bottom: 1px solid rgba(148, 163, 184, .12); text-align: left; white-space: nowrap; }
.patch93-table th { position: sticky; top: 0; background: rgba(15, 23, 42, .96); color: #e5eefb; z-index: 1; }
#patch93HistoryBtn.patch36-active, #patch93HistoryBtn.patch55-active { background: rgba(34, 197, 94, .22); border-color: rgba(34, 197, 94, .60); }
@media (max-width: 850px) { .patch93-grid { grid-template-columns: 1fr; } }

/* patch94: Historisk exclusive full view */
body.patch94-history-active {
  overflow: hidden;
}

body.patch94-history-active #map,
body.patch94-history-active #mapContainer,
body.patch94-history-active .map-container,
body.patch94-history-active .leaflet-container {
  display: none !important;
}

#patch94HistoryWorkspace {
  position: fixed;
  left: 0;
  right: 0;
  top: 64px;
  bottom: 0;
  z-index: 7000;
  overflow: auto;
  padding: 18px;
  background: linear-gradient(180deg, rgba(2,6,23,.98), rgba(15,23,42,.98));
  color: #e5eefb;
}

#patch94HistoryWorkspace[hidden] {
  display: none !important;
}

.patch94-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, .24);
  background: rgba(15, 23, 42, .72);
  border-radius: 14px;
}

.patch94-header h1 {
  margin: 0 0 6px 0;
  font-size: 26px;
  color: #f8fafc;
}

.patch94-header p {
  margin: 0;
  color: #cbd5e1;
}

.patch94-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.patch94-actions button,
.patch94-actions select {
  background: rgba(30, 41, 59, .95);
  color: #e5eefb;
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: 8px;
  padding: 8px 11px;
}

.patch94-actions label {
  color: #cbd5e1;
  font-size: 12px;
}

.patch94-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.patch94-grid div,
.patch94-card {
  background: rgba(15, 23, 42, .76);
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 12px;
  padding: 12px;
}

.patch94-grid b,
.patch94-grid span {
  display: block;
}

.patch94-grid b {
  color: #f8fafc;
  font-size: 13px;
}

.patch94-grid span {
  color: #cbd5e1;
  margin-top: 4px;
}

.patch94-card {
  margin: 12px 0;
}

.patch94-card h2 {
  margin: 0 0 8px 0;
  color: #f8fafc;
  font-size: 18px;
}

.patch94-muted {
  color: #cbd5e1;
  font-size: 13px;
}

.patch94-table-wrap {
  max-height: 460px;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 10px;
}

.patch94-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.patch94-table th,
.patch94-table td {
  padding: 7px 9px;
  border-bottom: 1px solid rgba(148, 163, 184, .13);
  text-align: left;
  white-space: nowrap;
}

.patch94-table th {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, .98);
  color: #f8fafc;
  z-index: 1;
}

#patch93HistoryBtn.patch36-active,
#patch93HistoryBtn.patch55-active,
#patch94HistoryBtn.patch36-active,
#patch94HistoryBtn.patch55-active {
  background: rgba(34, 197, 94, .22) !important;
  border-color: rgba(34, 197, 94, .65) !important;
}

@media (max-width: 900px) {
  #patch94HistoryWorkspace {
    top: 92px;
    padding: 10px;
  }

  .patch94-header {
    flex-direction: column;
  }

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


/* patch104: clean historisk fullscreen */
body.patch104-history-active {
  overflow: hidden;
}

body.patch104-history-active #map,
body.patch104-history-active #mapContainer,
body.patch104-history-active .map-container,
body.patch104-history-active .leaflet-container {
  display: none !important;
}

#patch104HistoryWorkspace {
  position: fixed;
  left: 0;
  right: 0;
  top: 64px;
  bottom: 0;
  z-index: 9000;
  overflow: auto;
  padding: 18px;
  background: linear-gradient(180deg, rgba(2,6,23,.98), rgba(15,23,42,.98));
  color: #e5eefb;
}

#patch104HistoryWorkspace[hidden] {
  display: none !important;
}

.patch104-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid rgba(148,163,184,.25);
  background: rgba(15,23,42,.76);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.patch104-header h1 {
  margin: 0 0 6px 0;
  font-size: 26px;
  color: #f8fafc;
}

.patch104-header p,
.patch104-muted {
  color: #cbd5e1;
  margin: 0;
  font-size: 13px;
}

.patch104-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.patch104-actions button,
.patch104-actions select {
  background: rgba(30,41,59,.95);
  color: #e5eefb;
  border: 1px solid rgba(148,163,184,.35);
  border-radius: 8px;
  padding: 8px 11px;
}

.patch104-actions label {
  color: #cbd5e1;
  font-size: 12px;
}

.patch104-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.patch104-grid div,
.patch104-card {
  background: rgba(15,23,42,.76);
  border: 1px solid rgba(148,163,184,.24);
  border-radius: 12px;
  padding: 12px;
}

.patch104-grid b,
.patch104-grid span {
  display: block;
}

.patch104-grid b {
  color: #f8fafc;
  font-size: 13px;
}

.patch104-grid span {
  color: #cbd5e1;
  margin-top: 4px;
}

.patch104-card {
  margin: 12px 0;
}

.patch104-card h2 {
  margin: 0 0 8px 0;
  color: #f8fafc;
  font-size: 18px;
}

.patch104-table-wrap {
  max-height: 460px;
  overflow: auto;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 10px;
}

.patch104-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.patch104-table th,
.patch104-table td {
  padding: 7px 9px;
  border-bottom: 1px solid rgba(148,163,184,.13);
  text-align: left;
  white-space: nowrap;
}

.patch104-table th {
  position: sticky;
  top: 0;
  background: rgba(15,23,42,.98);
  color: #f8fafc;
  z-index: 1;
}

@media (max-width: 900px) {
  #patch104HistoryWorkspace { top: 92px; padding: 10px; }
  .patch104-header { flex-direction: column; }
  .patch104-grid { grid-template-columns: 1fr 1fr; }
}


/* patch105: clean history fullscreen */
body.patch105-history-active {
  overflow: hidden;
}

body.patch105-history-active #map,
body.patch105-history-active #mapContainer,
body.patch105-history-active .map-container,
body.patch105-history-active .leaflet-container {
  display: none !important;
}

#patch105HistoryWorkspace {
  position: fixed;
  left: 0;
  right: 0;
  top: 64px;
  bottom: 0;
  z-index: 9500;
  overflow: auto;
  padding: 18px;
  background: linear-gradient(180deg, rgba(2,6,23,.98), rgba(15,23,42,.98));
  color: #e5eefb;
}

#patch105HistoryWorkspace[hidden] {
  display: none !important;
}

.patch105-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid rgba(148,163,184,.25);
  background: rgba(15,23,42,.76);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.patch105-header h1 {
  margin: 0 0 6px 0;
  font-size: 26px;
  color: #f8fafc;
}

.patch105-header p,
.patch105-muted {
  color: #cbd5e1;
  margin: 0;
  font-size: 13px;
}

.patch105-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.patch105-actions button,
.patch105-actions select {
  background: rgba(30,41,59,.95);
  color: #e5eefb;
  border: 1px solid rgba(148,163,184,.35);
  border-radius: 8px;
  padding: 8px 11px;
}

.patch105-actions label {
  color: #cbd5e1;
  font-size: 12px;
}

.patch105-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.patch105-grid div,
.patch105-card {
  background: rgba(15,23,42,.76);
  border: 1px solid rgba(148,163,184,.24);
  border-radius: 12px;
  padding: 12px;
}

.patch105-grid b,
.patch105-grid span {
  display: block;
}

.patch105-grid b {
  color: #f8fafc;
  font-size: 13px;
}

.patch105-grid span {
  color: #cbd5e1;
  margin-top: 4px;
}

.patch105-card {
  margin: 12px 0;
}

.patch105-card h2 {
  margin: 0 0 8px 0;
  color: #f8fafc;
  font-size: 18px;
}

.patch105-table-wrap {
  max-height: 460px;
  overflow: auto;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 10px;
}

.patch105-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.patch105-table th,
.patch105-table td {
  padding: 7px 9px;
  border-bottom: 1px solid rgba(148,163,184,.13);
  text-align: left;
  white-space: nowrap;
}

.patch105-table th {
  position: sticky;
  top: 0;
  background: rgba(15,23,42,.98);
  color: #f8fafc;
  z-index: 1;
}

@media (max-width: 900px) {
  #patch105HistoryWorkspace { top: 92px; padding: 10px; }
  .patch105-header { flex-direction: column; }
  .patch105-grid { grid-template-columns: 1fr 1fr; }
}


/* patch107: unified history fullscreen */
body.patch107-history-active {
  overflow: hidden;
}

body.patch107-history-active #map,
body.patch107-history-active #mapContainer,
body.patch107-history-active .map-container,
body.patch107-history-active .leaflet-container {
  display: none !important;
}

#patch107HistoryWorkspace {
  position: fixed;
  left: 0;
  right: 0;
  top: 64px;
  bottom: 0;
  z-index: 9800;
  overflow: auto;
  padding: 18px;
  background: linear-gradient(180deg, rgba(2,6,23,.98), rgba(15,23,42,.98));
  color: #e5eefb;
}

#patch107HistoryWorkspace[hidden] {
  display: none !important;
}

.patch107-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid rgba(148,163,184,.25);
  background: rgba(15,23,42,.76);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.patch107-header h1 {
  margin: 0 0 6px 0;
  font-size: 26px;
  color: #f8fafc;
}

.patch107-header p,
.patch107-muted {
  color: #cbd5e1;
  margin: 0;
  font-size: 13px;
}

.patch107-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.patch107-actions button,
.patch107-actions select {
  background: rgba(30,41,59,.95);
  color: #e5eefb;
  border: 1px solid rgba(148,163,184,.35);
  border-radius: 8px;
  padding: 8px 11px;
}

.patch107-actions label {
  color: #cbd5e1;
  font-size: 12px;
}

.patch107-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.patch107-grid div,
.patch107-card {
  background: rgba(15,23,42,.76);
  border: 1px solid rgba(148,163,184,.24);
  border-radius: 12px;
  padding: 12px;
}

.patch107-grid b,
.patch107-grid span {
  display: block;
}

.patch107-grid b {
  color: #f8fafc;
  font-size: 13px;
}

.patch107-grid span {
  color: #cbd5e1;
  margin-top: 4px;
}

.patch107-card {
  margin: 12px 0;
}

.patch107-card h2 {
  margin: 0 0 8px 0;
  color: #f8fafc;
  font-size: 18px;
}

.patch107-table-wrap {
  max-height: 460px;
  overflow: auto;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 10px;
}

.patch107-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.patch107-table th,
.patch107-table td {
  padding: 7px 9px;
  border-bottom: 1px solid rgba(148,163,184,.13);
  text-align: left;
  white-space: nowrap;
}

.patch107-table th {
  position: sticky;
  top: 0;
  background: rgba(15,23,42,.98);
  color: #f8fafc;
  z-index: 1;
}

@media (max-width: 900px) {
  #patch107HistoryWorkspace { top: 92px; padding: 10px; }
  .patch107-header { flex-direction: column; }
  .patch107-grid { grid-template-columns: 1fr 1fr; }
}


/* patch108: Netatmo rain card */
.patch108-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin: 8px 0 10px 0; }
.patch108-grid div { background: rgba(15,23,42,.45); border: 1px solid rgba(148,163,184,.18); border-radius: 10px; padding: 8px; }
.patch108-grid b, .patch108-grid span { display: block; }
.patch108-grid span { color: #cbd5e1; font-size: 12px; margin-top: 2px; }

/* patch111 removed patch110 CSS */

/* patch112 removed old Soil map CSS */

/* patch113 removed old Soil map CSS */

/* patch113: Soil map uses sidebar/active-points truth */
.patch113-soil-divicon {
  background: transparent !important;
  border: 0 !important;
  pointer-events: auto;
}

.patch113-soil-label {
  background: rgba(15, 23, 42, .96);
  color: #f8fafc;
  border: 1px solid rgba(34, 197, 94, .92);
  border-radius: 9px;
  padding: 4px 8px;
  min-width: 58px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.38);
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  line-height: 1.1;
}

.patch113-soil-name {
  font-size: 12px;
  font-weight: 800;
}

.patch113-soil-pct {
  font-size: 16px;
  font-weight: 900;
  color: #bbf7d0;
}


/* patch122: rawlog — full width, map hidden */
#app.rawlog-active {
  grid-template-columns: 1fr;
}
#app.rawlog-active main {
  display: none !important;
}
#app.rawlog-active #sidebar {
  max-width: 100%;
  width: 100%;
  overflow-y: auto;
}

.p122-rawlog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.p122-rawlog-header h2 { margin: 0 0 2px 0; }
.p122-status { font-size: 13px; color: #94a3b8; }

.p122-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.p122-controls input[type=text] {
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  width: 220px;
  outline: none;
}
.p122-controls input[type=text]:focus { border-color: #38bdf8; }
.p122-auto-label {
  font-size: 13px;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.p122-table-wrap {
  overflow-y: auto;
  max-height: calc(100vh - 160px);
}
.p122-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.p122-table th {
  position: sticky;
  top: 0;
  background: #1e293b;
  padding: 6px 8px;
  text-align: left;
  color: #94a3b8;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid #334155;
  z-index: 1;
}
.p122-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(51,65,85,.5);
  vertical-align: top;
}
.p122-table tbody tr:hover td { background: rgba(255,255,255,.03); }

.p122-type-soil td { border-left: 3px solid #22c55e; }
.p122-type-vann td { border-left: 3px solid #38bdf8; }
.p122-type-generic td { border-left: 3px solid #475569; }

.p122-ts {
  color: #64748b;
  white-space: nowrap;
  font-family: monospace;
  font-size: 11px;
}
.p122-dev {
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
}
.p122-type-soil .p122-dev { color: #4ade80; }
.p122-type-vann .p122-dev { color: #38bdf8; }

.p122-badge {
  display: inline-block;
  background: #1e293b;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  color: #64748b;
  white-space: nowrap;
}
.p122-type-soil .p122-badge { color: #22c55e; }
.p122-type-vann .p122-badge { color: #38bdf8; }

.p122-src { color: #475569; font-size: 11px; white-space: nowrap; }

.p122-payload {
  color: #94a3b8;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  cursor: pointer;
  word-break: break-all;
  display: block;
  max-width: 480px;
}
.p122-payload:hover { color: #e2e8f0; }
.p122-payload.expanded {
  white-space: pre-wrap;
  background: #0f172a;
  border-radius: 4px;
  padding: 6px;
  cursor: default;
  max-width: none;
}

.p122-empty {
  color: #475569;
  padding: 40px 0;
  text-align: center;
  font-size: 14px;
}

@media (max-width: 850px) {
  .p122-src { display: none; }
  .p122-controls input[type=text] { width: 140px; }
}
