/* Client portal. The same quiet, neutral look as the rest of the site: near-black ink on
   white and soft gray, one blue accent, red only for what's late or urgent, green for
   done. Written for a phone first: big tap targets, one column, tabs at the bottom of the
   screen like a banking app. */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f5f6;
  --ink: #18181b;
  --muted: #63636b;
  --line: #e4e4e7;
  --accent: #3451b2;
  --accent-ink: #ffffff;
  --accent-soft: #eef1fa;
  --sun: #a1a1aa;
  --sun-soft: #f1f1f3;
  --sun-ink: #3f3f46;
  --sky: #f5f5f6;
  --coral: #b42318;
  --coral-soft: #fdf1f0;
  --ok: #1f7a46;
  --ok-soft: #eef6f0;
  --focus: #3451b2;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
  --font-display: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f11; --surface: #18181b; --surface-2: #1f1f23; --ink: #ececee; --muted: #a1a1aa; --line: #2c2c31;
    --accent: #8ea2ef; --accent-ink: #0f0f11; --accent-soft: #1e2236; --sun: #71717a; --sun-soft: #26262b; --sun-ink: #d4d4d8;
    --sky: #1f1f23; --coral: #f2867b; --coral-soft: #2d1816; --ok: #6cc28a; --ok-soft: #16231b; --focus: #8ea2ef;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f11; --surface: #18181b; --surface-2: #1f1f23; --ink: #ececee; --muted: #a1a1aa; --line: #2c2c31;
  --accent: #8ea2ef; --accent-ink: #0f0f11; --accent-soft: #1e2236; --sun: #71717a; --sun-soft: #26262b; --sun-ink: #d4d4d8;
  --sky: #1f1f23; --coral: #f2867b; --coral-soft: #2d1816; --ok: #6cc28a; --ok-soft: #16231b; --focus: #8ea2ef;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 17px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 30; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 0.88rem; }
.eyebrow { margin: 0; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; color: var(--muted); }

/* ---------- top bar, tabs and quick exit ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px max(16px, env(safe-area-inset-left)); padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; min-width: 0; margin-right: auto; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: 0.95rem; font-weight: 700; }
.brand-mark::before { content: "§"; }
.exit { flex: none; border: 0; border-radius: 999px; padding: 8px 14px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 0.88rem; cursor: pointer; }
.exit::after { content: " ✕"; }
.tabs { display: flex; gap: 4px; }
.tabs a { position: relative; display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.tabs a:hover { background: var(--surface); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.tab-ico { font-size: 1rem; }
.pip { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; font-weight: 800; }
.pip-inline { height: auto; padding: 2px 10px; }
@media (max-width: 760px) {
  /* A backdrop filter would make the fixed tab bar stick to the header instead of the screen. */
  .top { backdrop-filter: none; background: var(--bg); }
  body:not(.bare) { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; justify-content: space-around; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06); }
  .tabs a { flex: 1; flex-direction: column; gap: 0; padding: 6px 2px; border-radius: 12px; font-size: 0.72rem; }
  .tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .tab-ico { font-size: 1.25rem; line-height: 1.2; }
  .tabs .pip { position: absolute; top: 2px; left: calc(50% + 8px); }
}

.main { max-width: 820px; margin: 0 auto; padding: 20px 16px 40px; }
.foot { max-width: 820px; margin: 0 auto; padding: 0 16px 32px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; color: var(--muted); font-size: 0.88rem; }
.foot p { margin: 0; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; }
.flash { margin: 0 0 16px; padding: 12px 16px; border-radius: 14px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.flash-error { background: var(--coral-soft); color: var(--coral); }
.page-title { font-family: var(--font-display); font-weight: 600; font-size: 1.75rem; margin: 4px 0 4px; letter-spacing: -0.01em; }
.lede { margin: 0 0 20px; color: var(--muted); }

/* ---------- forms and buttons ---------- */
.stack { display: grid; gap: 8px; }
.label { font-weight: 600; font-size: 0.95rem; margin-top: 6px; }
.input { width: 100%; min-height: 50px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 1rem; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea.input { resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-size: 0.95rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; border-radius: 999px; border: 1.5px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center; }
.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.secondary { background: var(--surface); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); color: var(--accent); }
.button.ghost { background: transparent; color: var(--accent); }
.button.big { width: 100%; min-height: 54px; font-size: 1.05rem; margin-top: 10px; }
.button:hover { filter: brightness(1.06); }
.choice { display: grid; gap: 2px; text-align: left; padding: 16px 18px; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; }
.choice:hover { border-color: var(--accent); }
.choice-title { font-weight: 700; font-size: 1.05rem; }

/* ---------- sign-in ---------- */
body.bare .main { max-width: 460px; padding-top: 28px; }
.auth { background: var(--surface); border-radius: 12px; padding: 28px 24px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-title { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; line-height: 1.2; margin: 0 0 8px; }
.auth-lede { margin: 0 0 16px; color: var(--muted); }
.auth-links { text-align: center; margin: 16px 0 0; }
.auth-note { margin: 14px 0 0; font-size: 0.88rem; color: var(--muted); padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- home ---------- */
.hello { margin: 4px 0 18px; }
.hello-title { font-family: var(--font-display); font-weight: 600; font-size: 2rem; margin: 2px 0 2px; letter-spacing: -0.01em; }
.hello-sub { margin: 0; color: var(--muted); font-size: 1.05rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-head a { font-weight: 600; font-size: 0.92rem; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; margin: 0 0 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

.journey-top { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.ring { flex: none; display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--surface) 76%, transparent 77% 100%), conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0); }
.ring span { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; }
.ring small { font-size: 0.8rem; color: var(--muted); }
.journey-stage { font-family: var(--font-display); font-weight: 600; font-size: 1.45rem; margin: 2px 0 0; line-height: 1.2; }
.now-you { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 600px) { .now-you { grid-template-columns: 1fr; } }
.now-you > div { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.now-you .you { background: var(--accent-soft); border-color: transparent; }
.now-you p { margin: 0; }
.mini-label { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px !important; }
.you .mini-label { color: var(--accent); }
.all-steps { margin-top: 12px; }
.all-steps summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 0; }
.steps { list-style: none; margin: 10px 0 0; padding: 0; }
.step { position: relative; display: flex; gap: 14px; padding: 0 0 16px; }
.step::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.step-dot { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font-size: 0.8rem; font-weight: 800; color: var(--accent-ink); z-index: 1; }
.step-done .step-dot { background: var(--accent); border-color: var(--accent); }
.step-done::before { background: var(--accent); }
.step-current .step-dot { border-color: var(--accent); background: var(--surface); box-shadow: inset 0 0 0 5px var(--accent); }
.step-title { margin: 2px 0 0; font-weight: 700; }
.step-ahead .step-title { color: var(--muted); font-weight: 600; }
.step-text { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.step-ahead .step-text { display: none; }
.you-are-here { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.72rem; font-weight: 700; vertical-align: 2px; }

.todo-mini { list-style: none; margin: 0; padding: 0; }
.todo-mini li { border-top: 1px solid var(--line); }
.todo-mini li:first-child { border-top: 0; }
.todo-mini a, .done-list .todo-mini li { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: var(--ink); text-decoration: none; }
.todo-mini-title { flex: 1; min-width: 0; display: grid; gap: 3px; justify-items: start; font-weight: 600; }
.box { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--accent); font-size: 0.8rem; font-weight: 800; color: var(--accent); }
.box-wait { border-color: var(--sun); color: var(--sun-ink); background: var(--sun-soft); }
.box-done { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.all-clear { margin: 0; padding: 14px; border-radius: 14px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.due { flex: none; font-size: 0.78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.due-overdue, .due-today { background: var(--coral-soft); color: var(--coral); border-color: transparent; }
.due-soon { background: var(--sun-soft); color: var(--sun-ink); border-color: transparent; }
.state { display: inline-block; font-size: 0.8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.state-wait { background: var(--sun-soft); color: var(--sun-ink); }
.state-done { background: var(--ok-soft); color: var(--ok); }
.state-back { background: var(--coral-soft); color: var(--coral); }

.dates { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.dates li { display: flex; gap: 12px; align-items: center; }
.dates p { margin: 0; }
.cal { flex: none; display: grid; width: 50px; border-radius: 12px; overflow: hidden; text-align: center; border: 1px solid var(--line); background: var(--surface); }
.cal-m { background: var(--accent); color: var(--accent-ink); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 0; }
.cal-d { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; padding: 2px 0 4px; }
.date-title { font-weight: 700; }

.last-msg { margin: 0 0 12px; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); border-left: 4px solid var(--accent); }
.last-msg p { margin: 0; overflow-wrap: anywhere; }
.team-name { margin: 0; font-weight: 700; font-size: 1.1rem; }
.team .muted { margin: 0; }
.team-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.quick-tile { display: grid; gap: 2px; padding: 16px 18px; border-radius: var(--radius); background: var(--sky); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.quick-n { font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; }
.quick-owe { background: var(--sun-soft); }
.privacy-tip { margin: 8px 0 0; padding: 12px 14px; border-radius: 14px; border: 1px dashed var(--line); color: var(--muted); font-size: 0.88rem; }

/* ---------- to-do list ---------- */
.todos { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 14px; }
.todo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); scroll-margin-top: 80px; }
.todo.status-submitted { background: var(--surface-2); }
.todo.sent-back { border-color: color-mix(in srgb, var(--coral) 45%, var(--line)); }
.todo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.todo-title { margin: 0; font-size: 1.1rem; font-weight: 700; line-height: 1.3; }
.todo-detail { margin: 8px 0 0; color: var(--muted); }
.todo > .state { margin-top: 8px; }
.firm-note { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--coral-soft); color: var(--ink); }
.sent-files { list-style: none; margin: 10px 0 0; padding: 0; font-size: 0.92rem; }
.sent-files li { padding: 2px 0; overflow-wrap: anywhere; }
.upload { margin-top: 14px; display: grid; gap: 10px; }
.drop { position: relative; display: grid; justify-items: center; gap: 2px; padding: 18px 14px; border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 16px; background: var(--accent-soft); text-align: center; cursor: pointer; }
.drop:hover, .drop:focus-within { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop-ico { font-size: 1.6rem; color: var(--accent); line-height: 1; }
.drop-main { font-weight: 700; color: var(--accent); }
.drop-sub { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.drop.has-files { background: var(--ok-soft); border-style: solid; border-color: var(--ok); }
.done-list { margin: 8px 0 16px; }
.done-list summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 0; }

/* ---------- messages ---------- */
.chat { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: var(--surface); border: 1px solid var(--line); scroll-margin-top: 80px; }
.msg.from-client { justify-self: end; border-radius: 18px 18px 6px 18px; background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.msg-who { margin: 0 0 2px; font-size: 0.75rem; font-weight: 700; opacity: 0.75; }
.msg-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-empty { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px dashed var(--line); color: var(--muted); }
.composer { position: sticky; bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; padding: 10px 0; background: var(--bg); }
@media (max-width: 760px) { .composer { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); } }

/* ---------- documents ---------- */
.files { list-style: none; margin: 0; padding: 0; }
.files li { border-top: 1px solid var(--line); }
.files li:first-child { border-top: 0; }
.files a { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: var(--ink); text-decoration: none; }
.file-ico { flex: none; display: grid; place-items: center; width: 38px; height: 44px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 0.9rem; }
.file-ico-bill { background: var(--surface-2); color: var(--ink); }
.file-ico-up { background: var(--accent-soft); color: var(--accent); }
.file-main { flex: 1; min-width: 0; display: grid; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-go { flex: none; font-size: 0.85rem; font-weight: 700; color: var(--accent); }
