/* MARONDERACONNECT STYLES
   Green and white council theme. No images except the logo.
   The logo also appears as a faint watermark behind every screen. */

:root {
  --green: #146c43;
  --green-dark: #0d4d2e;
  --green-light: #e6f3ec;
  --bg: #f4faf6;
  --card: #ffffff;
  --line: #d6e8dd;
  --text: #15241b;
  --muted: #5a7568;
  --red: #c0392b;
  --amber: #e0a800;
  --blue: #2f6fd6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 15px;
}

h1, h2, h3, h4 { color: var(--green-dark); margin: 0 0 8px 0; }
h2 { font-size: 24px; }
p { line-height: 1.5; }

/* ---------- logo watermark ---------- */

.watermark-bg, #appScreen::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("../assets/logo.png") center 42% no-repeat;
  background-size: 52%;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}

#authScreen { position: relative; }
.login-wrap { position: relative; z-index: 1; }

/* ---------- header ---------- */

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(90deg, var(--green-dark), var(--green));
  color: #fff;
  padding: 10px 18px;
  position: relative;
  z-index: 2;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.brand b { display: block; font-size: 15px; }
.brand span { font-size: 12px; opacity: 0.85; }

.header-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: 13px; }

/* ---------- login screen ---------- */

.login-wrap {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 14px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 34px rgba(13, 77, 46, 0.12);
  padding: 28px;
  width: 420px;
  max-width: 96vw;
}
.login-card.wide { width: 640px; }
.login-card h1 { font-size: 22px; text-align: center; }
.motto { text-align: center; color: var(--green); font-style: italic; font-weight: 700; letter-spacing: 0.5px; margin: 2px 0 0 0; font-size: 13.5px; }
.tagline { text-align: center; color: var(--muted); margin-top: 4px; }
.login-logo { display: block; margin: 0 auto 10px auto; width: 84px; height: 84px; object-fit: contain; }
.login-logo.small { width: 60px; height: 60px; }

.tabs { display: flex; gap: 6px; margin: 14px 0; }
.tab {
  flex: 1; padding: 9px 6px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--muted); cursor: pointer; font-weight: 600;
}
.tab.active { background: var(--green); border-color: var(--green); color: #fff; }

.demo-box {
  margin-top: 16px; font-size: 11.5px; color: var(--muted);
  background: var(--green-light); border-radius: 8px; padding: 8px 10px; line-height: 1.6;
}

.link-btn {
  background: none; border: none; color: var(--green); cursor: pointer;
  margin-top: 12px; font-size: 13px; text-decoration: underline; width: 100%;
}

/* ---------- layout ---------- */

.layout { display: flex; min-height: calc(100vh - 64px); position: relative; z-index: 1; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--green-dark), var(--green));
  padding: 14px 10px;
}

.side-user {
  color: #fff; font-weight: 700; padding: 6px 10px 14px 10px; border-bottom: 1px solid rgba(255,255,255,0.25);
  margin-bottom: 10px; font-size: 14px;
}
.side-user span { display: block; font-weight: 400; font-size: 12px; opacity: 0.85; }

.nav-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; color: #dff0e6;
  padding: 11px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.12); }
.nav-item.active { background: #fff; color: var(--green-dark); font-weight: 700; }

.content { flex: 1; padding: 22px; min-width: 0; }

/* ---------- cards, stats, grids ---------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; box-shadow: 0 2px 8px rgba(21, 36, 27, 0.05);
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; text-align: center;
}
.stat-card b { display: block; font-size: 26px; color: var(--green); }
.stat-card.danger b { color: var(--red); }
.stat-card span { color: var(--muted); font-size: 12.5px; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.row2 { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.row2 > * { flex: 1; min-width: 140px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 18px; }
.mb8 { margin-bottom: 12px; } .ml8 { margin-left: 8px; }
.full { width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, monospace; font-size: 13px; }
.warn-card { border-left: 5px solid var(--amber); }
.danger-card { border-left: 5px solid var(--red); }
.alert-card { border-left: 5px solid var(--red); }

.demo-note { font-size: 12.5px; color: var(--muted); background: var(--green-light); border-radius: 8px; padding: 8px 10px; }
.warn-note { font-size: 13px; color: #7a2020; background: #fdeaea; border-radius: 8px; padding: 8px 10px; }
.ok-note { font-size: 13px; color: var(--green-dark); background: var(--green-light); border-radius: 8px; padding: 8px 10px; }

/* ---------- AI insight lists (staff dashboards) ---------- */

.insight-list { list-style: none; margin: 0; padding: 0; }
.insight-list li { margin-bottom: 6px; border-radius: 8px; }
.insight-list li:last-child { margin-bottom: 0; }
.alert-card .btn, .warn-card .btn { margin-left: 6px; }

/* ---------- forms ---------- */

.label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 12px 0 4px 0; }
.input, .select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--text);
}
.input:focus, .select:focus { outline: 2px solid rgba(20, 108, 67, 0.35); border-color: var(--green); }
.select.small { width: auto; padding: 6px 8px; font-size: 13px; }
textarea.input { resize: vertical; }

.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin: 4px 10px 4px 0; }

/* ---------- buttons ---------- */

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--green); background: #fff; color: var(--green);
  font-size: 14px; font-weight: 600;
}
.btn:hover { background: var(--green-light); }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; }
.table th {
  text-align: left; background: var(--green-light); color: var(--green-dark);
  padding: 9px 10px; font-size: 13px; border-bottom: 2px solid var(--line);
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.click-row { cursor: pointer; }
.click-row:hover td { background: #f2f9f5; }

.details-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 6px; }
.details-table td { border: 1px solid var(--line); padding: 7px 9px; }
.details-table td:first-child { background: var(--green-light); font-weight: 700; width: 38%; color: var(--green-dark); }

/* ---------- badges ---------- */

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; vertical-align: middle;
}
.badge.pending { background: #eef1ef; color: #5a6b62; }
.badge.acknowledged { background: #e3edfb; color: var(--blue); }
.badge.action { background: #fdf3d7; color: #a97b00; }
.badge.solved { background: #e2f3e8; color: var(--green); }
.badge.escalated { background: #fdeaea; color: var(--red); }
.badge.int-low { background: #e2f3e8; color: var(--green); }
.badge.int-med { background: #fdf3d7; color: #a97b00; }
.badge.int-high { background: #fdeaea; color: var(--red); }

/* ---------- stage chips ---------- */

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; padding: 4px 9px; border-radius: 14px; border: 1px solid var(--line);
  color: var(--muted); background: #fff;
}
.chip.done { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.chip.current { border: 2px solid var(--blue); color: var(--blue); font-weight: 700; }
.chip.locked { border-style: dashed; opacity: 0.65; }

.progress-track { background: #e4ede8; border-radius: 10px; height: 12px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), #22a45d); border-radius: 10px; }

/* ---------- maps ---------- */

.big-map { height: 470px; border-radius: 12px; border: 1px solid var(--line); z-index: 1; }
.mini-map { height: 250px; border-radius: 10px; border: 1px solid var(--line); margin-top: 8px; }
.map-toolbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 13.5px; }
.map-toolbar label { display: inline-flex; align-items: center; gap: 5px; }

.legend { margin-top: 12px; font-size: 13px; }
.legend div { margin: 4px 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.ring { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 3px solid var(--green); margin-right: 6px; vertical-align: middle; }
.stand-label span { background: rgba(255,255,255,0.92); border: 1px solid #146c43; border-radius: 3px; padding: 0 3px; font-size: 10px; font-weight: 700; color: #0d4d2e; white-space: nowrap; line-height: 14px; display: inline-block; }

/* ---------- photos ---------- */

.photo-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* Photographs carried by a council notice. Wider than a report thumbnail,
   because a notice is read on its own and the picture is usually the point. */
.thumb-row {
  display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0;
}
.thumb-row img {
  width: 150px; height: 110px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
.thumb-row.large img { width: 100%; max-width: 420px; height: 200px; }
.thumb-row.large { margin: 14px 0; }

.urgent-card {
  border-left: 5px solid var(--danger, #b03a2e);
  background: #fff6f4;
}
.urgent-card h4 { margin: 6px 0 4px; }

/* ---------- attribute tables ---------- */

/* The column chooser sits under the toolbar and is only shown on request, so
   the table itself is not pushed off the screen. */
.col-picker {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  padding: 10px 12px; margin: 10px 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.col-picker label { font-size: 12.5px; white-space: nowrap; cursor: pointer; }

/* A council table can hold long text, so the numbers stay in a column instead
   of stretching the row and pushing the other attributes off the screen. */
.attr-table { font-size: 12.5px; }
.attr-table th, .attr-table td {
  white-space: nowrap; max-width: 240px;
  overflow: hidden; text-overflow: ellipsis;
}
.attr-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg); text-align: left;
}
.attr-table tbody tr:nth-child(even) { background: rgba(20, 108, 67, 0.035); }

#smTableCard.hidden { display: none; }

/* ---------- chat ---------- */

.chat-log { height: 340px; overflow-y: auto; padding: 8px; background: var(--bg); border-radius: 10px; }
.chat-bubble {
  max-width: 78%; padding: 9px 12px; border-radius: 12px; margin: 6px 0;
  font-size: 13.5px; white-space: pre-wrap;
}
.chat-bubble.bot { background: #fff; border: 1px solid var(--line); }
.chat-bubble.me { background: var(--green); color: #fff; margin-left: auto; }

/* ---------- memos, meetings, replies ---------- */

.memo-box, .meeting-box { border-left: 4px solid var(--green); background: #f7fbf9; border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.meeting-box { border-left-color: var(--blue); }
.reply-box { background: var(--green-light); border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-size: 13.5px; }

/* ---------- modal and toast ---------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(13, 32, 22, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal {
  background: #fff; border-radius: 14px; width: 540px; max-width: 94vw;
  max-height: 86vh; overflow-y: auto; padding: 18px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed; right: 18px; bottom: 18px; background: var(--green-dark); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 14px; z-index: 300;
  opacity: 0; transform: translateY(12px); transition: all 0.25s; max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.stand-label span { background: rgba(255,255,255,0.92); border: 1px solid #146c43; border-radius: 3px; padding: 0 3px; font-size: 10px; font-weight: 700; color: #0d4d2e; white-space: nowrap; }
.pick-pulse { width: 22px; height: 22px; border-radius: 50%; background: #146c43; border: 3px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.35); position: relative; }
.pick-pulse::after { content:""; position:absolute; inset:-10px; border-radius:50%; border:2px solid #146c43; animation: pulse-ring 1.6s ease-out infinite; }
.pick-halo { stroke: #146c43; stroke-opacity:0.18; fill:#146c43; fill-opacity:0.12; }
.digit-vertex { width:24px; height:24px; background:#c0392b; border:2px solid #fff; border-radius:50%; color:#fff; font-size:11px; font-weight:800; display:flex; align-items:center; justify-content:center; box-shadow:0 2px 8px rgba(0,0,0,0.35); }
.digit-boundary { filter: drop-shadow(0 2px 6px rgba(192,57,43,0.45)); }
@keyframes pulse-ring { 0%{transform:scale(0.6);opacity:0.7}100%{transform:scale(1.9);opacity:0} }
.leaflet-tooltip.stand-tip { background: rgba(255,255,255,0.95); border:1px solid #146c43; color:#0d4d2e; font-weight:700; font-size:10px; padding:1px 5px; border-radius:4px; }

/* Cadastre map: tick-box panel beside the map */
.map-split{display:grid;grid-template-columns:290px 1fr;gap:12px;align-items:start}
.map-side{max-height:640px;overflow:auto;background:#fff;border:1px solid #dde5e0;border-radius:10px;padding:12px}
.map-side h3{margin:0 0 8px;font-size:14px}
.map-main{min-width:0}
.layer-group{margin-bottom:12px}
.layer-group>b{display:block;font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:#5a7568;margin:6px 0 4px}
.layer-row{display:flex;align-items:center;gap:6px;padding:3px 0;font-size:12.5px;cursor:pointer;line-height:1.3}
.layer-row:hover{background:#f2f7f4;border-radius:4px}
.layer-row .swatch{width:11px;height:11px;border-radius:3px;flex:0 0 11px;border:1px solid rgba(0,0,0,.15)}
.mini-table{margin-top:6px;font-size:11.5px;border-collapse:collapse;width:100%}
.mini-table th{text-align:left;padding:2px 6px 2px 0;color:#5a7568;font-weight:600;vertical-align:top;white-space:nowrap}
.mini-table td{padding:2px 0;word-break:break-word}
@media (max-width:820px){.map-split{grid-template-columns:1fr}.map-side{max-height:280px}}

/* ---------- the sheet when a second window is blocked ---------- */

.print-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: #eef2ef; overflow: auto; padding: 0 0 40px;
}
.print-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; background: #0d4d2e; color: #fff;
}
.print-bar b { font-size: 15px; }
.print-sheet {
  width: 210mm; min-height: 290mm; margin: 16px auto; padding: 14mm;
  box-sizing: border-box; background: #fff; color: #15241b;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.18);
  position: relative; font-family: Arial, Helvetica, sans-serif;
}
.print-sheet .watermark { position: absolute; top: 38%; left: 22%; width: 60%; opacity: .06; z-index: 0; }
.print-sheet .content { position: relative; z-index: 1; }
.print-sheet table.details { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.print-sheet table.details td { border: 1px solid #cfe3d7; padding: 6px 8px; }
.print-sheet table.details td:first-child { background: #eef7f1; font-weight: bold; width: 34%; }
.print-sheet .doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #146c43; padding-bottom: 8px; }
.print-sheet .doc-head img { width: 78px; height: 78px; object-fit: contain; }
.print-sheet .doc-head .mid { text-align: center; }
.print-sheet .doc-head .mid h2 { margin: 0; color: #146c43; font-size: 20px; }
.print-sheet .doc-head .mid small { color: #40604f; }
.print-sheet .doc-id { font-family: monospace; font-weight: bold; font-size: 15px; border: 2px solid #146c43; padding: 6px 10px; color: #0e4f30; }
.print-sheet .stripes { height: 44px; margin-top: 16px; background: repeating-linear-gradient(90deg, #146c43 0, #146c43 2px, transparent 2px, transparent 6px); }
.print-sheet .foot { margin-top: 14px; font-size: 11px; color: #5a7568; text-align: center; }
.print-sheet table.table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 8px; }
.print-sheet table.table th, .print-sheet table.table td { border: 1px solid #cfe3d7; padding: 4px 6px; text-align: left; }
.print-sheet table.table th { background: #eef7f1; }

/* Only the sheet reaches the paper. */
@media print {
  body > *:not(.print-overlay) { display: none !important; }
  .print-overlay { position: static; background: #fff; padding: 0; overflow: visible; }
  .print-bar { display: none !important; }
  .print-sheet { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
}

/* ---------- the legend on the map ---------- */

/* The legend sits over the map, so it has to be readable on a street map and
   a satellite image as well as on a plain background. */
.legend {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin: 12px 0 0;
}
.legend .row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.legend-rows { margin-top: 6px; }
.legend-row {
  display: flex; align-items: center; gap: 9px;
  padding: 3px 0; font-size: 13px;
  border-top: 1px solid rgba(13, 77, 46, .08);
}
.legend-row:first-child { border-top: 0; }
.legend-row .key { flex: 0 0 auto; }
.legend-row .key-label { flex: 1 1 auto; min-width: 0; }
.legend-row .key-count { flex: 0 0 auto; font-size: 11.5px; color: var(--muted, #5a7568); }
.legend-row.legend-empty { opacity: .55; }
.legend .key-img { width: 24px; height: 24px; object-fit: contain; }

.map-toolbar label.grow { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; }
.map-toolbar label.grow input { flex: 1 1 auto; max-width: 340px; }

/* ============================================================
   PHONE AND TABLET
   The app is built desktop-first. On a small screen the sidebar
   stops being a column beside the content and becomes a single
   strip of scrollable buttons above it, fields go full width,
   and maps, tables and modals shrink to fit. Nothing here
   changes the desktop layout.
   ============================================================ */

@media (max-width: 860px) {

  html, body { font-size: 15px; -webkit-text-size-adjust: 100%; }

  /* the sidebar becomes one scrollable strip of buttons, kept reachable */
  .layout { flex-direction: column; min-height: auto; }
  .sidebar {
    width: 100%; flex: none;
    display: flex; flex-wrap: nowrap; align-items: center;
    gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 8px 10px;
    position: sticky; top: 0; z-index: 60;
  }
  .sidebar::-webkit-scrollbar { height: 0; }
  .side-user {
    flex: 0 0 auto; white-space: nowrap;
    border-bottom: 0; border-right: 1px solid rgba(255, 255, 255, 0.3);
    padding: 4px 10px 4px 4px; margin: 0 4px 0 0; font-size: 13px;
  }
  .side-user span { display: none; }
  .nav-item {
    flex: 0 0 auto; width: auto; margin: 0; white-space: nowrap;
    padding: 9px 12px; font-size: 13.5px;
  }

  .content { padding: 14px 12px; width: 100%; overflow-wrap: anywhere; }
  .content h2, h2 { font-size: 19px; }
  h3 { font-size: 16px; }
  .mt16 { margin-top: 12px; }
  .mt12 { margin-top: 10px; }

  /* header shrinks and wraps instead of squeezing */
  #header { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
  .brand img { width: 34px; height: 34px; }
  .brand b { font-size: 14px; }
  .brand span { font-size: 11px; }
  .header-right { flex-wrap: wrap; gap: 8px; }
  .who { font-size: 12px; }

  /* login */
  .login-wrap { min-height: auto; padding: 20px 10px; }
  .login-card { padding: 20px 16px; border-radius: 12px; }
  .login-card.wide { width: 100%; }
  .login-card h1 { font-size: 19px; }

  /* cards and stats */
  .card { padding: 13px; border-radius: 10px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
  .stat-card { padding: 10px 8px; }
  .stat-card b { font-size: 21px; }
  .stat-card span { font-size: 11.5px; }
  .chart-grid { gap: 10px; }
  canvas { max-width: 100%; }

  /* forms: full width, and 16px inputs so iOS does not zoom on focus */
  .input, .select, textarea.input { font-size: 16px; padding: 10px 12px; }
  .row2 { flex-direction: column; gap: 8px; }
  .row2 > * { min-width: 100%; }
  .label { margin: 10px 0 4px 0; font-size: 13px; }
  .check-inline { margin: 6px 12px 6px 0; }

  /* buttons sized for a finger */
  .btn { padding: 11px 15px; min-height: 42px; font-size: 14.5px; }
  .btn.small { padding: 8px 11px; min-height: 36px; }
  .alert-card .btn, .warn-card .btn { margin-left: 0; margin-top: 6px; }

  /* tables stay inside the card and scroll, with tighter padding */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table th, .table td { padding: 7px 8px; font-size: 12.5px; }
  .attr-table { font-size: 12px; }
  .attr-table th, .attr-table td { max-width: 170px; }
  .details-table { font-size: 12.5px; }
  .details-table td { padding: 6px 7px; }
  .details-table td:first-child { width: 40%; }
  .mini-table { font-size: 11px; }

  /* ---- the map screens ---- */
  /* The map comes first and the layer list sits under it, expanded, so
     nothing above the fold is a scrolling box. */
  .map-split { display: flex; flex-direction: column; gap: 10px; }
  .map-main { order: 1; width: 100%; }
  .map-side { order: 2; width: 100%; max-height: none; overflow: visible; }
  .map-side h3 { margin: 0 0 6px; }
  .layer-row { padding: 8px 0; font-size: 13.5px; align-items: flex-start; }
  .layer-row input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; }
  .layers-toggle { display: block; }

  .big-map { height: 56vh; min-height: 300px; }
  .mini-map { height: 200px; }
  .map-toolbar { gap: 8px 12px; font-size: 12.5px; }
  .map-toolbar label.grow { flex-basis: 100%; }
  .map-toolbar label.grow input { max-width: none; }
  .map-toolbar .btn.small { flex: 0 0 auto; }

  /* Leaflet furniture sized for a phone */
  .leaflet-popup-content-wrap { max-width: 76vw; }
  .leaflet-popup-content { margin: 10px 12px; font-size: 13px; }
  .leaflet-control-attribution { font-size: 9.5px; }
  .leaflet-touch .leaflet-control-zoom a { width: 34px; height: 34px; line-height: 34px; }

  /* chat */
  .chat-log { height: 260px; }
  .chat-bubble { max-width: 86%; font-size: 13px; }

  /* modals become near-full screen sheets */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100vw; max-width: 100vw; max-height: 92dvh;
    border-radius: 14px 14px 0 0; padding: 14px;
  }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; }
  .modal-head { flex-wrap: wrap; gap: 8px; }

  /* photos */
  .thumb { width: 72px; height: 72px; }
  .thumb-row img { width: 116px; height: 88px; }
  .thumb-row.large img { width: 100%; height: 160px; }

  /* notices and chips */
  .chip { font-size: 10.5px; padding: 3px 8px; }
  .chip-row { gap: 4px; }
  .col-picker { gap: 4px 10px; padding: 8px 10px; }
  .col-picker label { font-size: 12px; }

  /* toasts span the screen */
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; text-align: center; }

  .print-bar { flex-wrap: wrap; gap: 8px; }
  .print-sheet { margin: 8px auto; padding: 6mm; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .tabs { gap: 4px; }
  .tab { font-size: 12.5px; padding: 8px 4px; }
  .tabs .tab { white-space: nowrap; }
  .legend { font-size: 12px; padding: 8px 10px; }
  .progress-track { height: 10px; }
  /* the signed-in name is already shown in the strip above */
  .who { display: none; }
  .big-map { height: 52vh; min-height: 280px; }
}