:root {
  --ground: #ffffff;
  --surface: #f6f7f5;
  --raised: #ffffff;
  --border: #e6e7e4;
  --rule: #efefed;
  --control: #d9d9d6;
  --text: #1f201d;
  --muted: #5f5f5c;
  --accent: #1b6e66;
  --negative: #b42318;
  --salary-1: #a9d6cf;
  --salary-2: #5aa79c;
  --salary-3: #1b6e66;
  --salary-4: #0d3d38;
  --salary-none: #b3b3ae;
  --radius-card: 22px;
  --radius-inner: 12px;
  --gap: 16px;
  --pad: 20px;
  --control-height: 38px;
}

body { font-size: 14px; line-height: 20px; }

.num { font-variant-numeric: tabular-nums; }
.unit { color: var(--muted); font-size: 0.58em; margin-left: 3px; }

.app-column {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
  box-sizing: content-box;
}
@media (min-width: 1140px) {
  .app-column { padding-left: 0; padding-right: 0; }
}
@media (max-width: 1139px) {
  .app-column { box-sizing: border-box; }
}

.app-bar { padding: 20px 0 0; }
.wordmark { font-size: 15px; font-weight: 600; color: var(--text); text-decoration: none; }
.wordmark:hover { color: var(--accent); }

.greeting {
  font-weight: 600;
  font-size: 32px;
  line-height: 38px;
  letter-spacing: -0.02em;
  margin: 0;
}
.greeting-line { font-size: 16px; line-height: 24px; color: var(--muted); max-width: 64ch; }
.greeting-line strong { color: var(--text); font-weight: 500; }
@media (max-width: 640px) {
  .greeting { font-size: 24px; line-height: 30px; }
  .greeting-line { font-size: 15px; }
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
}
.span-3 { grid-column: span 3; }
.span-9 { grid-column: span 9; }
.span-12 { grid-column: span 12; }
@media (max-width: 960px) {
  .span-3, .span-9 { grid-column: span 12; }
}

.panel { background: var(--surface); border-radius: var(--radius-card); padding: var(--pad); }
.panel-title { font-size: 14px; line-height: 20px; font-weight: 600; margin: 0; }
.panel-note { font-size: 12px; line-height: 16px; color: var(--muted); }

.figures {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border-radius: var(--radius-card);
}
.figure { padding: 18px var(--pad) 20px; }
.figure + .figure { border-left: 1px solid var(--border); }
.figure-label { font-size: 14px; color: var(--muted); }
.figure-value { font-size: 24px; line-height: 32px; font-weight: 400; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.figure-lead .figure-value { font-size: 32px; line-height: 40px; margin-top: 2px; }
.figure-caption { font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 4px; }
.figure-missing { color: var(--muted); }
@media (max-width: 900px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .figures { grid-template-columns: 1fr; }
  .figure {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "label value" "caption value";
    column-gap: 12px;
    align-items: center;
    padding: 14px var(--pad);
  }
  .figure + .figure { border-left: 0; border-top: 1px solid var(--border); }
  .figure-label { grid-area: label; }
  .figure-caption { grid-area: caption; }
  .figure-value { grid-area: value; margin-top: 0; font-size: 22px; line-height: 28px; text-align: right; }
  .figure-lead .figure-value { font-size: 28px; line-height: 34px; margin-top: 0; }
}

.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--raised); border: 1px solid var(--border); }
.segmented button {
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  transition: color 120ms ease, background-color 120ms ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--text); color: #fff; }
.segmented button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.map-frame { flex: 1 1 auto; min-height: 420px; border-radius: var(--radius-inner); overflow: hidden; background: var(--raised); }
@media (max-width: 640px) { .map-frame { min-height: 320px; } }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.swatch { width: 10px; height: 10px; border-radius: 999px; flex: none; }
.s1 { background: var(--salary-1); }
.s2 { background: var(--salary-2); }
.s3 { background: var(--salary-3); }
.s4 { background: var(--salary-4); }
.s0 { background: var(--salary-none); }

.rank { list-style: none; margin: 0; padding: 0; }
.rank li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.rank li:first-child { border-top: 0; }
.rank .rank-count { font-variant-numeric: tabular-nums; color: var(--muted); }
.rank .rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ruler { position: relative; height: 140px; margin: 12px 12px 0; }
.ruler-axis { position: absolute; left: 0; right: 0; top: 70px; height: 1px; background: var(--control); }
.ruler-tick {
  position: absolute;
  top: 118px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ruler-median { position: absolute; top: 4px; height: 92px; width: 0; border-left: 1px dashed var(--text); }
.ruler-median span { position: absolute; top: -4px; left: 6px; font-size: 12px; white-space: nowrap; }
.ruler-dot {
  position: absolute;
  top: 70px;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 999px;
  border: 2px solid var(--surface);
}
.ruler-name {
  position: absolute;
  transform: translateX(-50%);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  text-align: center;
}
.ruler-name.up { top: 32px; }
.ruler-name.down { top: 84px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field,
.select {
  height: var(--control-height);
  border: 1px solid var(--control);
  border-radius: 999px;
  background: var(--raised);
  font-size: 14px;
  color: var(--text);
  padding: 0 14px;
}
.field::placeholder { color: var(--muted); opacity: 1; }
.field:focus,
.select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.search { position: relative; flex: 1 1 240px; }
.search svg { position: absolute; left: 13px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; color: var(--muted); pointer-events: none; }
.search .field { width: 100%; padding-left: 36px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { background: #3a3b37; }
.btn-secondary { background: var(--raised); color: var(--text); border: 1px solid var(--control); }
.btn-secondary:hover { border-color: var(--text); }
.btn-quiet { color: var(--muted); padding: 0 10px; }
.btn-quiet:hover { color: var(--text); }

.table-wrap { overflow-x: auto; position: relative; }
.stages { width: 100%; border-collapse: collapse; font-size: 14px; }
.stages th {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  text-align: left;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.stages td { padding: 0 12px; height: 56px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.stages tr:last-child td { border-bottom: 0; }
.stages th:first-child, .stages td:first-child { padding-left: 0; }
.stages th:last-child, .stages td:last-child { padding-right: 0; }
.stages .num { text-align: right; }
.person { display: flex; align-items: center; gap: 12px; font-weight: 500; }
.initials {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--raised);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.dash { color: var(--muted); }
.salary-cell { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.delete-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 120ms ease, background-color 120ms ease;
}
.delete-btn:hover { color: var(--negative); background: #fdecea; }
.delete-btn:focus-visible { outline: 2px solid var(--negative); outline-offset: 1px; }
.company-job { display: none; }

@media (max-width: 860px) {
  .stages thead { display: none; }
  .stages, .stages tbody, .stages td { display: block; width: 100%; }
  .stages tr {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-areas: "who pay del" "job job del" "where where del";
    column-gap: 12px;
    row-gap: 2px;
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
  }
  .stages tr:last-child { border-bottom: 0; }
  .stages td { height: auto; padding: 0; border: 0; white-space: normal; }
  .stages td.c-who { grid-area: who; }
  .stages td.c-pay { grid-area: pay; text-align: right; width: auto; }
  .stages td.c-company { grid-area: job; padding-left: 44px; color: var(--muted); font-size: 13px; }
  .stages td.c-job { display: none; }
  .stages td.c-where { grid-area: where; padding-left: 44px; color: var(--muted); font-size: 13px; }
  .stages td.c-del { grid-area: del; align-self: center; width: 32px; }
  .stages td.c-company .company-job { display: inline; }
}

.empty {
  border: 1px dashed var(--control);
  border-radius: var(--radius-inner);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer { padding-top: 32px; padding-bottom: 32px; font-size: 12px; color: var(--muted); }

.dialog-scrim { background: rgba(31, 32, 29, 0.45); }
.dialog {
  background: var(--raised);
  border-radius: var(--radius-card);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
  width: 100%;
  max-width: 520px;
}
.dialog .field-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.dialog .field { width: 100%; border-radius: 12px; }
.dialog .help { font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 6px; }
.optional { color: var(--muted); font-weight: 400; }
.picker-frame { height: 220px; min-height: 220px; width: 100%; border-radius: var(--radius-inner); overflow: hidden; margin-top: 10px; }
.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.close-btn:hover { color: var(--text); background: var(--surface); }

.leaflet-container { font-family: "IBM Plex Sans", system-ui, sans-serif; }
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 18px; }
.pop-company { font-weight: 600; font-size: 14px; }
.pop-meta { color: var(--muted); }
.pop-salary { margin-top: 6px; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

.row-actions { display: inline-flex; gap: 2px; }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 120ms ease, background-color 120ms ease;
}
.icon-btn:hover { color: var(--text); background: var(--surface); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn.delete-btn:hover { color: var(--negative); background: #fdecea; }
.stages .admin-only.hidden { display: none; }
@media (max-width: 860px) {
  .stages td.c-del { width: auto; }
  .stages td.c-del.hidden { display: none; }
  .stages tr:has(td.c-del.hidden) { grid-template-columns: 1fr auto; grid-template-areas: "who pay" "job job" "where where"; }
}

.btn-danger { background: var(--negative); color: #fff; }
.btn-danger:hover { background: #8f1c13; }
.dialog-sm { max-width: 400px; }
.picker-frame-sm { height: 180px; min-height: 180px; }

.pop-group { min-width: 220px; max-width: 280px; }
.pop-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.pop-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
}

.login-wrap { min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 48px 0; }
.login-panel { width: 100%; max-width: 420px; }
.login-panel .field { width: 100%; border-radius: 12px; }
.login-panel .field-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.login-panel .help { font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 6px; }
.code-field { font-size: 18px; letter-spacing: 0.08em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.login-error { background: #fdecea; color: #7a1d14; border-radius: 12px; padding: 10px 14px; font-size: 14px; }

.wordmark { white-space: nowrap; }
@media (max-width: 520px) {
  #nav-admin-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #nav-admin-btn { padding: 0 8px; }
  .row-actions { flex-direction: column; }
}
