/* Portal pages build on /styles.css (shared theme variables). No inline styles anywhere. */
.portal-page { padding: 40px 0 72px; min-height: 70vh; }
.portal-page h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 6px; }
.portal-page .sub { color: var(--muted); margin: 0 0 28px; }
.narrow { max-width: 440px; margin: 24px auto; }
.portal-brand small { color: var(--muted); font-weight: 500; }
.form input[type=password], .form input[type=email], .form input[type=text], .form input[type=search] {
  width: 100%; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; font: inherit;
}
.form input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 123, 255, .3); }
.linklike { background: none; border: 0; padding: 0; color: var(--blue-2); font: inherit; text-decoration: underline; cursor: pointer; justify-self: start; }
.stack { display: grid; gap: 12px; }
.note { color: var(--muted); font-size: .92rem; margin: 0; }
.qr { background: #fff; padding: 12px; border-radius: 12px; justify-self: center; max-width: 100%; height: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; }
[hidden] { display: none !important; }

/* Customer pages */
.portal-nav { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; justify-content: flex-end; }
.nav .portal-nav a:not(.btn) { display: inline; color: var(--muted); padding: 6px 2px; border-bottom: 2px solid transparent; }
.nav .portal-nav a:not(.btn):hover { color: var(--text); }
.nav .portal-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--blue-2); }
.portal-nav a:focus-visible, .portal-page a:focus-visible, .portal-nav .btn:focus-visible, .portal-page .btn:focus-visible {
  outline: 3px solid var(--blue-2); outline-offset: 3px; border-radius: 6px;
}
.portal-header .nav-inner { height: auto; min-height: 64px; flex-wrap: wrap; row-gap: 6px; padding-block: 8px; }
.portal-header .brand { white-space: nowrap; flex: none; }
.portal-header .portal-nav { flex: 1 1 auto; }
@media (max-width: 560px) {
  .portal-brand small { display: none; }
  .portal-header .portal-nav { justify-content: flex-start; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.portal-page .card:hover { transform: none; border-color: var(--line); }
.project-name { margin: 28px 0 12px; font-size: 1.2rem; }
.two { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .two { grid-template-columns: 1.1fr 1fr; } }
.portal-page .card .pct { margin: 0; font-size: 1.2rem; font-weight: 700; }
.portal-page .card h2.eyebrow { font-size: .8rem; line-height: 1.4; margin: 0 0 10px; }
.stages { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.stages li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; margin-top: 2px; }
.stages .done .dot { background: #4ade80; border-color: #4ade80; }
.stages .now .dot { border-color: var(--blue-2); box-shadow: 0 0 0 4px rgba(47, 123, 255, .25); }
.stages .done, .stages .now { color: var(--text); }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 14px 0 4px; }
.bar > .fill { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-2)); }
.notice { background: rgba(255, 214, 107, .1); border: 1px solid #6b5416; color: #ffd66b; border-radius: 10px; padding: 10px 14px; margin: 14px 0 0; }
.feed { display: grid; gap: 14px; margin-top: 14px; }
.feed article { border-left: 3px solid var(--blue); padding: 2px 0 2px 14px; }
.feed time { color: var(--muted); font-size: .82rem; }
.feed h3 { margin: 2px 0 4px; }
.feed p { margin: 0; color: var(--muted); }
.banner { margin-bottom: 20px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
#banner:empty { display: none; }
.invoice { margin-bottom: 20px; }
.invoice-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; align-items: center; }
.invoice-number { margin: 0; font-size: 1.17rem; }
.portal-page table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.portal-page th, .portal-page td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.portal-page th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.portal-page td.num, .portal-page th.num { text-align: right; white-space: nowrap; }
.portal-page td small { display: block; color: var(--muted); }
.pill { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: .8rem; font-weight: 700; }
.pill.paid { background: rgba(74, 222, 128, .15); color: #4ade80; }
.pill.due { background: rgba(255, 214, 107, .15); color: #ffd66b; }
.pill.overdue { background: rgba(255, 59, 48, .15); color: #ff8a82; }
.pill.draft { background: rgba(154, 168, 207, .15); color: var(--muted); }
.pill.revised { background: rgba(122, 162, 255, .15); color: #9db8ff; }
.portal-page .revisions { display: block; }
.portal-page .revisions small { display: block; font-size: .78rem; }
#co-list li { display: grid; gap: 4px; }
#co-list .actions select, #co-list .actions input[type=date] { width: auto; }
.total { display: flex; justify-content: space-between; padding: 14px 10px 0; font-weight: 700; font-size: 1.1rem; }
.total.sub-total { font-weight: 500; color: var(--muted); font-size: 1rem; padding-top: 8px; }
.how { background: var(--bg-alt); border: 1px dashed var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 18px; color: var(--muted); font-size: .92rem; }
.how b { color: var(--text); display: block; margin-bottom: 6px; }
.pdf-link { margin: 14px 0 0; }
.portal-page .card a:not(.btn) { color: var(--blue-2); }
.terms-card .prewrap { color: var(--text); }

@media print {
  .nav, .btn, .no-print, .sub, .status, .footer { display: none !important; }
  body, .card { background: #fff !important; color: #000 !important; border: 0 !important; box-shadow: none !important; }
  .card *, .terms-card .prewrap, .portal-page h1 { color: #000 !important; }
  .portal-page { padding: 0; min-height: 0; }
}

/* Admin pages */
.portal-page #content > .card, .portal-page #record > .card { margin-bottom: 20px; }
.section-title { margin: 0 0 14px; font-size: 1.15rem; }
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 20px; }
.tile { display: grid; gap: 4px; padding: 20px; }
.tile-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.tile-value { font-size: 1.7rem; line-height: 1.2; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll table { margin-top: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-bottom: 10px; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 10px 0; }
.big-number { font-size: 1.8rem; font-weight: 700; margin: 0 0 6px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.list-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.follow-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.follow-list li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }

.portal-page .field, .portal-page fieldset.field { display: grid; gap: 6px; }
.portal-page .field > label, .portal-page legend { font-weight: 600; font-size: .92rem; }
.portal-page .field small { color: var(--muted); font-weight: 400; }
.portal-page input[type=text], .portal-page input[type=email], .portal-page input[type=number], .portal-page input[type=date], .portal-page input[type=time], .portal-page input[type=search],
.portal-page select, .portal-page textarea {
  width: 100%; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; font: inherit; color-scheme: dark;
}
.portal-page textarea { resize: vertical; }
.portal-page input:focus, .portal-page select:focus, .portal-page textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 123, 255, .3); }
.portal-page .choice { display: flex; align-items: center; gap: 10px; font-weight: 400; cursor: pointer; }
.portal-page .choice input { width: 20px; height: 20px; flex: none; accent-color: var(--blue); }
.portal-page .choice input:focus-visible { outline: 3px solid var(--blue-2); outline-offset: 2px; }
.portal-page .form { margin-top: 0; }
.narrow-form { max-width: 360px; margin-bottom: 20px; }
.line-row { display: grid; gap: 12px; grid-template-columns: 1fr; padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; align-items: end; }
@media (min-width: 700px) { .line-row { grid-template-columns: 1fr 1fr; } }
.line-row .btn { justify-self: start; }
.preview { background: var(--bg-alt); border: 1px dashed var(--line); border-radius: 12px; padding: 14px 16px; }
.preview .total { padding-inline: 0; }
.project-row { display: grid; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.project-fields { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .project-fields { grid-template-columns: 2fr 1fr; } }
.project-row .btn { justify-self: start; }
.inline-form { display: grid; gap: 12px; margin-top: 18px; max-width: 420px; }
.inline-form .btn { justify-self: start; }
.print-only { display: none; }
.portal-page .card a:not(.btn):focus-visible { outline: 3px solid var(--blue-2); outline-offset: 3px; }

@media print {
  .print-only { display: block !important; color: #000 !important; }
  .print-only h2 { color: #000 !important; margin: 0 0 12px; }
  .print-only .prewrap { color: #000 !important; }
}
@media (max-width: 700px) { .portal-header { position: static; } }
@media (max-width: 560px) {
  .portal-header .portal-nav { gap: 0 14px; }
  .portal-header .portal-nav a:not(.btn) { padding: 4px 2px; font-size: .95rem; }
}

.preview-banner { background: #3a2a00; color: #ffd66b; border: 1px solid #6b4e00; border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; font-size: .92rem; }
.preview-banner a { color: #ffe6a0; }

/* Pricing estimator */
.est-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-bottom: 14px; }
.est-warns { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.est-warns li { border-radius: 10px; padding: 10px 14px; font-size: .92rem; }
.est-warn { background: rgba(255, 214, 107, .1); border: 1px solid #6b5416; color: #ffd66b; }
.est-info { background: rgba(74, 222, 128, .08); border: 1px solid #1f5a37; color: #86efac; }
.est-error { background: rgba(255, 59, 48, .1); border: 1px solid #6b1a16; color: #ff8a82; }
p.est-warn { border-radius: 10px; padding: 8px 12px; }
.tiles.stale { opacity: .45; }
.running-banner { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; background: rgba(47, 123, 255, .14); border: 1px solid var(--blue); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.running-banner a { color: var(--blue-2); }
#time-entries li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
#time-entries li small { flex-basis: 100%; }
#time-card input[type=date] { width: 100%; }
#time-summary th, #time-summary td { padding-left: 6px; padding-right: 6px; }
.est-figure { display: block; opacity: .7; white-space: nowrap; }
.tile.ok .tile-value { color: #4ade80; }
.tile.warn .tile-value { color: #ffd66b; }
.tile.bad .tile-value { color: #ff8a82; }
.portal-page td input { min-width: 0; }
.portal-page td.num input { text-align: right; max-width: 110px; }

/* Inquiries */
.duplicates { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }
.duplicates a { color: #ffd66b; font-size: .85rem; font-weight: 600; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
#filters .field { min-width: 200px; }
#record { display: grid; gap: 18px; }
.brief-heading { font-size: .85rem; color: var(--muted); margin: 14px 0 4px; }

/* Calendar */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 6px; }
.cal-views, .cal-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-views .btn[aria-pressed="false"] { background: transparent; box-shadow: none; border: 1.5px solid var(--line); color: var(--text); }
.cal-title { margin: 0; font-size: 1.15rem; flex: 1 1 200px; }
.cal-view { margin-top: 10px; }
.cal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cal-chip { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; width: 100%; text-align: left; font: inherit; font-size: .88rem; line-height: 1.35; color: var(--text); background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px; padding: 6px 9px; text-decoration: none; cursor: pointer; }
button.cal-chip:hover, a.cal-chip:hover { border-color: var(--blue-2); }
.cal-chip:focus-visible, .cal-num:focus-visible, .cal-day-link:focus-visible, .cal-more:focus-visible { outline: 3px solid var(--blue-2); outline-offset: 2px; }
.cal-time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.cal-name { font-weight: 600; overflow-wrap: anywhere; }
.cal-detail { flex-basis: 100%; color: var(--muted); }
.cal-consultation { border-left-color: #4ade80; }
.cal-meeting { border-left-color: var(--blue); }
.cal-task { border-left-color: #ffd66b; }
.cal-done { opacity: .6; }
.cal-cancelled { opacity: .5; text-decoration: line-through; }
.cal-auto { border-left-color: #a78bfa; border-style: dashed; border-left-style: solid; }
.cal-invoice_due { border-left-color: #ff8a82; }
.cal-block { cursor: default; border-left-color: #6b7690; background: repeating-linear-gradient(135deg, #12193a 0 6px, #0d1430 6px 12px); }
button.cal-block { cursor: pointer; }
.cal-more { background: none; border: 0; color: var(--blue-2); font: inherit; font-size: .8rem; cursor: pointer; padding: 2px 4px; }
.cal-day-head { margin: 14px 0 6px; font-size: 1rem; }
.cal-day-link, .cal-num { background: none; border: 0; padding: 0; font: inherit; color: inherit; font-weight: 700; cursor: pointer; text-align: left; }
.cal-today .cal-day-link, .cal-today > .cal-num { color: #4ade80; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-weekday { color: var(--muted); font-size: .8rem; text-align: center; padding: 4px 0; }
.cal-cell { min-height: 96px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.cal-cell.cal-out { opacity: .5; }
.cal-cell.cal-today { border-color: #4ade80; }
.cal-cell .cal-chip { padding: 3px 6px; font-size: .75rem; }
.cal-cell .cal-time { display: none; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-col { min-width: 0; }
.cal-sheet { margin-top: 18px; }
.cal-sheet-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.cal-sheet-head .section-title { margin-bottom: 8px; }
.cal-form { display: grid; gap: 14px; max-width: 520px; }
.cal-form .choice { display: flex; gap: 8px; align-items: center; }
.cal-client p { margin: 4px 0; }
.cal-brief { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.cal-brief dt { color: var(--muted); }
.cal-brief dd { margin: 0; overflow-wrap: anywhere; }
.cal-todos { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; }
@media (max-width: 760px) {
  .cal-week { grid-template-columns: 1fr; }
  .cal-cell { min-height: 64px; }
  .cal-cell .cal-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cal-cell .cal-chip { border-left-width: 3px; }
  .cal-sheet { position: sticky; bottom: 8px; max-height: 80vh; overflow: auto; box-shadow: 0 -10px 30px rgba(0, 0, 0, .5); }
}

/* ---- Light theme for portal and admin pages (palette variables live in /styles.css) ---- */
[data-theme="light"] .portal-page input[type=text], [data-theme="light"] .portal-page input[type=email], [data-theme="light"] .portal-page input[type=number],
[data-theme="light"] .portal-page input[type=date], [data-theme="light"] .portal-page input[type=time], [data-theme="light"] .portal-page input[type=search],
[data-theme="light"] .portal-page select, [data-theme="light"] .portal-page textarea { background: #fff; color-scheme: light; }
[data-theme="light"] .form input[type=password], [data-theme="light"] .form input[type=email], [data-theme="light"] .form input[type=text],
[data-theme="light"] .form input[type=search] { background: #fff; }
[data-theme="light"] .form input:focus, [data-theme="light"] .portal-page input:focus, [data-theme="light"] .portal-page select:focus,
[data-theme="light"] .portal-page textarea:focus { box-shadow: 0 0 0 3px rgba(29, 111, 214, .25); }
[data-theme="light"] .stages .done .dot { background: #15803d; border-color: #15803d; }
[data-theme="light"] .stages .now .dot { box-shadow: 0 0 0 4px rgba(29, 111, 214, .22); }
[data-theme="light"] .notice, [data-theme="light"] .est-warn { background: rgba(245, 179, 0, .14); border-color: #e3c36a; color: #7a5200; }
[data-theme="light"] .est-info { background: rgba(21, 128, 61, .09); border-color: #9bd3b0; color: #15693a; }
[data-theme="light"] .est-error { background: rgba(196, 40, 29, .08); border-color: #eab0aa; color: #a82217; }
[data-theme="light"] .pill.paid { background: rgba(21, 128, 61, .12); color: #15803d; }
[data-theme="light"] .pill.due { background: rgba(245, 179, 0, .2); color: #7a5200; }
[data-theme="light"] .pill.overdue { background: rgba(196, 40, 29, .12); color: #b02418; }
[data-theme="light"] .pill.draft { background: rgba(93, 107, 125, .15); }
[data-theme="light"] .pill.revised { background: rgba(29, 111, 214, .13); color: #1659b8; }
[data-theme="light"] .preview-banner { background: #fff3cf; color: #6b4e00; border-color: #e3c36a; }
[data-theme="light"] .preview-banner a { color: #7a3d00; }
[data-theme="light"] .running-banner { background: rgba(29, 111, 214, .1); }
[data-theme="light"] .tile.ok .tile-value { color: #15803d; }
[data-theme="light"] .tile.warn .tile-value { color: #8a5a00; }
[data-theme="light"] .tile.bad .tile-value { color: #b02418; }
[data-theme="light"] .duplicates a { color: #8a5a00; }
/* calendar */
[data-theme="light"] .cal-consultation { border-left-color: #15803d; }
[data-theme="light"] .cal-task { border-left-color: #e0a100; }
[data-theme="light"] .cal-auto { border-left-color: #7c5ce0; }
[data-theme="light"] .cal-invoice_due { border-left-color: #c4281d; }
[data-theme="light"] .cal-block { border-left-color: #8a96ab; background: repeating-linear-gradient(135deg, #ebe6da 0 6px, #f4f0e6 6px 12px); }
[data-theme="light"] .cal-today .cal-day-link, [data-theme="light"] .cal-today > .cal-num { color: #15803d; }
[data-theme="light"] .cal-cell.cal-today { border-color: #15803d; }
[data-theme="light"] .cal-sheet { box-shadow: 0 -10px 30px rgba(60, 50, 20, .18); }
[data-theme="light"] .card, [data-theme="light"] .cal-chip { box-shadow: 0 1px 8px rgba(60, 50, 20, .06); }
[data-theme="light"] .portal-page input[type=text], [data-theme="light"] .portal-page input[type=email], [data-theme="light"] .portal-page input[type=number],
[data-theme="light"] .portal-page input[type=date], [data-theme="light"] .portal-page input[type=time], [data-theme="light"] .portal-page input[type=search],
[data-theme="light"] .portal-page select, [data-theme="light"] .portal-page textarea,
[data-theme="light"] .form input[type=password], [data-theme="light"] .form input[type=email], [data-theme="light"] .form input[type=text] { border-color: #c9c0aa; }
