.customer-portal .layout-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: var(--md-spacing-5);
    align-items: start;
}

.customer-portal .content-area {
    display: grid;
    gap: 1.25rem;
}

.portal-sidebar {
    position: sticky;
    border-radius: 18px;
    background: linear-gradient(180deg, #fff, rgba(79, 70, 229, 0.06));
    border: 1px solid rgba(79, 70, 229, 0.12);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.portal-sidebar-header {
    margin-bottom: 1rem;
}

.portal-nav {
    display: grid;
    gap: 0.35rem;
}

.portal-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    font-weight: 600;
    color: #1f2937;
}

.portal-nav .nav-count {
    min-width: 2.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.12);
    color: var(--md-primary);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.portal-nav a.active {
    background: var(--blue-light);
    color: var(--md-primary);
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.25);
}

.eyebrow {
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    color: var(--text-soft, #64748b);
}

.lead {
    margin: 0.35rem 0 0;
    color: var(--text-soft, #64748b);
}

.portal-card {
    background: var(--md-surface);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: var(--md-shadow-1);
    display: grid;
    gap: 1rem;
}

.portal-messages {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.portal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.portal-section-card h1 {
    margin: 0;
}

.portal-empty-state {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 14px;
    border: 1px dashed rgba(148, 163, 184, 0.6);
    background: rgba(148, 163, 184, 0.08);
}

.portal-empty-state h3 {
    margin: 0 0 0.35rem;
}

.portal-search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.portal-search-form input {
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.6);
}

.portal-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
}

.portal-table th {
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
}

.portal-table td,
.portal-table th {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.portal-table tr.note-awaiting-response {
    background: #fff9e6;
}

.portal-cell-main {
    display: grid;
    gap: 0.2rem;
}

.portal-cell-main .subdued {
    color: var(--text-soft, #64748b);
    font-size: 0.9rem;
}

.portal-cell-main .mono {
    font-family: "Roboto Mono", monospace;
    letter-spacing: 0.04em;
}

.portal-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.portal-grid > div {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 14px;
    padding: 1rem;
}

.overview-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
    margin: 0;
}

.overview-list dt {
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.overview-notes {
    grid-column: 1 / -1;
}

.simple-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.75rem;
}

.simple-list li {
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(255, 255, 255, 0.8);
}

.simple-list.compact li {
    padding: 0.6rem;
}

.simple-list .item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.simple-list .meta {
    font-size: 0.85rem;
    color: var(--text-soft);
}

.portal-split {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.portal-split > div {
    background: rgba(148, 163, 184, 0.1);
    border-radius: 14px;
    padding: 1rem;
}

.portal-flex {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.portal-column {
    display: grid;
    gap: 1rem;
}

.portal-card-section {
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 14px;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
}

.portal-collapsible {
    padding: 0;
}

.portal-collapsible > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    cursor: pointer;
    list-style: none;
}

.portal-collapsible > summary::-webkit-details-marker {
    display: none;
}

.portal-collapsible[open] > summary {
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.portal-collapsible .portal-collapse-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.portal-collapsible .portal-card-body {
    padding: 0 1rem 1rem;
}

.portal-collapsible .chevron {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(79, 70, 229, 0.1);
    transition: transform 0.2s ease;
    position: relative;
}

.portal-collapsible .chevron::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--md-primary);
    border-bottom: 2px solid var(--md-primary);
    transform: rotate(45deg);
    display: block;
    margin-top: -2px;
}

.portal-collapsible[open] .chevron {
    transform: rotate(180deg);
}

.document-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.75rem;
}

.document-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stacked-form {
    display: grid;
    gap: 0.5rem;
}

.stacked-form input,
.stacked-form select,
.stacked-form textarea {
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 0.5rem 0.75rem;
}

.stacked-form button {
    margin-top: 0.5rem;
}

.customer-notes {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.75rem;
}

.customer-notes li {
    border-radius: 14px;
    padding: 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(148, 163, 184, 0.08);
}

.customer-notes li.is-open {
    border-color: rgba(217, 3, 104, 0.4);
    background: var(--pink-light);
}

.customer-notes .note-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-soft);
}

.portal-note-replies {
    list-style: none;
    margin: 0.5rem 0 0;
    padding-left: 0.75rem;
    display: grid;
    gap: 0.5rem;
}

.portal-note-replies li {
    border-left: 3px solid rgba(148, 163, 184, 0.6);
    padding-left: 0.75rem;
}

.note-response-form {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.35rem;
}

.note-response-form textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 0.5rem 0.75rem;
}

.portal-login h1 {
    margin: 0;
}

.customer-portal-login .layout-shell {
    grid-template-columns: minmax(0, 1fr);
}

.customer-portal-login .content-area {
    min-height: calc(100vh - 240px);
    align-content: center;
    justify-items: center;
}

.customer-portal-login .portal-login {
    width: min(100%, 520px);
    margin: 0 auto;
}

.portal-login form {
    display: grid;
    gap: 0.5rem;
}

.portal-login input {
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(148, 163, 184, 0.6);
}

.portal-login .portal-help {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.portal-login .portal-help a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 600;
}

.portal-login .portal-help a:hover {
    text-decoration: underline;
}

.form-errors {
    background: var(--pink-light);
    border-radius: 10px;
    padding: 0.5rem;
    font-size: 0.85rem;
}

.portal-detail-header .detail-meta {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.inline-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.inline-form input[type="text"] {
    max-width: 140px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 0.35rem 0.5rem;
}

.portal-filters {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    overflow: hidden;
}

.portal-filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
    align-items: end;
}

.portal-filter-row label {
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.portal-filter-row input,
.portal-filter-row select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 0.5rem 0.65rem;
}

.portal-filter-row select[multiple] {
    min-height: 9rem;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.4rem;
}

.checkbox-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    cursor: pointer;
}

.date-range {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.4rem;
}

.portal-filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-start;
}

.portal-filter-actions .btn-link {
    min-width: 9.5rem;
    text-align: center;
}

.portal-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.portal-report-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.portal-report-form {
    display: grid;
    gap: 0.75rem;
}

.portal-report-grid-fields {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.portal-report-grid-fields .full {
    grid-column: 1 / -1;
}

.portal-report-list {
    display: grid;
    gap: 0.75rem;
}

.portal-report-card {
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    padding: 0.9rem;
    background: rgba(255, 255, 255, 0.9);
    display: grid;
    gap: 0.5rem;
}

.portal-report-card.is-paused {
    opacity: 0.7;
}

.portal-report-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.portal-report-meta {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-soft);
}

.portal-report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.portal-report-actions form {
    margin: 0;
}

.portal-report-edit summary {
    cursor: pointer;
}

.portal-filters > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    cursor: pointer;
    background: rgba(148, 163, 184, 0.1);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.portal-filters > summary::-webkit-details-marker {
    display: none;
}

.portal-filters .chevron {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(79, 70, 229, 0.1);
    transition: transform 0.2s ease;
    position: relative;
}

.portal-filters .chevron::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--md-primary);
    border-bottom: 2px solid var(--md-primary);
    transform: rotate(45deg);
    display: block;
    margin-top: -2px;
}

.portal-filters[open] .chevron {
    transform: rotate(180deg);
}

.portal-filters form {
    padding: 0 1rem 1rem;
}

.timeline-collapsible {
    padding: 0;
    overflow: hidden;
}

.timeline-collapsible > summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    list-style: none;
}

.timeline-collapsible[open] > summary {
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.timeline-collapsible > summary::-webkit-details-marker {
    display: none;
}

.timeline-collapsible .chevron {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(79, 70, 229, 0.1);
    position: relative;
    transition: transform 0.2s ease;
}

.timeline-collapsible .chevron::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--md-primary);
    border-bottom: 2px solid var(--md-primary);
    transform: rotate(45deg);
    display: block;
    margin-top: -2px;
}

.timeline-collapsible[open] .chevron {
    transform: rotate(180deg);
}

.timeline-collapsible .lead {
    margin: 0.1rem 0 0;
}

.timeline-collapsible .portal-timeline {
    padding: 1.1rem 1.5rem 1.25rem 1.85rem;
}

.portal-timeline {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0 0.5rem;
    position: relative;
}

.portal-timeline::before {
    content: "";
    position: absolute;
    inset-block: 0.4rem 0.4rem;
    left: 7px;
    width: 2px;
    background: rgba(148, 163, 184, 0.35);
}

.timeline-event {
    position: relative;
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 0.75rem;
    align-items: flex-start;
}

.timeline-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--md-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.18);
    position: relative;
    z-index: 1;
}

.timeline-content {
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    background: rgba(148, 163, 184, 0.08);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.timeline-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
}

.timeline-label {
    font-weight: 700;
    letter-spacing: 0.01em;
}

.timeline-time {
    color: var(--text-soft, #64748b);
    font-size: 0.9rem;
}

.timeline-meta {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.timeline-description {
    margin: 0.35rem 0 0;
    color: var(--text-soft, #64748b);
}

.timeline-event.timeline-hold .timeline-marker {
    background: var(--pink);
    box-shadow: 0 0 0 4px rgba(217, 3, 104, 0.22);
}

.timeline-event.timeline-hold-cleared .timeline-marker {
    background: var(--md-secondary);
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.2);
}

.timeline-event.timeline-task .timeline-marker {
    background: var(--orange);
    box-shadow: 0 0 0 4px rgba(247, 92, 3, 0.2);
}

.timeline-empty {
    padding-left: 1.5rem;
    color: var(--text-soft, #64748b);
}
