:root {
    --primary: #3f7de8;
    --primary-dark: #2b5cb6;
    --accent: #25c7b3;
    --text: #1f2933;
    --muted: #6b7280;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --border-radius: 18px;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    font-family: 'Segoe UI', 'PingFang SC', sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}
body.watermarked {
    position: relative;
    overflow-x: hidden;
}
.watermark-layer {
    position: fixed;
    inset: -80px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-auto-rows: 120px;
    gap: 40px;
    transform: rotate(-18deg);
    transform-origin: center;
    pointer-events: none;
    z-index: 999;
    opacity: 0.08;
}
.watermark-layer span {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: #1f2933;
    opacity: 0.5;
}
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 40px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(63, 125, 232, 0.08);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
}
.logo-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-block;
}
.tagline {
    color: var(--muted);
    font-size: 0.9rem;
}
.top-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.9rem;
}
.notice {
    color: var(--primary-dark);
    font-weight: 600;
}
.muted {
    color: var(--muted);
    font-size: 0.95rem;
}
.user-label {
    color: #111827;
}
.page-body {
    padding: 30px 40px 80px;
    position: relative;
    z-index: 10;
}
.auth-wrapper, .card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: 0 20px 45px rgba(59, 130, 246, 0.08);
    margin-bottom: 24px;
}
.auth-shell {
    min-height: calc(100vh - 140px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 30px;
    padding: 36px;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.12);
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: 24px;
    border: 1px solid rgba(63, 125, 232, 0.15);
    pointer-events: none;
}
.login-card h1 {
    margin-top: 0;
    margin-bottom: 12px;
}
.switch-links {
    margin-top: 26px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.switch-links .btn {
    flex: 1;
}
.grid {
    display: grid;
    gap: 24px;
}
.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 50px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 12px 24px rgba(63, 125, 232, 0.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
}
.btn-secondary {
    background: #e5e7eb;
    color: #1f2933;
}
.btn-compact {
    padding: 8px 16px;
    font-size: 0.9rem;
}
input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid #e0e7ff;
    margin-bottom: 16px;
    font-size: 1rem;
    background: #f9fafc;
}
label {
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}
.alert {
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 12px;
}
.alert-success {
    background: #ecfdf5;
    color: #047857;
}
.alert-error {
    background: #fef2f2;
    color: #991b1b;
}
.alert-info {
    background: #eff6ff;
    color: #1d4ed8;
}
.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.statement-card {
    border: 1px dashed #cbd5f5;
    background: #f8fbff;
}
.stat {
    display: flex;
    flex-direction: column;
    background: #f7f9ff;
    padding: 16px;
    border-radius: 16px;
}
.stat-label {
    color: var(--muted);
    font-size: 0.9rem;
}
.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
}
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 12px 10px;
    border-bottom: 1px solid #eef2ff;
    text-align: left;
}
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
}
.badge-success {
    background: #dcfce7;
    color: #166534;
}
.badge-warning {
    background: #fef3c7;
    color: #b45309;
}
.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}
.chat-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    height: calc(100vh - 160px);
}
.chat-sidebar {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.thread-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}
.thread-list li {
    border-bottom: 1px solid #f1f5f9;
}
.thread-list a {
    display: block;
    padding: 16px 20px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.2s ease;
}
.thread-list a.active,
.thread-list a:hover {
    background: #eef2ff;
}
.sidebar-actions {
    padding: 16px 20px;
    border-top: 1px solid #eef2ff;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fff;
}
.chat-panel {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 25px 55px rgba(15, 23, 42, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.chat-header {
    padding: 24px 28px 12px;
    border-bottom: 1px solid #eef2ff;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    background: linear-gradient(180deg, #f9fafc 0%, #ffffff 40%);
}
.message {
    margin-bottom: 24px;
    display: flex;
}
.message .bubble {
    padding: 18px 20px;
    border-radius: 22px;
    max-width: 80%;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    background: #fff;
}
.message.user {
    justify-content: flex-end;
}
.message.user .bubble {
    background: #dbeafe;
    border-bottom-right-radius: 8px;
}
.message.assistant .bubble {
    background: #f3e8ff;
    border-bottom-left-radius: 8px;
}
.chat-form {
    padding: 24px 28px;
    border-top: 1px solid #eef2ff;
    background: #fff;
}
.chat-form textarea {
    min-height: 140px;
}
.bubble img,
.chat-thumb {
    max-width: 220px;
    border-radius: 16px;
    margin-top: 8px;
    cursor: zoom-in;
}
.bubble.loading {
    align-items: center;
}
.loader {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.loader span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #6366f1;
    animation: bubblePulse 0.8s infinite alternate;
}
.loader span:nth-child(2) {
    animation-delay: 0.2s;
}
.loader span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes bubblePulse {
    from {
        opacity: 0.3;
        transform: translateY(0);
    }
    to {
        opacity: 0.9;
        transform: translateY(-6px);
    }
}
.image-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    cursor: zoom-out;
}
.upload-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.file-input {
    display: none;
}
.file-label {
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px dashed #c7d2fe;
    background: #f8fafc;
    font-weight: 600;
    cursor: pointer;
}
.file-label:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.file-name {
    font-size: 0.9rem;
    color: var(--muted);
}
.site-footer {
    text-align: center;
    padding: 20px;
    color: var(--muted);
}
@media (max-width: 960px) {
    .top-bar {
        flex-direction: column;
        gap: 12px;
    }
    .chat-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    .chat-sidebar {
        order: 2;
    }
}
