/* JnS Bros engagement tracker.
   Palette and type lifted from the existing JnS decks so the tracker looks like
   the same company that sent the proposal. Mobile first: every rule below is the
   phone layout, and the media queries only add width. */

:root {
  --navy:      #0D1B3E;
  --navy-700:  #16264f;
  --navy-300:  #4B5768;
  --cyan:      #0EA5C4;
  --cyan-dark: #0b8aa6;
  --muted:     #6B7A90;
  --line:      #E4E9F2;
  --line-soft: #EEF2F8;
  --bg:        #F6F8FC;
  --card:      #ffffff;

  --ok-fg:   #166534;  --ok-bg:   #DCFCE7;
  --warn-fg: #92400E;  --warn-bg: #FEF3C7;
  --bad-fg:  #991B1B;  --bad-bg:  #FEE2E2;
  --idle-fg: #4B5768;  --idle-bg: #EEF2F8;
  --go-fg:   #075985;  --go-bg:   #E0F2FE;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(13, 27, 62, .06), 0 8px 24px rgba(13, 27, 62, .06);
  --shadow-lift: 0 2px 4px rgba(13, 27, 62, .08), 0 16px 40px rgba(13, 27, 62, .12);

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Sora', 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--navy);
  background: var(--bg);
  /* Nothing may ever scroll sideways. */
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--display); margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; font-weight: 700; }
h2 { font-size: 1.1rem;  font-weight: 650; }
h3 { font-size: .98rem;  font-weight: 600; }
p  { margin: 0 0 .6em; }
a  { color: var(--cyan-dark); }

/* ---------------------------------------------------------------- shell */
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}
.topbar-in {
  display: flex; align-items: center; gap: 10px;
  min-height: 56px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--display); font-weight: 700; font-size: .98rem;
  color: #fff; text-decoration: none;
  margin-right: auto; min-width: 0;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--cyan), #6ee7f5);
  display: grid; place-items: center;
  color: var(--navy); font-size: .72rem; font-weight: 800; letter-spacing: -.02em;
}
.brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { display: none; font-weight: 400; color: #9fb0cc; font-size: .8rem; }

.topbar .icon-btn {
  background: rgba(255,255,255,.10); color: #fff; border: 0;
  height: 36px; min-width: 36px; padding: 0 10px;
  border-radius: 9px; font: inherit; font-size: .82rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.topbar .icon-btn:hover { background: rgba(255,255,255,.18); }
.who { display: none; color: #9fb0cc; font-size: .8rem; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tabs scroll sideways on a phone instead of wrapping into a tangle */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  background: var(--navy-700); padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs-in { display: flex; gap: 4px; width: 100%; max-width: 1120px; margin: 0 auto; }
.tab {
  flex: none; appearance: none; background: none; border: 0;
  color: #9fb0cc; font: inherit; font-size: .86rem; font-weight: 600;
  padding: 11px 12px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab[aria-current="true"] { color: #fff; border-bottom-color: var(--cyan); }

main { padding: 18px 0 72px; }

/* ---------------------------------------------------------------- bits */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.tiny  { font-size: .76rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page-head { margin-bottom: 16px; }
.page-head h1 { margin-bottom: 2px; }
.crumb {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 0; margin-bottom: 8px;
  color: var(--muted); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer;
}
.crumb:hover { color: var(--cyan-dark); }

.btn {
  appearance: none; font: inherit; font-weight: 600; font-size: .86rem;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: #fff; color: var(--navy);
  padding: 0 14px; min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #cfd8e8; background: var(--line-soft); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); border-color: var(--navy-700); }
.btn-accent { background: var(--cyan); border-color: var(--cyan); color: #04242c; }
.btn-accent:hover { background: var(--cyan-dark); border-color: var(--cyan-dark); color: #fff; }
.btn-danger { color: var(--bad-fg); border-color: #f3c9c9; background: #fff; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-done        { color: var(--ok-fg);   background: var(--ok-bg); }
.pill-in_progress { color: var(--go-fg);   background: var(--go-bg); }
.pill-not_started { color: var(--idle-fg); background: var(--idle-bg); }
.pill-on_hold     { color: var(--warn-fg); background: var(--warn-bg); }
.pill-blocked     { color: var(--bad-fg);  background: var(--bad-bg); }
.pill-plain { color: var(--muted); background: var(--line-soft); }
.pill-plain::before { display: none; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--line-soft); color: var(--navy-300);
  font-size: .72rem; font-weight: 600;
}

/* segmented progress, one slice per state */
.bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--line); }
.bar span { display: block; height: 100%; }
.bar .s-done        { background: #22C55E; }
.bar .s-in_progress { background: var(--cyan); }
.bar .s-blocked     { background: #ef4444; }
.bar .s-not_started { background: #cdd7e6; }

.money {
  font-family: var(--display); font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}

/* ---------------------------------------------------------------- client cards */
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }

.client-card {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px; cursor: pointer; font: inherit; color: inherit;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.client-card:hover { box-shadow: var(--shadow-lift); border-color: #cfd8e8; transform: translateY(-1px); }
.client-card h2 { margin-bottom: 3px; }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.stat { min-width: 0; }
.stat-k { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-v { font-family: var(--display); font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- project block */
.project { padding: 0; overflow: hidden; }
.project + .project { margin-top: 12px; }

.project-head {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  background: none; border: 0; padding: 15px; cursor: pointer;
}
.project-head:hover { background: #fbfcfe; }
.project-title { display: flex; align-items: flex-start; gap: 9px; }
.project-title h2 { flex: 1 1 auto; min-width: 0; }
.chev { flex: none; color: var(--muted); font-size: .8rem; margin-top: 2px; transition: transform .18s ease; }
.project[data-open="true"] > .project-head .chev { transform: rotate(90deg); }

.project-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.project-pay {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line);
}
.project-progress { margin-top: 10px; }
.project-progress .bar { margin-top: 6px; }

.project-body { padding: 0 15px 15px; border-top: 1px solid var(--line-soft); }
.project[data-open="false"] .project-body { display: none; }

.group + .group { margin-top: 14px; }
.group-head {
  display: flex; align-items: center; gap: 7px;
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 14px 0 7px;
}
.group-head .count {
  background: var(--line-soft); color: var(--navy-300);
  border-radius: 999px; padding: 1px 7px; font-size: .72rem; letter-spacing: 0;
}

.items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px; background: #fff;
}
.item + .item { border-top: 1px solid var(--line-soft); }
.item-name { flex: 1 1 auto; min-width: 0; font-size: .9rem; font-weight: 500; }
.item-note { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; margin-top: 2px; }
.item-side { flex: none; display: flex; align-items: center; gap: 6px; }
.item.is-done .item-name { color: var(--muted); }

.dot-btn {
  appearance: none; border: 0; background: none; padding: 4px; margin: -4px;
  cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; border-radius: 6px;
}
.dot-btn:hover { background: var(--line-soft); color: var(--navy); }

.empty {
  text-align: center; padding: 34px 18px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); background: #fff;
}
.empty h3 { color: var(--navy); margin-bottom: 4px; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--navy-300); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  color: var(--navy); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(14,165,196,.16);
}
.field + .field { margin-top: 12px; }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 5px; }
.err {
  background: var(--bad-bg); color: var(--bad-fg);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: .84rem; font-weight: 600;
}
.ok-note {
  background: var(--ok-bg); color: var(--ok-fg);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: .84rem; font-weight: 600;
}

/* ---------------------------------------------------------------- dialog
   The width is set on the dialog itself. Leaving it to the flex parent is what
   collapses a dialog into a thin strip on a phone. */
dialog {
  width: min(560px, calc(100vw - 24px));
  max-width: none;
  border: 0; border-radius: var(--radius); padding: 0;
  box-shadow: var(--shadow-lift); color: var(--navy);
  max-height: calc(100dvh - 32px);
  overflow: visible;
}
dialog::backdrop { background: rgba(13,27,62,.45); backdrop-filter: blur(2px); }
.dlg-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px; border-bottom: 1px solid var(--line);
}
.dlg-head h2 { flex: 1 1 auto; min-width: 0; }
.dlg-body { padding: 16px; overflow-y: auto; max-height: calc(100dvh - 190px); }
.dlg-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 13px 16px; border-top: 1px solid var(--line); background: var(--line-soft);
  border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap;
}
.dlg-foot .btn { flex: 1 1 auto; }

/* ---------------------------------------------------------------- tables that become cards */
.tablish { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.trow { display: grid; gap: 4px 12px; padding: 13px 14px; grid-template-columns: 1fr auto; align-items: center; }
.trow + .trow { border-top: 1px solid var(--line-soft); }
.trow-head { display: none; }
.tcell-k { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------------------------------------------------------------- login and setup */
.auth-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 20px 16px; background:
    radial-gradient(900px 500px at 50% -10%, #17306b 0%, transparent 60%), var(--navy);
}
.auth-card {
  width: min(420px, 100%); background: #fff;
  border-radius: 18px; box-shadow: var(--shadow-lift); padding: 24px;
}
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head .brand-mark { width: 44px; height: 44px; font-size: 1rem; margin: 0 auto 11px; border-radius: 12px; }
.auth-head p { color: var(--muted); font-size: .86rem; margin: 4px 0 0; }
.auth-card .btn { width: 100%; min-height: 46px; }
.qr-box { text-align: center; padding: 14px; background: var(--line-soft); border-radius: var(--radius); }
.qr-box img { width: 190px; height: 190px; display: block; margin: 0 auto 10px; border-radius: 8px; background: #fff; }
.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem; font-weight: 600; word-break: break-all;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.code-input {
  text-align: center; letter-spacing: .5em; font-size: 22px; font-weight: 700;
  font-family: var(--display); padding-left: .5em;
}
.steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.steps i { width: 26px; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--cyan); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 60px 0; }
.center-load .spinner { border-color: var(--line); border-top-color: var(--cyan); width: 26px; height: 26px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--navy); color: #fff; font-size: .86rem; font-weight: 600;
  padding: 11px 16px; border-radius: 999px; box-shadow: var(--shadow-lift);
  z-index: 100; max-width: calc(100vw - 32px); text-align: center;
}

/* ================================================================ 560px and up */
@media (min-width: 560px) {
  .field-row { grid-template-columns: 1fr 1fr; }
  .dlg-foot .btn { flex: 0 0 auto; }
  .who { display: block; }
}

/* ================================================================ 760px and up */
@media (min-width: 760px) {
  body { font-size: 15.5px; }
  h1 { font-size: 1.7rem; }
  .wrap { padding: 0 24px; }
  .tabs { padding: 0 24px; }
  .topbar-in { min-height: 62px; }
  .brand { font-size: 1.05rem; }
  .brand-sub { display: inline; margin-left: 8px; }
  main { padding: 26px 0 80px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .project-head, .project-body { padding-left: 18px; padding-right: 18px; }
  .item { padding: 12px 14px; }

  /* the record list becomes a real table with a header row */
  .trow { grid-template-columns: 2fr 1.4fr 1fr auto; padding: 12px 16px; }
  .trow-head {
    display: grid; background: var(--line-soft);
    font-size: .72rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
  }
  .tcell-k { display: none; }
}

/* ================================================================ 1040px and up */
@media (min-width: 1040px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .topbar, .tabs, .btn, .dot-btn { display: none !important; }
  body { background: #fff; }
  .card, .project, .tablish { box-shadow: none; break-inside: avoid; }
}

/* the status pill doubles as the admin's one tap control, so it needs a button reset */
button.pill {
  border: 0; font: inherit; font-size: .74rem; font-weight: 700;
  cursor: pointer; line-height: 1.5;
}
button.pill:hover { filter: brightness(.95); }
button.pill:active { transform: scale(.97); }

/* On a phone the page title gets its own row, so a client name never has to
   compete with the action buttons for width and get truncated. */
.page-head .spread { flex-wrap: wrap; }
.page-head .spread > .grow { flex: 1 1 100%; }
.page-head .spread > .row { flex: 1 1 auto; }
.page-head .spread > .row .btn { flex: 1 1 auto; }
@media (min-width: 560px) {
  .page-head .spread > .grow { flex: 1 1 auto; }
  .page-head .spread > .row { flex: 0 0 auto; }
  .page-head .spread > .row .btn { flex: 0 0 auto; }
}

/* single day and repeating projects */
[hidden] { display: none !important; }
.pill-cancelled { color: var(--muted); background: var(--line-soft); }
.item.is-cancelled .item-name { color: var(--muted); text-decoration: line-through; }
.tag-next { background: var(--go-bg); color: var(--go-fg); }
.item-name .tag-next { margin-left: 6px; vertical-align: 1px; }

/* reorder list */
.reorder { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.reorder-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; background: #fff; }
.reorder-row + .reorder-row { border-top: 1px solid var(--line-soft); }
.reorder-row .dot-btn { width: 36px; height: 36px; margin: 0; font-size: 1.05rem; }
.grip {
  flex: none; width: 32px; height: 36px; display: grid; place-items: center;
  color: var(--muted); font-size: 1.2rem; cursor: grab; border-radius: 6px;
  touch-action: none; user-select: none;
}
.grip:hover { background: var(--line-soft); color: var(--navy); }
.reorder-row.dragging { background: var(--go-bg); box-shadow: var(--shadow); position: relative; z-index: 1; }
.reorder-row.dragging .grip { cursor: grabbing; }

/* combined client fee */
.fee-card { padding: 14px 16px; margin-bottom: 12px; border-left: 4px solid var(--cyan); }
.fee-amount { font-size: 1.35rem; }

/* collapsible status groups and long lists */
.group-toggle {
  width: 100%; appearance: none; background: none; border: 0; cursor: pointer;
  font-family: inherit; text-align: left; padding: 6px 0; margin: 8px 0 4px;
}
.group-toggle:hover .chev { color: var(--navy); }
.group-toggle .chev { font-size: .7rem; margin-top: 0; }
.group[data-open="true"] > .group-toggle .chev { transform: rotate(90deg); }
.group[data-open="false"] > .group-body { display: none; }
.group + .group { margin-top: 4px; }
.more-btn {
  display: block; width: 100%; margin-top: 6px; padding: 10px;
  appearance: none; border: 1px dashed var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--cyan-dark); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer;
}
.more-btn:hover { background: var(--line-soft); }
