/* PM+ app shell (WP-17b). Tokens from the PM+ prototype (apps/prototype), light and dark. */
:root {
  color-scheme: light dark;
  --bg: #f3f6f5;
  --panel: #ffffff;
  --panel2: #eef3f1;
  --fg: #122220;
  --muted: #5b6d69;
  --line: #dbe4e1;
  --brand: #0e6b5f;
  --brand-ink: #ffffff;
  --brand-soft: #dcefeb;
  --ok: #1f7a3a;
  --ok-soft: #e1f2e5;
  --warn: #a05c00;
  --warn-soft: #fbefd8;
  --bad: #b4322a;
  --bad-soft: #fbe5e3;
  --focus: #1d5fd6;
  --radius: 12px;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1514;
    --panel: #141f1d;
    --panel2: #1a2826;
    --fg: #e3ecea;
    --muted: #9bb0ac;
    --line: #273836;
    --brand: #4fc2b1;
    --brand-ink: #06201c;
    --brand-soft: #173a35;
    --ok: #7fd295;
    --ok-soft: #173322;
    --warn: #f0b65c;
    --warn-soft: #3a2b12;
    --bad: #f08c84;
    --bad-soft: #3d1c1a;
    --focus: #8fb5ff;
  }
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 var(--f-body);
}
body {
  padding-bottom: env(safe-area-inset-bottom);
}
a {
  color: var(--brand);
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.logo {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  padding-bottom: 10px;
}
.logo b {
  color: var(--brand);
}
.tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.tabs a {
  padding: 10px 12px 12px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 3px solid transparent;
}
/* Four tabs on a narrow phone: tighter, and the row scrolls rather than spilling over. */
@media (max-width: 440px) {
  .top {
    gap: 8px;
  }
  .tabs {
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs a {
    /* 5px sides: all five tabs fit a 375px phone without scrolling (Me was cut off, 21 Nov). */
    padding: 10px 5px 12px;
    font-size: 15px;
    white-space: nowrap;
  }
}
.tabs a:hover {
  color: var(--fg);
}
/* Selected: two cues, colour and the underline (KZ-002). */
.tabs a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--brand);
}

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}
h1 {
  font-size: 22px;
  margin: 4px 0 2px;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 15px;
  margin: 22px 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sub {
  color: var(--muted);
  margin: 0 0 12px;
}
.state {
  color: var(--muted);
  padding: 24px 0;
  text-align: center;
}
.state.error {
  color: var(--bad);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 10px;
}
.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.name {
  font-weight: 700;
  font-size: 17px;
  overflow-wrap: anywhere;
}
.meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: 2px;
}
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.overdue {
  background: var(--bad-soft);
  color: var(--bad);
}
.badge.new {
  background: var(--brand-soft);
  color: var(--brand);
}
.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.stages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.stages button {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.stages button:hover {
  border-color: var(--brand);
}
.stages button:active {
  transform: translateY(1px);
}
/* The lead's current stage: filled and marked with a tick (two cues). */
.stages button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
}
.stages button[aria-pressed="true"]::before {
  content: "✓ ";
}
.stages button.lost[aria-pressed="false"] {
  color: var(--bad);
}
.stages button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn.secondary {
  background: transparent;
  color: var(--brand);
}
/* Close account: the one action that cannot be undone, in the warning colour. */
.btn.danger {
  background: transparent;
  border-color: var(--bad);
  color: var(--bad);
}
.btn.danger:disabled {
  cursor: not-allowed;
}
.btn:hover {
  filter: brightness(1.05);
}
.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}
.btn + .btn {
  margin-top: 8px;
}

label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
}
input[type="email"],
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg);
}
textarea {
  min-height: 120px;
  resize: vertical;
}
/* A field the server refused: the warning colour, with its sentence below (two cues). */
[aria-invalid="true"] {
  border-color: var(--bad);
}
.field-error {
  margin-top: 4px;
}
.field-error:empty {
  display: none;
}
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400;
}
.check input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex: none;
}

ol.steps {
  padding-left: 22px;
  margin: 8px 0 0;
}
ol.steps li {
  margin: 6px 0;
}
.note {
  background: var(--panel2);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
}
.msg {
  margin-top: 10px;
  font-size: 14px;
}
.msg.ok {
  color: var(--ok);
}
.msg.bad {
  color: var(--bad);
}
ul.devices {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.devices li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
/* A small secondary action in a list row ("Remove" next to another phone). */
.btn.small {
  width: auto;
  min-height: 36px;
  padding: 4px 12px;
  font-size: 14px;
  flex: none;
}
ul.devices li:first-child {
  border-top: 0;
}

form > .btn {
  margin-top: 14px;
}
form > .btn + .btn {
  margin-top: 8px;
}

/* Card editor: grouped choices (template, featured listings). */
fieldset {
  border: 0;
  padding: 0;
  margin: 12px 0 0;
}
legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 4px;
}
fieldset .check {
  margin: 8px 0;
}
.check input[type="checkbox"]:disabled + span {
  color: var(--muted);
}

/* Card photo: the agent's photo, cropped round at a fixed size. */
.card-photo {
  display: block;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin: 8px 0;
  background: var(--panel2);
}
/* Hidden from sight only: still in the page, focusable and labelled (never display: none). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
/* The photo picker's label, shown as a secondary button; the hidden input's focus shows on it. */
label.photo-button {
  margin: 8px 0 4px;
}
.visually-hidden:focus-visible + .photo-button {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.photo-button.disabled {
  opacity: 0.6;
  cursor: progress;
  pointer-events: none;
}

/* Insights: three numbers per period, then the per-campaign table. */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 440px) {
  .stats {
    grid-template-columns: 1fr;
  }
}
.stat {
  display: flex;
  flex-direction: column;
}
.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.stat-num {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 0 10px;
}
table.campaigns {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.campaigns caption {
  text-align: left;
  padding: 10px 12px 4px;
  color: var(--muted);
  font-weight: 600;
}
table.campaigns th,
table.campaigns td {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
table.campaigns th:first-child {
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
table.campaigns thead th {
  color: var(--muted);
  font-weight: 600;
}

/* Setup (first run): five step cards, and the "Finish setting up" card on Today. */
ol.setup {
  list-style: none;
  padding: 0;
  margin: 0;
}
.setup-step .btn {
  margin-top: 10px;
}
.text-button {
  display: block;
  margin: 6px auto 0;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}
a.setup-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--fg);
  text-decoration: none;
  border-color: var(--brand);
  background: var(--brand-soft);
}
a.setup-card .name {
  color: var(--brand);
}

/* Your writing style (#/voice): a section per channel, pasted posts and style rules as cards. */
.voice-channel {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.voice-channel h3 {
  margin: 0;
}
.voice-channel > .btn,
#voice-rule + .btn {
  margin-top: 10px;
}
ul.voice-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
/* Long posts and unbroken links wrap inside 375px instead of widening the page. */
.voice-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
}

/* Listings: the link at the top of Today, and one card per listing with its Edit button. */
.top-link {
  margin: 0 0 12px;
  font-weight: 600;
}
.listing-list {
  margin-top: 14px;
}
.listing-row .btn.small {
  margin-top: 10px;
}
/* Enquiries (#/leads): search, stage and "Show archived", then one tappable row per lead. */
input[type="search"],
input[type="datetime-local"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg);
}
.lead-filters {
  margin-bottom: 12px;
}
.lead-filters label:first-child {
  margin-top: 0;
}
ul.lead-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
}
.lead-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 46px;
  margin: 0 0 8px;
  padding: 12px 14px;
  text-align: left;
  font: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.lead-row:hover {
  border-color: var(--brand);
}
.lead-row .row {
  justify-content: flex-start;
  flex-wrap: wrap;
}
.lead-row .name {
  margin-right: auto;
}
/* On a lead card: the follow-up date and archive, folded away until opened. */
.lead-more {
  margin-top: 12px;
}
.lead-more summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
  min-height: 40px;
  display: flex;
  align-items: center;
}
/* Appointment calendar (#/calendar, Today, the lead card): tappable cards that wrap at 375px. */
.viewing-open {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.viewing-time {
  font-weight: 600;
  min-width: 4.5em;
}
.viewing-card .meta {
  overflow-wrap: anywhere;
}
.viewing-answers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.lead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
/* Files for buyers (listing edit) and the project pack (lead card). */
ul.file-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
.file-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.file-row .file-kind {
  font-weight: 600;
  margin-right: auto;
}
.listing-files input[type="file"] {
  width: 100%;
  min-height: 46px;
}
.listing-files .btn,
.project-pack .btn,
.site-visit .btn {
  margin-top: 10px;
}
.pack-panel {
  margin-top: 10px;
}
/* The message preview wraps inside 375px (long signed links included). */
.pack-text {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: 14px;
}
.check.rights {
  margin-top: 18px;
  font-weight: 600;
}
/* The listing form in two steps: the post, then the private follow-up behind one button. */
.new-launch {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.disclosure {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.disclosure::before {
  content: "▸";
  margin-right: 8px;
  color: var(--brand);
}
.disclosure[aria-expanded="true"]::before {
  content: "▾";
}
.follow-up-panel {
  padding: 0 0 8px;
}
.check.publish {
  margin-top: 16px;
  font-weight: 600;
}
.note.mixed {
  margin-top: 16px;
}
.link-button {
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.licence {
  margin-top: 10px;
}
input[type="date"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--fg);
}
.card select + .btn {
  margin-top: 10px;
}

/* Focus moved to a new screen's heading for screen readers: no ring (it is not a control). */
h1[tabindex="-1"]:focus {
  outline: none;
}

/* A link waiting on its request (e.g. "Send a new code"): not tappable again yet. */
a.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Pull to refresh (installed app): a strip above the page that grows as the agent pulls. */
/* No iOS rubber-band bounce in the installed app; our own pull strip shows the refresh. */
html,
body {
  overscroll-behavior-y: none;
}

.version {
  margin-top: 2rem;
  font-size: 0.7rem;
  text-align: center;
  opacity: 0.6;
}

.pull {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--muted, #6b7280);
  transition: height 0.15s ease;
}
