/* ---------- fonts ---------- */
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- tokens ---------- */
:root {
  --ink: #243545;          /* logo navy */
  --ink-hover: #30475c;
  --ink-deep: #1a2733;
  --sky: #4ac0e8;          /* logo sky */
  --sky-ink: #11709a;      /* sky dark enough for text on white */
  --sky-wash: #e7f6fc;
  --sky-line: #bfe5f4;
  --paper: #ffffff;
  --wash: #f2f6f8;
  --line: #dde5eb;
  --muted: #5a6b79;
  --danger: #c0392f;
  --danger-wash: #fbeceb;
  --warn: #9a5c00;
  --warn-wash: #fff3dc;
  --ok: #18734c;
  --ok-wash: #e3f4ec;
  --font: 'Plex Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --radius: 10px;
  --shadow-float: 0 2px 10px rgba(18, 32, 46, 0.22);

  /* roles that change between light and dark */
  --text: #243545;
  --surface: #ffffff;        /* top bar, side panel */
  --surface-2: #ffffff;      /* dialogs, menus, sign-in card */
  --input-bg: #ffffff;
  --primary: #243545;
  --primary-hover: #30475c;
  --on-primary: #ffffff;
  --on-danger: #ffffff;
  --danger-hover: #a83128;
  --sky-wash-hover: #d9f1fa;
  --ok-wash-hover: #d2eee1;
  --placeholder: #5f6f7c;
  --auth-bg: #243545;
  --pop-shadow: 0 12px 32px rgba(18, 32, 46, 0.18);
  --modal-shadow: 0 24px 64px rgba(10, 20, 30, 0.35);
  --backdrop: rgba(18, 30, 42, 0.5);
  --toast-bg: #1a2733;
  --grab: #c9d4dc;
  --map-ctrl-bg: #ffffff;
  --scale-bg: rgba(255, 255, 255, 0.8);
  color-scheme: light;
}

/* Dark is the default (set in js/theme-init.js before the page draws). */
:root[data-theme='dark'] {
  --text: #e4ecf2;
  --muted: #93a5b4;
  --surface: #15202a;
  --surface-2: #1b2833;
  --input-bg: #0f1820;
  --wash: #1f2d39;
  --line: #2a3a47;
  --primary: #4ac0e8;
  --primary-hover: #74d0ef;
  --on-primary: #0d1c27;
  --sky-ink: #7fd3f0;
  --sky-wash: rgba(74, 192, 232, 0.13);
  --sky-wash-hover: rgba(74, 192, 232, 0.22);
  --sky-line: rgba(74, 192, 232, 0.35);
  --danger: #ff7b70;
  --danger-wash: rgba(255, 123, 112, 0.12);
  --danger-hover: #ff958c;
  --on-danger: #2a0d0a;
  --warn: #f2b45a;
  --warn-wash: rgba(242, 180, 90, 0.13);
  --ok: #5fd39c;
  --ok-wash: rgba(95, 211, 156, 0.13);
  --ok-wash-hover: rgba(95, 211, 156, 0.22);
  --placeholder: #8495a3;
  --auth-bg: #0e1720;
  --pop-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --modal-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  --backdrop: rgba(3, 8, 12, 0.65);
  --toast-bg: #2a3d4e;
  --grab: #3a4b59;
  --map-ctrl-bg: #1b2833;
  --scale-bg: rgba(21, 32, 42, 0.85);
  --shadow-float: 0 2px 10px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* each logo file is drawn for one background */
:root[data-theme='dark'] .logo-light, :root:not([data-theme='dark']) .logo-dark { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.has-modal { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--sky-ink); }
:focus-visible { outline: 3px solid rgba(74, 192, 232, 0.7); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }
[dir='rtl'] .flip { transform: scaleX(-1); }
.icon { width: 20px; height: 20px; flex: none; }

.app { min-height: 100dvh; }
.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot img { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid transparent; background: none;
  font-weight: 600; font-size: 15px; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn .icon { width: 18px; height: 18px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn--secondary { background: var(--sky-wash); color: var(--text); border-color: var(--sky-line); }
.btn--secondary:hover:not(:disabled) { background: var(--sky-wash-hover); }
.btn--ghost { color: var(--text); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { background: var(--wash); }
.btn--danger { background: var(--danger); color: var(--on-danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn--sm { height: 36px; padding: 0 12px; font-size: 14px; gap: 6px; }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: var(--radius);
  border: 0; background: transparent; color: var(--text); text-decoration: none;
}
.icon-btn:hover { background: var(--wash); }
.icon-btn--sm { width: 32px; height: 32px; }
.icon-btn--sm .icon { width: 17px; height: 17px; }
.icon-btn--danger { color: var(--danger); }
.icon-btn--danger:hover { background: var(--danger-wash); }
.icon-btn--wa { width: 36px; height: 36px; color: var(--ok); background: var(--ok-wash); border-radius: 50%; }
.icon-btn--wa:hover { background: var(--ok-wash-hover); }
.icon-btn--wa .icon { width: 18px; height: 18px; }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 0;
  border: 0; background: none; color: var(--sky-ink); font-weight: 600; font-size: 14.5px;
}
.link-btn .icon { width: 18px; height: 18px; }
.link-btn--muted { color: var(--muted); font-weight: 500; font-size: 13.5px; }

.chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chip--ok { background: var(--ok-wash); color: var(--ok); }
.chip--warn { background: var(--warn-wash); color: var(--warn); }
.chip--muted { background: var(--wash); color: var(--muted); }

.spinner {
  display: inline-block; width: 16px; height: 16px; flex: none;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; min-width: 0; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.req { color: var(--danger); margin-inline-start: 3px; }
.field input, .field select, .user-controls select {
  height: 46px; padding: 0 12px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--input-bg);
  font-size: 16px; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input::placeholder { color: var(--placeholder); }
.field input:focus, .field select:focus, .user-controls select:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(74, 192, 232, 0.28); }
[dir='rtl'] .field input[dir='ltr'] { text-align: right; }
[dir='rtl'] .field input[dir='ltr']::placeholder { text-align: right; }
.field-hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13.5px; color: var(--danger); font-weight: 500; }
.has-error input, .has-error select { border-color: var(--danger); }
.has-error input:focus { box-shadow: 0 0 0 3px rgba(192, 57, 47, 0.2); }
.field-row { display: flex; gap: 12px; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 500; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- auth screens ---------- */
.auth {
  position: relative; min-height: 100dvh; display: grid; place-items: center; padding: 72px 16px 32px;
  background-color: var(--auth-bg);
  /* the solar-panel grid from the logo leaves */
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 2px, transparent 2px);
  background-size: 46px 46px;
  background-position: center;
}
.auth-panel {
  width: 100%; max-width: 400px; background: var(--surface-2); border-radius: 18px;
  padding: 28px 28px 24px; box-shadow: 0 24px 60px rgba(8, 16, 24, 0.35);
}
.auth-logo { display: block; width: 116px; height: auto; margin: 0 auto 18px; }
.auth-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-intro { text-align: center; color: var(--muted); font-size: 14.5px; margin-bottom: 18px; }
.auth-form { margin-top: 18px; display: flex; flex-direction: column; }
.auth-form .btn--block { margin-top: 6px; }
.auth-form .form-error { margin-bottom: 10px; }
.auth-hint { margin-top: 16px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-signout { align-self: center; margin-top: 10px; color: var(--muted); }
.auth-tools { position: absolute; top: 16px; inset-inline-end: 16px; display: flex; gap: 8px; }
.auth-tools .lang-btn { color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.auth-tools .lang-btn:hover { background: rgba(255, 255, 255, 0.08); }

.lang-btn {
  display: inline-flex; align-items: center; height: 36px; padding: 0 8px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 14px;
  transition: background-color 0.2s;
}
.lang-btn:hover { background: var(--wash); }
.lang-btn .icon { width: 18px; height: 18px; }
/* Icon only; the name slides out on hover or keyboard focus. */
.pill-label {
  display: inline-block; max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0;
  transition: max-width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, margin 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (hover: hover) {
  .lang-btn:hover .pill-label { max-width: 160px; opacity: 1; margin-inline: 6px 4px; }
}
.lang-btn:focus-visible .pill-label { max-width: 160px; opacity: 1; margin-inline: 6px 4px; }

/* ---------- shell ---------- */
.shell { display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  flex: none; height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 36px; height: 36px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-company { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.brand-app { margin: 0; font-size: 16.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px; padding-inline-end: 12px;
  border: 0; border-radius: 999px; background: transparent; text-align: start;
}
.user-btn:hover, .user-btn[aria-expanded='true'] { background: var(--wash); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 14px; text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta-name { font-weight: 600; font-size: 14px; }
.user-meta-role { font-size: 12.5px; color: var(--muted); }
.menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 250px; z-index: 30;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: var(--pop-shadow);
}
.menu-who { display: grid; gap: 1px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.menu-who strong { font-size: 15px; }
.menu-who span { font-size: 13px; color: var(--muted); }
[dir='rtl'] .menu-who span[dir='ltr'] { text-align: right; }
.menu [role='menuitem'] {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 10px;
  border: 0; border-radius: 8px; background: none; text-align: start; font-weight: 500;
}
.menu [role='menuitem']:hover, .menu [role='menuitem']:focus-visible { background: var(--wash); outline: none; }
.menu .icon { width: 18px; height: 18px; color: var(--muted); }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 384px minmax(0, 1fr); position: relative; }
.panel {
  display: flex; flex-direction: column; min-height: 0; background: var(--surface);
  border-inline-end: 1px solid var(--line); position: relative; z-index: 10;
}
.panel-inner, .list-view, .detail { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.panel-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.sheet-grab { display: none; }
.map-wrap { position: relative; min-width: 0; }
.map { position: absolute; inset: 0; background: #1c2a37; }

/* ---------- list ---------- */
.panel-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.search {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 12px;
  background: var(--wash); border: 1px solid transparent; border-radius: var(--radius);
}
.search:focus-within { background: var(--input-bg); border-color: var(--sky); box-shadow: 0 0 0 3px rgba(74, 192, 232, 0.25); }
.search .icon { color: var(--muted); width: 19px; height: 19px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font-size: 16px; outline: none; }
.search input::-webkit-search-cancel-button { appearance: none; }
.search input::placeholder { color: var(--placeholder); }
.panel-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; min-height: 36px; }
.count { font-size: 14px; color: var(--muted); font-weight: 500; }

.project-list { list-style: none; margin: 0; padding: 4px 0 24px; }
.project-row {
  position: relative; display: grid; gap: 2px; width: 100%; text-align: start;
  padding: 12px 16px; padding-inline-start: 40px; border: 0; background: none;
  border-bottom: 1px solid var(--wash);
}
.project-row::before {
  content: ''; position: absolute; inset-inline-start: 17px; top: 19px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--sky); box-shadow: 0 0 0 2.5px var(--surface), 0 0 0 3.5px var(--sky-line);
}
.project-row:hover { background: var(--wash); }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.row-name { font-weight: 600; font-size: 15.5px; line-height: 1.35; }
.row-date { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 36px 24px; text-align: center; color: var(--muted); display: grid; gap: 6px; }
.empty-title { color: var(--text); font-weight: 600; }

/* ---------- project detail ---------- */
.detail-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 10px; border-bottom: 1px solid var(--line); }
.detail-title { flex: 1; min-width: 0; font-size: 19px; font-weight: 700; line-height: 1.3; outline: none; }
.detail-actions { display: flex; gap: 2px; }
.detail-body { padding-bottom: 28px; }

.loc-card { padding: 16px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.coords { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
[dir='rtl'] .coords { text-align: right; }
.loc-source { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.loc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.people { padding: 4px 16px; border-bottom: 1px solid var(--line); }
.contact { padding: 12px 0; display: grid; gap: 2px; }
.contact + .contact { border-top: 1px solid var(--wash); }
.contact-role { font-size: 13px; color: var(--muted); font-weight: 500; }
.contact-name { font-size: 16px; font-weight: 600; }
.contact.is-empty .contact-name { font-size: 14.5px; }
.phone-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.phone-link {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--sky-wash); color: var(--text); font-weight: 600; font-size: 14.5px; text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.phone-link:hover { background: var(--sky-wash-hover); }
.phone-link .icon { width: 16px; height: 16px; color: var(--sky-ink); }

.visits { padding: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.section-head h3 { font-size: 16px; font-weight: 700; }
.visits-empty { font-size: 14px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.visit { position: relative; padding-inline-start: 26px; padding-bottom: 18px; }
.visit::before {
  content: ''; position: absolute; inset-inline-start: 4px; top: 8px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--text); box-shadow: 0 0 0 3px var(--sky-wash);
}
.visit::after {
  content: ''; position: absolute; inset-inline-start: 8px; top: 24px; bottom: 2px; width: 2px; background: var(--line);
}
.visit:last-child::after { display: none; }
.visit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.visit-date { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.visit-date .icon { width: 16px; height: 16px; color: var(--muted); }
.visit-actions { display: flex; gap: 2px; }
.visit-eng { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.visit-eng strong { font-weight: 600; font-size: 15.5px; }
.visit-job { font-size: 14px; color: var(--muted); }
.visit-by { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.added-by { padding: 0 16px; font-size: 13px; color: var(--muted); }

/* ---------- map pins ---------- */
.pin {
  width: 30px; height: 30px; padding: 0; border: 0; background: transparent;
  display: grid; place-items: center;
}
.pin-dot {
  grid-area: 1 / 1; width: 14px; height: 14px; border-radius: 50%; background: var(--sky);
  box-shadow: 0 0 0 3px #fff, 0 1px 8px 2px rgba(10, 20, 30, 0.55);
  transition: transform 0.15s;
}
.pin:hover .pin-dot { transform: scale(1.2); }
.pin-label {
  position: absolute; top: 50%; inset-inline-start: calc(100% - 4px); transform: translateY(-50%);
  display: none; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 8px; border-radius: 6px; pointer-events: none;
  background: rgba(26, 39, 51, 0.86); color: #fff; font-size: 12.5px; font-weight: 600; line-height: 1.25;
}
.pins-labelled .pin-label, .pin:hover .pin-label, .pin.is-selected .pin-label { display: block; }
.maplibregl-marker.is-selected { z-index: 5; }
.pin.is-selected .pin-dot, .picker-pin .pin-dot {
  width: 18px; height: 18px; background: var(--ink);
  box-shadow: 0 0 0 4px var(--sky), 0 0 0 6.5px #fff, 0 2px 12px 3px rgba(10, 20, 30, 0.5);
}
.pin.is-selected .pin-label { background: var(--ink); }
/* the signal arcs from the logo, sent out from the selected site */
.pin-signal { grid-area: 1 / 1; position: relative; width: 0; height: 0; pointer-events: none; }
.pin.is-selected .pin-signal::before, .pin.is-selected .pin-signal::after,
.picker-pin .pin-signal::before, .picker-pin .pin-signal::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--sky); transform: translate(-50%, -50%); opacity: 0;
  animation: signal 2.4s ease-out infinite;
}
.pin.is-selected .pin-signal::after, .picker-pin .pin-signal::after { animation-delay: 1.2s; }
@keyframes signal {
  0% { width: 18px; height: 18px; opacity: 0.95; }
  100% { width: 70px; height: 70px; opacity: 0; }
}
.picker-pin { width: 44px; height: 44px; display: grid; place-items: center; cursor: grab; }
.picker-pin:active { cursor: grabbing; }

/* The button is the marker MapLibre moves; never give it a transform transition (it would trail the map). */
.cluster { display: grid; place-items: center; border: 0; padding: 0; background: none; border-radius: 50%; }
.cluster-dot {
  display: grid; place-items: center; width: 100%; height: 100%; flex: none; border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; line-height: 1; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 4px rgba(74, 192, 232, 0.6), 0 2px 12px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s;
}
.cluster:hover .cluster-dot { transform: scale(1.08); }
.cluster--sm { width: 34px; height: 34px; }
.cluster--md { width: 42px; height: 42px; }
.cluster--md .cluster-dot { font-size: 15px; }
.cluster--lg { width: 52px; height: 52px; }
.cluster--lg .cluster-dot { font-size: 16px; }

/* ---------- map controls ---------- */
.maplibregl-map { font-family: var(--font); }
.maplibregl-ctrl-group { border-radius: var(--radius) !important; box-shadow: var(--shadow-float) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 38px !important; height: 38px !important; }
.maplibregl-ctrl-group .fit-btn { display: grid; place-items: center; color: var(--text); }
.maplibregl-ctrl-group .fit-btn .icon { width: 18px; height: 18px; }
/* The labels toggle sits under the Satellite option it belongs to (start side, so right in Arabic). */
.basemap-ctrl { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.basemap-seg {
  position: relative; isolation: isolate; display: flex; padding: 3px;
  background: var(--map-ctrl-bg); border-radius: var(--radius); box-shadow: var(--shadow-float);
}
/* the highlight that slides to the chosen map */
.basemap-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 0; z-index: -1; border-radius: 8px; background: var(--primary);
  transition: transform 0.34s cubic-bezier(0.3, 0.9, 0.3, 1), width 0.34s cubic-bezier(0.3, 0.9, 0.3, 1);
}
.basemap-thumb.no-anim { transition: none; }
.basemap-ctrl .basemap-seg button, .basemap-ctrl .basemap-labels {
  height: 32px; padding: 0 12px; border: 0; border-radius: 8px;
  font-weight: 600; font-size: 13.5px; color: var(--text); transition: color 0.25s, background-color 0.2s;
}
/* MapLibre darkens every control button on hover; these keep our own colours instead. */
.basemap-ctrl .basemap-seg button,
.basemap-ctrl .basemap-seg button:not(:disabled):hover { background-color: transparent; }
.basemap-ctrl .basemap-seg button[aria-pressed='false']:not(:disabled):hover { background-color: var(--wash); }
.basemap-ctrl .basemap-seg button[aria-pressed='true'] { color: var(--on-primary); }
.basemap-ctrl .basemap-labels {
  margin-inline-start: 3px; padding: 0 10px; text-align: center;
  background: var(--map-ctrl-bg); box-shadow: var(--shadow-float);
  transition: color 0.25s, background-color 0.2s, opacity 0.25s, transform 0.25s, visibility 0.25s;
}
.basemap-ctrl .basemap-labels:not(:disabled):hover { background-color: var(--wash); }
.basemap-ctrl .basemap-labels[aria-pressed='true'],
.basemap-ctrl .basemap-labels[aria-pressed='true']:not(:disabled):hover {
  background: linear-gradient(var(--sky-wash), var(--sky-wash)), var(--map-ctrl-bg);
  box-shadow: var(--shadow-float), inset 0 0 0 1px var(--sky-line);
}
.basemap-ctrl .basemap-labels[aria-pressed='false'] { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.basemap-ctrl .basemap-labels.is-hidden { opacity: 0; transform: translateY(-6px); visibility: hidden; pointer-events: none; }
.maplibregl-ctrl-attrib { font-size: 11px; direction: ltr; }
.maplibregl-ctrl-scale { border-color: var(--text); color: var(--text); background: var(--scale-bg); font-size: 11px; direction: ltr; }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: var(--backdrop); opacity: 0; transition: opacity 0.18s;
}
.modal-backdrop.is-open { opacity: 1; }
.modal {
  width: 100%; max-height: calc(100dvh - 48px); display: flex; flex-direction: column;
  background: var(--surface-2); border-radius: 16px; box-shadow: var(--modal-shadow);
  transform: translateY(8px); transition: transform 0.2s;
}
.is-open .modal { transform: none; }
.modal--sm { max-width: 440px; }
.modal--form { max-width: 640px; }
.modal--wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 14px 20px; padding-inline-start: 20px; padding-inline-end: 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; font-weight: 700; outline: none; }
.modal-body { padding: 20px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}
.modal-text { color: var(--text); font-size: 15px; }

/* ---------- project form ---------- */
.pform fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fgroup { margin-bottom: 22px !important; }
.fgroup > legend { padding: 0; margin-bottom: 10px; font-size: 15.5px; font-weight: 700; }
.fgroup-hint { font-size: 13.5px; color: var(--muted); margin: -4px 0 12px; }
.form-context { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 10px 12px; border-radius: var(--radius); background: var(--wash); font-weight: 600; }
.form-context .icon { color: var(--sky-ink); width: 18px; height: 18px; }

.picker { position: relative; height: 250px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #1c2a37; }
.picker-map { position: absolute; inset: 0; }
.picker-empty {
  position: absolute; inset-inline: 12px; bottom: 12px; z-index: 2; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius);
  background: rgba(26, 39, 51, 0.88); color: #fff; font-size: 14px; font-weight: 500;
}
.picker-empty .icon { color: var(--sky); width: 18px; height: 18px; }
.loc-buttons { display: flex; gap: 8px; margin-top: 10px; }
.loc-buttons .btn { flex: 1; }
.loc-buttons .btn.is-working { background: var(--ok); }
.link-row { display: flex; gap: 8px; margin-top: 10px; }
.link-row input {
  flex: 1; min-width: 0; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 16px; background: var(--input-bg);
}
.link-row input::placeholder { color: var(--placeholder); }
.link-row input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(74, 192, 232, 0.28); }
[dir='rtl'] .link-row input::placeholder { text-align: right; }
.loc-status { margin-top: 10px; display: grid; gap: 6px; }
.loc-status:empty { display: none; }
.loc-readout { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.loc-readout .coords { font-size: 15px; }
.loc-readout .loc-source { font-size: 13.5px; color: var(--muted); }
.loc-hint { font-size: 13px; color: var(--muted); }
.loc-warn { font-size: 13.5px; color: var(--warn); background: var(--warn-wash); padding: 8px 10px; border-radius: 8px; }
.loc-error { font-size: 14px; color: var(--danger); background: var(--danger-wash); padding: 10px 12px; border-radius: 8px; }
.loc-progress { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 500; color: var(--sky-ink); }
.fgroup--loc.has-error .picker { border-color: var(--danger); }
.fgroup--loc > .field-error { margin-top: 8px; }
.secondary-wrap { margin: -8px 0 18px; }
.secondary-fields .fgroup { margin-bottom: 4px !important; }

/* ---------- users admin ---------- */
.add-user > summary { list-style: none; display: inline-flex; width: auto; }
.add-user > summary::-webkit-details-marker { display: none; }
.add-user[open] > summary { background: var(--primary-hover); }
.add-user-form { margin-top: 12px; padding: 16px; background: var(--wash); border-radius: 12px; }
.field-row--3 > .field { flex: 1; }
.add-user-actions { display: flex; justify-content: flex-end; }
.user-list { list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--line); }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.user-row.is-inactive .user-who { opacity: 0.55; }
.user-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-who .avatar { width: 38px; height: 38px; font-size: 15px; }
.user-name { font-weight: 600; font-size: 15px; }
.user-email { font-size: 13.5px; color: var(--muted); }
[dir='rtl'] .user-email { text-align: right; }
.user-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.user-badges:empty { display: none; }
.user-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.user-controls select { height: 36px; width: auto; font-size: 14px; padding: 0 10px; }
.role-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 0; font-size: 13px; }
.role-legend dt { font-weight: 700; }
.role-legend dd { margin: 2px 0 0; color: var(--muted); }
.temp-pass { margin-top: 16px; padding: 18px; border-radius: 12px; background: var(--wash); text-align: center; border: 1px dashed var(--sky-line); }
.temp-pass code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 26px; font-weight: 700; letter-spacing: 0.06em; color: var(--text); user-select: all; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 200;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: var(--radius);
  background: var(--toast-bg); color: #fff; font-weight: 500; font-size: 14.5px; box-shadow: 0 8px 24px rgba(10, 20, 30, 0.3);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: var(--danger); color: var(--on-danger); }

/* ---------- phones ---------- */
@media (max-width: 767px) {
  .topbar { height: 54px; padding: 0 10px; }
  .brand img { width: 32px; height: 32px; }
  .brand-company { font-size: 12px; }
  .brand-app { font-size: 15.5px; }
  .user-meta { display: none; }
  .user-btn { padding: 0 4px; height: 40px; }
  .topbar-actions { gap: 6px; }

  .workspace { display: block; }
  .map-wrap { position: absolute; inset: 0; }
  .panel {
    position: absolute; inset-inline: 0; bottom: 0; height: 150px; border: 0;
    border-radius: 18px 18px 0 0; box-shadow: 0 -6px 28px rgba(10, 20, 30, 0.22);
    transition: height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.no-anim { transition: none; }
  .sheet-grab { display: flex; justify-content: center; padding: 8px 0 0; touch-action: none; cursor: grab; flex: none; }
  .sheet-grab span { width: 42px; height: 5px; border-radius: 3px; background: var(--grab); }
  .panel-head { padding-top: 8px; border-bottom-color: transparent; }
  .panel[data-sheet='half'] .panel-head, .panel[data-sheet='full'] .panel-head { border-bottom-color: var(--line); }
  .panel-sub, .detail-head { touch-action: none; }
  .panel[data-sheet='peek'] .panel-scroll { overflow: hidden; }
  .detail-head { padding-top: 4px; }

  .maplibregl-ctrl-top-right { top: 0; }
  .basemap-ctrl .basemap-seg button, .basemap-ctrl .basemap-labels { height: 34px; }

  .toast { bottom: calc(var(--sheet-h, 150px) + 12px); }
  body.has-modal .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }

  .field-row { flex-direction: column; gap: 0; }
  .modal-backdrop--form, .modal-backdrop--wide { padding: 0; }
  .modal--form, .modal--wide { height: 100dvh; max-height: none; border-radius: 0; }
  .modal-backdrop--sm { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-foot .btn { flex: 1; }
  .picker { height: 230px; }

  .user-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .user-controls { justify-content: flex-start; }
  .role-legend { grid-template-columns: 1fr; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .workspace { grid-template-columns: 330px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .pin.is-selected .pin-signal::before, .picker-pin .pin-signal::before { width: 34px; height: 34px; opacity: 0.8; animation: none; }
  .pin.is-selected .pin-signal::after, .picker-pin .pin-signal::after { display: none; }
}

/* ---------- mixed Arabic / English text ----------
   Names are typed in either language. Each one keeps its own direction (so "Co." keeps its full stop
   at the end inside the Arabic interface) while lining up with the rest of the interface. */
.row-name, .row-sub, .detail-title, .contact-name, .visit-eng strong, .visit-job, .user-name,
.form-context span, .pin-label, .menu-who strong, .user-meta-name, .modal-head h2, .visit-by, .added-by {
  unicode-bidi: plaintext;
}
[dir='rtl'] :is(.row-name, .row-sub, .detail-title, .contact-name, .user-name, .visit-by, .added-by) { text-align: right; }
[dir='ltr'] :is(.row-name, .row-sub, .detail-title, .contact-name, .user-name, .visit-by, .added-by) { text-align: left; }

/* ---------- map controls in dark mode ---------- */
:root[data-theme='dark'] .maplibregl-ctrl-group { background: var(--map-ctrl-bg); }
:root[data-theme='dark'] .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
:root[data-theme='dark'] .maplibregl-ctrl-group button .maplibregl-ctrl-icon,
:root[data-theme='dark'] .maplibregl-ctrl-attrib-button { filter: invert(1) hue-rotate(180deg); }
:root[data-theme='dark'] .maplibregl-ctrl-group button:not(:disabled):hover { background-color: rgba(255, 255, 255, 0.07); }
:root[data-theme='dark'] .maplibregl-ctrl.maplibregl-ctrl-attrib,
:root[data-theme='dark'] .maplibregl-ctrl.maplibregl-ctrl-attrib.maplibregl-compact { background-color: var(--map-ctrl-bg); color: var(--muted); }
:root[data-theme='dark'] .maplibregl-ctrl-attrib a { color: var(--muted); }

/* ---------- project card (pop-up) ---------- */
.project-row.is-active { background: var(--sky-wash); }
.project-row.is-active::before { background: var(--primary); }

.map-card { position: absolute; left: 0; top: 0; z-index: 15; width: 440px; max-width: calc(100% - 24px); }
.map-card-box {
  position: relative; z-index: 1; overflow: hidden;
  background: var(--surface-2); color: var(--text); border-radius: 14px; box-shadow: var(--modal-shadow);
}
.map-card-tip {
  position: absolute; bottom: -7px; width: 16px; height: 16px; margin-inline-start: 0;
  background: var(--surface-2); border-radius: 3px; transform: translateX(-50%) rotate(45deg);
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.25);
}
.pcard {
  display: flex; flex-direction: column; max-height: var(--card-max, 520px);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  transform-origin: 50% 100%; animation: card-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes card-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
.pcard-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 10px; padding-inline-start: 18px; border-bottom: 1px solid var(--line); }
.pcard-title { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; line-height: 1.3; outline: none; unicode-bidi: plaintext; }
[dir='rtl'] .pcard-title { text-align: right; }
[dir='ltr'] .pcard-title { text-align: left; }
.pcard-tools, .modal-head-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.pcard-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 14px; }
.pcard-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

.facts { margin: 0; display: grid; grid-template-columns: minmax(92px, max-content) 1fr; }
.fact { display: contents; }
.fact dt, .fact dd { padding: 11px 0; border-bottom: 1px solid var(--wash); }
.fact dt { padding-inline-end: 16px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.fact dd { margin: 0; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.fact .coords { font-size: 15px; }
.coords-row { display: flex; align-items: center; gap: 4px; margin-block: -4px; }
.coords-row .icon-btn { color: var(--muted); }
.fact-name { font-size: 15.5px; font-weight: 600; unicode-bidi: plaintext; }
.fact-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.fact .phone-actions { margin-top: 2px; }

.pvisits { padding-top: 14px; }
.pvisits-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.pvisits-head h3 { font-size: 15.5px; font-weight: 700; }
.vlist { list-style: none; margin: 0; padding: 0; }
.vrow { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--wash); }
.vrow:last-child { border-bottom: 0; }
.vrow-main { min-width: 0; }
.vrow-date { font-size: 14px; font-weight: 700; color: var(--sky-ink); font-variant-numeric: tabular-nums; }
.vrow-eng { margin-top: 2px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.vrow-eng strong { font-size: 15px; font-weight: 600; unicode-bidi: plaintext; }
.vrow .phone-actions { margin-top: 6px; }
.vrow-tools { display: flex; gap: 2px; flex: none; }
.card-meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); unicode-bidi: plaintext; }
[dir='rtl'] .card-meta { text-align: right; }

/* the same card on phones: a sheet that slides up, leaving the pin visible above it */
.modal--sheet { max-width: 520px; }
.modal--sheet .modal-body { padding-top: 4px; }
.modal--sheet .modal-foot { justify-content: flex-start; flex-wrap: wrap; }
@media (max-width: 767px) {
  .modal-backdrop--sheet { place-items: end stretch; padding: 0; background: rgba(3, 8, 12, 0.28); }
  .modal--sheet {
    max-width: none; max-height: 62dvh; border-radius: 18px 18px 0 0;
    transform: translateY(40px); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .modal--sheet .modal-foot .btn { flex: 1 1 auto; }
}

/* ---------- accessibility & touch polish (UI/UX Pro Max audit) ---------- */
/* Names and other typed text can be long words with no spaces; let them wrap instead of overflowing. */
.row-name, .row-sub, .pcard-title, .fact-name, .vrow-eng strong, .user-name, .contact-name, .modal-head h2 { overflow-wrap: anywhere; }
/* Removes the double-tap zoom delay on phones. */
button, a, input, select, summary, label { touch-action: manipulation; }

.skip-link {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 300;
  padding: 10px 14px; border-radius: var(--radius); background: var(--primary); color: var(--on-primary);
  font-weight: 600; text-decoration: none; transition: top 0.15s;
}
.skip-link:focus { top: 10px; }

/* show / hide password */
.pw-wrap { position: relative; }
[dir='rtl'] .pw-wrap input { padding-left: 48px; }
[dir='ltr'] .pw-wrap input { padding-right: 48px; }
.pw-toggle { position: absolute; top: 3px; inset-inline-end: 3px; color: var(--muted); }
.pw-toggle .icon { width: 19px; height: 19px; }

/* Phones and tablets: every control at least 44 × 44 px to the finger (visuals stay the same size where possible). */
@media (pointer: coarse) {
  .lang-btn { height: 44px; min-width: 44px; justify-content: center; }
  .user-btn { height: 44px; }
  .icon-btn, .icon-btn--sm, .icon-btn--wa { width: 44px; height: 44px; }
  .icon-btn--wa { border-radius: 50%; }
  .btn, .btn--sm { height: 44px; }
  .phone-link { height: 44px; }
  .link-btn { min-height: 44px; }
  .menu [role='menuitem'] { height: 48px; }
  .user-controls select { height: 44px; }
  .basemap-ctrl .basemap-seg button, .basemap-ctrl .basemap-labels { height: 44px; }
  .skip-link { min-height: 44px; }
  .maplibregl-ctrl-group button { width: 44px !important; height: 44px !important; }
  /* the tap area grows; the dot you see stays the same */
  .pin { width: 44px; height: 44px; }
  .pin .pin-label { inset-inline-start: calc(100% - 11px); }
  .cluster--sm { width: 44px; height: 44px; }
  .cluster--sm .cluster-dot { width: 34px; height: 34px; }
  .cluster--md { width: 46px; height: 46px; }
  .cluster--md .cluster-dot { width: 42px; height: 42px; }
}

/* ---------- stages, visit notes, departments (step 2) ---------- */
/* One colour per stage. Step 3 uses the same colours for map pins. */
:root {
  --st-not_visited: #5f6f7c;
  --st-visited: #11709a;
  --st-interested: #9a5c00;
  --st-quoted: #6b3fc4;
  --st-won: #18734c;
  --st-lost: #c0392f;
}
:root[data-theme='dark'] {
  --st-not_visited: #93a5b4;
  --st-visited: #7fd3f0;
  --st-interested: #f2b45a;
  --st-quoted: #b99cff;
  --st-won: #5fd39c;
  --st-lost: #ff7b70;
}
.stage--not_visited { --st: var(--st-not_visited); }
.stage--visited { --st: var(--st-visited); }
.stage--interested { --st: var(--st-interested); }
.stage--quoted { --st: var(--st-quoted); }
.stage--won { --st: var(--st-won); }
.stage--lost { --st: var(--st-lost); }

.stage-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--st); background: color-mix(in srgb, var(--st) 14%, transparent);
}
.stage-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.stage-select {
  height: 38px; padding: 0 10px; max-width: 100%;
  border: 1px solid color-mix(in srgb, var(--st) 45%, var(--line)); border-radius: var(--radius);
  background: color-mix(in srgb, var(--st) 10%, var(--input-bg)); color: var(--st);
  font-size: 15px; font-weight: 600;
}
.stage-select option { color: var(--text); background: var(--input-bg); }
.stage-select:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(74, 192, 232, 0.28); }
.stage-select:disabled { opacity: 0.6; }

.stage-history { font-size: 13px; color: var(--muted); }
.stage-history > summary { cursor: pointer; font-weight: 600; color: var(--sky-ink); padding: 4px 0; }
.stage-history ol { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stage-history li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.row-meta { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 4px; }
.row-meta .row-sub { flex: 1; min-width: 0; }

.vrow-by { margin-top: 2px; font-size: 13.5px; font-weight: 600; color: var(--text); unicode-bidi: plaintext; }
.vrow-notes {
  margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--wash);
  font-size: 14px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; unicode-bidi: plaintext;
}

.field textarea {
  min-height: 84px; padding: 10px 12px; width: 100%; resize: vertical; line-height: 1.5;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--input-bg); font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea::placeholder { color: var(--placeholder); }
.field textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(74, 192, 232, 0.28); }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.check {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--input-bg); cursor: pointer;
  font-size: 15px;
}
.check input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--primary); }
.check:has(input:checked) { border-color: var(--sky-line); background: var(--sky-wash); }
.check:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(74, 192, 232, 0.28); }
.check--toggle { margin-bottom: 10px; }

.dept-list { list-style: none; margin: 8px 0 18px; padding: 0; border-top: 1px solid var(--line); }
.dept-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.dept-edit { display: flex; align-items: flex-end; gap: 12px; }
.dept-edit .field { margin-bottom: 0; }
.dept-tools { display: flex; align-items: center; gap: 6px; padding-bottom: 4px; }
.dept-add { padding: 16px; background: var(--wash); border-radius: 12px; }
.dept-add h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

@media (max-width: 767px) {
  .stage-select { height: 44px; }
  .dept-edit { flex-wrap: wrap; }
  .dept-edit .field { flex: 1 1 140px; }
}

/* ---------- map colours, filters, summary (step 3) ---------- */
/* Pin colours sit on satellite imagery, so they are the same in light and dark mode. */
.pin--recent { --pin: #22c55e; }
.pin--mid { --pin: #f59e0b; }
.pin--old { --pin: #ef4444; }
.pin--never, .pin--st-not_visited { --pin: #94a3b8; }
.pin--st-visited { --pin: #38bdf8; }
.pin--st-interested { --pin: #f59e0b; }
.pin--st-quoted { --pin: #a78bfa; }
.pin--st-won { --pin: #22c55e; }
.pin--st-lost { --pin: #ef4444; }
.pin .pin-dot { background: var(--pin, var(--sky)); }
.pin.is-selected .pin-dot { background: var(--pin, var(--ink)); }
/* Nobody has been there yet: a hollow pin, so it reads differently even without colour. */
.pin.pin--never .pin-dot, .pin.pin--st-not_visited .pin-dot {
  background: #fff; box-shadow: 0 0 0 3px var(--pin), 0 0 0 5px #fff, 0 1px 8px 2px rgba(10, 20, 30, 0.55);
}

.color-ctrl {
  display: flex; flex-direction: column; gap: 8px; padding: 8px; max-width: 260px;
  background: var(--map-ctrl-bg); border-radius: var(--radius); box-shadow: var(--shadow-float); color: var(--text);
}
.color-seg { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--wash); }
.color-ctrl .color-seg button {
  flex: 1; height: 30px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.color-ctrl .color-seg button:not(:disabled):hover { background: var(--map-ctrl-bg); color: var(--text); }
.color-ctrl .color-seg button[aria-pressed='true'],
.color-ctrl .color-seg button[aria-pressed='true']:not(:disabled):hover { background: var(--primary); color: var(--on-primary); }
.legend { list-style: none; margin: 0; padding: 0 2px; display: grid; gap: 4px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--pin); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.15); }
.legend-dot.pin--never, .legend-dot.pin--st-not_visited { background: #fff; box-shadow: inset 0 0 0 3px var(--pin); }
.legend-label { flex: 1; }
.legend-n { font-weight: 700; font-variant-numeric: tabular-nums; }

.panel-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn.is-active { border-color: var(--sky); box-shadow: inset 0 0 0 1px var(--sky); }

.filters { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--wash); }
.filters .field { margin-bottom: 10px; }
.filters .field select, .filters .field input { height: 40px; font-size: 15px; }
.filter-group { margin: 0 0 10px; padding: 0; border: 0; }
.filter-group > legend { padding: 0; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--input-bg); color: var(--text); font-size: 13px; font-weight: 600;
}
.stage-toggle::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--st); flex: none; }
.stage-toggle[aria-pressed='true'] { border-color: var(--st); background: color-mix(in srgb, var(--st) 16%, var(--input-bg)); color: var(--st); }
.filters [data-clear-filters] { margin-top: 2px; }

.summary-btn .icon { width: 17px; height: 17px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--wash); }
.seg button {
  height: 34px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--primary); color: var(--on-primary); }
.summary-range { margin: 10px 0 12px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.summary-scroll { overflow-x: auto; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.summary-table th, .summary-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.summary-table thead th { font-size: 13px; font-weight: 600; color: var(--muted); }
.summary-table th[scope='row'], .summary-table thead th:first-child { text-align: start; }
.summary-table tbody th .link-btn { padding: 0; font-size: 15px; unicode-bidi: plaintext; }
.summary-table td { font-weight: 700; }
.summary-table tfoot th, .summary-table tfoot td { border-bottom: 0; border-top: 2px solid var(--line); font-weight: 700; }
.summary-note { margin-top: 14px; }

@media (max-width: 767px) {
  .summary-btn span { display: none; }
  .summary-btn { width: 44px; padding: 0; justify-content: center; }
  .color-ctrl { max-width: 210px; padding: 6px; gap: 6px; }
  .legend { font-size: 12px; }
  .stage-toggle { height: 40px; }
  .seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .seg button { height: 44px; padding: 0 10px; }
  .summary-table th, .summary-table td { padding: 10px 8px; font-size: 14px; }
}
