/* Isaac Explains client portal: design system.
   Navy and gold brand, mobile first (most clients are on phones),
   no frameworks, one stylesheet for every portal and admin page.
   Type: Georgia serif for display headings, system sans for UI text,
   matching isaacexplains.com. */

:root {
  --navy: #0b2447;
  --navy-2: #103058;
  --navy-3: #19376d;
  --gold: #efaa0c;
  --gold-dark: #b97e04;
  --gold-soft: #fdf3d7;
  --ink: #16233a;
  --muted: #5b6b82;
  --line: #dde4ee;
  --bg: #f2f5f9;
  --card: #ffffff;
  --green: #1e7d46;
  --green-bg: #e5f4ec;
  --red: #b3261e;
  --red-bg: #fbeae8;
  --amber: #9a6a00;
  --amber-bg: #fdf0d3;
  --blue: #1b4b9b;
  --blue-bg: #e7eefa;
  --teal: #0e6e6e;
  --teal-bg: #e2f2f2;
  --grey-bg: #edf0f4;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(11, 36, 71, .06), 0 8px 24px rgba(11, 36, 71, .07);
  --shadow-lg: 0 12px 40px rgba(11, 36, 71, .22);
  --space: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
}
a { color: var(--blue); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--serif); color: var(--navy); line-height: 1.2; margin: 0 0 .45em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 264px; flex: 0 0 264px; background: var(--navy); color: #dbe5f2;
  display: flex; flex-direction: column; padding: 18px 14px; gap: 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: #fff; padding: 4px 6px; }
.brand img { width: 42px; height: 42px; border-radius: 10px; flex: none; }
.brand b { display: block; font-family: var(--serif); font-size: 1.06rem; letter-spacing: .2px; }
.brand small { display: block; color: var(--gold); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.brand.center { justify-content: center; color: var(--navy); }
.brand.center small { color: var(--gold-dark); }
.side-user { display: flex; align-items: center; gap: 10px; background: var(--navy-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.side-user b { display: block; color: #fff; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user small { display: block; color: #a9bcd6; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--gold); color: var(--navy); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; font-size: .95rem;
}
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a, .side-foot a {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px; min-height: 44px;
  border-radius: var(--radius-sm); color: #dbe5f2; text-decoration: none; font-size: .97rem;
  transition: background .15s ease, color .15s ease;
}
.side-nav a svg, .side-foot a svg { width: 20px; height: 20px; flex: none; }
.side-nav a:hover, .side-foot a:hover { background: var(--navy-2); color: #fff; }
.side-nav a.active { background: var(--gold); color: var(--navy); font-weight: 700; }
.side-nav .badge, .side-foot .badge {
  margin-left: auto; background: var(--red); color: #fff; border-radius: 999px;
  font-size: .72rem; font-weight: 700; padding: 1px 8px;
}
.side-nav a.active .badge { background: var(--navy); color: #fff; }
.side-foot { margin-top: auto; border-top: 1px solid var(--navy-3); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; gap: 12px; background: var(--navy); color: #fff;
  padding: 10px 16px; position: sticky; top: 0; z-index: 30;
}
.topbar h1 { color: #fff; font-size: 1.15rem; margin: 0; }
.nav-toggle {
  background: var(--navy-2); color: #fff; border: 1px solid var(--navy-3);
  border-radius: 8px; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer;
}
.content { padding: 26px clamp(16px, 4vw, 40px) 40px; max-width: 1060px; width: 100%; margin: 0 auto; }
.foot { padding: 18px; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---------- cards, stats, lists ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: var(--space);
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: var(--space); }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; text-decoration: none; color: var(--ink); display: block;
}
.stat .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--gold-soft); color: var(--gold-dark); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.stat .ic svg { width: 21px; height: 21px; }
.stat b { display: block; font-family: var(--serif); font-size: 1.7rem; color: var(--navy); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .88rem; }
.stat.alert b { color: var(--red); }
.row-list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 13px; padding: 14px 4px; min-height: 48px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); width: 100%;
  background: none; border-top: 0; border-left: 0; border-right: 0; font: inherit; text-align: left; cursor: pointer;
}
.list-row:last-child { border-bottom: 0; }
.list-row .row-ic { width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--blue-bg); color: var(--blue); display: flex; align-items: center; justify-content: center; }
.list-row .row-ic svg { width: 20px; height: 20px; }
.list-row b { display: block; font-size: .99rem; }
.list-row .meta { color: var(--muted); font-size: .86rem; display: block; }
.empty {
  text-align: center; padding: 34px 22px; border: 1.5px dashed var(--line);
  border-radius: var(--radius); background: #fbfcfe; margin-bottom: var(--space);
}
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 46ch; margin-left: auto; margin-right: auto; }

/* ---------- buttons, badges, forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border-radius: 999px; border: 1.5px solid transparent;
  font: inherit; font-weight: 700; font-size: .97rem; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn svg { width: 18px; height: 18px; }
.btn-gold { background: linear-gradient(180deg, #f7bd33, var(--gold)); color: var(--navy); box-shadow: 0 4px 14px rgba(239, 170, 12, .35); }
.btn-gold:hover { transform: translateY(-1px); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-3); }
.btn-outline { background: #fff; border-color: var(--navy); color: var(--navy); }
.btn-outline:hover { background: var(--grey-bg); }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-sm { min-height: 40px; padding: 7px 15px; font-size: .9rem; }
.btn.full { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 11px;
  font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.teal { background: var(--teal-bg); color: var(--teal); }
.pill.grey { background: var(--grey-bg); color: var(--muted); }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 6px; color: var(--navy); }
.field .hint { font-weight: 400; color: var(--muted); font-size: .85rem; margin-top: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="tel"], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 13px; font: inherit; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: 3px solid rgba(239, 170, 12, .35); outline-offset: 0; }
input[type="file"] { font: inherit; padding: 10px 0; }
.form-err { background: var(--red-bg); color: var(--red); border-radius: var(--radius-sm); padding: 12px 15px; margin-bottom: 16px; font-weight: 600; }
.form-ok { background: var(--green-bg); color: var(--green); border-radius: var(--radius-sm); padding: 12px 15px; margin-bottom: 16px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th {
  text-align: left; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals-box { background: var(--gold-soft); border-radius: var(--radius-sm); padding: 16px 18px; margin-top: 14px; }
.totals-box .trow { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; }
.totals-box .trow.grand { border-top: 1.5px solid var(--gold); margin-top: 8px; padding-top: 10px; font-weight: 700; color: var(--navy); font-size: 1.05rem; }

/* ---------- timeline ---------- */
.tracker { list-style: none; display: flex; margin: 6px 0 4px; padding: 0; }
.tracker .step { flex: 1 1 0; text-align: center; position: relative; padding: 0 2px; }
.tracker .step::before {
  content: ""; position: absolute; top: 17px; left: calc(-50% + 19px); right: calc(50% + 19px);
  height: 3px; background: var(--line); border-radius: 2px;
}
.tracker .step:first-child::before { display: none; }
.tracker .step.done::before { background: var(--green); }
.tracker .dot {
  width: 35px; height: 35px; margin: 0 auto; border-radius: 50%; position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem;
  background: var(--grey-bg); color: var(--muted); border: 2px solid var(--line);
}
.tracker .dot svg { width: 16px; height: 16px; }
.tracker .step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.tracker .step.current .dot { background: var(--gold); border-color: var(--gold); color: var(--navy); box-shadow: 0 0 0 5px rgba(239, 170, 12, .25); }
.tracker .s-label { display: block; margin-top: 7px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.tracker .step.done .s-label { color: var(--green); }
.tracker .step.current .s-label { color: var(--navy); }
.tracker .s-date { display: block; font-size: .72rem; color: var(--muted); }
.step-list { list-style: none; margin: 0; padding: 0; }
.step-item { display: flex; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.step-item:last-child { border-bottom: 0; }
.step-item .n {
  width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--grey-bg); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.step-item.done .n { background: var(--green); color: #fff; }
.step-item.now .n { background: var(--gold); color: var(--navy); }
.step-item b { display: block; color: var(--navy); }
.step-item span { color: var(--muted); font-size: .9rem; }

/* ---------- messages ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.msg { max-width: 82%; padding: 12px 15px; border-radius: 14px; background: var(--grey-bg); }
.msg.mine { align-self: flex-end; background: var(--navy); color: #eef3fa; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg .who { font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .75; margin-bottom: 3px; }
.msg .when { font-size: .75rem; opacity: .7; margin-top: 5px; }
.msg .attach { display: inline-flex; gap: 6px; align-items: center; margin-top: 7px; font-size: .85rem; }
.msg .attach svg { width: 15px; height: 15px; }
.msg.mine a { color: var(--gold); }

/* ---------- modal, toast ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(11, 36, 71, .55); z-index: 80;
  display: none; align-items: flex-end; justify-content: center; padding: 0;
}
.modal-back.open { display: flex; }
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 24px; box-shadow: var(--shadow-lg);
}
.modal h2 { margin-top: 0; }
.pay-opt { border: 1.5px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 13px 14px; }
.pay-opt.active { border-color: var(--gold); background: var(--gold-soft); }
.pay-panel { display: none; background: #fbfcfe; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 15px 17px; margin: 4px 0 14px; }
.pay-panel.active { display: block; }
.m-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.toast {
  background: var(--navy); color: #fff; border-radius: var(--radius-sm); padding: 14px 18px;
  margin-bottom: var(--space); box-shadow: var(--shadow); font-weight: 600;
  animation: toast-in .25s ease;
}
.toast.error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 22px 16px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-3) 130%); }
.auth-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); padding: 30px 28px; width: 100%; max-width: 430px; }
.auth-card h1 { font-size: 1.5rem; text-align: center; }
.auth-card .brand { margin-bottom: 16px; }
.auth-card p { color: var(--muted); }

/* ---------- misc ---------- */
.attention { border-left: 5px solid var(--gold); }
.attention .list-row .row-ic { background: var(--amber-bg); color: var(--amber); }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity .dotline { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); margin-top: 7px; flex: none; }
.activity .when { color: var(--muted); font-size: .82rem; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs a {
  padding: 9px 16px; min-height: 42px; display: inline-flex; align-items: center; border-radius: 999px;
  background: #fff; border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .93rem;
}
.tabs a.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.searchbar .grow input, .searchbar .grow select { width: 100%; }
.doc-item { padding: 15px 0; border-bottom: 1px solid var(--line); }
.doc-item:last-child { border-bottom: 0; }
.doc-item .head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.note-box { background: var(--amber-bg); color: #6d5200; border-radius: var(--radius-sm); padding: 11px 14px; font-size: .92rem; margin-top: 9px; }
.info-box { background: var(--blue-bg); color: #14315e; border-radius: var(--radius-sm); padding: 11px 14px; font-size: .92rem; margin-top: 9px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .topbar { display: flex; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-105%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .side.open { transform: none; }
  .content { padding-top: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .tracker .s-label { font-size: .68rem; }
  .msg { max-width: 92%; }
  .modal { padding: 20px 18px; }
}
@media (min-width: 761px) {
  .modal-back { align-items: center; padding: 20px; }
  .modal { border-radius: 18px; }
}
@media print {
  .side, .topbar, .foot, .btn, .tabs { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
