/* AgriEnergy additions on top of the LTV design system (styles.css). */
.formgrid { display: grid; gap: 10px; }
.formgrid label { display: grid; gap: 4px; font-size: 13px; }
.formgrid .inp { width: 100%; }
.tbl-wrap { overflow-x: auto; }
.money-neg { color: var(--bad, #e5484d); font-weight: 700; }
.lst { display: grid; gap: 6px; }
.attn { padding: 8px 0; border-bottom: 1px solid rgba(128,128,128,.18); display: flex; justify-content: space-between; gap: 12px; }
.attn:last-child { border-bottom: 0; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.sec-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.sec-h h3 { margin: 0; }
.kvline { display: grid; grid-template-columns: 170px 1fr; gap: 4px 12px; font-size: 14px; }
.kvline .k { opacity: .65; }
.sql-ed { width: 100%; min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.fk { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.schema-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.schema-t { font-size: 12px; padding: 10px; }
.schema-t b { font-size: 13px; }
.schema-t div.c { display: flex; justify-content: space-between; gap: 8px; opacity: .85; }
.job { display: grid; gap: 8px; margin-bottom: 12px; }
.job .big { font-size: 17px; font-weight: 700; }
.job a.call { display: block; text-align: center; padding: 12px; }
.job .btn { min-height: 44px; }
.job-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 640px) { .kvline { grid-template-columns: 120px 1fr; } .cols2 { grid-template-columns: 1fr; } }

/* Left menu: tiles, two in a row */
.side { --tile: 1fr; }
.side nav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: start; padding: 4px 10px 12px; }
.side nav .grp { grid-column: 1 / -1; margin: 10px 4px 0; }
.side nav .nav { flex-direction: column; justify-content: center; gap: 4px; padding: 10px 4px; min-height: 66px; text-align: center; font-size: 12px; line-height: 1.2; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; }
.side nav .nav:hover { background: var(--glass-2); }
.side nav .nav .ic { font-size: 18px; width: auto; }
.side nav .nav.on { background: linear-gradient(135deg, var(--blue-s), var(--glass)); border-color: var(--rim); }

/* Table tools */
.tbl-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.tbl-tools .inp { width: auto; max-width: 190px; font-size: 13px; }
.tbl-tools input.inp { flex: 1 1 180px; max-width: 320px; }
.tbl-tools .muted { margin-left: auto; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
tr.click:focus-visible { outline: 2px solid var(--blue, #4566E8); outline-offset: -2px; }

/* Popup cards */
.modal.wide { width: min(1240px, 96vw) !important; max-width: 96vw !important; max-height: 94vh; display: flex; flex-direction: column; }
.modal.wide .modal-b { overflow-y: auto; }
.popup-card .page { padding: 0; max-width: none; }
.popup-card .cols2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
@media (max-width: 640px) { .modal.wide { width: 100vw !important; max-width: 100vw !important; height: 100dvh; max-height: 100dvh; border-radius: 0; } .popup-card .cols2 { grid-template-columns: 1fr; } }

/* Chat on the client card */
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; padding: 4px; }
.bub { max-width: 82%; padding: 8px 10px; border-radius: 12px; background: var(--glass-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.bub.out { align-self: flex-end; background: var(--blue-s, rgba(69,102,232,.2)); }
.bub.in { align-self: flex-start; }

/* Calendar */
.mcal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mcal-h { font-size: 11px; font-weight: 800; color: var(--muted); text-align: center; padding: 4px; }
.mcal-d { min-height: 92px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mcal-d.off { opacity: .45; }
.mcal-d.now { border-color: var(--blue, #4566E8); box-shadow: inset 0 0 0 1px var(--blue, #4566E8); }
.mcal-n { font-size: 12px; font-weight: 700; color: var(--ink2); }
.mcal-e { font: inherit; font-size: 11px; line-height: 1.3; text-align: left; border: 0; border-radius: 6px; padding: 2px 4px; background: var(--glass-2); color: var(--ink); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcal-e.done { opacity: .5; text-decoration: line-through; }
.mcal-e.hot { font-weight: 800; }
@media (max-width: 640px) { .mcal-d { min-height: 64px; } .mcal-e { font-size: 10px; } }

/* Charts: one hue per chart, text in ink tokens */
.viz { --viz: #2a78d6; --viz-on: #1c5cab; }
.hbars { --viz: #2a78d6; }
:root[data-theme="dark"] .viz, :root[data-theme="dark"] .hbars { --viz: #3987e5; --viz-on: #6aa6ee; }
.viz svg { width: 100%; height: auto; display: block; }
.viz-grid { stroke: var(--line); stroke-width: 1; }
.viz-axis { fill: var(--muted); font-size: 11px; }
.viz-bar { fill: var(--viz); }
.viz-bar.on { fill: var(--viz-on); }
.viz-tip { font-size: 13px; min-height: 20px; margin-top: 4px; color: var(--ink); }
.hbars { display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.hbar.click { cursor: pointer; }
.hbar-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink2); }
.hbar-t { height: 8px; border-radius: 0 4px 4px 0; background: var(--line); }
.hbar-f { height: 100%; border-radius: 0 4px 4px 0; background: var(--viz); }
.hbar-v { color: var(--ink); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* A popup is a solid sheet: glass over a table is unreadable */
.modal-bg { background: rgba(3, 5, 18, .72); }
.modal { background: var(--bg1) !important; backdrop-filter: none !important; }
.modal .card { background: var(--glass); backdrop-filter: none; }

/* Council 03.11: compact tiles, phone ergonomics, contrast */
.side nav .nav { min-height: 50px; padding: 6px 4px; gap: 2px; font-size: 11.5px; }
.side nav .nav .ic { font-size: 15px; }
.side nav .grp { margin: 6px 4px 0; font-size: 9.5px; }
.col-k.none { flex: 0 0 130px; min-width: 130px; opacity: .75; }
.dcard { flex-shrink: 0; }
.quick-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.viz-axis { font-size: 15px; }
.offline-note { margin-bottom: 10px; }
.job.today { border-color: var(--blue, #4566E8); }
.job-addr { display: block; padding: 6px 0; font-weight: 600; }
.job-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.job-photos img { width: 100%; height: 84px; object-fit: cover; border-radius: 8px; display: block; }
.job-photos .ph { font-size: 11px; display: grid; gap: 2px; }
.job-photos .ph.failed span { color: var(--red, #e5484d); }
.job-photo-btn { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; min-height: 44px; }
.agenda-d { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.agenda-d.now b { color: var(--blue, #4566E8); }
.agenda .mcal-e { font-size: 14px; padding: 8px; white-space: normal; }
:root[data-theme="light"] { --muted: #565E82; }
:root[data-theme="milk"] { --muted: #6A6558; }
:root[data-theme="light"] .btn, :root[data-theme="milk"] .btn { border-color: rgba(17, 22, 58, .22); }
@media (max-width: 760px) {
  .inp, select.inp, textarea.inp { font-size: 16px !important; min-height: 44px; }
  .btn, .btn.sm, .tabs button { min-height: 44px; }
  .x { min-width: 44px; min-height: 44px; }
  .modal.wide, .modal { margin: 0 !important; }
  .modal:not(.wide) { max-height: 100dvh; overflow-y: auto; }
  .modal-bg { align-items: stretch; padding: 0; }
  .popup-card .kpis { grid-template-columns: 1fr 1fr; gap: 6px; }
  .popup-card .kpi-v { font-size: 18px; }
  .tabs { flex-wrap: wrap; }
  .hello { display: none; }
}

/* Card popups 03.11: sections are small blocks that pack into columns, tables inside them are tiles */
.popup-card .cols2 { display: block; columns: 3 300px; column-gap: 12px; }
.popup-card .cols2 > * { break-inside: avoid; margin-bottom: 12px; display: block; width: 100%; }
.popup-card .card { padding: 12px 14px; border-radius: 14px; }
.popup-card .sec-h { margin-bottom: 8px; }
.popup-card .sec-h h3 { font-size: 14px; }
.popup-card .empty { padding: 2px 0; text-align: left; font-size: 13px; }
.popup-card .kpis { gap: 8px; }
.popup-card .kpi { padding: 10px 12px; }
.popup-card .kpi .kpi-v { font-size: 20px; }
.popup-card .page { gap: 12px; }
.popup-card h1 { font-size: 22px; }
.popup-card .kvline { grid-template-columns: 130px 1fr; font-size: 13px; }
.tiles { display: grid; gap: 6px; }
.tile { display: grid; gap: 3px; padding: 8px 10px; border-radius: 10px; background: var(--glass); border: 1px solid var(--line); cursor: pointer; font-size: 13px; min-width: 0; }
.tile:hover { background: var(--glass-2); }
.tile:focus-visible { outline: 2px solid var(--blue, #4566E8); outline-offset: -2px; }
.tile-t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tile-m { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--ink2); }
.tile-m i { font-style: normal; color: var(--muted); }
.tile-p { font-size: 12.5px; color: var(--ink2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tile-a { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tile-a:empty { display: none; }
@media (max-width: 640px) { .popup-card .cols2 { columns: 1; } }

/* Apple: browsers on macOS and iOS blink while scrolling when blurred, see-through layers sit inside the scrolling area over
   a moving colour field (each one re-samples what is behind it on every frame). There the blur stays only on the fixed sidebar
   and top bar, cards get a denser fill instead, and the field, the sheen and the glow stand still. */
:root[data-apple] .bgfield i { animation: none !important; will-change: auto; }
:root[data-apple] .card::before { display: none; }
:root[data-apple] .glow::after { animation: none; }
:root[data-apple] .side, :root[data-apple] .top {
  backdrop-filter: blur(var(--blur)) saturate(160%); -webkit-backdrop-filter: blur(var(--blur)) saturate(160%); }
:root[data-apple] .content, :root[data-apple] .content *, :root[data-apple] .search-res, :root[data-apple] .btn {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
:root[data-apple] .content .card, :root[data-apple] .content .col-k, :root[data-apple] .content .dcard {
  background: linear-gradient(135deg, color-mix(in srgb, var(--bg1) 82%, transparent), color-mix(in srgb, var(--bg1) 66%, transparent)); }
:root[data-apple] .search-res, :root[data-apple] .cal-head { background: var(--bg1); }
:root[data-apple] .content { overscroll-behavior: contain; }

.attn.done > span:first-child { text-decoration: line-through; opacity: .55; }

/* Comments on cards */
.comments { display: grid; gap: 8px; }
.cm-new { display: grid; gap: 6px; }
.cm-new .btn { justify-self: end; }
.cm-new .flex-l { justify-content: flex-end; }
.cm { padding: 8px 10px; border-radius: 10px; background: var(--glass); border: 1px solid var(--line); display: grid; gap: 4px; }
.cm-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 13px; }
.cm-a { margin-left: auto; display: flex; gap: 10px; }
.cm-b { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
