/* ==========================================================================
   Tradedesk — mobile-first stylesheet.
   Designed for a 375px screen held in one hand, in daylight, possibly gloved.
   Desktop (>=768px) is the enhancement.
   Brand colours are provisional — swap the tokens below in one place.
   ========================================================================== */

:root {
  /* Palette — provisional, swap these. */
  --color-accent: #0f766e;        /* teal */
  --color-accent-dark: #0b5952;
  --color-accent-tint: #d7efec;
  --color-ink: #14181b;           /* near-black text */
  --color-ink-soft: #55606a;
  --color-line: #e2e6ea;
  --color-surface: #ffffff;
  --color-bg: #f4f6f8;
  --color-danger: #c0392b;
  --color-warn: #b7791f;
  --color-ok: #2f855a;

  /* Status hues */
  --st-enquiry: #6b7280;
  --st-quoted: #2563eb;
  --st-accepted: #7c3aed;
  --st-scheduled: #0891b2;
  --st-in_progress: #b7791f;
  --st-complete: #2f855a;
  --st-invoiced: #0f766e;
  --st-paid: #15803d;

  --radius: 12px;
  --radius-sm: 8px;
  --tap: 44px;                    /* minimum tap target */
  --shadow: 0 1px 2px rgba(20, 24, 27, .06), 0 2px 8px rgba(20, 24, 27, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --header-h: 56px;
  --bottomnav-h: 64px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--color-ink);
  background: var(--color-bg);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-line);
}
.app-header__inner {
  height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  max-width: 1100px; margin: 0 auto;
}
.app-header__brand { font-weight: 700; color: var(--color-ink); font-size: 1.05rem; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-accent); color: #fff; font-size: .8rem; font-weight: 700;
}

/* ---------- Layout ---------- */
.layout { max-width: 1100px; margin: 0 auto; display: block; }
.content {
  padding: 16px 16px calc(var(--bottomnav-h) + 24px);
  min-height: calc(100vh - var(--header-h));
}
.content--auth {
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; min-height: 100vh;
}
.sidebar { display: none; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--bottomnav-h);
  display: flex; align-items: stretch;
  background: var(--color-surface);
  border-top: 1px solid var(--color-line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--color-ink-soft); font-size: .68rem; min-height: var(--tap);
}
.bottom-nav__item:hover { text-decoration: none; }
.bottom-nav__item.is-active { color: var(--color-accent); }
.bottom-nav__icon { font-size: 1.2rem; line-height: 1; }
.bottom-nav__add {
  flex: 0 0 auto; width: 56px; height: 56px; margin: 4px 6px 0;
  border: none; border-radius: 50%;
  background: var(--color-accent); color: #fff; font-size: 1.9rem; line-height: 1;
  box-shadow: var(--shadow); cursor: pointer;
  align-self: center;
}
.bottom-nav__add:active { background: var(--color-accent-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 18px; gap: 8px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  background: var(--color-surface); color: var(--color-ink);
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--color-accent); color: #fff; }
.btn--primary:active { background: var(--color-accent-dark); }
.btn--ghost { background: var(--color-surface); border-color: var(--color-line); color: var(--color-ink); }
.btn--danger { background: transparent; border-color: var(--color-danger); color: var(--color-danger); }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }

/* ---------- Page head ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.page-head__title { font-size: 1.5rem; }
.page-head__meta { color: var(--color-ink-soft); font-size: .9rem; margin: 0; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--color-surface); border: 1px solid var(--color-line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.stat__value { font-size: 1.9rem; font-weight: 700; color: var(--color-accent); }
.stat__label { font-size: .82rem; color: var(--color-ink-soft); }

/* ---------- Panels ---------- */
.panel {
  background: var(--color-surface); border: 1px solid var(--color-line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel--accent { border-left: 3px solid var(--color-accent); }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel__title { font-size: 1.05rem; margin: 0; }
.panel__action { font-size: .85rem; }

/* ---------- Lists ---------- */
.job-list { list-style: none; margin: 0; padding: 0; }
.job-list__item + .job-list__item { border-top: 1px solid var(--color-line); }
.job-list__link { display: flex; align-items: center; gap: 12px; padding: 12px 2px; color: var(--color-ink); }
.job-list__link:hover { text-decoration: none; }
.job-list__time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--color-accent); width: 48px; }
.job-list__main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.job-list__title { font-weight: 600; }
.job-list__sub { font-size: .82rem; color: var(--color-ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-list { display: flex; flex-direction: column; }
.card-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 4px;
  border-bottom: 1px solid var(--color-line); color: var(--color-ink);
}
.card-row:hover { text-decoration: none; }
.card-row__main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.card-row__title { font-weight: 600; }
.card-row__sub { font-size: .82rem; color: var(--color-ink-soft); overflow: hidden; text-overflow: ellipsis; }
.card-row__actions { display: flex; gap: 12px; flex-shrink: 0; }
.link-sm { font-size: .85rem; }

.empty { color: var(--color-ink-soft); padding: 8px 2px; }

/* ---------- Detail lists ---------- */
.detail-list { display: grid; grid-template-columns: minmax(90px, 30%) 1fr; gap: 6px 12px; margin: 0; }
.detail-list dt { color: var(--color-ink-soft); font-size: .85rem; }
.detail-list dd { margin: 0; }
.detail-sub { font-size: .82rem; color: var(--color-ink-soft); }
.detail-notes { margin-top: 12px; white-space: pre-wrap; }

/* ---------- Tags & status ---------- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; background: var(--color-bg); color: var(--color-ink-soft);
  border: 1px solid var(--color-line);
}
.tag--domestic { background: #eef2ff; color: #4338ca; border-color: transparent; }
.tag--commercial { background: #ecfeff; color: #0e7490; border-color: transparent; }
.tag--landlord { background: #fef3c7; color: #92400e; border-color: transparent; }
.tag--agent { background: #f3e8ff; color: #6b21a8; border-color: transparent; }
.tag--before { background: #e0f2fe; color: #075985; border-color: transparent; }
.tag--during { background: #fef9c3; color: #854d0e; border-color: transparent; }
.tag--after { background: #dcfce7; color: #166534; border-color: transparent; }
.tag--issue { background: #fee2e2; color: #991b1b; border-color: transparent; }

.status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; color: #fff; white-space: nowrap; background: var(--st-enquiry);
}
.status--enquiry { background: var(--st-enquiry); }
.status--quoted { background: var(--st-quoted); }
.status--accepted { background: var(--st-accepted); }
.status--scheduled { background: var(--st-scheduled); }
.status--in_progress { background: var(--st-in_progress); }
.status--complete { background: var(--st-complete); }
.status--invoiced { background: var(--st-invoiced); }
.status--paid { background: var(--st-paid); }

/* ---------- Filter chips ---------- */
.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 4px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: var(--color-surface); border: 1px solid var(--color-line); color: var(--color-ink-soft);
}
.chip:hover { text-decoration: none; }
.chip.is-active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Forms ---------- */
.form { display: block; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; }
.field label, .field > label { font-size: .85rem; color: var(--color-ink-soft); margin-bottom: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field__error { color: var(--color-danger); font-size: .8rem; margin-top: 4px; }
.field__hint { color: var(--color-ink-soft); font-size: .8rem; margin: 4px 0 0; }
.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--color-line); border-radius: var(--radius-sm);
  font-size: 1rem; font-family: inherit; color: var(--color-ink); background: #fff;
}
.input:focus { outline: 2px solid var(--color-accent); outline-offset: 0; border-color: var(--color-accent); }
textarea.input { min-height: 80px; resize: vertical; }
.input--inline { min-height: 40px; width: auto; }
.fieldset { border: 1px solid var(--color-line); border-radius: var(--radius-sm); padding: 12px; margin: 0 0 16px; }
.fieldset legend { padding: 0 6px; font-size: .8rem; color: var(--color-ink-soft); font-weight: 600; }
.checkbox { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: .95rem; }
.checkbox input { width: 20px; height: 20px; }
.form__actions { display: flex; gap: 12px; margin-top: 8px; }

.search { margin-bottom: 12px; position: relative; }
.htmx-indicator { position: absolute; right: 14px; top: 12px; opacity: 0; transition: opacity .2s; color: var(--color-ink-soft); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- Status row ---------- */
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.status-row__label { display: block; font-size: .8rem; color: var(--color-ink-soft); margin-bottom: 4px; }

/* ---------- Notes ---------- */
.note-form { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.note-form .input { margin: 0; }
.note-list { list-style: none; margin: 0; padding: 0; }
.note { border: 1px solid var(--color-line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; background: var(--color-bg); }
.note__head { display: flex; justify-content: space-between; font-size: .78rem; color: var(--color-ink-soft); margin-bottom: 4px; }
.note__body { margin: 0; white-space: pre-wrap; }

/* ---------- Photos ---------- */
.photo-form { margin-bottom: 16px; }
.photo-form .input[type=file] { padding: 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.photo { margin: 0; border: 1px solid var(--color-line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.photo img { width: 100%; height: 130px; object-fit: cover; display: block; }
.photo__cap { padding: 6px 8px; font-size: .78rem; color: var(--color-ink-soft); display: flex; gap: 6px; align-items: center; }

/* ---------- Trade picker ---------- */
.trade-picker { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.trade-option { display: flex; border: 1px solid var(--color-line); border-radius: var(--radius-sm); padding: 12px; gap: 12px; align-items: center; }
.trade-option__body { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.trade-option__name { font-weight: 600; }
.trade-option__primary { font-size: .8rem; color: var(--color-ink-soft); display: flex; align-items: center; gap: 4px; }

/* ---------- Danger zone ---------- */
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--color-line); }

/* ---------- Auth ---------- */
.auth-card {
  width: 100%; max-width: 380px; background: var(--color-surface);
  border: 1px solid var(--color-line); border-radius: var(--radius); padding: 28px 22px;
  box-shadow: var(--shadow);
}
.auth-card--wide { max-width: 460px; }
.auth-card__brand { text-align: center; color: var(--color-accent); font-size: 1.6rem; margin-bottom: 2px; }
.auth-card__sub { text-align: center; color: var(--color-ink-soft); margin-top: 0; margin-bottom: 20px; }
.auth-card__links { display: flex; justify-content: space-between; margin-top: 18px; font-size: .88rem; flex-wrap: wrap; gap: 8px; }
.auth-card__note { font-size: .8rem; color: var(--color-ink-soft); text-align: center; margin-top: 14px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 16px; right: 16px; top: calc(var(--header-h) + 8px); z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  background: var(--color-ink); color: #fff; font-size: .92rem;
  animation: toast-in .2s ease-out;
}
.toast--success { background: var(--color-ok); }
.toast--error { background: var(--color-danger); }
.toast--info { background: var(--color-accent); }
.toast__close { background: none; border: none; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Quick add sheet ---------- */
.quick-add { position: fixed; inset: 0; z-index: 80; }
.quick-add[hidden] { display: none; }
.quick-add__backdrop { position: absolute; inset: 0; background: rgba(20, 24, 27, .4); }
.quick-add__sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--color-surface); border-radius: 18px 18px 0 0; padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.quick-add__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--color-line); margin: 4px auto 10px; }
.quick-add__option { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 12px; border-radius: var(--radius-sm); background: var(--color-bg); color: var(--color-ink); font-weight: 600; }
.quick-add__option:hover { text-decoration: none; }
.quick-add__glyph { font-size: 1.3rem; }
.quick-add__cancel { min-height: var(--tap); border: none; background: none; color: var(--color-ink-soft); font-size: 1rem; cursor: pointer; margin-top: 4px; }

/* ---------- Error pages ---------- */
.error-page { text-align: center; padding: 48px 16px; }
.error-page__code { font-size: 3rem; font-weight: 800; color: var(--color-accent); }
.error-page__heading { font-size: 1.4rem; }
.error-page__message { color: var(--color-ink-soft); margin-bottom: 20px; }

/* ==========================================================================
   Desktop enhancement (>=768px): sidebar in, bottom nav out.
   ========================================================================== */
@media (min-width: 768px) {
  .layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 24px; padding: 0 16px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 20px;
    position: sticky; top: calc(var(--header-h) + 16px); align-self: start;
    height: calc(100vh - var(--header-h) - 32px);
    padding: 16px 0;
  }
  .sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar__link {
    display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm);
    color: var(--color-ink); font-weight: 600;
  }
  .sidebar__link:hover { background: var(--color-bg); text-decoration: none; }
  .sidebar__link.is-active { background: var(--color-accent-tint); color: var(--color-accent-dark); }
  .sidebar__actions { display: flex; flex-direction: column; gap: 8px; }
  .sidebar__foot { margin-top: auto; font-size: .85rem; color: var(--color-ink-soft); display: flex; flex-direction: column; gap: 4px; }

  .bottom-nav { display: none; }
  .content { padding: 24px 0 48px; min-height: auto; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .toasts { left: auto; right: 24px; width: 360px; }
}

/* ==========================================================================
   Phase 2 — quotes builder, public pages, documents
   ========================================================================== */
.ta-r { text-align: right; }
.mono-break { font-family: ui-monospace, monospace; font-size: .82rem; word-break: break-all; background: var(--color-bg); padding: 8px 10px; border-radius: var(--radius-sm); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.signature { max-width: 260px; border: 1px solid var(--color-line); border-radius: var(--radius-sm); margin-top: 8px; background: #fff; }

/* quote status colours */
.status--draft { background: var(--st-enquiry); }
.status--sent { background: var(--st-quoted); }
.status--viewed { background: var(--st-scheduled); }
.status--accepted { background: var(--st-paid); }
.status--declined { background: var(--color-danger); }
.status--superseded { background: #9aa4ad; }
.status--issued { background: var(--st-invoiced); }
.status--part_paid { background: var(--st-in_progress); }
.status--paid { background: var(--st-paid); }
.status--overdue { background: var(--color-danger); }
.status--cancelled { background: #9aa4ad; }

/* Builder */
.qb-meta .field { margin-bottom: 10px; }
.qb-section { border: 1px solid var(--color-line); border-radius: var(--radius-sm); margin-bottom: 12px; }
.qb-section--optional { border-left: 3px solid var(--color-accent); }
.qb-section__head { padding: 8px 10px; background: var(--color-bg); font-weight: 600; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.qb-section__title em { color: var(--color-accent); font-style: normal; font-size: .82rem; }
.qb-lines { padding: 6px 8px; overflow-x: auto; }
.qb-line { display: grid; grid-template-columns: minmax(120px,2fr) 68px 80px 60px 64px 78px 28px; gap: 6px; align-items: center; padding: 3px 0; }
.qb-line--head { font-size: .7rem; text-transform: uppercase; color: var(--color-ink-soft); }
.qb-line__net { font-variant-numeric: tabular-nums; font-weight: 600; }
.qb-line__del { border: none; background: none; color: var(--color-danger); font-size: 1.2rem; cursor: pointer; line-height: 1; }
.input--sm { min-height: 34px; padding: 4px 6px; font-size: .88rem; }
.qb-section__tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--color-line); position: relative; }
.qb-catsearch { max-width: 220px; }
.qb-cat { position: relative; width: 100%; }
.qb-cat__list { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--color-line); border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto; background: #fff; }
.qb-cat__item { display: flex; justify-content: space-between; width: 100%; border: none; background: none; padding: 8px 10px; cursor: pointer; text-align: left; border-bottom: 1px solid var(--color-line); }
.qb-cat__item:hover { background: var(--color-accent-tint); }
.qb-cat__price { color: var(--color-ink-soft); font-variant-numeric: tabular-nums; }
.qb-cat__empty { color: var(--color-ink-soft); font-size: .85rem; padding: 6px; }
.qb-addsection { display: flex; gap: 8px; margin: 10px 0; }
.qb-totals { margin-top: 12px; margin-left: auto; max-width: 320px; }
.qb-totals__row { display: flex; justify-content: space-between; padding: 4px 0; }
.qb-totals__row--total { border-top: 2px solid var(--color-ink); font-weight: 700; font-size: 1.1rem; margin-top: 4px; padding-top: 8px; }
.qb-totals__row--deposit { color: var(--color-accent); font-weight: 600; }
.qb-issue { margin-top: 16px; }
.qb-issue__note { font-size: .8rem; color: var(--color-ink-soft); text-align: center; margin-top: 6px; }

/* Public pages */
body.public { background: var(--color-bg); }
.public-head { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--color-surface); border-bottom: 2px solid var(--color-accent); }
.public-head__logo { max-height: 44px; }
.public-head__name { font-weight: 700; font-size: 1.1rem; }
.public-head__contact { margin-left: auto; color: var(--color-ink-soft); font-size: .9rem; }
.public-main { max-width: 640px; margin: 0 auto; padding: 16px; }
.public-foot { text-align: center; color: var(--color-ink-soft); font-size: .75rem; padding: 20px; }
.public-doc { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.public-doc__head h1 { margin: 0 0 4px; }
.public-doc__ref { color: var(--color-ink-soft); font-size: .88rem; margin: 0; }
.public-doc__valid { color: var(--color-accent); font-size: .85rem; margin-top: 4px; }
.public-doc__intro { margin: 12px 0; }
.public-banner { padding: 12px; border-radius: var(--radius-sm); margin: 12px 0; font-weight: 600; }
.public-banner--ok { background: #dcfce7; color: #166534; }
.public-banner--muted { background: var(--color-bg); color: var(--color-ink-soft); }
.public-section { margin: 16px 0; border-top: 1px solid var(--color-line); padding-top: 12px; }
.public-section--optional { background: var(--color-accent-tint); border-radius: var(--radius-sm); padding: 12px; border-top: none; }
.public-section__head { display: flex; justify-content: space-between; align-items: center; }
.public-section__head h2 { font-size: 1.05rem; margin: 0; }
.opt-toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--color-accent); }
.opt-toggle input { width: 22px; height: 22px; }
.public-lines { list-style: none; margin: 8px 0 0; padding: 0; }
.public-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--color-line); }
.public-line__desc em { color: var(--color-ink-soft); font-style: normal; }
.public-line__amt { font-variant-numeric: tabular-nums; }
.public-totals { margin-top: 14px; border-top: 2px solid var(--color-ink); padding-top: 10px; }
.public-totals__row { display: flex; justify-content: space-between; padding: 4px 0; }
.public-totals__row--total { font-weight: 700; font-size: 1.2rem; }
.public-totals__row--deposit { color: var(--color-accent); font-weight: 600; }
.public-doc__vatnote { font-size: .78rem; color: var(--color-ink-soft); margin-top: 8px; }
.public-doc__terms { margin-top: 16px; font-size: .85rem; color: var(--color-ink-soft); }
.public-actions { margin-top: 20px; border-top: 2px solid var(--color-line); padding-top: 16px; }
.accept-form h3 { margin: 0 0 8px; }
.accept-form label { display: block; font-size: .85rem; color: var(--color-ink-soft); margin: 10px 0 4px; }
.accept-form__deposit { background: var(--color-accent-tint); padding: 10px; border-radius: var(--radius-sm); font-size: .88rem; }
.sigpad-wrap { display: flex; flex-direction: column; gap: 6px; }
.sigpad { border: 1px dashed var(--color-line); border-radius: var(--radius-sm); background: #fff; width: 100%; touch-action: none; }
.decline { margin-top: 16px; }
.decline summary { cursor: pointer; color: var(--color-ink-soft); font-size: .9rem; }
.decline-form { margin-top: 8px; }
.public-outcome { text-align: center; padding: 32px 20px; }
.public-outcome__icon { font-size: 3rem; color: var(--color-ok); }
.public-outcome__icon--muted { color: var(--color-ink-soft); }

/* Phase 2 — invoices */
.qb-line--inv { grid-template-columns: minmax(110px,2fr) 62px 74px 54px 58px 44px 74px 26px; }
.qb-line--inv.qb-line--head { font-size: .68rem; }
.qb-labour { width: 20px; height: 20px; justify-self: center; }
.qb-totals__note { font-size: .78rem; color: var(--color-accent); margin-top: 4px; }
.totals-table { width: 100%; max-width: 380px; margin-left: auto; border-collapse: collapse; }
.totals-table td { padding: 5px 4px; }
.totals-table .ta-r { text-align: right; font-variant-numeric: tabular-nums; }
.totals-grand td { border-top: 2px solid var(--color-ink); font-weight: 700; font-size: 1.1rem; }
.totals-note { font-size: .78rem; color: var(--color-ink-soft); }
.pay-list { list-style: none; margin: 10px 0 0; padding: 0; }
.pay-list__item { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--color-line); font-size: .9rem; }
.public-pay { margin-top: 18px; border-top: 2px solid var(--color-line); padding-top: 16px; }
.public-pay__due { font-size: 1.1rem; margin-bottom: 10px; }
.public-pay__note { font-size: .8rem; color: var(--color-ink-soft); margin-top: 6px; }

/* Phase 2 — diary */
.diary-switch { display: flex; gap: 8px; margin-bottom: 12px; }
.diary-switch__desk { display: none; }
.diary-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.diary-nav__label { font-weight: 600; }

/* Agenda */
.agenda-day { margin-bottom: 18px; }
.agenda-day__head { font-size: 1rem; color: var(--color-ink-soft); border-bottom: 1px solid var(--color-line); padding-bottom: 6px; margin-bottom: 8px; }
.agenda-day__today { background: var(--color-accent); color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 999px; }
.agenda-day__list { display: flex; flex-direction: column; gap: 8px; }

.appt { display: grid; grid-template-columns: 62px 1fr; gap: 10px; background: var(--color-surface); border: 1px solid var(--color-line); border-left: 4px solid var(--color-line); border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: var(--shadow); }
.appt--status-completed { opacity: .6; border-left-color: var(--st-paid); }
.appt--status-cancelled { opacity: .5; border-left-color: #9aa4ad; }
.appt--status-no_access { border-left-color: var(--color-danger); }
.appt--status-scheduled, .appt--status-confirmed { border-left-color: var(--color-accent); }
.appt__time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--color-accent); font-size: .9rem; }
.appt__title { font-weight: 600; color: var(--color-ink); }
.appt__sub { font-size: .82rem; color: var(--color-ink-soft); }
.appt__notes { font-size: .85rem; margin-top: 4px; }
.appt__badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.appt-status { font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--color-bg); color: var(--color-ink-soft); text-transform: uppercase; }
.appt-status--completed { background: #dcfce7; color: #166534; }
.appt-status--no_access { background: #fee2e2; color: #991b1b; }
.appt-status--cancelled { background: #e5e7eb; color: #4b5563; }
.appt__actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--color-line); }
.appt__act { border: 1px solid var(--color-line); background: var(--color-surface); border-radius: var(--radius-sm); padding: 6px 12px; font-size: .82rem; font-weight: 600; cursor: pointer; min-height: 36px; color: var(--color-ink); }
.appt__act--ok { border-color: var(--st-paid); color: var(--st-paid); }
.appt__act--warn { border-color: var(--color-danger); color: var(--color-danger); }
.appt__act--danger { color: var(--color-danger); }
.appt__act--rebook, .appt__rebook-hint { color: var(--color-accent); font-weight: 600; }
.appt__rebook-hint { grid-column: 1 / -1; display: block; margin-top: 6px; font-size: .85rem; }
.appt--editing, .reschedule-form { display: block; }
.reschedule-form .field-row { margin-bottom: 8px; }

/* Week grid */
.week-grid-wrap { overflow-x: auto; }
.week-grid { width: 100%; border-collapse: collapse; min-width: 640px; }
.week-grid th, .week-grid td { border: 1px solid var(--color-line); vertical-align: top; }
.week-grid th { padding: 6px; font-size: .8rem; background: var(--color-bg); text-align: center; }
.week-grid th.is-today { background: var(--color-accent-tint); }
.week-grid__hour { width: 52px; font-size: .72rem; color: var(--color-ink-soft); text-align: right; padding: 4px 6px; white-space: nowrap; }
.week-grid__cell { height: 44px; position: relative; padding: 2px; }
.week-grid__cell.is-today { background: #fbfdfc; }
.week-grid__add { position: absolute; right: 2px; top: 2px; opacity: 0; color: var(--color-ink-soft); font-weight: 700; text-decoration: none; }
.week-grid__cell:hover .week-grid__add { opacity: 1; }
.week-chip { display: block; font-size: .72rem; padding: 2px 5px; border-radius: 4px; margin-bottom: 2px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-chip.appt-status--cancelled, .month-chip.appt-status--cancelled { text-decoration: line-through; opacity: .6; }

/* Month grid */
.month-grid-wrap { overflow-x: auto; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(90px, 1fr)); gap: 1px; background: var(--color-line); border: 1px solid var(--color-line); }
.month-grid__dow { background: var(--color-bg); text-align: center; font-size: .72rem; font-weight: 600; color: var(--color-ink-soft); padding: 6px 0; }
.month-cell { background: var(--color-surface); min-height: 84px; padding: 4px; }
.month-cell--out { background: #fafbfc; }
.month-cell--out .month-cell__num { color: var(--color-line); }
.month-cell.is-today { background: var(--color-accent-tint); }
.month-cell__num { font-size: .78rem; font-weight: 600; color: var(--color-ink); display: inline-block; margin-bottom: 2px; }
.month-chip { display: block; font-size: .68rem; padding: 1px 4px; border-radius: 3px; margin-bottom: 2px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-chip--more { background: var(--color-bg); color: var(--color-ink-soft); }

@media (min-width: 768px) {
  .diary-switch__desk { display: inline-flex; }
}

/* Phase 2 — dashboard money tiles + reminder ladder */
.stat--link { text-decoration: none; transition: border-color .15s; }
.stat--link:hover { text-decoration: none; border-color: var(--color-accent); }
.stat--alert { border-color: var(--color-danger); }
.stat--alert .stat__value { color: var(--color-danger); }
.rule-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.rule-row { display: flex; align-items: center; gap: 14px; padding: 8px; border: 1px solid var(--color-line); border-radius: var(--radius-sm); flex-wrap: wrap; }
.rule-row .checkbox { margin: 0; }
.rule-row__offset { font-variant-numeric: tabular-nums; }
.rule-row__ch { color: var(--color-ink-soft); font-size: .85rem; margin-left: auto; }

/* ==========================================================================
   Landing / marketing page (public front door — Tradedesk-branded)
   ========================================================================== */
body.landing { background: var(--color-surface); }
.lp-header { border-bottom: 1px solid var(--color-line); position: sticky; top: 0; background: rgba(255,255,255,.9); backdrop-filter: blur(6px); z-index: 20; }
.lp-header__inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.lp-brand { font-weight: 800; font-size: 1.25rem; color: var(--color-accent); }
.lp-nav { display: flex; align-items: center; gap: 16px; }
.lp-nav__link { font-weight: 600; color: var(--color-ink); }
.lp-hero { padding: 64px 16px 48px; text-align: center; background: linear-gradient(180deg, var(--color-accent-tint), var(--color-surface)); }
.lp-hero__inner { max-width: 760px; margin: 0 auto; }
.lp-hero h1 { font-size: 2.4rem; line-height: 1.1; letter-spacing: -.02em; margin-bottom: 16px; }
.lp-hero__sub { font-size: 1.15rem; color: var(--color-ink-soft); margin-bottom: 28px; }
.lp-hero__cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.lp-hero__note { color: var(--color-ink-soft); font-size: .9rem; margin-top: 16px; }
.lp-section { padding: 56px 16px; }
.lp-section--tint { background: var(--color-bg); }
.lp-wrap { max-width: 1080px; margin: 0 auto; }
.lp-h2 { font-size: 1.8rem; text-align: center; letter-spacing: -.01em; }
.lp-sub { text-align: center; color: var(--color-ink-soft); margin-bottom: 24px; }
.lp-grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 28px; }
.lp-card { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.lp-card__icon { width: 44px; height: 44px; border-radius: 10px; background: var(--color-accent-tint); color: var(--color-accent-dark); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 800; margin-bottom: 12px; }
.lp-card h3 { font-size: 1.15rem; margin-bottom: 6px; }
.lp-card p { color: var(--color-ink-soft); margin: 0; }
.lp-pricing { display: grid; grid-template-columns: 1fr; gap: 16px; margin: 24px 0; }
.lp-plan { border: 1px solid var(--color-line); border-radius: var(--radius); padding: 24px; background: var(--color-surface); text-align: center; }
.lp-plan--featured { border-color: var(--color-accent); box-shadow: 0 8px 24px rgba(15,118,110,.12); }
.lp-plan__name { font-weight: 700; color: var(--color-ink-soft); text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; }
.lp-plan__price { font-size: 2.4rem; font-weight: 800; color: var(--color-accent); margin: 8px 0 12px; }
.lp-plan__price span { font-size: 1rem; color: var(--color-ink-soft); font-weight: 600; }
.lp-plan ul { list-style: none; padding: 0; margin: 0; text-align: left; display: inline-block; }
.lp-plan li { padding: 5px 0 5px 22px; position: relative; color: var(--color-ink); }
.lp-plan li::before { content: "✓"; position: absolute; left: 0; color: var(--color-accent); font-weight: 700; }
.lp-footer { border-top: 1px solid var(--color-line); padding: 24px 16px; color: var(--color-ink-soft); font-size: .9rem; }
.lp-footer .lp-wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

@media (min-width: 700px) {
  .lp-hero h1 { font-size: 3rem; }
  .lp-grid { grid-template-columns: repeat(3, 1fr); }
  .lp-pricing { grid-template-columns: repeat(3, 1fr); }
}

/* Onboarding checklist (new-account dashboard) */
.onboard__count { font-size: .82rem; color: var(--color-ink-soft); }
.onboard__bar { height: 8px; background: var(--color-bg); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.onboard__bar span { display: block; height: 100%; background: var(--color-accent); border-radius: 999px; transition: width .3s; }
.onboard__list { list-style: none; margin: 0; padding: 0; }
.onboard__step { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--color-line); }
.onboard__step.is-done { color: var(--color-ink-soft); }
.onboard__step.is-done span:last-child { text-decoration: line-through; }
.onboard__tick { color: var(--color-accent); font-weight: 700; width: 18px; text-align: center; }

/* Phase 4 — running timer pill + job costing panel */
.timer-pill { position: sticky; top: var(--header-h); z-index: 25; display: flex; align-items: center; gap: 10px; background: var(--color-ink); color: #fff; padding: 8px 14px; max-width: 1100px; margin: 0 auto; }
.timer-pill__dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.timer-pill__job { color: #fff; font-weight: 700; }
.timer-pill__elapsed { font-variant-numeric: tabular-nums; font-weight: 700; margin-left: auto; }
.timer-pill__form { margin: 0; }
.timer-pill__stop { background: #ef4444; color: #fff; border: none; border-radius: var(--radius-sm); padding: 6px 12px; font-weight: 700; cursor: pointer; }

.cost-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.cost-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--color-line); }
.cost-row--total { font-weight: 700; border-bottom: none; }
.cost-profit { text-align: center; padding: 14px; border-radius: var(--radius); margin-bottom: 12px; }
.cost-profit--good { background: #dcfce7; color: #166534; }
.cost-profit--bad { background: #fee2e2; color: #991b1b; }
.cost-profit__value { font-size: 2rem; font-weight: 800; }
.cost-profit__label { font-size: .85rem; }
.cost-variance { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--color-bg); }
.cost-variance--over { background: #fef3c7; color: #92400e; font-weight: 600; }
.time-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--color-line); }
.time-row__hrs { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Phase 5 — My Day (operative view) */
.myday-list { display: flex; flex-direction: column; gap: 10px; }
.myday-job { border: 1px solid var(--color-line); border-left: 4px solid var(--color-accent); border-radius: var(--radius-sm); padding: 12px; box-shadow: var(--shadow); }
.myday-job__main { display: flex; flex-direction: column; gap: 3px; color: var(--color-ink); }
.myday-job__main:hover { text-decoration: none; }
.myday-job__title { font-weight: 700; font-size: 1.05rem; }
.myday-job__site { color: var(--color-ink-soft); font-size: .9rem; }
.myday-job__time { font-weight: 700; color: var(--color-accent); }
.myday-job__access { font-size: .85rem; background: var(--color-bg); padding: 4px 8px; border-radius: 6px; margin: 2px 0; }
.myday-job__nav { display: inline-block; margin-top: 8px; font-weight: 600; }
