/* Classtime Compass — light theme, house style of the public customer map.
   Colour roles come from the Classtime blue ramp; see README § Farben. */
:root {
  /* brand + ink (shared with classtime-customer-map/website) */
  --brand: #0091EA;
  --brand-dark: #0064B7;
  --ink: #334148;
  --muted: #78909C;
  --line: #ECEFF1;
  --line2: #DDE4E8;
  --surface: #ffffff;
  --plane: #F7F9FB;
  --map-bg: #eaf1f8;

  /* Classtime blue ramp (sequential / ordinal encoding) */
  --blue-200: #A6DAF8;
  --blue-250: #7FCAF5;
  --blue-300: #4FB6F1;
  --blue-350: #1E9FEC;
  --blue-400: #0091EA;
  --blue-450: #007ECC;
  --blue-500: #00699E;
  --blue-550: #0F5C95;
  --blue-650: #0D3D63;
  --blue-700: #0A2F4C;

  /* prospect hue — validated against the status tokens on the map surface */
  --violet-300: #C7C2D8;
  --violet-500: #9E96B8;
  --violet-700: #7A719E;
  --violet-800: #665C8C;
  --violet-900: #4A4269;

  /* reserved status tokens — never used as a series colour */
  --status-critical: #D03B3B;
  --status-neutral: #78716C;
  --status-good: #0CA30C;

  --sidebar: 316px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(51, 65, 72, .12);
  --shadow-lg: 0 6px 24px rgba(51, 65, 72, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.45; color: var(--ink);
  background: var(--plane);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand-dark); }

/* ---------------------------------------------------------------- brand mark */
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; text-decoration: none; color: inherit; }
.brand img { width: 30px; height: 30px; flex: none; }
.brand .word { font-size: 19px; font-weight: 800; letter-spacing: -.02em; color: var(--brand); }
.brand .sep { width: 1px; height: 20px; background: var(--line2); flex: none; }
.brand .app { font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand .app small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); }

/* -------------------------------------------------------------- landing page */
body.landing { display: flex; flex-direction: column; background: var(--surface); }
.landing-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
}
.landing-main { flex: 1; display: grid; place-items: center; padding: 40px 24px; }
.landing-card { max-width: 660px; text-align: center; }
.landing-card h1 { font-size: 34px; line-height: 1.15; margin: 0 0 14px; letter-spacing: -.02em; }
.landing-card h1 .accent { color: var(--brand); }
.landing-card .lead { font-size: 16.5px; color: #55646c; margin: 0 auto 26px; max-width: 560px; }
/* 2 or 4 columns — both divide the four cards evenly, unlike auto-fit. */
.landing-features {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 14px; text-align: left; margin: 0 0 30px;
}
@media (min-width: 900px) { .landing-features { grid-template-columns: repeat(4, 1fr); } }
.landing-features .f {
  background: var(--plane); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px;
}
.landing-features .f b { display: flex; gap: 7px; font-size: 13.5px; margin-bottom: 4px; }
.landing-features .f span { font-size: 12.5px; color: var(--muted); }
.landing-note { font-size: 12.5px; color: var(--muted); }
.landing-foot { padding: 16px 28px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* White button with a Classtime-blue outline — the Google mark keeps its own
   colours, which is how Google's sign-in branding is meant to be used. */
.btn-login {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--brand); border-radius: 10px;
  padding: 10px 18px; font-size: 14px; font-weight: 700; text-decoration: none;
  box-shadow: var(--shadow); cursor: pointer;
}
.btn-login:hover { border-color: var(--brand-dark); background: #F5FBFF; }
.btn-login img.g { width: 18px; height: 18px; display: block; }
.btn-login.big { padding: 13px 26px; font-size: 15.5px; }
.btn-login.big img.g { width: 21px; height: 21px; }

/* --------------------------------------------------------------- app chrome */
#shell { display: grid; grid-template-rows: auto 1fr; height: 100%; }

header.app-head {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  flex-wrap: wrap;          /* two layer toggles + choropleth + CSV + sync need room */
}
header.app-head .spacer { flex: 1; }

.tabs { display: flex; background: var(--line); border-radius: 10px; padding: 3px; }
.tabs button {
  border: 0; background: transparent; padding: 7px 17px; border-radius: 8px;
  font-size: 13px; color: var(--muted); cursor: pointer; font-weight: 600;
}
.tabs button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn {
  background: var(--surface); border: 1px solid var(--line2); border-radius: 9px;
  padding: 7px 11px; cursor: pointer; white-space: nowrap; font-size: 13px; color: var(--ink);
}
.btn:hover { border-color: var(--muted); }
.btn.on { background: #E6F4FE; border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn .cti { width: 16px; height: 16px; border-radius: 50%; display: block; }
.btn .dot { width: 10px; height: 10px; border-radius: 50%; display: block; }

/* Separates the three groups in the toolbar: view mode | layers | export. */
.actions .divide { width: 1px; height: 24px; background: var(--line2); margin: 0 7px; flex: none; }

/* A layer toggle plus its own display sub-control (symbols vs heatmap). Both stay
   in place at all times — a control that disappears costs more than a dim one. */
.layer { display: flex; align-items: center; gap: 5px; }
.layer-btn { display: inline-flex; align-items: center; gap: 7px; }
.layer.off .layer-btn { color: var(--muted); }
.layer.off .layer-btn .dot, .layer.off .layer-btn .cti { filter: grayscale(1); opacity: .5; }
.layer.off .seg { opacity: .4; pointer-events: none; }

/* Sliding switch: the white thumb moves, the labels stay put. */
.seg {
  position: relative; display: flex; background: var(--line); border-radius: 9px; padding: 2px;
}
.seg .thumb {
  position: absolute; top: 2px; left: 2px; width: calc(50% - 2px); height: calc(100% - 4px);
  background: var(--surface); border-radius: 7px; box-shadow: var(--shadow);
  transition: transform .18s ease;
}
.seg.heat .thumb { transform: translateX(100%); }
.seg button {
  position: relative; z-index: 1; border: 0; background: transparent; padding: 5px 0;
  width: 58px; text-align: center; border-radius: 7px;
  font-size: 11.5px; color: var(--muted); cursor: pointer; font-weight: 600;
}
.seg button.on { color: var(--brand); }
/* Compact slider inside a section heading (Schulträger ein-/ausgeblendet). */
.seg.seg-mini { margin-left: auto; }
.seg.seg-mini button { width: auto; padding: 3px 9px; font-size: 10.5px; }
.seg.seg-mini .thumb { width: calc(50% - 2px); }
.block > h2 .seg-mini + .caret { margin-left: 8px; }

/* "Heute fällig" sits right under the search box — it is a work-list switch,
   not a data facet, so it does not live inside a section. */
.duecheck { font-size: 12.5px; padding: 2px 2px 0; user-select: none; }
.duecheck small { color: var(--muted); font-size: 11px; }
.duecheck.off { opacity: .45; cursor: default; }

/* facet groups inside a sidebar section */
.facet + .facet { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.fcap {
  font-size: 11.5px; font-weight: 700; color: var(--ink); margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px;
}
.fcap .n { font-weight: 500; color: var(--muted); font-size: 11px; }
.fsearch { margin-bottom: 5px; padding: 5px 9px !important; font-size: 12px; }
.facet .list { max-height: 168px; }
.facet[hidden] { display: none; }

.who { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; line-height: 1.3; }
.who a { color: var(--muted); }

#body { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 0; }

/* ------------------------------------------------------------------ sidebar */
#side {
  background: var(--surface); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
/* The sections used to blur into each other: a hairline in --line on white is
   nearly invisible. Stronger border, tinted header, bold ink title. */
.block {
  border: 1px solid #CFD9E0; border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  box-shadow: 0 1px 2px rgba(51, 65, 72, .05);
  /* Flex items shrink by default: with two sections open, the taller one got
     squeezed and its lists were clipped into the section below. The column
     scrolls instead — an open section always shows all of itself. */
  flex: 0 0 auto;
}
.block > h2 {
  font-size: 12px; letter-spacing: .03em; color: var(--ink); font-weight: 800;
  margin: 0; padding: 11px 12px; display: flex; align-items: center; gap: 7px;
  cursor: pointer; user-select: none; background: #F2F6F9;
  border-bottom: 1px solid transparent;
}
.block:not(.collapsed) > h2 { border-bottom-color: #CFD9E0; }
.block > h2:hover { background: #E9F0F5; }
.block > h2 .caret { margin-left: auto; font-size: 9px; transition: transform .15s; color: var(--muted); }
.block.collapsed > h2 .caret { transform: rotate(-90deg); }
.block.collapsed > .inner { display: none; }
.block > h2 .badge {
  background: var(--brand); color: #fff; border-radius: 999px;
  font-size: 10px; padding: 1px 6px; letter-spacing: 0;
}
.inner { padding: 12px; display: flex; flex-direction: column; gap: 9px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  border: 1px solid var(--line2); border-radius: 999px; padding: 4px 10px;
  font-size: 12.5px; background: var(--surface);
}
.chip:hover { border-color: var(--muted); }
.chip.off { opacity: .38; }
.chip .d { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chip .cn { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }

input[type=search], input[type=text], input[type=number], select {
  width: 100%; background: var(--surface); border: 1px solid var(--line2);
  border-radius: 10px; padding: 8px 11px; outline: none; color: var(--ink);
}
input:focus, select:focus { border-color: var(--brand); }
.searchwrap { position: relative; }
.searchwrap .hintkey {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px; color: var(--muted); background: var(--line);
  border-radius: 5px; padding: 2px 6px; pointer-events: none;
}

.list { max-height: 210px; overflow-y: auto; display: flex; flex-direction: column; }
.list label {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  padding: 4px 5px; border-radius: 7px; cursor: pointer;
}
.list label:hover { background: var(--plane); }
/* Exhausted under the current filters: still listed, still in the same place. */
.list label.zero { color: var(--muted); opacity: .5; cursor: default; }
.list label.zero:hover { background: transparent; }
/* Tri-state rows (Schuldaten): leer → ✓ gewählt → ✕ ausgeschlossen. An excluded
   row stays fully readable — it is an active decision, not an exhausted value. */
.tri {
  width: 15px; height: 15px; flex: none; border-radius: 4px; box-sizing: border-box;
  border: 1.5px solid var(--line2); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; line-height: 1; color: transparent;
}
.tri.inc { background: var(--brand); border-color: var(--brand); color: #fff; }
.tri.exc { background: #FBEAEA; border-color: var(--status-critical); color: var(--status-critical); }
.list label.excluded { opacity: 1; }
.list label.excluded .nm { color: var(--status-critical); text-decoration: line-through; }
.list label > .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .cn { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.list .pct { font-size: 11px; font-weight: 700; color: var(--brand-dark); font-variant-numeric: tabular-nums; }

.radios { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; }
.radios label, .check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.hint { font-size: 11.5px; color: var(--muted); }
.row2 { display: flex; gap: 7px; }
.row2 > * { flex: 1; }

/* ---------------------------------------------------------------- map panel */
.pane { position: relative; min-width: 0; display: none; }
.pane.on { display: block; }
#map { position: absolute; inset: 0; background: var(--map-bg); }

#stats {
  position: absolute; left: 12px; bottom: 12px; z-index: 500; max-width: calc(100% - 250px);
  background: rgba(255, 255, 255, .95); border: 1px solid var(--line2); border-radius: var(--radius);
  padding: 9px 13px; font-size: 12.5px; box-shadow: var(--shadow); backdrop-filter: blur(6px);
  /* A grid, not a wrapping flex row: the column count follows the *container*, so
     nothing shifts sideways when a number gets a digit longer or a layer is
     switched off. Each cell is wide enough for its longest possible value. */
  /* Tracks cap at 216px but may shrink with the window — stability against
     CONTENT changes comes from the cap, narrow windows must not overflow the
     box into the legend. */
  display: grid; grid-template-columns: repeat(2, minmax(140px, 216px));
  gap: 2px 16px; align-items: center;
}
#stats b { font-size: 15px; }
#stats .pill { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#stats .pill.accent { color: var(--brand-dark); font-weight: 600; }
#stats .pill.off { color: var(--muted); font-weight: 400; }
#stats .pill { overflow: hidden; text-overflow: ellipsis; }

#legend {
  position: absolute; right: 12px; bottom: 12px; z-index: 500; width: 234px;
  background: rgba(255, 255, 255, .95); border: 1px solid var(--line2); border-radius: var(--radius);
  padding: 10px 12px; font-size: 12px; box-shadow: var(--shadow); backdrop-filter: blur(6px);
  /* All layers on + choropleth is ~20 rows — scroll inside, never over the toolbar. */
  max-height: calc(100% - 24px); overflow-y: auto;
}
#legend .lg-title { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
#legend .row { display: flex; align-items: center; gap: 8px; padding: 1.5px 0; }
#legend .d { width: 11px; height: 11px; border-radius: 50%; flex: none; }
#legend .sw { width: 15px; height: 11px; border-radius: 3px; flex: none; }
/* Same construction as the map pin's head: the logo fills the circle, so it
   cannot drift off-centre the way a smaller centred image did. */
#legend .pin {
  width: 16px; height: 16px; border-radius: 50%; background: #fff; flex: none;
  border: 2px solid var(--brand); box-sizing: border-box; overflow: hidden;
}
#legend .pin img { width: 100%; height: 100%; display: block; }
/* Ring, not a dot: on the map the colour sits around the logo, not inside it. */
#legend .ring {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 3px solid var(--muted); box-sizing: border-box; background: #fff;
}
#legend .ring.dash { border-style: dashed; border-width: 2px; }
#legend .lg-nm { flex: 1; min-width: 0; }
#legend .lg-n { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5ch; text-align: right; }
#legend .row.dim { opacity: .45; }
#legend .lg-foot { font-size: 10.5px; color: var(--muted); margin-top: 5px; }
#legend hr { border: 0; border-top: 1px solid var(--line); margin: 7px 0; }

#empty {
  position: absolute; inset: 0; z-index: 600; display: grid; place-items: center;
  background: rgba(247, 249, 251, .82); padding: 24px; text-align: center;
}
#empty.hidden { display: none; }
#empty .card {
  background: var(--surface); border: 1px solid var(--line2); border-radius: 16px;
  padding: 24px 28px; max-width: 400px; box-shadow: var(--shadow-lg);
}
#empty h3 { margin: 0 0 8px; font-size: 16px; }
#empty p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------- map marks */
.cl-wrap { background: transparent; }
/* Cluster bubbles are an *aggregate* and stay neutral slate: since the dots
   underneath now encode the work state per organization, any work-state hue on
   the bubble would claim something about its contents that isn't counted. */
.cl {
  width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 700; background: #78909C;
  border: 3px solid rgba(255, 255, 255, .92); box-shadow: 0 2px 10px rgba(51, 65, 72, .3);
  font-variant-numeric: tabular-nums;
}
.cl.c-md { background: #667E8C; }
.cl.c-lg { background: #546E7A; }
.cl.c-xl { background: #40565F; }

.ct-pin { position: relative; width: 30px; height: 30px; }
.ct-pin .head {
  width: 30px; height: 30px; border-radius: 50%; background: #fff;
  border: 3px solid var(--c, #0091EA); box-shadow: 0 2px 6px rgba(51, 65, 72, .4); overflow: hidden;
}
/* No Bildungsstufe in the CRM: a dashed ring says "unknown" without spending a
   colour that would then compete with the seven real classes. */
.ct-pin.nostufe .head { border-width: 2.5px; border-style: dashed; }
.ct-pin .head img { width: 100%; height: 100%; display: block; }
.ct-pin .tip {
  position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 8px solid var(--c, #0091EA);
}

/* Pipeline: gold diamond with a €. Its own shape — never mistakable for a
   prospect dot or a customer pin, even where markers crowd. The diamond is a
   rotated square; the € inside is counter-rotated so it stays upright. */
.pipe-pin {
  width: 22px; height: 22px; transform: rotate(45deg); border-radius: 4px;
  background: var(--fill, #fff); border: 2.5px solid var(--c, #5C4A12); box-sizing: border-box;
  color: var(--c, #5C4A12); font-weight: 800; font-size: 11.5px; line-height: 1;
  box-shadow: 0 2px 6px rgba(51, 65, 72, .35);
  display: flex; align-items: center; justify-content: center;
}
.pipe-pin.dark { color: #fff; }         /* € stays readable on the deep-gold end */
.pipe-pin > span { transform: rotate(-45deg); }
.pipe-pin.lg { width: 15px; height: 15px; border-width: 2px; font-size: 8px; flex: none; }
.pipe-dot {
  width: 13px; height: 13px; transform: rotate(45deg); border-radius: 3px;
  border: 2px solid #8A6D1C; color: #8A6D1C; box-sizing: border-box;
  font-size: 7.5px; font-weight: 800; line-height: 1; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.pipe-dot > span { transform: rotate(-45deg); }

/* Neutralise everything leaflet-tooltip brings along: its own padding, the
   nowrap (which would stretch long org names into one endless line) and the
   white direction arrow, which would float next to our own card. */
.hoverwrap { background: transparent; border: 0; box-shadow: none; padding: 0; white-space: normal; }
.hoverwrap::before { display: none; }
.hovercard {
  background: rgba(255, 255, 255, .97); border: 1px solid var(--line2); border-radius: 10px;
  padding: 9px 12px; font-size: 12.5px; line-height: 1.5; color: var(--ink);
  box-shadow: var(--shadow-lg); width: max-content; max-width: 340px;
}
.hovercard b { display: block; margin-bottom: 3px; font-size: 13px; }
.hovercard .k {
  display: inline-block; min-width: 96px; color: var(--muted); font-size: 11.5px;
}

.area-label {
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line2); border-radius: 7px;
  padding: 1px 6px; font-size: 11px; font-weight: 700; color: var(--ink);
  white-space: nowrap; box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}
.area-label.zero { color: var(--muted); font-weight: 500; }

/* ----------------------------------------------------------------- popups */
.leaflet-popup-content-wrapper { border-radius: var(--radius); box-shadow: var(--shadow-lg); }
/* Contacts, activity and note make the card taller than the map on small
   viewports; autoPan cannot rescue a popup taller than the view, so it scrolls.
   scrollbar-gutter keeps a classic (macOS "always show") scrollbar from lying
   on top of the right-aligned letterhead — the reported cut-off corner. */
.leaflet-popup-content {
  margin: 13px 15px; max-height: 62vh; overflow-y: auto;
  scrollbar-gutter: stable; padding-right: 4px;
}
/* Everything in the card reads left-to-right; only the letterhead is right-aligned. */
.pp, .pp .contact, .pp .contact .who { text-align: left; }
.pp .badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; color: #fff;
  padding: 2px 8px; border-radius: 999px; margin-bottom: 7px;
}
.pp .badge.dnc { background: var(--status-critical) !important; margin-left: 4px; }
.pp h3 { margin: 0 0 7px; font-size: 14.5px; line-height: 1.3; }

/* header: title block left, address as a letterhead on the right */
.pp .head { display: flex; gap: 12px; align-items: flex-start; }
.pp .head .title { flex: 1; min-width: 0; }
.pp .letterhead {
  flex: 0 0 auto; max-width: 46%; text-align: right;
  font-size: 12px; line-height: 1.35; color: var(--muted); padding-top: 2px;
}
.pp .letterhead .street { color: var(--ink); font-weight: 600; }
/* Address, thin rule, then the Gebiet chain — values only, the map is the key. */
.pp .letterhead hr { border: 0; border-top: 1px solid var(--line2); margin: 6px 0 5px; }
/* direct school phone/mail in the main block */
.pp .reach { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; margin-bottom: 6px; }
.pp .reach a { color: var(--brand-dark); text-decoration: none; font-weight: 600; }
.pp .reach a:hover { text-decoration: underline; }
.pp .meta-line-act { font-size: 12.5px; margin-bottom: 2px; }
/* section groups in the main block — bold caps so the sections read as sections */
.pp .meta-sect { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); }
.pp .meta-sect > .cap {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink); font-weight: 800; margin-bottom: 3px;
}
/* main contact row */
.pp .mc-row { display: flex; align-items: center; gap: 8px; }
.pp .mc-row select { flex: 1; min-width: 0; }
.pp .mc-msg { font-size: 11px; color: var(--muted); white-space: nowrap; }
.pp .mc-msg.err { color: var(--status-critical); font-weight: 600; }
.pp h3 a { color: var(--brand-dark); text-decoration: none; }
.pp h3 a:hover { text-decoration: underline; }
.pp .weblink { margin: -4px 0 7px; font-size: 12px; overflow-wrap: anywhere; }
.pp .weblink a {
  color: var(--brand); text-decoration: none; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.pp .weblink a .globe { flex: none; }
.pp .weblink a:hover span { text-decoration: underline; }
.pp .meta { display: grid; gap: 2px; font-size: 12.5px; }
.pp .k { color: var(--muted); }
.pp .act-open { color: var(--blue-550); font-weight: 600; }
.pp .act-none { color: var(--muted); }
.pp .tags { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 4px; }
.pp .tag {
  font-size: 10.5px; background: var(--plane); border: 1px solid var(--line2);
  border-radius: 999px; padding: 1px 7px; color: #55646c;
}
/* contact panel inside the organization popup */
.pp .sect { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.pp .sect > .cap {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink); font-weight: 800; margin-bottom: 5px;
}
.pp select { width: 100%; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line2); }
.pp .contact { margin-top: 8px; font-size: 12.5px; display: grid; gap: 2px; justify-items: start; }
.pp .contact .who { font-weight: 700; font-size: 13.5px; }
.pp .contact .who a { color: var(--brand-dark); text-decoration: none; }
.pp .contact .who a:hover { text-decoration: underline; }
.pp .contact .role { color: var(--muted); }
.pp .contact .cta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.pp .contact .cta a {
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
  background: var(--plane); border: 1px solid var(--line2); border-radius: 8px;
  padding: 5px 10px; color: var(--brand-dark); font-weight: 600;
}
.pp .contact .cta a:hover { border-color: var(--brand); }
.pp .act { font-size: 12.5px; }
.pp .act .subj { font-weight: 700; }
.pp .act .due { color: var(--brand-dark); font-weight: 600; }

/* activity list + the write form (the only place the app writes to Pipedrive) */
.pp .acts { display: flex; flex-direction: column; gap: 4px; margin-bottom: 7px; }
.pp .act-open-btn {
  display: flex; align-items: baseline; gap: 7px; width: 100%; text-align: left;
  background: var(--plane); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; cursor: pointer; font-size: 12.5px;
}
.pp .act-open-btn:hover { border-color: var(--brand); background: #F5FBFF; }
.pp .act-open-btn .due {
  font-weight: 700; color: var(--brand-dark); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pp .act-open-btn .due.late { color: var(--status-critical); }
.pp .act-open-btn .subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp .act-new { width: 100%; font-size: 12.5px; padding: 6px; }
.pp .af { display: flex; flex-direction: column; gap: 6px; margin-top: 9px;
          border-top: 1px solid var(--line); padding-top: 9px; }
.pp .af > .cap { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pp .af input, .pp .af select, .pp .af textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line2);
  border-radius: 8px; padding: 6px 9px; font-size: 12.5px; outline: none;
}
.pp .af input:focus, .pp .af select:focus, .pp .af textarea:focus { border-color: var(--brand); }
.pp .af textarea { resize: vertical; min-height: 54px; font-family: inherit; }
.pp .af-row { display: flex; gap: 6px; }
.pp .af-row select { flex: 1.2; min-width: 0; }
.pp .af-row input { flex: 1; min-width: 0; }
.pp .af-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pp .af-actions .btn { font-size: 12.5px; padding: 6px 11px; }
.pp .af-actions .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pp .af-actions .btn.primary:hover { background: var(--brand-dark); }
.pp .af-msg { font-size: 11.5px; color: var(--muted); }
.pp .af-msg.err { color: var(--status-critical); font-weight: 600; }

/* Notes keep the formatting they were written with, so the block gets real room
   instead of a cramped 88px strip. */
.pp .rich {
  margin-top: 6px; color: #44535b; font-size: 12.5px; line-height: 1.5;
  background: var(--plane); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px;
  max-height: 220px; overflow-y: auto; overflow-wrap: anywhere;
}
.pp .rich > :first-child { margin-top: 0; }
.pp .rich > :last-child { margin-bottom: 0; }
.pp .rich p { margin: 0 0 7px; }
.pp .rich ul, .pp .rich ol { margin: 0 0 7px; padding-left: 18px; }
.pp .rich li { margin: 1px 0; }
.pp .rich h1, .pp .rich h2, .pp .rich h3, .pp .rich h4 {
  font-size: 13px; margin: 8px 0 4px; color: var(--ink);
}
.pp .rich a { color: var(--brand-dark); }
.pp .rich code, .pp .rich pre { font-size: 11.5px; background: #eef2f5; border-radius: 4px; padding: 0 3px; }
.pp .rich blockquote { margin: 0 0 7px; padding-left: 9px; border-left: 2px solid var(--line2); color: var(--muted); }
.pp .note .meta-line { color: var(--muted); font-size: 11.5px; }
.pp .loading { color: var(--muted); font-size: 12px; }

/* The empty state names Pipedrive explicitly, so it keeps the logo. */
.btn-login .pdi { width: 15px; height: 15px; border-radius: 3.5px; vertical-align: -3px; }

/* -------------------------------------------------------------- analytics */
#tabAnalytics { overflow-y: auto; padding: 18px 20px 30px; background: var(--plane); }
.an-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.an-head h2 { font-size: 17px; margin: 0; }
.an-head .scope { font-size: 12.5px; color: var(--muted); }

/* Fixed column counts that divide the six tiles evenly — auto-fit would strand
   a single card on its own row at most laptop widths. */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
@media (min-width: 820px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1500px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 13px; box-shadow: var(--shadow);
}
.kpi .label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .val { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin-top: 3px; }
.kpi .val.accent { color: var(--brand); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.card > header {
  padding: 13px 15px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card > header h3 { margin: 0; font-size: 14px; }
.card > header .sub { font-size: 12px; color: var(--muted); }
.card > header .spacer { flex: 1; }
.card .body { padding: 14px 15px; }
.card .foot { padding: 9px 15px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }

/* stage bar — ordinal, one hue */
.stage-bar { display: flex; gap: 2px; height: 26px; border-radius: 6px; overflow: hidden; }
.stage-bar > span { position: relative; }
.stage-bar > span:first-child { border-radius: 6px 0 0 6px; }
.stage-bar > span:last-child { border-radius: 0 6px 6px 0; }
.stage-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 11px; font-size: 12.5px; }
.stage-legend .it { display: flex; align-items: center; gap: 7px; }
.stage-legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.stage-legend .n { color: var(--muted); font-variant-numeric: tabular-nums; }

table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 0 10px 8px; white-space: nowrap;
  border-bottom: 1px solid var(--line); cursor: pointer; user-select: none;
}
table.grid th.num, table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid th .arrow { color: var(--brand); }
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.grid tbody tr:hover { background: var(--plane); }
table.grid tbody tr { cursor: pointer; }
table.grid td .flag { color: var(--muted); font-size: 11px; }
.bar-cell { min-width: 130px; }
.bar-track { background: var(--line); border-radius: 4px; height: 9px; position: relative; }
.bar-fill { background: var(--blue-450); border-radius: 4px; height: 9px; }
.tablewrap { max-height: 460px; overflow-y: auto; }

.empty-note { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- overlay */
#overlay {
  position: fixed; inset: 0; z-index: 2000; background: rgba(247, 249, 251, .93);
  display: grid; place-items: center; text-align: center; padding: 24px;
}
#overlay.hidden { display: none; }
#overlay .spin {
  width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%;
  border: 3px solid var(--line2); border-top-color: var(--brand);
  animation: spin 1s linear infinite;
}
#overlay.error .spin { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#overlayMsg { font-size: 14.5px; font-weight: 600; }
#overlaySub { font-size: 12.5px; color: var(--muted); margin-top: 7px; }

@media (max-width: 900px) {
  #body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #side { max-height: 42vh; }
  #legend { display: none; }
  #stats { max-width: calc(100% - 24px); }
  header.app-head { flex-wrap: wrap; }
}
