:root {
  /* House style: one brand colour for both bars (CueMaster uses its baize green). */
  --brand: #0b5cad;
  --brand-dark: #084785;
  --on-brand: #ffffff;
  --on-brand-muted: #a9c6e8;
  --bg: #f6f8fb;
  --card: #ffffff;
  --fg: #1a1a1a;
  --muted: #5b636e;
  --line: #dde3ea;
  --undecided: #d97706;
  --approved: #15803d;
  --refused: #c42b2b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); height: 100dvh; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand); color: var(--on-brand);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 19px; font-weight: 700; letter-spacing: .3px; margin: 0; }
.icon-btn {
  background: none; border: 0; color: var(--on-brand); padding: 8px 10px; border-radius: 8px;
  display: flex; align-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }

/* Views */
.views { position: relative; min-height: 0; }
.view { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; }

/* Bottom tab bar */
.tabbar {
  display: flex; background: var(--brand); border-top: 1px solid var(--brand-dark);
  padding-bottom: env(safe-area-inset-bottom); z-index: 1100;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; color: var(--on-brand-muted); padding: 7px 0 6px; font-size: 11px; font-weight: 600;
}
.tab svg .fillable { fill: none; }
.tab.active { color: var(--on-brand); }
.tab.active svg .fillable { fill: currentColor; fill-opacity: .28; }

/* Map legend panel */
.panel {
  position: absolute; left: 12px; bottom: 30px; z-index: 1000; max-width: min(340px, calc(100% - 24px));
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.14); font-size: .85rem;
}
.panel-head {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 5px; padding: 0;
  background: none; border: 0; color: inherit; text-align: left; font-size: inherit;
}
#status { flex: 1; font-weight: 600; }
.panel-head .chev { flex: none; color: var(--muted); transition: transform .15s; }
/* Collapsed: just the count line, the arrow pointing up to open it again. */
.panel.collapsed .legend { display: none; }
.panel.collapsed .panel-head { margin-bottom: 0; }
.panel.collapsed .chev { transform: rotate(180deg); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend b { margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; }
.dot {
  display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35);
}
.dot.undecided { background: var(--undecided); }
.dot.approved { background: var(--approved); }
.dot.refused { background: var(--refused); }
.dot.permitted { background: #bbf7d0; border-color: #15803d; }
.dot.major { width: 18px; height: 18px; margin: -3px; background: none; border: 2px solid #1f2937; box-shadow: 0 0 0 1px #fff; }
.kinds .kind-text { display: flex; flex-direction: column; gap: 1px; }
.kinds .kind-text b { font-weight: 600; }
.kinds .kind-text small { font-size: .8rem; line-height: 1.3; }
.kinds > p { margin: 10px 0; }

.locate-btn {
  width: 40px; height: 40px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: #fff; color: #333; border: 2px solid rgba(0,0,0,.2); border-radius: 6px;
}
.locate-btn:hover { background: #f4f4f4; }
.locate-btn.locating { color: #1a73e8; }
.locate-btn.locating svg { animation: locate-pulse 1s ease-in-out infinite; }
@keyframes locate-pulse { 50% { opacity: .35; } }

/* Settings */
.settings { overflow-y: auto; padding: 20px 16px 32px; }
.settings > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.settings h2 { font-size: 26px; margin: 0 auto 16px; }
.settings h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px auto 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.card p { margin: 10px 0; line-height: 1.45; font-size: .92rem; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.switch-row:last-child { border-bottom: 0; }
.switch-row > span { display: flex; align-items: center; gap: 9px; }
.switch-row input {
  appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; border-radius: 13px;
  background: #c9d1da; position: relative; transition: background .15s; cursor: pointer; margin: 0;
}
.switch-row input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s;
}
.switch-row input:checked { background: var(--brand); }
.switch-row input:checked::after { transform: translateX(18px); }
.switch-row input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.job { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.job:last-child { border-bottom: 0; }
.job b { display: block; margin-bottom: 2px; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.warn { color: var(--refused); }

/* Tip jar modal */
.modal {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--card); border-radius: 14px; padding: 18px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.modal-card h2 { font-size: 19px; margin: 6px 0; }
.modal-card p { margin: 0; font-size: 15px; }
.tip-link {
  margin: 16px 0 8px; padding: 11px 22px; border-radius: 8px; background: var(--brand);
  color: #fff; font-weight: 700; text-decoration: none;
}
.close-btn {
  margin-top: 14px; padding: 9px 22px; border-radius: 8px; border: 1px solid var(--line);
  background: none; color: var(--fg); font-weight: 600;
}

/* Alerts button, badge and sheet */
.top-actions { display: flex; align-items: center; }
.alerts-btn { position: relative; padding: 8px 14px; }
.qr-box { margin: 14px 0 8px; padding: 8px; background: #fff; border-radius: 8px; line-height: 0; }
.badge {
  position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px;
  background: var(--refused); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.sheet { max-width: 440px; align-items: stretch; text-align: left; max-height: calc(100dvh - 40px); }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.sheet-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.sheet-note { margin: 0 0 10px; line-height: 1.4; }
.alerts-list { overflow-y: auto; min-height: 0; flex: 1; }
.alert-row { display: flex; gap: 10px; background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; }
.alert-row.seen { opacity: .65; }
.alert-main { flex: 1; text-align: left; background: none; border: 0; padding: 0; color: var(--fg); display: flex; gap: 9px; }
.alert-main .dot { margin-top: 4px; }
.alert-title { font-weight: 600; font-size: .92rem; }
.alert-addr { font-size: .85rem; }
.alert-when { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.alert-del { background: none; border: 0; border-left: 1px solid var(--line); padding: 0 0 0 10px; font-size: 16px; }
.alerts-empty { color: var(--muted); font-size: .88rem; margin: 4px 0 8px; }
.alerts-earlier { font-size: .8rem; font-weight: 700; color: var(--muted); margin: 10px 0 6px; }

/* Buttons */
.primary-btn {
  padding: 11px 18px; border-radius: 8px; border: 0; background: var(--brand); color: #fff; font-weight: 700;
}
.primary-btn:disabled { opacity: .5; cursor: default; }
.secondary-btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--brand); background: none; color: var(--brand); font-weight: 600;
}
.wide { width: 100%; margin-top: 10px; }

/* Notifications card */
.notify .area-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-size: .92rem; }
#push-block { border-top: 1px solid var(--line); padding-bottom: 10px; }
#push-block .switch-row { border-bottom: 0; }

/* Area editing on the map */
.area-edit {
  position: absolute; top: 10px; left: 56px; right: 60px; z-index: 1000; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.area-edit p { margin: 0 0 8px; font-size: .88rem; }
.area-edit-buttons { display: flex; gap: 8px; }
.area-edit-buttons .primary-btn { flex: 1; padding: 9px 12px; }
.area-edit-buttons .close-btn { margin: 0; }
.radius-handle {
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 2px solid var(--brand); border-radius: 50%;
  color: var(--brand); font-size: 16px; font-weight: 700; line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: ew-resize; touch-action: none;
}

/* Popups */
.pop { font-size: .85rem; line-height: 1.4; max-width: min(280px, calc(100vw - 80px)); }
/* Leaflet's popup close (×): bigger, and an easier target for a finger. */
.leaflet-container a.leaflet-popup-close-button { width: 36px; height: 36px; font: 26px/34px system-ui, sans-serif; color: #555; }
.leaflet-container a.leaflet-popup-close-button:hover { color: #111; }
.pop .tag { display: inline-block; color: #fff; font-size: .72rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.pop .tag.undecided { background: var(--undecided); }
.pop .tag.approved { background: var(--approved); }
.pop .tag.refused { background: var(--refused); }
.pop .tag.permitted { background: #15803d; }
.pop .tag.major { background: #1f2937; margin-left: 4px; }
.pop h3 { font-size: .95rem; margin: 6px 0 2px; }
.pop .addr { color: var(--muted); margin: 0 0 6px; }
.pop .desc { margin: 0 0 6px; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; margin: 0 0 8px; }
.pop dt { color: var(--muted); }
.pop dd { margin: 0; }
.pop .deadline { font-weight: 600; margin: 0 0 8px; }
.pop .age { color: var(--muted); font-size: .75rem; margin: 6px 0 0; }
.leaflet-popup-content { max-height: var(--popup-max, 60vh); overflow-y: auto; overscroll-behavior: contain; }
.pop .drawings { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid var(--line); }
.pop .drawings p { margin: 4px 0 0; }
.pop .drawings .from { margin: 8px 0 0; font-size: .8rem; line-height: 1.35; }
.pop .outcome { display: inline-block; font-size: .72rem; font-weight: 600; padding: 0 5px; border-radius: 4px; background: #e5e7eb; color: #374151; white-space: nowrap; }
.pop .outcome.ok { background: #dcfce7; color: #166534; }
.pop .outcome.bad { background: #fee2e2; color: #991b1b; }
.pop .drawings ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
.pop .where { color: var(--muted); font-size: .8rem; margin: 8px 0 0; }
.pop .where a { white-space: nowrap; }
