.portal { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 79px); min-height: calc(100dvh - 79px); background: linear-gradient(90deg, var(--surface) 259px, var(--border) 259px, var(--border) 260px, transparent 260px); }
.portal-side { background: var(--surface); border-right: 1px solid var(--border); padding: 24px 14px; position: sticky; top: 79px; height: calc(100vh - 79px); height: calc(100dvh - 79px); overflow-y: auto; }
.portal-side .who { display: flex; gap: 12px; align-items: center; padding: 10px 12px 20px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--brand-grad); color: #1a1203; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.portal-main { padding: 32px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.portal-main h1 { font-size: 1.7rem; }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.p-head p { color: var(--muted); margin: 0; }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; }
.kcol { background: var(--surface-2); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.kcol h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; justify-content: space-between; margin: 4px 4px 12px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; font-size: .9rem; }
.kcard b { display: block; margin-bottom: 6px; }
.chat { display: grid; gap: 12px; max-height: 60vh; overflow-y: auto; padding: 16px; background: var(--surface-2); border-radius: var(--radius); margin-bottom: 14px; }
.bubble { max-width: 75%; padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); font-size: .93rem; white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { justify-self: end; background: var(--accent-bg); border-color: transparent; }
.bubble small { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.invoice-doc { background: #fff; color: #0E1830; border-radius: var(--radius-lg); padding: clamp(24px, 4vw, 48px); border: 1px solid var(--border); max-width: 860px; }
.invoice-doc table { width: 100%; border-collapse: collapse; margin: 24px 0; }
.invoice-doc th, .invoice-doc td { padding: 10px; border-bottom: 1px solid #E2E6F0; text-align: left; }
.invoice-doc .num { text-align: right; }
.auth-wrap { min-height: calc(100vh - 79px); min-height: calc(100dvh - 79px); display: grid; place-items: center; padding: 40px 20px; background: var(--hero-bg); }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 36px; box-shadow: var(--shadow-lg); }
.portal-tabs { display: none; }
@media (max-width: 960px) {
  .portal { grid-template-columns: 1fr; background: none; }
  .portal-side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px; }
  .portal-side .side-nav { display: flex; overflow-x: auto; gap: 4px; }
  .portal-side .side-nav a { white-space: nowrap; }
  .portal-side .who, .portal-side .side-title { display: none; }
}

/* unread badge on the Secure chat nav item */
.side-nav .nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: #dc2626; color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.side-nav .nav-badge[hidden] { display: none; }

/* upload guard feedback under a file input */
.upload-msg { margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
.upload-msg.bad { color: var(--err); font-weight: 600; }
.upload-msg.good { color: var(--ok); }

/* ==========================================================================
   Running projects on the dashboard: where the site is, and where the money is.
   ========================================================================== */
.pj-live { display: grid; gap: 14px; }
.pj-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: clamp(16px, 2vw, 22px); }
.pj-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pj-top h3 { margin: 0 0 3px; font-size: 1.05rem; }
.pj-top h3 a { color: inherit; }
.pj-top h3 a:hover { color: var(--accent); }

.pj-progress { margin-top: 14px; }

.pj-money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px;
  padding: 14px 0 0; border-top: 1px solid var(--border); }
.pj-money > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pj-l { font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pj-money b { font-size: clamp(1.05rem, 2.2vw, 1.3rem); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.pj-paid { color: var(--ok, #2e9e5b); }
.pj-left { color: var(--accent); }

.pj-bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.pj-bar i { display: block; height: 100%; border-radius: 99px; background: var(--brand-grad); }
.pj-note { margin: 8px 0 0; }

.pj-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

@media (max-width: 560px) {
  .pj-money { grid-template-columns: 1fr 1fr; }
  .pj-money > div:last-child { grid-column: span 2; }
}

/* ---------------------------------------------------------------- invoices (portal + print) */
.inv { position: relative; overflow: hidden; background: #fff; color: #1F2937; max-width: 900px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: clamp(22px, 4vw, 44px); padding-top: clamp(30px, 4.5vw, 52px);
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.inv::before { content: ""; position: absolute; inset: 0 0 auto; height: 8px;
  background: linear-gradient(#0E1830 0 5px, #F5A524 5px 8px); }
.inv b { color: #0E1830; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.inv-logo { width: min(230px, 60vw); height: auto; display: block; }
.inv-title { text-align: right; margin-left: auto; }
.inv-title h1 { margin: 0 0 10px; color: #0E1830; font-size: clamp(1.4rem, 3vw, 1.9rem); letter-spacing: .06em; text-transform: uppercase; }
.inv-title dl { display: grid; grid-template-columns: auto auto; gap: 3px 16px; margin: 0; font-size: .86rem; }
.inv-title dt { color: #667085; text-align: left; }
.inv-title dd { margin: 0; font-weight: 700; color: #0E1830; text-align: right; }
.inv-status { margin-top: 10px; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 28px 0 18px; }
.inv-party { background: #F6F7FB; border: 1px solid #E3E6EF; border-radius: 12px; padding: 14px 16px; border-top: 3px solid #F5A524; }
.inv-to { border-top-color: #0E1830; }
.inv-party p { margin: 6px 0 0; font-size: .9rem; line-height: 1.6; color: #344054; }
.inv-label { display: block; font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #A86608; }
.inv-subject { font-size: .92rem; margin: 0 0 14px; color: #344054; }
.inv-sep { display: inline-block; width: 22px; }
.inv-table-wrap { overflow-x: auto; margin: 0 -2px; }
.inv-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
.inv-table thead th { background: #0E1830; color: #fff; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; padding: 10px; text-align: left; }
.inv-table thead th:first-child { border-radius: 8px 0 0 0; }
.inv-table thead th:last-child { border-radius: 0 8px 0 0; }
.inv-table td { padding: 11px 10px; border-bottom: 1px solid #E3E6EF; vertical-align: top; color: #1F2937; }
.inv-table tbody tr:nth-child(even) td { background: #F9FAFC; }
.inv-table tbody tr:last-child td { border-bottom: 2px solid #0E1830; }
.inv-table .num, .inv-totals td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-table .c-n { width: 32px; color: #667085; }
.inv-table .c-sac { width: 70px; color: #667085; font-size: .82rem; }
.inv-details { color: #667085; font-size: .8rem; margin-top: 2px; }
.inv-money { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; margin-top: 22px; align-items: start; }
.inv-words p { margin: 4px 0 16px; font-size: .9rem; line-height: 1.6; color: #344054; }
.inv-words a { color: #A86608; font-weight: 700; }
.inv-totals { width: 100%; border-collapse: collapse; font-size: .92rem; }
.inv-totals th { text-align: left; font-weight: 500; color: #475467; padding: 7px 12px; }
.inv-totals td { padding: 7px 12px; color: #1F2937; }
.inv-totals tr:not(.inv-total):not(.inv-end) { border-bottom: 1px solid #EEF0F5; }
.inv-totals .inv-total th, .inv-totals .inv-total td { background: #0E1830; color: #fff; font-weight: 800; font-size: 1.05rem; padding: 12px; }
.inv-totals .inv-total th { border-radius: 10px 0 0 10px; }
.inv-totals .inv-total td { border-radius: 0 10px 10px 0; }
.inv-totals .inv-end th, .inv-totals .inv-end td { font-weight: 800; color: #A86608; padding-top: 10px; }
.inv-totals .inv-end-paid th, .inv-totals .inv-end-paid td { color: #12805C; }
.inv-foot { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 28px; margin-top: 30px; padding-top: 20px; border-top: 1px solid #E3E6EF; }
.inv-foot p, .inv-foot ol { font-size: .82rem; line-height: 1.6; color: #475467; margin: 4px 0 12px; }
.inv-foot ol { padding-left: 18px; }
.inv-sign { text-align: right; font-size: .86rem; color: #344054; }
.inv-sign p { margin: 0; }
.inv-sign-line { height: 52px; border-bottom: 1px solid #98A2B3; margin: 0 0 6px auto; width: 180px; }
.inv-computer { margin: 22px 0 0; font-size: .74rem; color: #98A2B3; text-align: center; }
.inv-stamp { position: absolute; top: 150px; right: 14%; transform: rotate(18deg); font-weight: 900; font-size: clamp(2.2rem, 7vw, 4rem);
  letter-spacing: .08em; text-transform: uppercase; padding: 4px 18px; border: 4px solid currentColor; border-radius: 14px;
  opacity: .16; pointer-events: none; }
.inv-stamp-paid { color: #12805C; }
.inv-stamp-cancelled { color: #B42318; }
.inv-stamp-draft { color: #667085; }
@media (max-width: 720px) {
  .inv-parties, .inv-money, .inv-foot { grid-template-columns: 1fr; }
  .inv-title { text-align: left; margin-left: 0; }
  .inv-sign { text-align: left; }
  .inv-sign-line { margin-left: 0; }
}
@media print {
  .inv { border: 0; box-shadow: none; max-width: none; padding: 0 0 0; padding-top: 20px; }
  .inv-table { min-width: 0; }
  .inv-table-wrap { overflow: visible; }
}
