/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f5f3ef;
    min-height: 100vh;
    padding: 0;
    color: #333;
    line-height: 1.6;
}

/* Header - Clean minimal style */
.header {
    background: white;
    border-bottom: 1px solid #e5e5e5;
    padding: 0;
    margin-bottom: 48px;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
}

.header-text h1 {
    font-size: 1.5rem;
    color: #1a1a1a;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-text .subtitle {
    display: none;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-left: auto;
}

.header-controls .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-controls .filter-group label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
}

.header-controls .filter-group select {
    padding: 8px 16px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    color: #1a1a1a;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.header-controls .filter-group select:hover {
    border-color: #c41e3a;
}

.header-controls .stats {
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 6px;
}

.header-controls .stat-item {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

.header-controls .stat-item strong {
    color: #c41e3a;
    font-size: 1.1rem;
    font-weight: 700;
}

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

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #c41e3a;
    text-decoration: none;
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: #9a1829;
}

/* Filters - Hidden, moved to header */
.filters {
    display: none;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.filter-group select {
    padding: 10px 18px;
    border: 2px solid #e5e3df;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    color: #333;
    font-weight: 500;
}

.filter-group select:hover {
    border-color: #c41e3a;
}

.filter-group select:focus {
    outline: none;
    border-color: #c41e3a;
    box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

.stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
}

.stat-item strong {
    color: #c41e3a;
    font-size: 1.2rem;
    font-weight: 700;
}

/* Documents grid - Rectangle cards */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.document-card {
    background: white;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    padding: 0;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
}

.document-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: #c41e3a;
}

.document-card-header {
    background: linear-gradient(135deg, #c41e3a 0%, #9a1829 100%);
    padding: 16px 20px;
    color: white;
}

.document-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.document-card-body {
    padding: 24px;
    flex: 1;
}

.document-number {
    display: inline-block;
    background: #f5f3ef;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #c41e3a;
    margin-bottom: 12px;
}

.document-title {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 14px;
    line-height: 1.5;
    font-weight: 600;
}

.document-summary {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 16px;
}

.document-meta {
    display: flex;
    gap: 20px;
    padding-top: 16px;
    border-top: 1px solid #f5f3ef;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-label {
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 0.9rem;
    color: #333;
    font-weight: 600;
}

.document-card-footer {
    padding: 16px 24px;
    background: #fafaf8;
    border-top: 1px solid #e5e3df;
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-primary {
    background: #c41e3a;
    color: white;
    box-shadow: 0 2px 8px rgba(196, 30, 58, 0.3);
}

.btn-primary:hover {
    background: #9a1829;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(196, 30, 58, 0.4);
}

.btn-secondary {
    background: white;
    color: #666;
    border: 2px solid #e5e3df;
}

.btn-secondary:hover {
    border-color: #c41e3a;
    color: #c41e3a;
}

.btn-chat {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.3);
}

.btn-chat:hover {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    transform: translateY(-2px);
}

.btn-chat.active {
    background: #dc3545;
}

.btn-chat.active:hover {
    background: #bb2d3b;
}

/* Pagination */
.pagination {
    background: white;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.pagination-btn {
    padding: 10px 24px;
    background: #c41e3a;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(196, 30, 58, 0.3);
}

.pagination-btn:hover {
    background: #9a1829;
    transform: translateY(-2px);
}

.pagination-info {
    color: #333;
    font-weight: 600;
    font-size: 1rem;
}

/* Document detail page */
.document-detail-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 40px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.document-detail-container.chat-open {
    grid-template-columns: 1fr 480px;
    gap: 24px;
}

.document-detail {
    background: white;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    padding: 36px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-header {
    border-bottom: 2px solid #f5f3ef;
    padding-bottom: 28px;
    margin-bottom: 28px;
}

.detail-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.detail-badge {
    display: inline-block;
    padding: 8px 18px;
    background: linear-gradient(135deg, #c41e3a 0%, #9a1829 100%);
    color: white;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(196, 30, 58, 0.3);
}

.detail-date {
    color: #666;
    font-size: 0.95rem;
    font-weight: 600;
}

.detail-title {
    font-size: 1.9rem;
    color: #333;
    margin-bottom: 24px;
    line-height: 1.3;
    font-weight: 700;
}

.detail-links {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-body {
    font-size: 1rem;
}

.analysis-section {
    margin-bottom: 32px;
}

.analysis-section h3 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.analysis-section h3::before {
    content: '';
    width: 4px;
    height: 28px;
    background: #c41e3a;
    border-radius: 2px;
}

.analysis-content {
    background: #fafaf8;
    padding: 28px;
    border-radius: 10px;
    border-left: 4px solid #c41e3a;
    white-space: pre-wrap;
    line-height: 1.9;
    color: #444;
}

.analysis-content strong {
    color: #c41e3a;
    font-weight: 700;
}

.summary-box {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8eb 100%);
    padding: 24px;
    border-radius: 10px;
    border-left: 4px solid #c41e3a;
    box-shadow: 0 2px 8px rgba(196, 30, 58, 0.1);
}

.summary-box h4 {
    font-size: 1.15rem;
    color: #c41e3a;
    margin-bottom: 12px;
    font-weight: 700;
}

.summary-box p {
    color: #555;
    line-height: 1.8;
}

.text-muted {
    color: #999;
    font-style: italic;
}

/* Chat sidebar - Modern design */
.chat-sidebar {
    background: white;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    display: none;
    flex-direction: column;
    height: fit-content;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-sidebar.visible {
    display: flex;
    opacity: 1;
    transform: translateX(0);
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 2px solid #e5e3df;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    border-radius: 12px 12px 0 0;
}

.chat-header h3 {
    font-size: 1.15rem;
    color: white;
    margin-bottom: 4px;
    font-weight: 700;
}

.chat-header p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.95);
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    max-height: 550px;
    min-height: 400px;
    background: #fafaf8;
}

.chat-message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.assistant {
    align-items: flex-start;
}

.chat-message-bubble {
    max-width: 90%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-message.user .chat-message-bubble {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-message-bubble {
    background: white;
    color: #333;
    border: 2px solid #e5e3df;
    border-bottom-left-radius: 4px;
}

.chat-message-time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 6px;
    padding: 0 6px;
    font-weight: 600;
}

.chat-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: white;
    border: 2px solid #e5e3df;
    border-radius: 16px;
    font-size: 0.9rem;
    color: #666;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-loading-dots {
    display: flex;
    gap: 5px;
}

.chat-loading-dots span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chat-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.chat-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-input-area {
    padding: 20px 24px;
    border-top: 2px solid #e5e3df;
    background: white;
    border-radius: 0 0 12px 12px;
}

.chat-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e5e3df;
    border-radius: 24px;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: #fafaf8;
    color: #333;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
}

.chat-input:focus {
    outline: none;
    border-color: #1e3a8a;
    background: white;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.chat-input::placeholder {
    color: #999;
}

.btn-send {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.4);
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(30, 58, 138, 0.5);
}

.btn-send:active {
    transform: scale(0.95);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Empty state */
.empty-state {
    background: white;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    padding: 80px 40px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 24px;
    opacity: 0.4;
}

.empty-state h2 {
    font-size: 1.75rem;
    color: #333;
    margin-bottom: 16px;
    font-weight: 700;
}

.empty-state p {
    color: #666;
    font-size: 1.05rem;
    margin-bottom: 32px;
}

/* Footer */
.footer {
    background: white;
    border-top: 3px solid #c41e3a;
    padding: 32px 0;
    text-align: center;
    color: #666;
    margin-top: 40px;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

.footer p {
    margin: 8px 0;
    font-size: 0.9rem;
}

.footer-note {
    font-size: 0.85rem;
    margin-top: 16px;
}

.footer-note a {
    color: #c41e3a;
    text-decoration: none;
    font-weight: 600;
}

.footer-note a:hover {
    text-decoration: underline;
}

/* Scrollbar - default system scrollbar */
/* Removed custom scrollbar styling for better UX */

/* Responsive */
@media (max-width: 1200px) {
    .document-detail-container.chat-open {
        grid-template-columns: 1fr;
    }

    .chat-sidebar {
        position: static;
        max-height: 600px;
    }
}

@media (max-width: 768px) {
    .header-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .header-logo {
        justify-content: center;
        width: 100%;
    }

    .header-text {
        text-align: center;
    }

    .header-text h1 {
        font-size: 1.3rem;
    }

    .header-user-menu {
        justify-content: center;
        width: 100%;
    }

    .filters {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }

    .documents-grid {
        grid-template-columns: 1fr;
    }

    .document-detail {
        padding: 24px;
    }

    .detail-title {
        font-size: 1.5rem;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .document-card-footer {
        flex-direction: column;
    }

    .auth-box {
        padding: 32px 24px;
    }

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

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px 0;
}

.auth-box {
    background: white;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    padding: 48px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.auth-box h2 {
    font-size: 1.75rem;
    color: #333;
    margin-bottom: 12px;
    font-weight: 700;
}

.auth-subtitle {
    color: #666;
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.form-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.form-input {
    padding: 12px 16px;
    border: 2px solid #e5e3df;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: #fafaf8;
    color: #333;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: #c41e3a;
    background: white;
    box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

.form-input::placeholder {
    color: #999;
}

.btn-full {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid #e5e3df;
}

.auth-footer p {
    color: #666;
    font-size: 0.95rem;
}

.auth-footer a {
    color: #c41e3a;
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 0.95rem;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

/* Profile page */
.profile-container {
    background: white;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.profile-header {
    background: linear-gradient(135deg, #c41e3a 0%, #9a1829 100%);
    padding: 32px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profile-user-info {
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.profile-user-info h2 {
    color: white;
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
}

.profile-email {
    color: rgba(255, 255, 255, 0.9);
    margin: 4px 0 0 0;
    font-size: 0.95rem;
}

.profile-section {
    padding: 40px;
}

.profile-section h3 {
    font-size: 1.4rem;
    color: #333;
    margin-bottom: 12px;
    font-weight: 700;
}

.profile-section-desc {
    color: #666;
    margin-bottom: 32px;
    font-size: 0.95rem;
}

/* Sources list */
.sources-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.source-item {
    background: #fafaf8;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.source-item:hover {
    border-color: #c41e3a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.source-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.source-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.source-info h4 {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 4px;
    font-weight: 700;
}

.source-info p {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 30px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .switch-slider {
    background-color: #c41e3a;
}

.switch input:checked + .switch-slider:before {
    transform: translateX(26px);
}

/* Save message */
.save-message {
    margin-top: 24px;
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.save-message-success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.save-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

/* User menu in header */
.header-user-menu {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-menu-btn {
    padding: 10px 24px;
    background: #c41e3a;
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.user-menu-btn:hover {
    background: #9a1829;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(196, 30, 58, 0.3);
}

.user-menu-btn.secondary {
    background: white;
    color: #1a1a1a;
    border: 1px solid #e5e5e5;
}

.user-menu-btn.secondary:hover {
    background: #f8f9fa;
    border-color: #d0d0d0;
}

.user-menu-name {
    color: #1a1a1a;
    font-weight: 600;
    font-size: 1rem;
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    white-space: nowrap;
}

/* legacy-notification linking section */
.legacy-notification-linked {
    background: #d4edda;
    border: 2px solid #c3e6cb;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legacy-notification-status {
    display: flex;
    align-items: center;
    gap: 20px;
}

.legacy-notification-icon-success {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #28a745;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.legacy-notification-status h4 {
    font-size: 1.1rem;
    color: #155724;
    margin-bottom: 4px;
    font-weight: 700;
}

.legacy-notification-status p {
    color: #155724;
    font-size: 0.9rem;
    margin: 0;
}

.legacy-notification-not-linked {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.legacy-notification-instructions {
    background: #fafaf8;
    border: 2px solid #e5e3df;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.instruction-step {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.95rem;
    color: #333;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.code-display {
    animation: fadeIn 0.3s ease;
}

.code-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    margin-bottom: 16px;
}

.code-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.code-value {
    font-size: 3.5rem;
    font-weight: 700;
    color: white;
    letter-spacing: 8px;
    font-family: 'Courier New', monospace;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 24px;
}

@keyframes codeChange {
    0% {
        transform: scale(0.9);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.code-timer {
    margin-top: 20px;
}

.timer-text {
    color: white;
    font-size: 0.95rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.timer-text span {
    font-size: 1.2rem;
    font-weight: 700;
}

.timer-progress {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.timer-progress-bar {
    height: 100%;
    background: white;
    border-radius: 4px;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.code-hint {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
}

/* Responsive */
@media (max-width: 1200px) {
    .document-detail-container.chat-open {
        grid-template-columns: 1fr;
    }

    .chat-sidebar {
        position: static;
        max-height: 600px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-logo {
        width: 100%;
    }

    .filters {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }

    .documents-grid {
        grid-template-columns: 1fr;
    }

    .document-detail {
        padding: 24px;
    }

    .detail-title {
        font-size: 1.5rem;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .document-card-footer {
        flex-direction: column;
    }
}

/* Fixed-height cards; text is clamped without breaking the grid. */
.documents-grid {grid-template-columns:repeat(auto-fill,minmax(min(100%,330px),1fr));align-items:stretch}
.document-card {height:370px;min-height:370px;max-height:370px}
.document-card:focus-visible {outline:3px solid #c41e3a;outline-offset:3px}
.document-card-body {min-height:0;overflow:hidden;display:flex;flex-direction:column;padding:16px 20px}
.document-title {display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-clamp:3;overflow:hidden;line-height:1.35;margin-bottom:10px}
.document-summary {display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-clamp:3;overflow:hidden;line-height:1.4;margin-bottom:8px}
.document-summary-pending {color:#888;font-style:italic}
.document-meta {margin-top:auto;padding-top:8px}
.document-card-header {padding:10px 20px}
.document-card-footer {padding:12px 16px;flex-shrink:0}
.document-card-footer .btn {flex:1;padding:9px 10px}
@media(max-width:480px){.documents-grid{grid-template-columns:minmax(0,1fr)}}

/* Твой закон UI patch: roomy cards and accessible page navigation */
.brand-home { color: inherit; text-decoration: none; }
.brand-home:hover, .brand-home:focus-visible { color: #c41e3a; text-decoration: underline; text-underline-offset: 4px; }
.document-card { min-height: 475px; height: auto; }
.document-card:focus-visible { outline: 3px solid #c41e3a; outline-offset: 3px; }
.document-card-body { flex: 1; display: flex; flex-direction: column; }
.document-summary { white-space: pre-line; overflow: visible; display: block; overflow-wrap: anywhere; }
.document-meta { margin-top: auto; }
.document-card-footer { margin-top: auto; }
.pagination { gap: 12px; flex-wrap: wrap; padding: 18px; }
.pagination-pages { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; }
.pagination-number { min-width: 42px; min-height: 42px; padding: 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: #333; border: 1px solid #dedbd7; background: #fff; text-decoration: none; font-weight: 700; }
.pagination-number:hover { border-color: #c41e3a; color: #c41e3a; }
.pagination-number.is-active { background: #c41e3a; border-color: #c41e3a; color: #fff; pointer-events: none; }
.pagination-dots { padding: 0 4px; color: #777; }
.pagination-disabled { background: #eee; color: #888; box-shadow: none; cursor: default; }
.pagination-disabled:hover { background: #eee; transform: none; }
@media (max-width: 640px) { .document-card { min-height: 0; } .pagination { gap: 8px; } .pagination-btn { padding: 9px 12px; } .pagination-number { min-width: 38px; min-height: 38px; } }

/* Твой закон brand identity and AI wait indicator */
.brand-home { display: inline-flex; align-items: center; gap: 10px; }
.brand-logo { display: block; width: 48px; height: 48px; object-fit: contain; flex-shrink: 0; }
.tz-loading-coin { display: block; width: 38px; height: 38px; object-fit: contain; flex-shrink: 0; animation: tz-coin-turn 1.25s linear infinite; transform-style: preserve-3d; }
.chat-loading { display: flex; align-items: center; gap: 10px; }
@keyframes tz-coin-turn { 0% { transform: perspective(160px) rotateY(0deg); } 100% { transform: perspective(160px) rotateY(360deg); } }
@media (prefers-reduced-motion: reduce) { .tz-loading-coin { animation: none; } }

/* TVOI_ZAKON_HEADER_FIX_V1 — компактный и выровненный фирменный знак */
.header-text .brand-home {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  vertical-align: middle;
  text-decoration: none;
}
.header-text .brand-home .brand-logo {
  width: 60px;
  height: 60px;
  flex: 0 0 60px;
  display: block;
  object-fit: contain;
}
.header-text .brand-home span {
  display: inline-block;
  line-height: 1.15;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .header-text .brand-home { gap: 9px; }
  .header-text .brand-home .brand-logo {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }
}


/* TVOI_ZAKON_BRAND_FIX_V2: complete artwork #2, never clip header */
.header-text, .header-text h1, .header-text .brand-home { overflow: visible !important; }
.header-text .brand-home, .header-content .brand-home {
  display: inline-flex !important; align-items: center !important;
  gap: 0 !important; line-height: 1 !important;
  text-decoration: none !important; max-width: 100%;
}
.header-text .brand-home .brand-logo, .header-content .brand-home .brand-logo {
  display: block !important;
  width: 116px !important; height: 116px !important;
  max-width: 100% !important; flex: 0 0 auto !important;
  object-fit: contain !important; object-position: center !important;
  border-radius: 0 !important; clip-path: none !important;
}
.header-content { min-height: 140px; }
/* Rotating artwork #3 is independent of the static header logo. */
.tz-loading-coin {
  display: block; width: 42px; height: 42px;
  flex: 0 0 42px; object-fit: contain;
  animation: tz-spin-v2 1.4s linear infinite !important;
}
@keyframes tz-spin-v2 { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .header-text .brand-home .brand-logo, .header-content .brand-home .brand-logo {
    width: 96px !important; height: 96px !important;
  }
  .header-content { min-height: 116px; }
}
@media (prefers-reduced-motion: reduce) { .tz-loading-coin { animation: none !important; } }

/* TVOI_ZAKON_HEADER_V3_BEGIN */
.header-content { min-height: 86px !important; }
.header-text, .header-text h1 { overflow: visible !important; }
.header-text .brand-home, .header-content .brand-home {
  display: inline-flex !important; align-items: center !important;
  gap: 12px !important; white-space: nowrap !important;
  text-decoration: none !important; line-height: 1.15 !important;
  max-width: none !important;
}
.header-text .brand-home img.tz-header-icon-v3,
.header-content .brand-home img.tz-header-icon-v3 {
  display: block !important; width: 58px !important; height: 58px !important;
  min-width: 58px !important; max-width: 58px !important;
  object-fit: contain !important; object-position: center !important;
  border-radius: 0 !important; clip-path: none !important;
  margin: 0 !important; padding: 0 !important; flex: 0 0 58px !important;
}
.header-text .brand-home .tz-brand-label-v3,
.header-content .brand-home .tz-brand-label-v3 {
  display: inline !important; font-size: 25px !important; font-weight: 700 !important;
  line-height: 1.2 !important; color: #101820 !important;
  white-space: nowrap !important;
}
@media (max-width: 640px) {
 .header-content { min-height: 72px !important; }
 .header-text .brand-home, .header-content .brand-home { gap: 8px !important; }
 .header-text .brand-home img.tz-header-icon-v3,
 .header-content .brand-home img.tz-header-icon-v3 {
   width: 44px !important; height: 44px !important; min-width:44px !important;
   max-width:44px !important; flex: 0 0 44px !important;
 }
 .header-text .brand-home .tz-brand-label-v3,
 .header-content .brand-home .tz-brand-label-v3 { font-size: 19px !important; }
}
/* TVOI_ZAKON_HEADER_V3_END */

/* TZ_PROFILE_STYLE_V1 - scoped styling for the user profile */
.tz-profile-layout { max-width: 1120px; padding-bottom: 70px; }
.tz-profile-title { margin: 0 0 24px; }
.tz-profile-title h2 { color:#162a45; font-size:clamp(1.7rem,3vw,2.15rem); margin:0 0 5px; }
.tz-profile-title p,.tz-profile-help { color:#687387; font-size:.93rem; line-height:1.65; }
.tz-profile-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:22px; align-items:start; }
.tz-profile-card { background:#fff; border:1px solid #e4e8ef; border-radius:16px; padding:27px; box-shadow:0 6px 20px rgba(14,39,66,.06); }
.tz-profile-card h3 { font-size:1.2rem; color:#172b48; margin:0 0 15px; }
.tz-profile-card .tz-profile-subtitle { margin-top:27px; margin-bottom:7px; font-size:1.07rem; }
.tz-profile-card p { margin-bottom:14px; }
.tz-profile-field { display:flex; justify-content:space-between; align-items:center; gap:20px; padding:12px 0; border-bottom:1px solid #eef0f4; flex-wrap:wrap; overflow-wrap:anywhere; }
.tz-profile-field span { color:#667184; }
.tz-profile-field strong { color:#15263a; }
.tz-profile-field .tz-verified { color:#147d56; }
.tz-profile-field .tz-unverified { color:#a36017; }
.tz-profile-form { display:flex; flex-direction:column; gap:10px; margin-top:14px; }
.tz-profile-form>label:not(.tz-profile-check) { font-weight:650; color:#31435c; font-size:.9rem; }
.tz-profile-form input[type=email],.tz-profile-form input[name=code] { display:block; width:100%; padding:12px 14px; min-height:45px; border:1px solid #cdd6e2; border-radius:9px; font:inherit; background:#fff; color:#223248; }
.tz-profile-form input:focus-visible { outline:3px solid #bdd1ec; outline-offset:1px; border-color:#0c467c; }
.tz-profile-button { align-self:flex-start; border:0; background:#073c73; color:#fff; font:inherit; font-weight:700; border-radius:9px; padding:11px 18px; cursor:pointer; margin-top:3px; }
.tz-profile-button:hover:not(:disabled) { background:#0e558f; }
.tz-profile-button:disabled { background:#aeb9c6; cursor:not-allowed; }
.tz-profile-pending { background:#f4f8fd; border:1px solid #dbe6f2; border-radius:11px; padding:15px; margin-top:20px; }
.tz-profile-pending p { margin:0 0 8px; overflow-wrap:anywhere; }
.tz-profile-info { color:#654c14; background:#fff6dc; padding:12px 14px; border-radius:9px; margin:16px 0; }
.tz-profile-check { display:flex; gap:9px; align-items:center; cursor:pointer; margin:4px 0; }
.tz-profile-check input { width:17px; height:17px; accent-color:#073c73; flex-shrink:0; }
.tz-profile-fieldset { padding:14px; border:1px solid #e0e6ee; border-radius:10px; display:flex; flex-direction:column; gap:8px; margin:10px 0; }
.tz-profile-fieldset legend { font-weight:650; color:#31435c; padding:0 6px; }
.tz-profile-alert { padding:12px 16px; border-radius:9px; background:#e9f5ed; border:1px solid #c5e4d1; margin-bottom:16px; }
.tz-profile-alert-error { background:#fff0f0; border-color:#ecc7c7; }
.tz-profile-logout { margin-top:25px; }
.tz-profile-back { color:#0d4d85; text-decoration:none; font-weight:650; }
.tz-profile-page .header-content { max-width:1400px; }
.tz-profile-page .header-content h1 { font-size:1.5rem; margin:0; }
@media(max-width:800px){ .tz-profile-grid { grid-template-columns:1fr; } .tz-profile-card { padding:21px; } }
@media(max-width:460px){ .tz-profile-page .header-content { gap:12px; padding:14px 18px; } .tz-profile-page .tz-profile-back { font-size:.85rem; } }
/* TZ_PROFILE_STYLE_V1_END */


/* TZ_DISCOVERY_V1: visual refresh and discovery, scoped to home */
body:has(.tz-intro){background:#f4f6fa;color:#142c49}
body:has(.tz-intro) .header{border-bottom:1px solid #e0e7f1;margin-bottom:25px}
body:has(.tz-intro) .document-card{position:relative;border:1px solid #e1e7f0;box-shadow:0 5px 22px rgba(9,42,79,.06);border-radius:14px;overflow:hidden;background:#fff}
body:has(.tz-intro) .document-card-header{background:#153e73!important}
body:has(.tz-intro) .document-date-badge{background:#e5eefb!important;color:#173e70!important}
body:has(.tz-intro) .document-number{color:#1b5088!important}
body:has(.tz-intro) .btn-primary{background:#13477d!important;border-color:#13477d!important}
body:has(.tz-intro) .header-controls .stat-item strong{color:#173e70}
.tz-intro{background:white;padding:22px 25px;border:1px solid #e2e8f0;border-radius:16px;margin-bottom:25px;box-shadow:0 5px 22px rgba(9,42,79,.04)}
.tz-intro-top{display:flex;justify-content:space-between;gap:30px;align-items:start;flex-wrap:wrap}
.tz-intro h2{font-size:clamp(1.35rem,2.7vw,1.85rem);line-height:1.25;margin:0 0 8px;color:#112e50}
.tz-intro p{color:#53657c;line-height:1.5;font-size:.9rem}
.tz-source-caption{color:#64768d;font-size:.76rem;max-width:260px}
.tz-search-form{margin-top:18px}.tz-search-form label{display:block;font-weight:650;font-size:.84rem;margin-bottom:7px;color:#264768}
.tz-search-row{display:flex;gap:9px;align-items:center;flex-wrap:wrap}
.tz-search-row input{flex:1 1 250px;min-width:0;height:44px;padding:10px 14px;border:1px solid #c9d7e7;border-radius:9px;font:inherit;color:#142c49;background:white}
.tz-search-row button,.tz-actions button{border:1px solid #1a508c;border-radius:9px;background:#174982;color:#fff;padding:9px 17px;font:inherit;font-weight:650;cursor:pointer}
.tz-search-row a{color:#235b97;text-decoration:underline;padding:7px}
.tz-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:16px}
.tz-actions button{background:#edf3fc;color:#153e73;border-color:#dbe6f4;font-size:.85rem}
.tz-results-count{font-size:.8rem;color:#586b83;margin-left:auto}
.tz-today-panel{background:#f6f9fd;border:1px solid #dce7f5;border-radius:12px;padding:16px;margin-top:15px}
.tz-today-panel h3{font-size:1.08rem;margin-bottom:5px}.tz-today-panel ul{padding-left:21px;margin:9px 0 0}.tz-today-panel li{margin:6px 0;font-size:.88rem}.tz-today-panel a{color:#154984}
.tz-empty-faves{padding:16px;background:#f6f9fd;border-radius:9px;margin-top:15px}
.document-card[hidden]{display:none!important}
.tz-bookmark{position:absolute;z-index:1;right:14px;top:12px;padding:5px 8px;border-radius:7px;border:1px solid #cdddf2;background:#fff;color:#154984;font-size:.77rem;cursor:pointer;font-weight:650}
.tz-bookmark[aria-pressed=true]{background:#eff6fe}
@media(max-width:650px){.tz-intro{padding:18px 15px}.tz-results-count{margin-left:0}.tz-bookmark{right:8px;top:9px}}


/* TZ_BRAND_UNIFY_V3: shared controls and visual system on every page. */
:root { --tz-navy:#123f75; --tz-navy-deep:#102d50; --tz-pale:#f3f6fa; --tz-line:#dce5ef; }
body { background:var(--tz-pale); color:#1a2c43; }
.header { border-bottom:1px solid var(--tz-line); }
.header-controls .filter-group select:hover,.header-controls .filter-group select:focus-visible { border-color:var(--tz-navy); }
.header-controls .stat-item strong { color:var(--tz-navy); }
.user-menu-btn:not(.secondary), .btn-primary, .pagination-btn:not(.pagination-disabled), .pagination-number.is-active {
 background:var(--tz-navy)!important; border-color:var(--tz-navy)!important; color:#fff!important;
 box-shadow:0 3px 9px rgba(18,63,117,.13);
}
.user-menu-btn:not(.secondary):hover,.btn-primary:hover,.pagination-btn:not(.pagination-disabled):hover,
.pagination-number.is-active:hover { background:#0c305b!important; }
.user-menu-btn.secondary,.pagination-number:not(.is-active) { background:#fff; color:var(--tz-navy); border-color:var(--tz-line); }
.pagination { border:1px solid var(--tz-line); box-shadow:0 4px 15px rgba(15,45,80,.06); }
.pagination-number:hover:not(.is-active){border-color:var(--tz-navy);color:var(--tz-navy)}
.pagination-disabled {background:#edf1f6!important;color:#7b8ca0!important;border-color:#edf1f6!important;box-shadow:none!important}
.back-link, .auth-footer a, .tz-profile-back { color:var(--tz-navy)!important; }
.form-input:focus, .auth-form input:focus-visible { border-color:var(--tz-navy)!important; outline-color:#bfd3e9; }
.auth-box { border:1px solid var(--tz-line); }
.tz-unified-footer { border-top:2px solid #244b7c; background:#fff; color:#53647a; }
.tz-unified-footer .footer-content { text-align:center; max-width:1000px; margin:0 auto; }
.tz-unified-footer a.vgame-secret-link {color:var(--tz-navy)!important;text-decoration:none!important;}
.tz-unified-footer a.vgame-secret-link:hover {text-decoration:underline!important;}
.tz-unified-footer .footer-note {color:#62758d;}
@media(max-width:620px){.pagination{gap:9px;padding:13px 9px;flex-wrap:wrap}.pagination-btn{padding:9px 12px}.tz-unified-footer{padding:22px 12px}}
/* TZ_BRAND_UNIFY_V3_END */


/* TZ_CARDS_V4: compact cards + calm document details. */
body:has(.tz-intro) .tz-card-v4 { cursor:pointer; border:1px solid #dce5ef; border-radius:15px; overflow:hidden; transition:transform .18s ease,box-shadow .18s ease,border-color .18s ease; background:#fff; display:flex; flex-direction:column; }
body:has(.tz-intro) .tz-card-v4:hover { transform:translateY(-3px); box-shadow:0 14px 30px rgba(18,53,95,.13);border-color:#afc5de; }
body:has(.tz-intro) .tz-card-v4:focus-visible { outline:3px solid #438cce; outline-offset:3px; }
body:has(.tz-intro) .tz-card-v4 .document-card-header { background:#f3f7fd!important; min-height:54px; display:flex; flex-wrap:wrap; align-items:center; gap:10px; padding:12px 15px; padding-right:125px; border-bottom:1px solid #e3ebf5; }
body:has(.tz-intro) .tz-card-v4 .document-date-badge { background:transparent!important;color:#65788e!important; font-size:.8rem; padding:0!important; border:0!important; box-shadow:none!important; }
body:has(.tz-intro) .tz-card-v4 .tz-card-number {color:#184876;font-weight:700;font-size:.82rem;line-height:1.35;overflow-wrap:anywhere;}
body:has(.tz-intro) .tz-card-v4 .document-card-body {padding:16px 17px 19px; flex:1;}
body:has(.tz-intro) .tz-card-v4 .document-title {color:#172d48;font-size:1.04rem;line-height:1.43; margin:0 0 12px;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;}
body:has(.tz-intro) .tz-card-v4 .document-summary {color:#637286;line-height:1.58;font-size:.88rem;margin:0;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4;overflow:hidden;}
body:has(.tz-intro) .tz-card-v4 .tz-bookmark {right:13px;top:11px;z-index:2;}
.tz-detail-v4 {border:1px solid #dce5ef; border-radius:16px; overflow:hidden; box-shadow:0 8px 27px rgba(17,54,97,.065);}
.tz-detail-v4 .detail-header {background:#fff; border-bottom:1px solid #e4eaf2;}
.tz-detail-v4 .detail-badge {background:#edf4fd!important; color:#184876!important;box-shadow:none!important;border:1px solid #d5e3f4!important;}
.tz-detail-v4 .detail-title {color:#152f50;line-height:1.32; overflow-wrap:anywhere;}
.tz-detail-v4 .analysis-section h3 {color:#173f73;border-color:#174b85;}
.tz-detail-v4 .analysis-content {background:#f7f9fc!important;border-left:3px solid #1b528d!important;color:#253b56;line-height:1.75;overflow-wrap:anywhere;}
.tz-detail-v4 .summary-box {border:1px solid #d7e4f3;background:#f2f7fe;}
.tz-analysis-disclaimer {color:#61758c;font-size:.82rem;line-height:1.55;margin:0 0 17px;}
@media (max-width:600px){body:has(.tz-intro) .tz-card-v4 .document-card-header{padding:12px 110px 12px 12px;min-height:58px} body:has(.tz-intro) .tz-card-v4 .document-card-body{padding:14px} .tz-detail-v4 .detail-title{font-size:clamp(1.3rem,5vw,1.8rem)}}
@media(prefers-reduced-motion:reduce){body:has(.tz-intro) .tz-card-v4{transition:none}body:has(.tz-intro) .tz-card-v4:hover{transform:none}}
/* TZ_CARDS_V4_END */


/* TZ_CARDS_V5: compact equal-content cards and reliable navigation */
body:has(.tz-intro) .documents-grid { align-items:start; grid-auto-rows:auto; gap:18px; }
body:has(.tz-intro) .documents-grid > .tz-card-v5 {
  height:auto !important; min-height:0 !important; max-height:none !important;
  align-self:start; display:flex; flex-direction:column; overflow:hidden;
  cursor:pointer; border:1px solid #d7e2ef; border-radius:14px;
  background:#fff; box-shadow:0 3px 12px rgba(18,54,97,.055);
}
body:has(.tz-intro) .documents-grid > .tz-card-v5:hover { box-shadow:0 12px 28px rgba(18,54,97,.14); border-color:#a9c5e5; transform:translateY(-2px); }
body:has(.tz-intro) .documents-grid > .tz-card-v5:focus-visible { outline:3px solid #3585c5; outline-offset:3px; }
body:has(.tz-intro) .tz-card-v5 .document-card-header {
  background:#f0f5fb !important; color:#184574; min-height:52px;
  padding:10px 116px 10px 15px; display:flex; gap:8px; align-items:center; flex-wrap:wrap;
}
body:has(.tz-intro) .tz-card-v5 .document-card-body {
  padding:17px 17px 12px; display:flex; flex-direction:column;
  height:auto !important; min-height:0 !important; max-height:none !important;
  overflow:visible !important; flex:0 0 auto !important;
}
body:has(.tz-intro) .tz-card-v5 .document-title {
  color:#153354; font-size:1.02rem; line-height:1.45; font-weight:700;
  margin:0 0 10px; -webkit-line-clamp:3; line-clamp:3;
}
body:has(.tz-intro) .tz-card-v5 .document-summary {
  color:#5a6c82; font-size:.91rem; line-height:1.58;
  margin:0; -webkit-line-clamp:4; line-clamp:4;
}
body:has(.tz-intro) .tz-card-v5 .tz-card-cta {
  display:flex; align-items:center; justify-content:space-between;
  margin-top:15px; border-top:1px solid #e9eff6; padding-top:12px;
  color:#1b528b; font-size:.83rem; font-weight:700;
}
body:has(.tz-intro) .tz-card-v5 .tz-card-cta span { font-size:1.1rem; }
body:has(.tz-intro) .tz-card-v5 .tz-bookmark { z-index:5; }
@media(max-width:600px) {
 body:has(.tz-intro) .tz-card-v5 .document-card-header { padding:10px 112px 10px 12px; }
 body:has(.tz-intro) .tz-card-v5 .document-card-body { padding:14px 14px 12px; }
}
@media(prefers-reduced-motion:reduce) { body:has(.tz-intro) .documents-grid > .tz-card-v5 { transition:none; } }
/* TZ_CARDS_V5_END */


/* TZ_AI_UX_V6: new guidance and review for document pages */
.tz-guide-v6{background:#f4f8fe;border:1px solid #d9e6f5;border-radius:16px;padding:22px;margin:0 0 28px;color:#183754}
.tz-guide-v6 .tz-guide-eyebrow-v6{color:#245c98;font-size:.76rem;text-transform:uppercase;letter-spacing:.09em;font-weight:700}
.tz-guide-v6 .tz-guide-title-v6 h3{font-size:1.32rem;line-height:1.3;margin:6px 0 8px;color:#18395d}
.tz-guide-v6 .tz-guide-title-v6 p{margin:0 0 16px;color:#5f748b;line-height:1.6;font-size:.92rem}
.tz-essence-v6{background:#fff;border-left:4px solid #245c98;border-radius:10px;padding:15px 17px;margin-bottom:16px}
.tz-essence-v6 strong{color:#153a68}.tz-essence-v6 p{line-height:1.65;margin:7px 0 0;white-space:pre-line;overflow-wrap:anywhere}
.tz-question-grid-v6{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.tz-question-v6{background:#fff;color:#164475;display:flex;flex-direction:column;align-items:flex-start;gap:4px;border:1px solid #cfdfef;border-radius:10px;text-align:left;padding:13px 15px;cursor:pointer;font:inherit}
.tz-question-v6 span{font-weight:700}.tz-question-v6 small{font-size:.77rem;color:#637b92;line-height:1.5}
.tz-question-v6:hover{border-color:#397ab4;background:#edf5ff}.tz-question-v6:focus-visible{outline:3px solid #397ab4;outline-offset:2px}
.tz-guide-note-v6{margin:14px 0 0;font-size:.78rem;line-height:1.6;color:#60748c}
@media(max-width:620px){.tz-guide-v6{padding:16px}.tz-question-grid-v6{grid-template-columns:1fr}}
/* TZ_AI_UX_V6_END */


/* TZ_LAYOUT_V7 — unified compact controls and single document overview */
.header-content .header-user-menu{margin-left:auto}
.tz-toolbar-v7{display:flex;align-items:center;gap:14px;flex-wrap:wrap;padding:13px 18px;margin:16px 0 24px;border-radius:14px}
.tz-toolbar-v7 .tz-toolbar-actions-v7{display:flex;align-items:center;gap:9px;flex-wrap:wrap}
.tz-toolbar-v7 .header-controls{display:flex!important;align-items:center;gap:14px;flex-wrap:wrap;margin-left:auto;width:auto;max-width:100%}
.tz-toolbar-v7 .filter-group{display:flex;align-items:center;gap:8px}
.tz-toolbar-v7 .filter-group[style*="display:none"]{display:none!important}
.tz-toolbar-v7 .filter-group select{max-width:220px}
.tz-toolbar-v7 .stats{white-space:nowrap}
.tz-toolbar-v7 .tz-today-panel,.tz-toolbar-v7 .tz-empty-faves{width:100%;flex:0 0 100%}
.tz-toolbar-v7 .tz-today-panel[hidden],.tz-toolbar-v7 .tz-empty-faves[hidden]{display:none!important}
.tz-detail-v4 .analysis-section{background:#fff;border:none!important;box-shadow:none!important;margin-bottom:0;padding:0}
.tz-detail-v4 .analysis-section::before,.tz-detail-v4 .analysis-section::after{display:none!important}
.tz-detail-v4 .analysis-section h3{border-left:0!important;padding-left:0!important;color:#173f73}
.tz-detail-v4 .analysis-content{border:1px solid #e1e9f3!important;border-left:1px solid #e1e9f3!important;border-radius:12px;background:#f7f9fc!important;max-width:100%;box-sizing:border-box}
.tz-inline-guide-v7{margin-top:20px}
.tz-inline-guide-v7 h4{margin:0 0 12px;color:#173f73}
.tz-disclaimer-v7{font-size:.75rem!important;color:#798698!important;line-height:1.55;margin:20px 0 0!important}
@media(max-width:920px){.tz-toolbar-v7 .header-controls{margin-left:0;justify-content:flex-start}}
@media(max-width:600px){.tz-toolbar-v7{padding:13px}.tz-toolbar-v7 .header-controls{width:100%;gap:12px}.tz-toolbar-v7 .filter-group{width:100%;justify-content:space-between}.tz-toolbar-v7 .filter-group select{max-width:60%;min-width:0}}
/* TZ_LAYOUT_V7_END */


/* TZ_UI_V8_20261023: compact branded toolbar buttons, no redundant overview heading */
.tz-toolbar-v7 .tz-toolbar-actions-v7 {display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
.tz-toolbar-v7 .tz-toolbar-actions-v7 > button#tz-today-toggle,
.tz-toolbar-v7 .tz-toolbar-actions-v7 > button#tz-favorites-toggle {
  appearance:none;-webkit-appearance:none;
  display:inline-flex;align-items:center;justify-content:center;
  min-height:42px;max-width:100%;padding:10px 16px;
  box-sizing:border-box;border:1px solid #ccdbed;border-radius:9px;
  background:#eaf2fc;color:#153f72;
  font-family:inherit;font-size:14px;font-weight:600;line-height:1.35;
  text-align:center;text-decoration:none;white-space:normal;
  cursor:pointer;box-shadow:none;transition:background-color .15s,border-color .15s,box-shadow .15s;
}
.tz-toolbar-v7 .tz-toolbar-actions-v7 > button#tz-today-toggle:hover,
.tz-toolbar-v7 .tz-toolbar-actions-v7 > button#tz-favorites-toggle:hover {
  background:#dbeafa;border-color:#9bbbe1;box-shadow:0 2px 7px rgba(18,62,112,.08);
}
.tz-toolbar-v7 .tz-toolbar-actions-v7 > button#tz-today-toggle:focus-visible,
.tz-toolbar-v7 .tz-toolbar-actions-v7 > button#tz-favorites-toggle:focus-visible {
  outline:3px solid #6a9fe0;outline-offset:2px;
}
.tz-toolbar-v7 .tz-toolbar-actions-v7 > button[aria-expanded="true"],
.tz-toolbar-v7 .tz-toolbar-actions-v7 > button[aria-pressed="true"] {
  background:#163f73;color:#fff;border-color:#163f73;
}
/* Keep legacy ::before accent from returning if a cached heading/style persists */
.tz-detail-v4 .analysis-section > h3::before,
.tz-detail-v4 .analysis-section > h3::after {content:none!important;display:none!important;}
@media(max-width:600px){
  .tz-toolbar-v7 .tz-toolbar-actions-v7{width:100%;}
  .tz-toolbar-v7 .tz-toolbar-actions-v7 > button{flex:1 1 170px;}
}
/* END TZ_UI_V8 */

/* TZ_CHAT_V9 — clean, responsive legal assistant chat */
.document-detail-container.chat-open {
  grid-template-columns: minmax(0,1fr) minmax(520px, 42%) !important;
  align-items:start; gap:22px !important;
}
.document-detail-container.chat-open > .document-detail { min-width:0; }
.document-detail-container .chat-sidebar {
  box-sizing:border-box; min-width:0; width:100%;
  height:min(780px,calc(100dvh - 112px)); min-height:520px;
  max-height:calc(100dvh - 34px);
  border:1px solid #d5e3f2; border-radius:18px;
  overflow:hidden; background:#fff;
  box-shadow:0 12px 35px rgba(18,48,90,.13);
  position:sticky; top:16px;
}
.document-detail-container .chat-sidebar.visible {display:flex;}
.chat-sidebar .chat-header {
  flex:0 0 auto; padding:22px 25px 18px;
  border:0; border-radius:0;
  background:linear-gradient(115deg,#153e73 0%,#2e65a8 100%);
}
.chat-sidebar .chat-header h3 { margin:0 0 5px; color:#fff; font-size:1.12rem; font-weight:700; }
.chat-sidebar .chat-header p { margin:0; color:#dce9fa; font-size:.87rem; }
.chat-sidebar .chat-messages {
  box-sizing:border-box; min-height:0 !important; max-height:none !important;
  flex:1 1 auto; overflow-y:auto; overscroll-behavior:contain;
  padding:24px 20px; background:#f5f8fc;
}
.chat-sidebar .chat-message {margin-bottom:18px;gap:3px;}
.chat-sidebar .chat-message-bubble {
  box-sizing:border-box; max-width:92%; padding:14px 17px;
  border-radius:15px;box-shadow:none;font-size:.92rem;line-height:1.68;
  overflow-wrap:anywhere;white-space:pre-wrap;
}
.chat-sidebar .chat-message.assistant .chat-message-bubble {
  background:white; border:1px solid #dee7f2; color:#243d58; border-bottom-left-radius:5px;
}
.chat-sidebar .chat-message.user .chat-message-bubble {
  background:#184b85;color:white;border:1px solid #184b85;border-bottom-right-radius:5px;
}
.chat-sidebar .chat-message-time {font-weight:400;color:#74859b;font-size:.73rem;}
.chat-sidebar .chat-loading {border:1px solid #dee7f2;box-shadow:none;max-width:max-content;color:#315476;}
.chat-sidebar .chat-input-area {
  flex:0 0 auto; padding:15px 18px 17px; background:#fff;
  border:0; border-top:1px solid #e3eaf3; border-radius:0;
}
.chat-sidebar .chat-input-group {align-items:flex-end;gap:10px;min-width:0;}
.chat-sidebar textarea.chat-input {
  display:block;box-sizing:border-box;min-width:0;width:100%;min-height:50px;max-height:152px;
  height:50px;margin:0 !important;padding:13px 15px;
  background:#f8fafc;border:1px solid #cfdded;border-radius:13px;
  line-height:1.5;font-size:.94rem;resize:none;overflow-y:auto;
}
.chat-sidebar textarea.chat-input:focus {border-color:#3975ba;box-shadow:0 0 0 3px rgba(57,117,186,.12);outline:none;}
.chat-sidebar .btn-send {
  box-sizing:border-box;flex:0 0 48px;width:48px;height:48px;min-height:48px;
  margin:0 !important;padding:0;border-radius:12px;
  background:#184b85;box-shadow:none; font-size:1.2rem;
}
.chat-sidebar .btn-send:hover:not(:disabled) {background:#2867aa;transform:translateY(-1px);}
.chat-sidebar .btn-send:disabled {opacity:.5;cursor:wait;}
.chat-sidebar .btn-send:focus-visible {outline:3px solid #8fb7ec;outline-offset:2px;}
@media (max-width:1180px) {
  .document-detail-container.chat-open {grid-template-columns:minmax(0,1fr) minmax(420px,45%) !important;gap:16px !important;}
}
@media (max-width:920px) {
  .document-detail-container.chat-open {grid-template-columns:minmax(0,1fr) !important;gap:18px !important;}
  .document-detail-container .chat-sidebar {position:static;height:min(700px,75dvh);min-height:420px;max-height:none;}
}
@media (max-width:600px) {
  .document-detail-container .chat-sidebar {min-height:440px;height:min(650px,75dvh);border-radius:14px;}
  .chat-sidebar .chat-header {padding:17px 18px;}
  .chat-sidebar .chat-messages {padding:15px 12px;}
  .chat-sidebar .chat-input-area {padding:12px;}
  .chat-sidebar .chat-message-bubble {max-width:95%;}
}
@media (prefers-reduced-motion:reduce) {
  .document-detail-container .chat-sidebar,.document-detail-container {transition:none !important;}
}
/* END TZ_CHAT_V9 */

/* TZ_CHAT_V9_COMPACT: size-only override for the v9 assistant sidebar. */
@media (min-width: 1181px) {
  .document-detail-container.chat-open {
    grid-template-columns: minmax(0, 1fr) minmax(390px, 34%) !important;
    gap: 20px !important;
  }
}
@media (min-width: 921px) and (max-width: 1180px) {
  .document-detail-container.chat-open {
    grid-template-columns: minmax(0, 1fr) minmax(350px, 40%) !important;
    gap: 16px !important;
  }
}
@media (min-width: 921px) {
  .document-detail-container .chat-sidebar {
    height: min(620px, calc(100dvh - 105px)) !important;
    min-height: 420px !important;
  }
}
@media (max-width: 920px) {
  .document-detail-container .chat-sidebar {
    height: min(570px, 68dvh) !important;
    min-height: 380px !important;
  }
}
@media (max-width: 600px) {
  .document-detail-container .chat-sidebar {
    height: min(530px, 70dvh) !important;
    min-height: 350px !important;
  }
}
/* END TZ_CHAT_V9_COMPACT */
