:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --accent: #e53e3e;
    --bg: #f7fafc;
    --card-bg: #ffffff;
    --text: #1a202c;
    --text-muted: #718096;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.logo-area h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.logo-area .subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 32px;
}

.login-card label {
    display: block;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.login-card input:focus {
    border-color: var(--primary);
}

.login-card button {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-card button:hover {
    background: var(--primary-light);
}

.error-msg {
    color: var(--accent);
    font-size: 0.875rem;
    margin-top: 12px;
    min-height: 1.2em;
}

/* Chat */
.chat-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.chat-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.badge {
    font-size: 0.75rem;
    opacity: 0.7;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.province-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.province-selector label {
    font-size: 0.8rem;
    opacity: 0.8;
    white-space: nowrap;
}

.province-selector select {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: background 0.2s;
}

.province-selector select:hover,
.province-selector select:focus {
    background: rgba(255, 255, 255, 0.25);
}

.province-selector select option {
    background: var(--primary);
    color: white;
}

.btn-ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.message.loading .message-content {
    color: var(--text-muted);
    font-style: italic;
}

.disclaimer {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

cite {
    font-size: 0.8rem;
    color: var(--primary-light);
    font-style: normal;
    font-weight: 600;
}

.sources {
    padding: 8px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.source-tag {
    display: inline-block;
    background: #edf2f7;
    padding: 2px 8px;
    border-radius: 4px;
    margin: 2px 4px 2px 0;
    font-size: 0.75rem;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
    transition: border-color 0.2s;
}

.chat-input-area textarea:focus {
    border-color: var(--primary);
}

.chat-input-area button {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.chat-input-area button:hover {
    background: var(--primary-light);
}

.chat-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.response-meta {
    padding: 2px 16px 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.deeper-wrap {
    padding: 4px 16px 8px;
}

.btn-deeper {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--primary-light);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-deeper:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

@media (max-width: 640px) {
    .chat-header {
        padding: 10px 16px;
    }

    .chat-header h1 {
        font-size: 1.1rem;
    }

    .chat-messages {
        padding: 16px 12px;
    }

    .message-content {
        max-width: 92%;
    }

    .chat-input-area {
        padding: 12px;
    }
}
