/* ═══════════════════════════════════════════════════════════════
   Carnmore AI — Client Portal Styles
   Light theme, clean, professional, spacious
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #f0f4f8;
    --bg-card: #ffffff;
    --bg-nav: #ffffff;
    --border: #e2e8f0;
    --text-primary: #1a1e2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent: #0679a6;
    --accent-hover: #056d95;
    --accent-light: rgba(6, 121, 166, 0.08);
    --gold: #d4a853;
    --gold-bg: rgba(212, 168, 83, 0.1);
    --green: #059669;
    --green-bg: rgba(5, 150, 105, 0.1);
    --red: #dc2626;
    --red-bg: rgba(220, 38, 38, 0.08);
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --nav-height: 60px;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    /* Round-2 typography uplift: explicit 16px base + 1.55 line-height
       so hardcoded px sizes downstream scale predictably and execs
       don't have to squint. */
    font-size: 16px;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}


/* ── Auth Screens ──────────────────────────────────────────── */

.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 24px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.auth-logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 28px;
}

.auth-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: var(--accent);
    text-decoration: none;
    font-size: 15px;
}

.auth-link:hover {
    color: var(--accent-hover);
}


/* ── Forms ─────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-card);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6, 121, 166, 0.12);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--text-muted);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 15px;
}


/* ── Portal Shell + Top Navigation ─────────────────────────── */

/* Round-2 5c fix: templates/client/shell.html uses #portal-header,
   .portal-brand, .portal-logo, #portal-nav, .nav-item, .portal-user.
   None of those had CSS rules — only the legacy #topnav block did —
   so the header rendered as plain stacked text. Real rules below. */

#portal-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#portal-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 0 24px;
    height: var(--nav-height);
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.portal-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #1a2d4a);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.portal-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.portal-brand-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.portal-brand-tagline {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--text-muted);
    font-weight: 600;
}

#portal-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

#portal-nav .nav-item {
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}

#portal-nav .nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

#portal-nav .nav-item.active {
    color: var(--accent);
    background: var(--accent-light);
}

.portal-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.portal-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.portal-user .btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.15s;
}

.portal-user .btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background: var(--bg-primary);
}

#portal-main {
    flex: 1;
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}


/* ── Legacy Top Navigation (unused — superseded by #portal-header) ─ */
/* Retained for now in case any other view targets these classes; safe
   to delete once a grep confirms no remaining references. */

#topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-height);
    padding: 0 24px;
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-brand {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.nav-link.active {
    color: var(--accent);
    background: var(--accent-light);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.nav-bell {
    position: relative;
    background: none;
    border: none;
    padding: 8px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}

.nav-bell:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.bell-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--red);
    color: white;
    font-size: 12px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.nav-profile {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.nav-profile:hover {
    background: var(--accent-hover);
}


/* ── Notification Dropdown ─────────────────────────────────── */

.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 200;
}

.notification-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}

.notification-item:hover {
    background: var(--bg-primary);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background: var(--accent-light);
}

.notification-message {
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.notification-time {
    font-size: 12px;
    color: var(--text-muted);
}

.notification-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 15px;
}


/* ── Main Content ──────────────────────────────────────────── */

#main-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 15px;
}


/* ── Cards ─────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.card-muted {
    font-size: 15px;
    color: var(--text-muted);
}


/* ── Phase Progress Bar ────────────────────────────────────── */

.phase-progress {
    margin-bottom: 32px;
}

.phase-bar {
    display: flex;
    gap: 3px;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--border);
}

.phase-segment {
    flex: 1;
    border-radius: 4px;
    background: var(--border);
    transition: background 0.3s;
}

.phase-segment.completed {
    background: var(--accent);
}

.phase-segment.in-progress {
    background: var(--accent);
    animation: phasePulse 2s ease-in-out infinite;
}

@keyframes phasePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.phase-labels {
    display: flex;
    gap: 3px;
    margin-top: 10px;
}

.phase-label {
    flex: 1;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.phase-label.completed {
    color: var(--accent);
    font-weight: 600;
}

.phase-label.in-progress {
    color: var(--accent);
    font-weight: 600;
}


/* ── Stat Cards Row ────────────────────────────────────────── */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 15px;
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-card.action-needed {
    border-left: 4px solid var(--gold);
    background: var(--gold-bg);
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.stat-card.action-needed:hover {
    box-shadow: var(--shadow-md);
}

.stat-card.action-needed .stat-value {
    color: var(--gold);
}


/* ── Action Needed Badge ───────────────────────────────────── */

.badge-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--gold-bg);
    color: var(--gold);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-new {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}


/* ── Status Pills ──────────────────────────────────────────── */

.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-pill.pending { background: var(--gold-bg); color: var(--gold); }
.status-pill.in-progress { background: var(--accent-light); color: var(--accent); }
.status-pill.completed { background: var(--green-bg); color: var(--green); }
.status-pill.needs-input { background: var(--gold-bg); color: var(--gold); }
.status-pill.not-started { background: #f1f5f9; color: var(--text-muted); }
.status-pill.blocked { background: var(--red-bg); color: var(--red); }

.priority-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-pill.high { background: var(--red-bg); color: var(--red); }
.priority-pill.medium { background: var(--gold-bg); color: var(--gold); }
.priority-pill.low { background: #f1f5f9; color: var(--text-muted); }


/* ── Task List ─────────────────────────────────────────────── */

.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.task-item:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e0;
}

.task-item.needs-input {
    border-left: 4px solid var(--gold);
    background: var(--gold-bg);
}

.task-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.task-check.completed {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.task-check.completed::after {
    content: '\2713';
    font-size: 15px;
    font-weight: 700;
}

.task-body {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.task-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}


/* ── Accordion (Phase Groups) ──────────────────────────────── */

.accordion-group {
    margin-bottom: 24px;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.accordion-header:hover {
    background: var(--bg-primary);
}

.accordion-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.accordion-chevron {
    color: var(--text-muted);
    transition: transform 0.2s;
    font-size: 18px;
}

.accordion-group.open .accordion-chevron {
    transform: rotate(180deg);
}

.accordion-body {
    display: none;
    padding: 8px 0 0 0;
}

.accordion-group.open .accordion-body {
    display: block;
}


/* ── Task Detail ───────────────────────────────────────────── */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 20px;
    transition: color 0.15s;
}

.back-link:hover {
    color: var(--accent);
}

.task-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.task-detail-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.task-detail-description {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 24px;
}

.detail-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.detail-meta-item label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: block;
    margin-bottom: 4px;
}

.detail-meta-item span {
    font-size: 15px;
    color: var(--text-primary);
}


/* ── Action Request Card ───────────────────────────────────── */

.action-request-card {
    background: var(--gold-bg);
    border: 1px solid var(--gold);
    border-left: 4px solid var(--gold);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.action-request-card .ar-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: rgba(212, 168, 83, 0.2);
    color: #9a7d3a;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.action-request-card .ar-prompt {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.6;
}

.action-request-card .ar-responded {
    padding: 12px 16px;
    background: var(--green-bg);
    border-radius: var(--radius);
    color: var(--green);
    font-size: 15px;
    font-weight: 500;
}


/* ── Notes Thread ──────────────────────────────────────────── */

.notes-section {
    margin-top: 28px;
}

.notes-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.note-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.note-item:last-child {
    border-bottom: none;
}

.note-author {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.note-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
}

.note-content {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.6;
}

.note-form {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.note-form textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: var(--font-body);
    color: var(--text-primary);
    resize: vertical;
    min-height: 60px;
}

.note-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6, 121, 166, 0.12);
}


/* ── Document List ─────────────────────────────────────────── */

.doc-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: box-shadow 0.15s;
}

.doc-item:hover {
    box-shadow: var(--shadow-md);
}

.doc-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.doc-icon svg {
    width: 20px;
    height: 20px;
}

.doc-body {
    flex: 1;
    min-width: 0;
}

.doc-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.doc-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.doc-download {
    padding: 8px 16px;
    background: var(--accent-light);
    color: var(--accent);
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

.doc-download:hover {
    background: rgba(6, 121, 166, 0.15);
}


/* ── Profile Section ───────────────────────────────────────── */

.profile-section {
    max-width: 480px;
}

.profile-section .card + .card {
    margin-top: 20px;
}


/* ── Toast ─────────────────────────────────────────────────── */

#toast-container {
    position: fixed;
    top: 76px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s, transform 0.3s;
    max-width: 360px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid var(--green);
}

.toast-error {
    border-left: 4px solid var(--red);
}

.toast-info {
    border-left: 4px solid var(--accent);
}


/* ── Empty State ───────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 15px;
}


/* ── Section Divider ───────────────────────────────────────── */

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
    margin-top: 28px;
}

.section-title:first-child {
    margin-top: 0;
}


/* ── Intake Form ──────────────────────────────────────────── */

.intake-form {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 0 40px;
}

.intake-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 16px;
}

.intake-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.intake-progress {
    display: flex;
    gap: 8px;
    margin-bottom: 28px;
}

.intake-progress-segment {
    flex: 1;
    text-align: center;
}

.intake-progress-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    margin-bottom: 6px;
    transition: background 0.3s;
}

.intake-progress-segment.filled .intake-progress-bar {
    background: var(--accent);
}

.intake-progress-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.intake-progress-segment.filled .intake-progress-label {
    color: var(--accent);
    font-weight: 600;
}

.intake-form .form-group {
    margin-bottom: 16px;
}

.intake-form .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.checkbox-group label {
    text-transform: none !important;
    font-weight: 400 !important;
    font-size: 14px !important;
    letter-spacing: 0 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-group label {
    text-transform: none !important;
    font-weight: 400 !important;
    font-size: 14px !important;
    letter-spacing: 0 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
}

.referral-toggle {
    display: inline-block;
    font-size: 15px;
    color: var(--accent);
    cursor: pointer;
    margin-top: 4px;
    transition: color 0.15s;
}

.referral-toggle:hover {
    color: var(--accent-hover);
}

.referral-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.copilot-hint {
    background: var(--accent-light);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 4px;
    border-left: 3px solid var(--accent);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.copilot-hint span {
    flex: 1;
    line-height: 1.5;
}

.copilot-hint-dismiss {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    flex-shrink: 0;
    line-height: 1;
}

.copilot-hint-dismiss:hover {
    color: var(--text-primary);
}

.stakeholder-entry {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 8px;
    position: relative;
}

.stakeholder-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.stakeholder-remove:hover {
    color: var(--red);
}

.stakeholder-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.intake-submitted {
    text-align: center;
    padding: 60px 24px;
}

.intake-submitted-icon {
    margin-bottom: 20px;
}

.intake-submitted h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.intake-submitted p {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.6;
}

.btn-submit {
    display: block;
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}

.btn-submit:hover {
    background: var(--accent-hover);
}

/* Intake confirmation modal */
.intake-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.intake-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px;
    max-width: 440px;
    width: 90%;
}

.intake-modal h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.intake-modal p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.intake-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}


/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 640px) {
    .auth-card {
        padding: 32px 24px;
    }

    #topnav {
        padding: 0 16px;
    }

    .nav-brand {
        display: none;
    }

    .nav-center {
        gap: 0;
    }

    .nav-link {
        padding: 8px 10px;
        font-size: 15px;
    }

    #main-content {
        padding: 20px 16px;
    }

    .stat-row {
        grid-template-columns: 1fr 1fr;
    }

    .detail-meta-grid {
        grid-template-columns: 1fr 1fr;
    }

    .notification-dropdown {
        width: calc(100vw - 32px);
        right: -8px;
    }

    .checkbox-group {
        grid-template-columns: 1fr;
    }

    .referral-fields {
        grid-template-columns: 1fr;
    }

    .stakeholder-fields {
        grid-template-columns: 1fr;
    }

    .intake-progress-label {
        font-size: 9px;
    }
}

/* Flash region — HTMX error surfacing */
#flash {
    position: fixed;
    top: 16px;
    right: 16px;
    left: auto;
    max-width: 420px;
    z-index: 10000;
    pointer-events: none;
}
#flash .flash {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    background: #ffffff;
    border: 1px solid #d6dbe3;
    color: #1a1e2e;
    margin-bottom: 8px;
}
#flash .flash-error {
    background: #fff5f5;
    border-color: #f5b5b5;
    color: #7a1f1f;
}
#flash .flash-text { flex: 1; }
#flash .flash-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}


/* ═════════════════════════════════════════════════════════════════
   Client Portal — Section Containers, Auto-Form Styling, Missing
   Component Classes. Backstops the partial templates.
   ═════════════════════════════════════════════════════════════════ */

/* Section container — every client partial wraps content in this */
.client-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px 32px;
    margin-bottom: 20px;
}

.client-section h1 { font-size: 22px; margin-bottom: 4px; color: var(--text-primary); }
.client-section h2 {
    font-size: 16px;
    margin-top: 28px;
    margin-bottom: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-primary);
}

.client-section h2:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* Section header — h1 + actions on the right */
.client-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.client-section .section-header h1 { margin: 0; }

/* Detail-grid (key/value) */
.client-section dl.detail-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 24px;
    margin-bottom: 20px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
}

.client-section dl.detail-grid dt {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    align-self: center;
}

.client-section dl.detail-grid dd {
    color: var(--text-primary);
    font-size: 15px;
    align-self: center;
}

/* Tables */
.client-section .data-table,
.client-section table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    margin-bottom: 8px;
}

.client-section .data-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    white-space: nowrap;
}

.client-section .data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

.client-section .data-table tbody td:last-child { text-align: right; white-space: nowrap; }
.client-section .data-table tbody td:last-child > * + * { margin-left: 6px; }

/* Muted helper */
.client-section .muted, .client-section td.muted, .client-section li.muted, .client-section span.muted {
    color: var(--text-muted) !important;
    font-style: italic;
    font-size: 15px;
}

/* Alerts and form errors */
.client-section .alert,
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin: 12px 0;
    font-size: 15px;
    border: 1px solid;
}

.alert-success {
    background: var(--green-bg);
    border-color: rgba(5, 150, 105, 0.3);
    color: var(--green);
}

.alert-error,
.form-error {
    background: var(--red-bg);
    border-color: rgba(220, 38, 38, 0.3);
    color: var(--red);
    padding: 10px 14px;
    border-radius: 6px;
    margin: 12px 0;
    font-size: 15px;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

/* Form layout — auto-style label-wrapper pattern */
.client-section form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 520px;
    margin-bottom: 8px;
}

.client-section form > label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

/* Style every editable field inside client sections */
.client-section input[type="text"],
.client-section input[type="email"],
.client-section input[type="password"],
.client-section input[type="number"],
.client-section input[type="search"],
.client-section input[type="url"],
.client-section input[type="date"],
.client-section input[type="file"],
.client-section input:not([type]),
.client-section select,
.client-section textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-card);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    font-weight: 400;
}

.client-section input:focus,
.client-section select:focus,
.client-section textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6, 121, 166, 0.12);
}

.client-section input::placeholder,
.client-section textarea::placeholder { color: var(--text-muted); }

.client-section select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23718096' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    min-height: 38px;
}

.client-section textarea {
    resize: vertical;
    min-height: 90px;
}

/* Bare buttons inside client sections — default secondary look */
.client-section button:not(.btn-primary):not(.btn-danger):not(.btn-icon):not(.btn-link) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    font-family: var(--font-body);
}

.client-section button:not(.btn-primary):not(.btn-danger):not(.btn-icon):not(.btn-link):hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* Form actions row */
.form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

/* btn-link */
.btn-link {
    display: inline-block;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: all 150ms ease;
}

.btn-link:hover {
    background: var(--bg-primary);
    color: var(--accent-hover);
    border-color: var(--accent);
}

/* List variants */
.client-section ul.engagement-list,
.client-section ul.user-list,
.client-section ul.note-list,
.client-section ul.ar-list,
.client-section ul.notification-list {
    list-style: none;
    padding: 0;
    margin: 0 0 14px 0;
}

.client-section ul.engagement-list > li,
.client-section ul.user-list > li,
.client-section ul.note-list > li,
.client-section ul.ar-list > li,
.client-section ul.notification-list > li {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 15px;
}

.client-section ul.engagement-list > li:last-child,
.client-section ul.user-list > li:last-child,
.client-section ul.note-list > li:last-child,
.client-section ul.ar-list > li:last-child,
.client-section ul.notification-list > li:last-child {
    border-bottom: none;
}

.client-section ul.note-list > li > p {
    margin-top: 4px;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

/* B3: visual distinction between read and unread notifications. The
   template already emits .read / .unread on each <li>; without these rules
   the row's appearance never changes after the user clicks "Mark read". */
.client-section ul.notification-list > li.unread {
    border-left: 3px solid var(--brand-primary, #0679a6);
    padding-left: 9px;
    background: rgba(6, 121, 166, 0.04);
}

.client-section ul.notification-list > li.read {
    opacity: 0.6;
    color: var(--text-muted);
}

.client-section ul.notification-list > li.read .notification-message {
    color: var(--text-muted);
}

/* Pager */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 15px;
    color: var(--text-muted);
}


/* ── Password field with show/hide toggle (5b) ─────────────── */

.password-field {
    position: relative;
    display: block;
}

.password-field input {
    width: 100%;
    /* !important so inline style="padding:0.5rem" on the auth screens
       (login.html, accept_invite.html, reset_password.html) doesn't
       crowd the toggle button. CSS-class specificity loses to inline
       declarations, so this is the cleanest way to keep those forms
       working without ripping out the inline styles. */
    padding-right: 70px !important;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.15s;
}

.password-toggle:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.confirm-error {
    display: block;
    margin-top: 6px;
    color: var(--red);
    font-size: 14px;
    min-height: 1.2em;
}

/* Flowchart (mermaid) — client (light) */
.flowchart-section .flowchart-canvas {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    margin-top: 16px;
}
.flowchart-section .flowchart-canvas pre.mermaid {
    margin: 0;
    background: transparent;
}
.flowchart-section .flowchart-hint {
    margin-top: 10px;
    font-size: 13px;
}
.flowchart-section .empty-state {
    padding: 24px;
    text-align: center;
}
