/* Fonts are stored in this app (Inter and Poppins, SIL Open Font License) so they also work offline. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/poppins-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/poppins-latin-600-normal.woff2") format("woff2");
}

:root {
  --navy: #141414;
  --navy-2: #262626;
  --blue: #B85500;
  --blue-dark: #8F4200;
  --sky: #FE7E00;
  --bg: #F6F5F3;
  --card: #FFFFFF;
  --line: #E4E0DA;
  --field: #CFC9C0;
  --text: #141414;
  --muted: #5A5650;
  --ok-bg: #DDF3E8;
  --ok: #0E5A3A;
  --warn-bg: #FDEFCF;
  --warn: #6F4300;
  --bad-bg: #FBE0E0;
  --bad: #8A1C1C;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Poppins", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; font-family: var(--font-head); font-weight: 600; }

a { color: var(--blue); }

/* ---------- shared form pieces ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }

form { display: flex; flex-direction: column; gap: 14px; }

input[type="text"], input[type="tel"], input[type="password"], input[type="date"], input[type="search"] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--field);
  border-radius: 10px;
}

input::placeholder { color: #55657F; opacity: 1; }

input:focus-visible, button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(254, 126, 0, 0.55);
  outline-offset: 2px;
}

.pinwrap { position: relative; }
.pinwrap input { padding-right: 76px; }
.pinwrap .toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
}

.btn {
  min-height: 48px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--field); }
.btn.secondary:hover { background: #F6F5F3; }
.btn[disabled] { opacity: 0.6; cursor: default; }

.message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  background: var(--bad-bg);
  color: var(--bad);
}
.message:empty { display: none; }
.message.info { background: #FDEBD9; color: #B85500; }
.message.warn { background: var(--warn-bg); color: var(--warn); }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chip { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #ECE8E1; color: #3E4D68; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 20px; }
.card.pad { padding: 20px; }
.card h2 { font-size: 17px; }
.card .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .k { color: var(--muted); }

/* ---------- sign-in and setup screens ---------- */

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 16px;
}

.brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.brand img { width: clamp(180px, 60vw, 240px); height: auto; border-radius: 0; }
.brand h1 { font-size: clamp(20px, 5vw, 24px); }

.panel {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 22px;
}
.panel h2 { font-size: 18px; margin-bottom: 4px; }
.panel .lead { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.foot { font-size: 12px; color: var(--muted); text-align: center; margin: 0; }

/* ---------- app shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 12px;
  background: var(--navy);
  color: #D6D1C9;
}

.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.side-brand img { width: 44px; height: 44px; border-radius: 0; object-fit: contain; flex: 0 0 auto; }
.side-brand .t1 { display: block; font-family: var(--font-head); font-weight: 600; font-size: 17px; color: #fff; line-height: 1.2; }
.side-brand .t2 { display: block; font-size: 12px; color: #CFC9C0; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8CA3C9;
}

.navlink {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: #D6D1C9;
  text-decoration: none;
  font-weight: 500;
}
.navlink:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.navlink.active { background: var(--navy-2); color: #fff; font-weight: 600; }
.navlink svg { flex: 0 0 auto; }
.lbl-short { display: none; }

.side-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--navy-2);
}
.side-user .nm { display: block; color: #fff; font-weight: 600; line-height: 1.25; }
.side-user .rl { display: block; font-size: 12px; color: #CFC9C0; }
.side-user .txt { min-width: 0; }
.side-user .nm, .side-user .rl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sky);
  color: var(--navy);
  font-weight: 600;
  font-size: 14px;
}

.main-col { min-width: 0; display: flex; flex-direction: column; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-logo { display: none; width: 34px; height: 34px; border-radius: 0; object-fit: contain; }
.top h1 { font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-right { position: relative; display: flex; align-items: center; gap: 12px; }

.net { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.net::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.net.off { background: var(--warn-bg); color: var(--warn); }

.userbtn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 6px 0 4px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.userbtn:hover { background: #F6F5F3; }

.pop {
  position: absolute;
  top: 54px;
  right: 0;
  width: 270px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(1, 24, 66, 0.16);
}
.pop[hidden] { display: none; }
.pop .who { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.pop .who strong { display: block; }
.pop .who span { display: block; font-size: 13px; color: var(--muted); }
.pop button, .pop a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.pop button:hover, .pop a:hover { background: #F6F5F3; }

.view { width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; outline: none; }

.empty { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 48px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .ic { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #FDEBD9; color: #B85500; margin-bottom: 8px; }
.empty h2 { font-size: 18px; }
.empty p { margin: 0; max-width: 420px; color: var(--muted); }

.tabs { display: none; }
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(1, 24, 66, 0.55); }
.scrim[hidden] { display: none; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: #fff;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet[hidden] { display: none; }
.sheet .grab { align-self: center; width: 44px; height: 5px; border-radius: 3px; background: var(--field); margin-bottom: 8px; }
.sheet .sheet-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 0 8px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.sheet .sheet-link.active { background: #FDEBD9; color: #B85500; font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-weight: 500;
}

.profile-actions { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px 0 12px; }
.profile-actions[hidden], .pop button[hidden] { display: none; }

.row > span:last-child { text-align: right; }

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  background: #FDEBD9;
  color: #B85500;
}

.update-bar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 24px);
  padding: 8px 8px 8px 16px;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 30px rgba(1, 24, 66, 0.3);
}
.update-bar button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--sky);
  color: var(--navy);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Tablet: slim icon sidebar with short labels */
@media (max-width: 1023px) {
  .shell { grid-template-columns: 84px minmax(0, 1fr); }
  .side { padding: 14px 6px; gap: 18px; align-items: stretch; }
  .side-brand { justify-content: center; padding: 0; }
  .side-brand .txt { display: none; }
  .side-brand img { width: 44px; height: 44px; }
  .nav-label { display: none; }
  .side-nav { gap: 2px; }
  .navlink { flex-direction: column; justify-content: center; gap: 3px; min-height: 58px; padding: 6px 2px; text-align: center; font-size: 11px; line-height: 1.2; }
  .lbl-full { display: none; }
  .lbl-short { display: block; }
  .side-user { justify-content: center; padding: 8px 0; background: transparent; }
  .side-user .txt { display: none; }
  .top { padding: 0 20px; }
  .view { padding: 20px; }
}

/* Phone: bottom tabs */
@media (max-width: 639px) {
  .shell { display: block; }
  .side { display: none; }
  .top { padding: 0 16px; min-height: 60px; }
  .top-logo { display: block; }
  .top h1 { font-size: 18px; }
  .net .net-text { display: none; }
  .net { padding: 0; width: 30px; justify-content: center; }
  .net::before { margin: 0; }
  .userbtn .uname { display: none; }
  .view { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: stretch;
    padding: 0 4px env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--line);
  }
  .tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
  }
  .tab.active { color: var(--blue); font-weight: 600; }
  .pop { position: fixed; top: 64px; right: 12px; left: auto; width: min(270px, calc(100vw - 24px)); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

/* ---------- users and audit screens ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .vh { font-size: 17px; }
.toolbar .sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.card.tbl { padding: 0; overflow: hidden; }
.trow { display: grid; grid-template-columns: minmax(180px, 1.4fr) auto minmax(150px, 1fr) auto; gap: 8px 16px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); }
.trow:first-child { border-top: 0; }
.tmain { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.tmain .sub, .tmeta { color: var(--muted); font-size: 13px; }
.tchips { display: flex; flex-wrap: wrap; gap: 6px; }
.tacts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.fchip { min-height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--field); background: #fff; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.fchip.on { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.more { display: flex; justify-content: center; margin: 14px 0; }
.more[hidden], .more button[hidden] { display: none; }
#a-list .trow { grid-template-columns: 1fr auto; }

.modal-scrim { position: fixed; inset: 0; background: rgba(1, 24, 66, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; }
.modal h2 { font-size: 18px; margin-bottom: 12px; }
.modal-body { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.modal-body p { margin: 0; }
.modal .sub { color: var(--muted); font-size: 14px; margin: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.modal .message { margin-top: 4px; }
.pinshow { font-family: var(--font-head); font-size: 32px; letter-spacing: 0.3em; text-align: center; padding: 14px; background: var(--bg); border-radius: 12px; user-select: all; }

@media (max-width: 720px) {
  .trow { grid-template-columns: 1fr; padding: 14px 16px; }
  .tacts { justify-content: flex-start; }
  #a-list .trow { grid-template-columns: 1fr; }
}

/* ---------- cohorts and beneficiaries ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select { min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 10px; font: inherit; background: #fff; color: var(--text); }
.filters input { flex: 1 1 240px; }
.filters select { flex: 0 1 220px; }
.field textarea, .field select, .field input[type="file"] { padding: 10px 12px; border: 1px solid var(--field); border-radius: 10px; font: inherit; background: #fff; color: var(--text); }
.field select { min-height: 48px; }
.brow { cursor: pointer; }
.brow:hover, .brow:focus-visible { background: #F6F5F3; outline: none; }
.crow .lnk { display: inline-flex; align-items: center; text-decoration: none; }
.tacts.left { justify-content: flex-start; margin-top: 4px; }
.dl .row { align-items: flex-start; padding: 10px 0; }
.dl .row > span:last-child { text-align: right; overflow-wrap: anywhere; }
.dl { margin-bottom: 4px; }

/* ---------- evidence ---------- */
.egrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.ecard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.ethumb { display: block; aspect-ratio: 4 / 3; background: var(--bg); }
.ethumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pdfbox { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--navy-2); font-size: 22px; letter-spacing: 0.1em; }
.ebody { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.ebody .sub { color: var(--muted); font-size: 13px; }
.ename { overflow-wrap: anywhere; }
#e-pending { margin-top: 14px; }
.meter { margin-bottom: 14px; }
.bar { height: 8px; background: var(--line); border-radius: 999px; margin-top: 12px; overflow: hidden; }
.bar > div { height: 100%; background: var(--blue); border-radius: 999px; }
.lnk { display: inline-flex; align-items: center; text-decoration: none; }
#e-pending:empty { margin: 0; }

/* ---------- check-ins ---------- */
.krow { cursor: pointer; }
.krow:hover, .krow:focus-visible { background: #F6F5F3; outline: none; }
.sec { font-size: 14px; margin: 14px 0 4px; }
.sec .sub { font-weight: 400; }
.pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.seg { display: flex; gap: 16px; flex-wrap: wrap; }
.seg label { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 44px; }
#k-sub a { color: var(--blue); }
[hidden] { display: none !important; }

/* ---------- beneficiary home ---------- */
.hello { margin-bottom: 14px; font-size: 20px; }
.status { border-left: 6px solid var(--blue); margin-bottom: 14px; }
.status.late { border-left-color: #C0392B; background: #FFF8F7; }
.status.soon { border-left-color: #D98E04; }
.status h2 { font-size: 15px; color: var(--muted); font-weight: 600; }
.status .big { font-family: var(--font-head); font-size: 26px; font-weight: 600; margin: 6px 0; color: var(--navy); }
.status .btn { margin-top: 10px; }
.two { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.card.pad + .card.pad { margin-top: 0; }
#view > .card.pad { margin-bottom: 14px; }
.reasons { margin: 8px 0 0; padding-left: 18px; }
.hrow { grid-template-columns: 1fr auto; }
@media (min-width: 900px) { .two { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .hrow { grid-template-columns: 1fr; } }

/* ---------- dashboard ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 420px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); min-height: 108px; }
a.tile:hover { border-color: var(--blue); }
.tile .tl { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile .tv { font-family: var(--font-head); font-size: 24px; line-height: 1.2; white-space: nowrap; }
.tile .ts { font-size: 13px; color: var(--muted); }
.tile.late { border-color: #E9B4B4; background: #FFF8F7; }
.tile.late .ts { color: var(--bad); font-weight: 600; }
.rbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--line); margin: 12px 0; }
.seg-pos { background: #1E8E5A; } .seg-med { background: #D98E04; } .seg-neg { background: #C0392B; } .seg-none { background: #8A97AD; }
.rleg { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; margin-bottom: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.ch { font-size: 16px; padding: 16px 20px 6px; }
.lrow { grid-template-columns: 1fr auto; text-decoration: none; color: inherit; }
.lrow:hover { background: #F6F5F3; }
@media (max-width: 720px) { .lrow { grid-template-columns: 1fr; } }

/* Printable report */
#print-root { display: none; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; color: #111; background: #fff; font: 12px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
  @page { margin: 16mm; }
  html, body.printing { background: #fff !important; min-height: 0 !important; height: auto !important; }
  #print-root h1 { font-size: 22px; margin: 10px 0 4px; color: #141414; }
  #print-root h2 { font-size: 14px; margin: 18px 0 6px; padding-bottom: 3px; border-bottom: 1.5px solid #B85500; color: #141414; }
  #print-root h3 { font-size: 12px; margin: 12px 0 4px; }
  #print-root .rp-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid #141414; padding-bottom: 8px; }
  #print-root .rp-brand { font-size: 15px; font-weight: 700; color: #141414; }
  #print-root .rp-sub { color: #555; font-size: 11px; }
  #print-root .rp-conf { color: #a00; font-weight: 600; }
  #print-root table { width: 100%; border-collapse: collapse; }
  #print-root .rp-kv th { width: 28%; text-align: left; vertical-align: top; padding: 3px 8px 3px 0; color: #444; font-weight: 600; }
  #print-root .rp-kv td { padding: 3px 0; }
  #print-root .rp-t th { background: #F7F1EA; text-align: left; padding: 5px 6px; border: 1px solid #D6D1C9; }
  #print-root .rp-t td { padding: 5px 6px; border: 1px solid #D6D1C9; vertical-align: top; }
  #print-root tr { break-inside: avoid; }
  #print-root h2, #print-root h3 { break-after: avoid; }
}

.cache-note { position: fixed; left: 50%; transform: translateX(-50%); bottom: 76px; max-width: min(560px, calc(100vw - 24px)); z-index: 60;
  background: #fff4e0; color: #7a4a00; border: 1px solid #f0c987; border-radius: 10px; padding: 9px 14px; font-size: 13px; box-shadow: 0 4px 14px rgba(12,30,85,.18); }
@media (min-width: 900px) { .cache-note { bottom: 18px; } }

/* Page controls */
.pager-host { margin: 14px 0 6px; }
.pager { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; font-size: 13px; color: #4a5a72; }
.pager-ctrl { display: flex; align-items: center; gap: 6px; }
.pager-nums { display: flex; align-items: center; gap: 4px; }
.pg { min-width: 36px; height: 36px; padding: 0 12px; border: 1px solid #D6D1C9; background: #fff; color: #141414; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.pg:hover:not(:disabled) { background: #F7F1EA; }
.pg:focus-visible { outline: 2px solid #B85500; outline-offset: 2px; }
.pg.on { background: #141414; border-color: #141414; color: #fff; }
.pg:disabled { opacity: .45; cursor: default; }
.pg-gap { padding: 0 4px; color: #7a889c; }
.pager-phone { display: none; font-weight: 600; color: #141414; padding: 0 6px; }
@media (max-width: 640px) {
  .pager { flex-direction: column; align-items: stretch; text-align: center; }
  .pager-ctrl { justify-content: space-between; }
  .pager-nums { display: none; }
  .pager-phone { display: inline; }
  .pg { flex: 0 0 auto; }
}
@media print { .pager-host { display: none; } }

/* ----- profile photos ----- */
.avatar.has-photo { padding: 0; overflow: hidden; background: #fff; }
.avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.ph-card { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.ph-card h2.ph-name { margin: 0 0 2px; font-size: 19px; color: var(--navy); }
.ph-card .ph-biz { margin: 0 0 6px; }
.ph-av { position: relative; flex: 0 0 auto; }
.ph-av .ph-big { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #FE7E00; }
.ph-av.can { cursor: pointer; }
.ph-badge { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--blue); border: 2px solid #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 8h3l2-3h6l2 3h3v11H4z'/><circle cx='12' cy='13' r='3.5'/></svg>");
  background-repeat: no-repeat; background-position: center; }
.ph-preview { width: 160px; height: 160px; margin: 4px auto 14px; border-radius: 50%; overflow: hidden; background: #F7F1EA; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 4px #fff, 0 0 0 6px #FE7E00; }
.ph-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-preview .ph-empty { font-family: var(--font-head); font-size: 44px; color: var(--blue); font-weight: 600; }
.ph-preview.busy { opacity: .5; }
.ph-btns { display: flex; gap: 10px; margin-bottom: 12px; }
.ph-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; }

.bwho { display: flex; align-items: center; gap: 14px; min-width: 0; }
.bav { flex: 0 0 auto; display: flex; align-items: center; }
.brow { align-items: center; }
.ph-detail { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.ph-detail .ph-big { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #FE7E00; }
.linkbtn { background: none; border: 0; padding: 0; margin-top: 4px; color: var(--blue); font: inherit; font-weight: 600; cursor: pointer; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #F26A0F; color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.pvrow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pv-pics { display: flex; gap: 10px; }
.pv-pics figure { margin: 0; text-align: center; }
.pv-pics img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; display: block; background: #F7F1EA; }
.pv-pics figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media print { #print-root .rp-who { display: flex; align-items: center; gap: 14px; } #print-root .rp-photo { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; } }

.privacy h3 { font-size: 15px; margin: 14px 0 4px; color: var(--navy); }
.privacy p { margin: 0 0 6px; color: var(--muted); line-height: 1.5; }
.privacy { max-height: 52vh; overflow-y: auto; padding-right: 4px; }

/* ---------- leads ---------- */
.modal.wide { max-width: 680px; }
.note { border-left: 3px solid var(--line); padding: 6px 0 6px 12px; margin-bottom: 10px; }
.note.note { border-left-color: var(--blue); }
.note.event { border-left-color: var(--line); color: var(--muted); }
.note .nmeta { font-size: 12px; color: var(--muted); }
.note .nbody { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.modal .sec { margin: 6px 0 0; }
.modal textarea { width: 100%; font: inherit; }

/* ---------- clients ---------- */
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.field.check input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; }

/* ---------- jobs ---------- */
.filters[hidden], .field[hidden] { display: none; }

/* ---------- money ---------- */
.trow.voided { opacity: 0.6; }
.trow.voided strong { text-decoration: line-through; }

/* ---- calendar (stage 7) ---- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-title { font-family: var(--font-head); font-size: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-h { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.cal-c { position: relative; min-height: 56px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; color: var(--text); cursor: pointer; padding: 6px; text-align: left; }
.cal-c.empty { border: 0; background: transparent; cursor: default; }
.cal-c.today { border-color: var(--blue); }
.cal-c.picked { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }
.cal-n { font-size: 14px; font-weight: 600; }
.cal-dot { position: absolute; right: 6px; bottom: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.cal-c.picked .cal-dot { background: #fff; color: var(--navy-2); }
@media (max-width: 640px) { .cal-c { min-height: 46px; padding: 4px; } .cal-dot { right: 3px; bottom: 3px; min-width: 18px; height: 18px; font-size: 11px; } }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; }

/* ---- insights (stage 8) ---- */
.ch-wrap { overflow-x: auto; }
.ch-svg { width: 100%; min-width: 560px; height: auto; display: block; }
.ch-grid { stroke: #ECE8E1; stroke-width: 1; }
.ch-base { stroke: #B8C2D1; stroke-width: 1; }
.ch-ax { font-size: 11px; fill: #6B665E; }
.ch-val { font-size: 11px; font-weight: 600; fill: #1B2A4A; }
.ch-bar { fill: #E06D00; }
.ch-bar:hover { fill: #1f63b5; }
.ch-table { margin-top: 8px; font-size: 14px; }
.ch-table summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.ch-table table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.ch-table th, .ch-table td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); }
.ins-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.ins-2 > .card { margin: 0; }
@media (max-width: 800px) { .ins-2 { grid-template-columns: 1fr; } }
.hb { display: flex; flex-direction: column; gap: 14px; }
.hb-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.hb-name { font-weight: 600; }
.hb-val { font-variant-numeric: tabular-nums; }
.hb-track { height: 8px; background: #ECE8E1; border-radius: 4px; margin: 4px 0; }
.hb-fill { display: block; height: 8px; background: #E06D00; border-radius: 0 4px 4px 0; }
.sp-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; margin-bottom: 8px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.s1 { background: #E06D00; }
.s2 { background: #4A4A4A; }
.sp-bar { display: flex; gap: 2px; height: 28px; }
.sp { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; min-width: 4px; }
.sp:first-child { border-radius: 6px 0 0 6px; }
.sp:last-child { border-radius: 0 6px 6px 0; }
.sp:only-child { border-radius: 6px; }
.sp-nums { display: flex; flex-wrap: wrap; gap: 8px 32px; margin-top: 12px; }
.sp-nums strong { font-size: 22px; font-family: var(--font-head); margin-right: 8px; }
.who { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.who:first-of-type { border-top: 0; }
.trow.lrow { grid-template-columns: 1fr auto; }
.card.inner { box-shadow: none; margin-top: 8px; }
section.card + section.card { margin-top: 14px; }

/* ---- invoices (stage 9) ---- */
.fhead, .fline { display: grid; grid-template-columns: minmax(140px, 1fr) 70px 110px 110px 80px; gap: 8px; align-items: center; }
.fhead { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 2px 4px; }
.fline { margin-bottom: 8px; }
.fline input { min-width: 0; }
.fl-amt { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
#f-cat { margin-left: 8px; min-height: 36px; border-radius: 8px; border: 1px solid var(--field); padding: 0 10px; font: inherit; background: #fff; }
@media (max-width: 640px) {
  .fhead { display: none; }
  .fline { grid-template-columns: 1fr 70px 1fr; }
  .fline [data-d] { grid-column: 1 / -1; }
  .fline .fl-amt { grid-column: 1 / 3; text-align: left; }
}
.dense .row { min-height: 0; padding-top: 8px; padding-bottom: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset.field { border: 0; padding: 0; margin: 12px 0; }
fieldset.field legend { font-weight: 600; font-size: 14px; margin-bottom: 4px; padding: 0; }
@media (max-width: 420px) { .field-row { grid-template-columns: 1fr; } }
.dl { display: block; margin-top: 4px; font-size: 12px; color: var(--muted, #5b6478); }
.dl.up { color: #1a7a3c; }
.dl.down { color: #b3361b; }
.cmp-toggle { margin: 0 0 12px; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 14px; }
table.cmp th, table.cmp td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line, #ECE8E1); white-space: nowrap; }
table.cmp th:not(:first-child), table.cmp td:not(:first-child) { text-align: right; }
.td-group { margin-top: 14px; }
.td-h { margin: 0 0 6px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.td-n { font-size: 12px; font-weight: 600; background: var(--line, #ECE8E1); border-radius: 10px; padding: 1px 8px; }
.td-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line, #ECE8E1); text-decoration: none; color: inherit; }
.td-row:hover .td-main strong { text-decoration: underline; }
.td-main { display: flex; flex-direction: column; min-width: 0; }
.td-main strong { font-weight: 600; overflow-wrap: anywhere; }
.td-pill { flex: none; min-width: 52px; text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 3px 8px; border-radius: 6px; margin-top: 1px; background: #ECE8E1; color: #3D3A35; }
.td-pill.late { background: #fbe3dd; color: #9a2a12; }
.td-pill.today { background: #fdebd3; color: #8a4a00; }
.td-pill.soon { background: #F7F1EA; color: #1c4a9a; }
.td-more { display: block; padding: 8px 0 0 62px; font-size: 13px; }
.rm-new { color: #8a4a00; font-weight: 600; }
.rm-msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.pu-prefs { margin: 10px 0; }
.pu-prefs .check { padding: 6px 0; }

/* ---------- desktop and laptop polish (Stage 16) ---------- */
.view:focus, .view:focus-visible { outline: none; }
.td-grid { display: block; }
.navlink:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* Short laptop screens: a tighter sidebar so the signed-in person always shows at the bottom */
@media (min-width: 1024px) and (max-height: 860px) {
  .side { gap: 14px; padding: 14px 12px; }
  .navlink { min-height: 38px; }
  .side-nav { gap: 2px; }
  .side-user { padding: 8px 12px; }
}

/* Laptops and desktops: use the width, keep lines readable */
@media (min-width: 1100px) {
  .view { padding: 28px 32px; gap: 18px; }
  .top { padding: 0 32px; }
  .td-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); column-gap: 32px; }
  .modal { max-width: 480px; }
  .modal.wide { max-width: 760px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .btn, .chip, .pg, .navlink, .brow, .krow, .td-row { cursor: pointer; }
  .brow:hover, .krow:hover { background: #F6F5F3; }
}
@media (min-width: 1500px) {
  .view { max-width: 1440px; }
}
@media (min-width: 1100px) and (max-width: 1499px) {
  .view { max-width: 1240px; }
}

/* Finance dashboard */
.fc-svg { width: 100%; height: auto; display: block; }
.fc-grid { stroke: #ECE8E1; stroke-width: 1; }
.fc-ax { fill: #6B665E; font-size: 11px; }
.fc-in { fill: #B85500; background: #B85500; }
.fc-out { fill: #F26A0F; background: #F26A0F; }
.fc-key { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; color: #3D3A35; }
.fc-key i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.fc-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.fc-ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.fc-av { display: flex; flex-direction: column; margin-bottom: 8px; }
.fc-av strong { font-size: 24px; font-family: var(--font-head); }
.fc-plus { color: #0B6B3A; }
.fc-minus { color: #9A2A12; }
.fc-p .dl div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }

.net-test { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #FDEBD3; color: #8A4A00; }
.net-test[hidden] { display: none; }
@media (max-width: 480px) { .net-test { padding: 0 8px; font-size: 11px; } }
.ex-box { background: #F7F1EA; }
.ex-box .sub { margin: 0 0 8px; }
.net-out { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px; border: 0; font: inherit; font-size: 12px; font-weight: 600; background: #FDEBD3; color: #8A4A00; cursor: pointer; }
.net-out[hidden] { display: none; }
.net-out.bad { background: var(--bad-bg); color: var(--bad); }
@media (max-width: 480px) { .net-out { padding: 0 8px; font-size: 11px; } }

/* ---------- phone and tablet (under 1024 px): navy top bar with a back arrow, home tiles, no sidebar or bottom tabs ---------- */
.backbtn { display: none; }
.launch { display: none; }
@media (max-width: 1023px) {
  .shell { display: block; }
  .side, .tabs, .sheet, .scrim { display: none !important; }
  .top { background: var(--navy); color: #fff; border-bottom: 0; padding: 0 12px; min-height: 60px; }
  .top h1 { color: #fff; font-size: 18px; }
  .top-logo { display: none; }
  body.at-home .top-logo { display: block; }
  .backbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -6px; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; }
  .backbtn:hover { background: rgba(255, 255, 255, 0.14); }
  body.at-home .backbtn { display: none; }
  .userbtn { color: #fff; }
  .userbtn:hover { background: rgba(255, 255, 255, 0.14); }
  .userbtn .uname { display: none; }
  .view { padding: 16px 16px 28px; }
  .toast { bottom: 20px; }
  .pop { position: fixed; top: 64px; right: 12px; left: auto; width: min(270px, calc(100vw - 24px)); }
  .launch { display: block; }
}
.launch .sec { margin: 6px 2px 8px; }
.launch-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
@media (min-width: 640px) { .launch-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .launch-grid { grid-template-columns: repeat(4, 1fr); } }
.lt { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 10px; min-height: 92px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); text-decoration: none; }
.lt:active, .lt:hover { border-color: var(--blue); }
.lt-ic { display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 10px; background: #FDEBD9; color: var(--blue); }
.lt-l { font-weight: 600; font-size: 15px; line-height: 1.2; }
.lt-b { position: absolute; top: 10px; right: 10px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--blue); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.lt-b.late { background: var(--bad); }
.lt-b[hidden] { display: none; }

.attn { display: none; }
@media (max-width: 1023px) {
  .attn { display: flex; align-items: center; gap: 14px; width: 100%; margin-bottom: 14px; padding: 12px 14px; border: 1px solid #F0D79A; border-radius: 14px; background: #FFF6E0; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
  .attn[hidden] { display: none; }
  .attn.late { background: #FDECEC; border-color: #F0B8B8; }
  .attn-n { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; border-radius: 50%; background: #D98E04; color: #fff; font-weight: 700; font-size: 17px; }
  .attn.late .attn-n { background: var(--bad); }
  .attn-t { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
  .attn-t strong { font-size: 15px; color: var(--text); }
}
