.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-section a {
    display: flex;
    align-items: center;
}

.logo {
    height: 32px;
    width: auto;
}

.logo-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.logo-subtitle {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.auth-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Spinner */
.spinner {
    border: 3px solid transparent;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    border-width: 3px;
    border-color: var(--border-color);
    border-top-color: var(--transcend-blue);
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Auth States */
#loadingState,
#authRequired,
#accessDenied {
    text-align: center;
    padding: 80px 20px;
}

#appContent.hidden {
    display: none !important;
}

/* Back Link */
.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
}

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

.resource-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.resource-actions .btn {
    text-decoration: none;
    white-space: nowrap;
}

.resource-actions .copy-md-btn {
    position: static;
    top: auto;
    right: auto;
    z-index: auto;
    box-shadow: none;
}

/* ==================== PIPELINE TEMPLATE STYLES ==================== */
.templates-wrapper {
    max-width: 960px;
    margin: 0 auto;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.6;
    color: #1a1a1a;
}

.templates-wrapper .tpl-header {
    border-bottom: 3px solid #1E3A8A;
    padding-bottom: 16px;
    margin-bottom: 24px;
}
.templates-wrapper .tpl-header h1,
.templates-wrapper .tpl-header .tpl-title {
    font-size: 22px;
    color: #1E3A8A;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
    font-weight: 700;
}
.templates-wrapper .tpl-header .meta {
    font-size: 11px;
    color: #4b5563;
}
.templates-wrapper .tpl-header .meta a { color: #2c5aa0; text-decoration: none; }

/* Decision Tree */
.templates-wrapper .decision-tree {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 24px;
    font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
    font-size: 11.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    color: #1a1a1a;
}
.templates-wrapper .decision-tree h2 {
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #1E3A8A;
    margin-bottom: 12px;
    letter-spacing: -0.2px;
}
.templates-wrapper .decision-tree-title {
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #1E3A8A;
    margin-bottom: 12px;
    letter-spacing: -0.2px;
    font-weight: 700;
}

/* Compliance table */
.templates-wrapper .compliance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 24px;
}
.templates-wrapper .compliance-table th {
    background: #1E3A8A;
    color: #fff;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
}
.templates-wrapper .compliance-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}
.templates-wrapper .compliance-table tr:last-child td { border-bottom: none; }

/* Template cards */
.templates-wrapper .template {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 20px;
    overflow: hidden;
    page-break-inside: avoid;
}
.templates-wrapper .template-header {
    background: #1E3A8A;
    color: #fff;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.templates-wrapper .template-header .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.templates-wrapper .template-header .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.templates-wrapper .template-header .tier {
    font-size: 10px;
    font-weight: 400;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.templates-wrapper .attach-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 3px;
    white-space: nowrap;
}
.templates-wrapper .attach-yes {
    background: rgba(39,174,96,0.3);
    color: #b7f0cc;
}
.templates-wrapper .attach-no {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
}
.templates-wrapper .template-body { padding: 16px; }
.templates-wrapper .subject-line {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 12px;
}
.templates-wrapper .subject-line strong { color: #1E3A8A; }
.templates-wrapper .email-body { padding: 4px 0; }
.templates-wrapper .email-body p { margin-bottom: 10px; }
.templates-wrapper .email-body ul {
    margin: 8px 0 12px 20px;
    padding: 0;
}
.templates-wrapper .email-body ul li { margin-bottom: 5px; }
.templates-wrapper .email-body a { color: #2c5aa0; }
.templates-wrapper .email-body .placeholder {
    background: #fef3c7;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 12px;
}

/* ============ Email zones + copy controls (copy-email.js) ============ */
/* Subject is restructured into a labeled zone that matches the email body —
   no separate gray box, same font size, with a copy button in its header. */
.templates-wrapper .subject-line {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0 0 14px 0;
    margin: 0 0 14px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: inherit;
}

/* Shared zone header: a label on the left, copy button on the right.
   Used for the subject, the main email body, and each variant body. */
.templates-wrapper .tpl-zone-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.templates-wrapper .tpl-zone-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.templates-wrapper .tpl-zone-content {
    color: var(--text-primary);
    line-height: 1.5;
}
.templates-wrapper .subject-line .tpl-zone-content {
    font-weight: 500;
    color: #1e293b;
}

/* Variant labels double as zone headers (label already present) */
.templates-wrapper .variant-label.tpl-zone-head {
    display: flex;
    margin-bottom: 8px;
}

/* Consistent copy button for every zone (subject + bodies) */
.templates-wrapper .tpl-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    background: #fff;
    color: #1e3a8a;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 4px 11px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
}
.templates-wrapper .tpl-copy-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}
.templates-wrapper .tpl-copy-btn svg {
    width: 13px;
    height: 13px;
}
.templates-wrapper .tpl-copy-btn--done,
.templates-wrapper .tpl-copy-btn--done:hover {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

/* Copy confirmation toast */
.tpl-copy-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e293b;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 1001;
}
.tpl-copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.tpl-copy-toast svg {
    width: 15px;
    height: 15px;
    color: #4ade80;
}

@media print {
    .templates-wrapper .tpl-copy-btn,
    .tpl-copy-toast {
        display: none !important;
    }
}

/* Variant */
.templates-wrapper .variant {
    border-top: 1px dashed #e2e8f0;
    margin-top: 16px;
    padding-top: 12px;
}
.templates-wrapper .variant-label {
    font-size: 11px;
    font-weight: 600;
    color: #2c5aa0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Notes */
.templates-wrapper .template-notes {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f0f9ff;
    border-left: 3px solid #2c5aa0;
    border-radius: 0 4px 4px 0;
    font-size: 11.5px;
    color: #4b5563;
}
.templates-wrapper .template-notes strong { color: #1E3A8A; }

/* Section dividers */
.templates-wrapper .section-divider {
    margin: 32px 0 20px;
    padding: 8px 0;
    border-bottom: 2px solid #1E3A8A;
    font-size: 16px;
    font-weight: 700;
    color: #1E3A8A;
    letter-spacing: -0.2px;
}

/* TOC */
.templates-wrapper .toc {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 24px;
}
.templates-wrapper .toc h2,
.templates-wrapper .toc-title {
    font-size: 13px;
    color: #1E3A8A;
    margin-bottom: 8px;
    font-weight: 700;
}
.templates-wrapper .toc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 24px;
}
.templates-wrapper .toc a {
    color: #2c5aa0;
    text-decoration: none;
    font-size: 12px;
    line-height: 1.8;
}
.templates-wrapper .toc a:hover { text-decoration: underline; }

/* Footer */
.templates-wrapper .tpl-footer {
    border-top: 1px solid #e2e8f0;
    margin-top: 32px;
    padding-top: 12px;
    font-size: 11px;
    color: #999;
}
.templates-wrapper .tpl-footer a { color: #2c5aa0; text-decoration: none; }

/* Page footer */
.page-footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.auth-copy {
    margin: 16px 0 24px;
}

.auth-copy-tight {
    margin-bottom: 16px;
}

.auth-copy-muted {
    color: var(--text-secondary);
}

.page-contract,
.source-freshness {
    max-width: 960px;
    margin: 0 auto 18px;
    padding: 18px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #f8fafc;
}

.page-contract {
    border-left: 4px solid #1e3a8a;
}

.page-contract h2 {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin: 0 0 8px;
}

.page-contract p,
.source-freshness p {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.6;
}

.access-summary {
    max-width: 960px;
    margin: 0 auto 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.access-summary > div {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #ffffff;
    padding: 14px;
}

.access-label,
.source-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.access-summary span:last-child {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.source-freshness {
    border-left: 4px solid #0f766e;
    background: #f0fdfa;
}

.template-library-heading {
    max-width: 960px;
    margin: 28px auto 14px;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 650;
}

.contact-selection-title {
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #1E3A8A;
    margin: 24px 0 8px;
    letter-spacing: 0.3px;
}

.contact-selection-copy {
    font-size: 12px;
    color: #4b5563;
    margin-bottom: 12px;
}

.template-notes-spaced {
    margin-bottom: 24px;
}

.comments-empty-help {
    font-size: 12px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .logo-section {
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-toolbar {
        align-items: flex-start;
    }

    .resource-actions {
        width: 100%;
    }

    .resource-actions .btn,
    .resource-actions .copy-md-btn {
        flex: 1 1 140px;
        justify-content: center;
    }

    .templates-wrapper .toc-grid {
        grid-template-columns: 1fr;
    }

    .templates-wrapper .template-header {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 8px;
    }

    .templates-wrapper .compliance-table {
        display: block;
        overflow-x: auto;
    }

    .access-summary {
        grid-template-columns: 1fr;
    }
}
