/* The real app (app.js): one firm's day, hours and invoices on each person's phone. It
   looks like the phones in the example (site/demo/), on purpose: what a client saw in the
   call is what they then use. The system font, so it opens fast and feels like the phone. */
:root {
  --bg: #F4F6F9;
  --card: #fff;
  --ink: #131A22;
  --muted: #5D6976;
  --line: #E1E6ED;
  --accent: #1F5FBF;
  --done: #17663F;
  --done-bg: #DFF3E7;
  --doing: #8A5300;
  --doing-bg: #FFF1D6;
  --doing-line: #E7A33C;
  --danger: #A3281D;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
.app { max-width: 560px; margin: 0 auto; padding: 8px 16px calc(32px + env(safe-area-inset-bottom)); }
.app h2, .app h3, .app p { margin: 0; }
.loading { padding: 48px 0; text-align: center; color: var(--muted); }

/* ---------- the top ---------- */
.app-head { padding: 10px 0 12px; }
.firm { font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent); }
.app-head h2 { margin: 3px 0 2px; font-size: 25px; line-height: 1.15; letter-spacing: -0.01em; }
.date { color: var(--muted); font-size: 14px; }
.net { margin: 0 0 12px; padding: 9px 12px; border-radius: 12px; background: #FFF8E6; border: 1px solid #F2DFAE; color: #6F5210; font-size: 13.5px; }
.tabs { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0 -16px 14px; padding: 6px 16px; background: var(--bg); }
.tabs div { display: contents; }
.tabs button { min-height: 40px; border: 0; border-radius: 10px; background: #E6EBF1; font-weight: 600; font-size: 14px; line-height: 1; color: var(--muted); }
.tabs [aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

/* ---------- pieces ---------- */
.app h3 { margin: 20px 0 8px; font-size: 12px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.hint { margin-top: 8px; color: var(--muted); font-size: 13px; }
.lead { margin: 0 0 14px; }
.av { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--c); color: #1B2430; font-weight: 700; font-size: 15px; }
.av.sm { width: 28px; height: 28px; font-size: 13px; }
.chip { flex: none; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip.todo { background: #EBEFF4; color: #56606C; }
.chip.doing { background: var(--doing-bg); color: var(--doing); }
.chip.done { background: var(--done-bg); color: var(--done); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 1px solid transparent; border-radius: 14px; font-weight: 600; font-size: 16px; line-height: 1; text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.finish { background: var(--done); color: #fff; }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.small { min-height: 38px; padding: 0 14px; border-radius: 11px; font-size: 14.5px; }
.btn.wide { width: 100%; }
.btn.danger { background: var(--card); border-color: #E7C2BD; color: var(--danger); }
.link { padding: 0; border: 0; background: none; color: var(--accent); font-size: 14px; text-decoration: underline; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row .btn { flex: 1 1 auto; }

/* the job on now */
.now { margin: 0 0 14px; padding: 14px; background: var(--card); border: 1px solid #F0C27A; border-radius: 16px; box-shadow: inset 4px 0 0 var(--doing-line); }
.now .kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--doing); }
.now strong { display: block; margin: 4px 0 2px; font-size: 19px; line-height: 1.25; }
.now .since { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.now .btn { width: 100%; margin-top: 12px; }
.now.late { border-color: #E7C2BD; box-shadow: inset 4px 0 0 var(--danger); }
.now.late .kicker { color: var(--danger); }

/* the day's clients */
.jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.job { display: grid; gap: 2px; padding: 13px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.job-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.job strong { font-size: 17px; line-height: 1.3; }
.addr { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.addr a { color: var(--accent); }
.note { margin-top: 6px; padding: 8px 10px; background: #FFF8E6; border: 1px solid #F2DFAE; border-radius: 12px; font-size: 14px; }
.job .btn { margin-top: 10px; }
.job.done { opacity: 0.85; }
.foot { margin-top: 16px; color: var(--muted); font-size: 13px; }

/* hours, as lines that open to correct them */
.lines { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.lines li + li { border-top: 1px solid var(--line); }
.lines button { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 11px 12px; border: 0; background: none; text-align: left; }
.lines .t { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines b { display: block; font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.lines span.who { display: block; font-size: 13px; color: var(--muted); }
.lines .h { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .h.on { color: var(--doing); }
.day-head { margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* the team right now */
.crew { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.crew li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.crew b { display: block; }
.crew span { font-size: 13px; color: var(--muted); }

/* the month */
.month { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; }
.month b { font-size: 17px; }
.month button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 20px; line-height: 1; color: var(--accent); }
.month button:disabled { opacity: 0.35; cursor: default; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { padding: 10px 11px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.tile b { display: block; font-size: 19px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile span { display: block; font-size: 12px; line-height: 1.25; color: var(--muted); }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: auto max(50px, var(--name, 0px)) 1fr auto; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.meter { height: 10px; overflow: hidden; background: #E3E8EF; border-radius: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; vertical-align: top; white-space: nowrap; }
.tbl tr:last-child th, .tbl tr:last-child td { border-bottom: 0; }
.tbl th { text-align: left; font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
.tbl th span { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
@media (max-width: 350px) { .tbl th, .tbl td { padding: 9px 7px; } }
.empty { padding: 16px; background: var(--card); border: 1px dashed #C9D2DC; border-radius: 14px; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* invoices */
.invoices { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.invoices button { width: 100%; display: flex; justify-content: space-between; gap: 10px; padding: 12px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.invoices b { display: block; overflow-wrap: anywhere; }
.invoices button > span > span { font-size: 13px; color: var(--muted); }
.amt { display: grid; justify-items: end; gap: 4px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.back { display: inline-flex; align-items: center; gap: 4px; padding: 6px 0; border: 0; background: none; font-weight: 600; font-size: 15px; line-height: 1; color: var(--accent); }
.back::before { content: ""; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-right: 2px; }
.paper { margin-top: 6px; padding: 16px 14px; background: #fff; border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px; line-height: 1.4; box-shadow: 0 10px 22px -16px rgba(0, 0, 0, 0.4); }
.paper header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 2px solid var(--ink); }
.paper header b { display: block; font-size: 15px; }
.paper header span { display: block; color: var(--muted); }
.paper .meta { text-align: right; }
.paper .to { margin: 6px 0; overflow-wrap: anywhere; }
.paper .to span { display: block; font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.paper table { width: 100%; margin: 10px 0 0; border-collapse: collapse; }
.paper th, .paper td { padding: 5px 3px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.paper th { font-size: 11px; color: var(--muted); font-weight: 600; }
.paper th:first-child, .paper td:first-child { text-align: left; }
.paper dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 10px 0 0; }
.paper dt { text-align: right; color: var(--muted); }
.paper dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.paper .total { margin-top: 4px; font-size: 14px; font-weight: 800; color: var(--ink); }
.paper footer { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #B6C0CC; color: var(--muted); }

/* the firm: clients, people, prices */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list button { width: 100%; display: grid; gap: 2px; padding: 12px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.list b { font-size: 16px; overflow-wrap: anywhere; }
.list span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.people span { font-size: 13px; color: var(--muted); }

/* forms: in a sheet over the app, or in the page (the firm's prices) */
.sheet { position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: var(--bg); padding: 12px 16px calc(28px + env(safe-area-inset-bottom)); }
.sheet form, .sheet .sheet-body { max-width: 560px; margin: 0 auto; }
.sheet form, .form { display: grid; gap: 12px; }
.sheet h2 { margin: 4px 0 2px; font-size: 22px; line-height: 1.2; }
.sheet label, .form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.sheet input, .sheet select, .sheet textarea, .form input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; line-height: 1.3; color: var(--ink); }
.sheet textarea { min-height: 76px; padding: 10px 12px; resize: vertical; }
.sheet .two, .form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet .err { color: var(--danger); font-size: 14px; font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.days label { display: block; }
.days input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.days span { display: grid; place-items: center; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 13px; font-weight: 700; color: var(--muted); }
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pick button { width: 100%; display: grid; gap: 2px; padding: 13px 14px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.pick b { font-size: 16px; }
.pick span { font-size: 13px; color: var(--muted); }

.toast { position: fixed; left: 50%; top: 14px; z-index: 50; transform: translate(-50%, -12px); opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 14px; width: max-content; max-width: min(92vw, 420px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.closed { padding: 32px 4px; }
.closed h2 { margin-bottom: 10px; font-size: 24px; }
.closed p { margin-bottom: 18px; }
