/* Client portal.
   Shares the brand palette with the public site and the console so it never
   feels like a third product, but it is its own stylesheet: the portal is a
   working surface for one engagement, and loading the marketing CSS here would
   drag in a header, a footer and a type scale none of it uses.

   Colours are the corrected set from the public site — the copper is darkened
   until white-on-copper clears 4.5:1, because a client reading their own
   financials on a phone in bad light is exactly who contrast rules are for. */

:root {
    --ink: #0e1726;
    --ink-2: #33415a;
    --ink-3: #5b6b80;
    --brand: #12314f;
    --brand-700: #0c2440;
    --brand-500: #1d4a76;
    --brand-100: #dfe9f2;
    --accent: #8c5f28;
    --accent-600: #744e20;
    --accent-100: #f5ead9;
    --bg: #f4f6f9;
    --panel: #ffffff;
    --line: #e2e7ee;
    --line-2: #cfd7e2;
    --ok: #1f7a53;
    --ok-100: #e2f2ea;
    --warn: #a8700c;
    --warn-100: #fbf0d9;
    --risk: #a63232;
    --risk-100: #fae5e3;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --serif: "Iowan Old Style", Palatino, Georgia, serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(14,23,38,.06), 0 4px 14px rgba(14,23,38,.05);
}

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

body {
    margin: 0; background: var(--bg); color: var(--ink-2);
    font-family: var(--sans); font-size: 15px; line-height: 1.58;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--ink); margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .85rem; }
a { color: var(--brand-500); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .85em; }
img, svg { max-width: 100%; }

.muted { color: var(--ink-3); }
.small { font-size: .86rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Visible to a screen reader, not to the eye. */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- signed out */

.portal-signed-out { background: var(--brand-700); }

.plain {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 2rem 1.25rem;
}
.plain-brand {
    display: flex; align-items: center; gap: .7rem; color: #fff;
    font-family: var(--serif); font-size: 1.2rem; margin-bottom: 1.5rem;
}
.plain-brand:hover { text-decoration: none; }
.plain-card {
    background: var(--panel); border-radius: 14px; padding: 2rem;
    width: min(100%, 440px); box-shadow: 0 24px 60px rgba(5, 16, 30, .35);
}
.plain-card.wide { width: min(100%, 560px); }
.plain-foot { margin-top: 1.5rem; font-size: .82rem; color: #8ba5c0; }
.plain-foot a { color: #cddcea; }

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

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.side {
    background: var(--brand); color: #b9cbdd; padding: 1.1rem .8rem;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column;
}
.side-brand {
    display: flex; align-items: center; gap: .6rem; color: #fff;
    padding: .3rem .5rem 1rem; text-decoration: none;
}
.side-brand:hover { text-decoration: none; }
.side-brand b { font-size: .98rem; font-weight: 650; letter-spacing: -.01em; }
.side-brand > span > span {
    display: block; font-size: .64rem; letter-spacing: .13em;
    text-transform: uppercase; color: #7d99b6;
}

.side-client {
    background: rgba(255,255,255,.07); border-radius: 8px;
    padding: .6rem .7rem; margin: 0 .1rem 1rem;
}
.side-client-name { margin: 0; color: #fff; font-weight: 600; font-size: .92rem; line-height: 1.3; }
.side-client-ref { margin: .15rem 0 0; font-family: var(--mono); font-size: .72rem; color: #8fa9c4; }

.side nav { display: grid; gap: .15rem; }
.side nav a {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .6rem; border-radius: 7px; color: #b9cbdd; font-size: .9rem;
}
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side nav a.is-active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.side nav a svg { flex: none; }
.side-badge {
    margin-left: auto; font-style: normal; background: var(--accent); color: #fff;
    border-radius: 999px; padding: 0 .42rem; font-size: .7rem; font-weight: 700; line-height: 1.5;
}

.side-foot { margin-top: auto; padding-top: 1.2rem; }
.side-advisor {
    background: rgba(255,255,255,.06); border-radius: 8px; padding: .6rem .7rem; margin: 0 0 .7rem;
    display: grid; gap: .05rem;
}
.side-advisor span { font-size: .7rem; color: #8fa9c4; }
.side-advisor strong { color: #fff; font-size: .9rem; }
.side-signout {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .6rem; border-radius: 7px; color: #b9cbdd; font-size: .86rem;
}
.side-signout:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }

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

.topbar {
    background: var(--panel); border-bottom: 1px solid var(--line);
    padding: .8rem 1.6rem; display: flex; align-items: center; gap: 1rem;
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.15rem; }
.topbar-you { margin-left: auto; font-size: .84rem; color: var(--ink-3); }

.menu-toggle {
    display: none; background: none; border: 1px solid var(--line-2);
    border-radius: 8px; padding: .35rem .45rem; color: var(--ink); cursor: pointer;
}

.content { padding: 1.6rem; max-width: 1240px; width: 100%; flex: 1; }
.foot { padding: 1rem 1.6rem 2rem; font-size: .8rem; color: var(--ink-3); }
.foot p { margin: 0; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; display: none; }
    body.side-open .side { display: flex; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 1.1rem; }
}

/* ---------------------------------------------------------------- cards */

.card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card-head {
    display: flex; align-items: center; gap: .8rem; justify-content: space-between;
    flex-wrap: wrap; margin: -.2rem 0 1rem;
}
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cols { display: grid; gap: 1.2rem; grid-template-columns: 1fr; }
@media (min-width: 1050px) { .cols { grid-template-columns: 1.7fr 1fr; align-items: start; } }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .95rem 1.05rem; }
.stat .k { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); }
.stat .v { font-size: 1.6rem; font-weight: 650; color: var(--ink); line-height: 1.1; margin-top: .2rem; }
.stat .d { font-size: .78rem; color: var(--ink-3); margin-top: .15rem; }
.stat.accent { border-left: 3px solid var(--accent); }

.note {
    background: var(--brand-100); border: 1px solid #c8dced; color: #1b3a58;
    border-radius: var(--radius); padding: .85rem 1rem; font-size: .88rem;
}
.note > :last-child { margin-bottom: 0; }
.note.accent { background: var(--accent-100); border-color: #e8d6bb; color: #5c3f1a; }

.empty {
    border: 1px dashed var(--line-2); border-radius: var(--radius);
    padding: 2rem 1.2rem; text-align: center; color: var(--ink-3);
}
.empty svg { color: var(--line-2); }

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .6rem 1.05rem; border-radius: 8px; border: 1px solid transparent;
    font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: background .14s ease, border-color .14s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); color: #fff; }
.btn-dark { background: var(--brand); color: #fff; }
.btn-dark:hover { background: var(--brand-700); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand-500); color: var(--brand); }
.btn-danger { background: #fff; border-color: #e8bfbb; color: var(--risk); }
.btn-danger:hover { background: var(--risk-100); }
.btn-sm { padding: .38rem .7rem; font-size: .82rem; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- forms */

.field { margin-bottom: .9rem; }
.field label, .label {
    display: block; font-size: .82rem; font-weight: 600;
    color: var(--ink); margin-bottom: .3rem;
}
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=tel], .field input[type=date], .field input[type=number],
.field input[type=file], .field select, .field textarea {
    width: 100%; padding: .6rem .75rem; font: inherit; font-size: .92rem;
    border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--brand-500); outline-offset: 1px; border-color: var(--brand-500);
}
.field .hint { font-size: .78rem; color: var(--ink-3); margin: .3rem 0 0; }
.row { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.check { display: flex; gap: .55rem; align-items: flex-start; font-size: .88rem; margin-bottom: .5rem; }
.check input { margin-top: .28rem; flex: none; }

/* ---------------------------------------------------------------- flash */

.flash { border-radius: 9px; padding: .8rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
.flash-success { background: var(--ok-100); color: #14563a; border: 1px solid #bfe0ce; }
.flash-error { background: var(--risk-100); color: #7d2020; border: 1px solid #eec4c0; }
.flash-warning { background: var(--warn-100); color: #6f4a06; border: 1px solid #ecd9a8; }
.flash-info { background: var(--brand-100); color: #1b3a58; border: 1px solid #c8dced; }
.flash a { color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
    text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
    color: var(--ink-3); padding: .5rem .6rem; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }

.badge {
    display: inline-block; padding: .12rem .5rem; border-radius: 999px;
    font-size: .72rem; font-weight: 650; background: var(--brand-100); color: var(--brand);
}
.badge-ok { background: var(--ok-100); color: #14563a; }
.badge-warn { background: var(--warn-100); color: #6f4a06; }
.badge-risk { background: var(--risk-100); color: #7d2020; }
.badge-accent { background: var(--accent-100); color: var(--accent-600); }
.badge-muted { background: #eef1f5; color: var(--ink-3); }

/* ---------------------------------------------------------------- progress */

.progress-track {
    height: 9px; background: var(--line); border-radius: 999px; overflow: hidden; margin: .6rem 0 .4rem;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* The engagement stages, as a rail. */
.stage-rail { display: grid; gap: .25rem; margin-top: .4rem; }
.stage-rail li { display: flex; gap: .7rem; align-items: flex-start; list-style: none; }
.stage-rail .dot {
    width: 20px; height: 20px; border-radius: 50%; flex: none; margin-top: .18rem;
    border: 2px solid var(--line-2); background: #fff;
    display: grid; place-items: center; color: #fff;
}
.stage-rail li.is-done .dot { background: var(--ok); border-color: var(--ok); }
.stage-rail li.is-now .dot { background: var(--accent); border-color: var(--accent); }
.stage-rail li.is-now strong { color: var(--accent-600); }
.stage-rail p { margin: 0; font-size: .82rem; color: var(--ink-3); }
.stage-rail ul { margin: 0; padding: 0; }

/* ---------------------------------------------------------------- checklist */

.checklist { display: grid; gap: .6rem; margin: 0; padding: 0; list-style: none; }
.check-item {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: #fff; padding: .85rem 1rem;
}
.check-item.is-done { background: #fbfcfd; border-style: dashed; }
.check-item.is-done .check-title { text-decoration: line-through; color: var(--ink-3); }
.check-item.is-blocked { border-left: 3px solid var(--warn); }
.check-head { display: flex; gap: .8rem; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.check-title { font-weight: 600; color: var(--ink); margin: 0; }
.check-item .detail { font-size: .85rem; color: var(--ink-3); margin: .2rem 0 0; }
.check-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }
.check-note {
    margin-top: .6rem; font-size: .84rem; background: var(--bg);
    border-radius: 7px; padding: .5rem .7rem;
}

/* ---------------------------------------------------------------- files */

.file-list { display: grid; gap: .5rem; }
.file-row {
    display: flex; align-items: center; gap: .9rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: #fff; padding: .7rem .9rem;
}
.file-icon {
    width: 40px; height: 40px; border-radius: 8px; flex: none;
    display: grid; place-items: center; font-size: .64rem; font-weight: 700;
    letter-spacing: .04em; background: var(--brand-100); color: var(--brand);
}
.file-icon.pdf { background: var(--risk-100); color: #7d2020; }
.file-icon.sheet { background: var(--ok-100); color: #14563a; }
.file-icon.image { background: var(--accent-100); color: var(--accent-600); }
.file-main { min-width: 0; flex: 1; }
.file-main strong { display: block; color: var(--ink); font-size: .92rem; word-break: break-word; }
.file-meta { font-size: .78rem; color: var(--ink-3); }
.file-actions { display: flex; gap: .4rem; flex: none; }

.folder-head {
    display: flex; align-items: baseline; gap: .6rem;
    margin: 1.6rem 0 .6rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line);
}
.folder-head h3 { margin: 0; }
.folder-head span { font-size: .78rem; color: var(--ink-3); }

/* ---------------------------------------------------------------- messages */

.thread { display: grid; gap: .8rem; }
.msg { display: grid; gap: .2rem; max-width: 72ch; }
.msg .bubble {
    border-radius: 12px; padding: .8rem 1rem; font-size: .92rem;
    white-space: pre-wrap; word-break: break-word;
}
.msg.from-staff .bubble { background: #fff; border: 1px solid var(--line); }
.msg.from-client { justify-items: end; margin-left: auto; }
.msg.from-client .bubble { background: var(--brand); color: #eaf1f8; }
.msg .who { font-size: .74rem; color: var(--ink-3); }
.msg.from-client .who { text-align: right; }

/* ---------------------------------------------------------------- agreement */

.agreement-body {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.2rem 1.4rem; max-height: 420px; overflow-y: auto;
    font-size: .9rem; white-space: pre-wrap; line-height: 1.6;
}
.sign-box {
    border: 1px solid var(--accent); background: var(--accent-100);
    border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-top: 1.2rem;
}
.sign-box input[type=text] {
    font-family: var(--serif); font-size: 1.15rem; letter-spacing: .01em;
}

/* ---------------------------------------------------------------- timeline */

.timeline { display: grid; gap: .1rem; margin: 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 20px 1fr; gap: .8rem; padding-bottom: 1rem; }
.timeline .mark {
    width: 11px; height: 11px; border-radius: 50%; background: var(--accent);
    margin: .4rem 0 0 4px; position: relative;
}
.timeline li:not(:last-child) .mark::after {
    content: ""; position: absolute; left: 50%; top: 14px; bottom: -18px;
    width: 1px; background: var(--line-2); transform: translateX(-50%);
}
.timeline .when { font-size: .74rem; color: var(--ink-3); }
.timeline p { margin: 0; }
