/**
 * Reversal3 logged-in portal shell
 */
.portal-body {
    margin: 0;
    background: var(--rvl-bg-elevated);
    min-height: 100vh;
}

.portal-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.portal-sidebar {
    background: var(--rvl-bg-card);
    border-right: 1px solid var(--rvl-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.portal-sidebar-brand .portal-logo {
    max-height: 36px;
    width: auto;
}

.portal-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 1.5rem;
    flex: 1;
}

.portal-nav-link {
    display: block;
    padding: 0.65rem 0.85rem;
    border-radius: var(--rvl-radius);
    color: var(--rvl-text-muted);
    text-decoration: none;
    font-weight: var(--rvl-weight-medium);
    font-size: 0.9375rem;
}

.portal-nav-link:hover,
.portal-nav-link.is-active {
    background: var(--rvl-blue-soft);
    color: var(--rvl-blue-dark);
}

.portal-nav-muted {
    color: var(--rvl-text-subtle);
}

.portal-sidebar-foot {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--rvl-border);
}

.portal-main-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.portal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background: var(--rvl-bg-card);
    border-bottom: 1px solid var(--rvl-border);
    min-height: var(--rvl-header-height);
}

.portal-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--rvl-border);
    border-radius: var(--rvl-radius);
    background: var(--rvl-bg-card);
    cursor: pointer;
}

.portal-menu-btn span {
    display: block;
    height: 2px;
    width: 18px;
    background: var(--rvl-text);
    margin: 0 auto;
}

.portal-page-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: var(--rvl-weight-semibold);
    flex: 1;
}

.portal-user-chip {
    font-size: 0.875rem;
    color: var(--rvl-text-muted);
    background: var(--rvl-bg-elevated);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--rvl-border);
}

.portal-content {
    padding: 1.25rem;
    flex: 1;
}

.portal-footer {
    padding: 1rem 1.25rem;
    font-size: 0.8125rem;
    color: var(--rvl-text-subtle);
    border-top: 1px solid var(--rvl-border);
    background: var(--rvl-bg-card);
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.portal-card {
    background: var(--rvl-bg-card);
    border: 1px solid var(--rvl-border);
    border-radius: var(--rvl-radius-lg);
    padding: 1.25rem;
    box-shadow: var(--rvl-shadow-sm);
}

.portal-card h2,
.portal-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.portal-card p {
    margin: 0;
    color: var(--rvl-text-muted);
    font-size: 0.9375rem;
}

.portal-stat {
    font-size: 1.75rem;
    font-weight: var(--rvl-weight-bold);
    color: var(--rvl-text);
    line-height: 1.2;
}

.portal-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: var(--rvl-weight-semibold);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
}

.portal-badge--ok {
    background: var(--rvl-success-bg);
    color: var(--rvl-success);
    border: 1px solid var(--rvl-success-border);
}

.portal-badge--pending {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.portal-badge--danger {
    background: var(--rvl-danger-bg);
    color: var(--rvl-danger);
    border: 1px solid var(--rvl-danger-border);
}

.portal-table-wrap {
    overflow-x: auto;
    margin-top: 1rem;
}

.portal-checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.portal-checklist li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--rvl-border-subtle);
}

.portal-checklist li:last-child {
    border-bottom: none;
}

.portal-check-icon {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 2px solid var(--rvl-border-strong);
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.portal-check-icon.done {
    background: var(--rvl-success);
    border-color: var(--rvl-success);
}

.portal-form-page {
    max-width: 520px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.portal-form-card {
    background: var(--rvl-bg-card);
    border: 1px solid var(--rvl-border);
    border-radius: var(--rvl-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--rvl-shadow-sm);
}

.portal-form-card h1 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

.portal-form-card label {
    display: block;
    font-size: 0.875rem;
    font-weight: var(--rvl-weight-medium);
    margin: 1rem 0 0.35rem;
    color: var(--rvl-text);
}

.portal-form-card input,
.portal-form-card select,
.portal-form-card textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--rvl-border);
    border-radius: var(--rvl-radius);
    font: inherit;
    background: var(--rvl-input-bg);
    color: var(--rvl-text);
}

.portal-form-card textarea {
    min-height: 100px;
    resize: vertical;
}

.portal-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--rvl-radius);
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

.portal-alert--error {
    background: var(--rvl-danger-bg);
    color: var(--rvl-danger);
    border: 1px solid var(--rvl-danger-border);
}

.portal-alert--success {
    background: var(--rvl-success-bg);
    color: var(--rvl-success);
    border: 1px solid var(--rvl-success-border);
}

.contract-doc {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--rvl-text-muted);
}

.contract-doc h2 {
    color: var(--rvl-text);
    margin-top: 0;
}

.contract-doc h3 {
    color: var(--rvl-text);
    font-size: 1rem;
    margin: 1.25rem 0 0.5rem;
}

.contract-meta {
    color: var(--rvl-text-subtle);
    font-size: 0.875rem;
}

.signature-pad-wrap {
    border: 1px dashed var(--rvl-border-strong);
    border-radius: var(--rvl-radius);
    background: var(--rvl-bg-elevated);
    margin: 1rem 0;
}

#signatureCanvas {
    display: block;
    width: 100%;
    height: 160px;
    touch-action: none;
    cursor: crosshair;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 767px) {
    .portal-shell {
        grid-template-columns: 1fr;
    }

    .portal-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--rvl-shadow);
    }

    .portal-shell.sidebar-open .portal-sidebar {
        transform: translateX(0);
    }

    .portal-menu-btn {
        display: flex;
    }

    .portal-user-chip {
        display: none;
    }
}
