/* =========================================================
   Milestone Eng. — Client Portal
   Tokens and base styles mirror milestoneeng.com.au
   ========================================================= */
:root {
  --ink: #0b1d26;
  --ink-2: #13303d;
  --text: #33464f;
  --muted: #5f727b;
  --line: #dde6e8;
  --bg: #ffffff;
  --bg-soft: #f3f7f7;
  --bg-tint: #e8f4f3;
  --teal: #0e98a6;
  --teal-dark: #0a7884;
  --green: #12906a;
  --mint: #6fc0b0;
  --amber: #b7791f;
  --amber-bg: #fdf5e6;
  --red: #c0392b;
  --red-bg: #fdecea;
  --grad: linear-gradient(120deg, #12906a 0%, #0e98a6 60%, #1aa9c4 100%);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11, 29, 38, .06), 0 8px 24px rgba(11, 29, 38, .08);
  --wrap: 1180px;
  --font-head: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg-soft); color: var(--text);
  font: 400 1rem/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--teal-dark); text-underline-offset: 3px; }
a:hover { color: var(--green); }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.015em; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: min(var(--wrap), 100% - 32px); margin-inline: auto; }
.wrap--narrow { width: min(760px, 100% - 32px); margin-inline: auto; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font: 700 .75rem/1 var(--font-head); letter-spacing: .14em; text-transform: uppercase;
  color: var(--teal-dark); margin-bottom: 12px;
}
.eyebrow::before { content: ""; width: 22px; height: 3px; border-radius: 2px; background: var(--grad); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 .95rem/1 var(--font-head); text-decoration: none; cursor: pointer;
  padding: 13px 22px; border-radius: 999px; border: 2px solid transparent;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(14, 152, 166, .3); }
.btn--primary:hover { color: #fff; }
.btn--ghost { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn--ghost:hover { background: var(--ink); color: #fff; }
.btn--danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn--danger:hover { background: var(--red); color: #fff; }
.btn--sm { padding: 9px 15px; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--teal-dark); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Header ---------- */
.site-header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.nav { display: flex; align-items: center; justify-content: space-between; height: 70px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 38px; width: auto; }
.brand span { font: 700 .78rem/1 var(--font-head); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; }
.nav__links { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav__links a, .nav__links button {
  display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; background: none; border: 0; cursor: pointer;
  font: 600 .92rem/1 var(--font-head); color: var(--ink);
}
.nav__links a:hover, .nav__links button:hover { background: var(--bg-soft); color: var(--teal-dark); }
.nav__links a[aria-current="page"] { color: var(--teal-dark); }
.nav__user { font-size: .85rem; color: var(--muted); padding: 0 8px; }
@media (max-width: 720px) {
  .brand span, .nav__user { display: none; }
  .nav__links a, .nav__links button { padding: 9px 8px; font-size: .85rem; }
}

.site-footer { padding: 28px 0; font-size: .85rem; color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- Page ---------- */
.page { padding: clamp(28px, 5vw, 48px) 0 56px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 3vw, 28px); box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card h2 { margin-bottom: 4px; }
.card__sub { color: var(--muted); font-size: .92rem; margin-bottom: 18px; }

/* ---------- Auth ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: calc(100vh - 71px); }
.auth__pitch { background: var(--ink); color: #b3c5cb; padding: clamp(32px, 6vw, 72px); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.auth__pitch::before { content: ""; position: absolute; right: -140px; top: -160px; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgba(14,152,166,.35), transparent 65%); }
.auth__pitch > * { position: relative; }
.auth__pitch h1 { color: #fff; font-size: clamp(1.8rem, 3.6vw, 2.6rem); }
.auth__pitch .eyebrow { color: var(--mint); }
.auth__steps { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 14px; }
.auth__steps li { display: flex; gap: 14px; align-items: flex-start; }
.auth__steps b { flex: 0 0 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.08); color: var(--mint); display: grid; place-items: center; font: 800 .85rem/1 var(--font-head); }
.auth__steps span { padding-top: 4px; }
.auth__form { padding: clamp(32px, 6vw, 72px); display: flex; align-items: center; justify-content: center; background: #fff; }
.auth__form .box { width: min(420px, 100%); }
.tabs { display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 999px; margin-bottom: 24px; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 999px; font: 700 .9rem/1 var(--font-head); color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth__pitch { padding: 32px 16px; } .auth__form { padding: 32px 16px; } }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label, .field .label { font: 600 .88rem/1.3 var(--font-head); color: var(--ink); }
.field .hint { font-size: .82rem; color: var(--muted); }
.req { color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #c8d5d8; border-radius: var(--radius-sm); padding: 11px 12px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,152,166,.18); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice label { display: block; height: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.choice label b { display: block; font-family: var(--font-head); color: var(--ink); margin-bottom: 2px; }
.choice label span { font-size: .85rem; color: var(--muted); }
.choice input:checked + label { border-color: var(--teal); background: var(--bg-tint); }
.choice input:focus-visible + label { outline: 3px solid var(--teal); outline-offset: 2px; }

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--teal); flex-shrink: 0; }
.check b { font-family: var(--font-head); color: var(--ink); font-weight: 700; }
.sub-options { margin: 4px 0 14px 27px; padding: 12px 14px; border-left: 3px solid var(--bg-tint); background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .92rem; margin-bottom: 16px; }
.alert--error { background: var(--red-bg); color: var(--red); }
.alert--ok { background: var(--bg-tint); color: var(--teal-dark); }
.alert--warn { background: var(--amber-bg); color: var(--amber); }

/* ---------- Document checklist ---------- */
.docs { display: grid; gap: 10px; }
.doc { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 8px; }
.doc--missing { border-color: #f1c6c1; background: #fffafa; }
.doc--done { border-color: #bfe3dc; }
.doc__head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.doc__title { font: 700 .95rem/1.3 var(--font-head); color: var(--ink); }
.doc__why { font-size: .82rem; color: var(--muted); }
.doc__files { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.doc__files li { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .88rem; background: var(--bg-soft); padding: 6px 10px; border-radius: 6px; }
.doc__files li span { overflow-wrap: anywhere; }
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Badges & tables ---------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font: 700 .75rem/1.2 var(--font-head); white-space: nowrap; }
.badge--draft { background: #eef1f2; color: var(--muted); }
.badge--submitted { background: #e6f0fb; color: #2463a6; }
.badge--in_progress { background: var(--amber-bg); color: var(--amber); }
.badge--under_review { background: #f1e9fb; color: #6b3fa0; }
.badge--complete { background: var(--bg-tint); color: var(--green); }
.badge--cancelled { background: var(--red-bg); color: var(--red); }
.badge--mandatory { background: var(--red-bg); color: var(--red); }
.badge--optional { background: #eef1f2; color: var(--muted); }
.badge--ok { background: var(--bg-tint); color: var(--green); }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th { text-align: left; font: 700 .75rem/1 var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.row-link { cursor: pointer; }
table.list tr.row-link:hover td { background: var(--bg-soft); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h3 { margin-bottom: 6px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: .92rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }

.steps { display: flex; gap: 0; margin: 4px 0 8px; list-style: none; padding: 0; flex-wrap: wrap; }
.steps li { flex: 1; min-width: 110px; text-align: center; font: 600 .78rem/1.3 var(--font-head); color: var(--muted); position: relative; padding-top: 22px; }
.steps li::before { content: ""; position: absolute; top: 6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--line); z-index: 1; }
.steps li::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.steps li:first-child::after { display: none; }
.steps li.is-done { color: var(--teal-dark); }
.steps li.is-done::before, .steps li.is-done::after { background: var(--teal); }

.layout-2 { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .layout-2 { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 90px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: .9rem; box-shadow: var(--shadow); z-index: 100; max-width: calc(100% - 32px); }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
