/* ============================================================
   KAIRO+ Platform - Design System & Styles
   Typography: Montserrat (headings) + Poppins (body)
   Palette: Black & White, no shadows, no emojis
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&family=Poppins:wght@300;400;500;600&display=swap');

/* ---- CSS VARIABLES ---- */
:root {
    /* Light theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #ebebeb;
    --bg-input: #f5f5f5;
    --text-primary: #0a0a0a;
    --text-secondary: #404040;
    --text-tertiary: #737373;
    --text-inverse: #ffffff;
    --border-color: #d4d4d4;
    --border-light: #e5e5e5;
    --accent: #0a0a0a;
    --accent-hover: #262626;
    --danger: #991b1b;
    --danger-hover: #7f1d1d;
    --success: #166534;
    --warning: #92400e;
    --sidebar-width: 260px;
    --header-height: 56px;
    --transition: 150ms ease;
    --radius: 4px;
    --radius-lg: 8px;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1f1f1f;
    --bg-input: #1a1a1a;
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-tertiary: #737373;
    --text-inverse: #0a0a0a;
    --border-color: #2e2e2e;
    --border-light: #1f1f1f;
    --accent: #fafafa;
    --accent-hover: #d4d4d4;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;
}

/* ---- RESET ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Poppins', sans-serif;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    line-height: 1.3;
}

a {
    color: var(--text-primary);
    text-decoration: none;
}

button {
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input, textarea, select {
    font-family: 'Poppins', sans-serif;
    font-size: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px 12px;
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

ul, ol {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ---- LAYOUT ---- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition), width var(--transition);
    z-index: 100;
}

.sidebar.collapsed {
    width: 60px;
    min-width: 60px;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-footer-info {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px;
}

.sidebar.collapsed .nav-item svg {
    margin-right: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
}

.sidebar-brand-logo {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 1.5px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.nav-section-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-tertiary);
    padding: 16px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: var(--text-inverse);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 1.5;
}

.nav-item .badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 10px;
    color: var(--text-tertiary);
}

.nav-item.active .badge {
    background: rgba(255,255,255,0.2);
    color: var(--text-inverse);
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding: 12px;
}

.sidebar-footer-info {
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 4px 8px;
}

/* ---- MAIN CONTENT ---- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ---- HEADER ---- */
.header {
    height: var(--header-height);
    min-height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-primary);
    z-index: 50;
}

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

.header-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    font-weight: 600;
}

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

.header-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: background var(--transition);
    color: var(--text-secondary);
}

.header-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.header-btn svg {
    width: 18px;
    height: 18px;
}

.toggle-sidebar-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.toggle-sidebar-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.toggle-sidebar-btn svg {
    width: 18px;
    height: 18px;
}

/* ---- PAGE CONTENT ---- */
.page-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.page-view {
    display: none;
    height: 100%;
}

.page-view.active {
    display: flex;
    flex-direction: column;
}

/* ---- CHAT VIEW ---- */
.chat-layout {
    display: flex;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

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

/* ---- REFERENCES SIDEBAR ---- */
.refs-sidebar {
    width: 280px;
    min-width: 280px;
    height: 100%;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.refs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}

.refs-header svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.refs-header span {
    flex: 1;
}

.refs-clear-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--text-tertiary);
    transition: all var(--transition);
}

.refs-clear-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.refs-clear-btn svg {
    width: 14px;
    height: 14px;
}

.refs-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.refs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 11px;
    line-height: 1.5;
}

.refs-empty svg {
    width: 28px;
    height: 28px;
    opacity: 0.25;
}

.ref-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 6px;
    transition: border-color var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.ref-item:hover {
    border-color: var(--accent);
}

.ref-icon-wrap {
    width: 28px;
    height: 28px;
    min-width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ref-favicon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: contain;
}

.ref-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    background: var(--bg-primary);
}

.ref-icon svg {
    width: 14px;
    height: 14px;
}

.ref-info {
    flex: 1;
    min-width: 0;
}

.ref-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.ref-url {
    font-size: 10px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ref-type-tag {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 2px;
    margin-top: 4px;
    display: inline-block;
    font-family: 'Montserrat', sans-serif;
}

@media (max-width: 1024px) {
    .refs-sidebar {
        display: none;
    }
}

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

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.chat-welcome-logo {
    width: 48px;
    height: 48px;
    background: var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 20px;
}

.chat-welcome h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.chat-welcome p {
    color: var(--text-tertiary);
    font-size: 13px;
    max-width: 400px;
}

.message {
    margin-bottom: 24px;
    animation: messageIn 200ms ease;
}

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

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

.message-user .message-content {
    background: var(--accent);
    color: var(--text-inverse);
    border-radius: var(--radius-lg) var(--radius-lg) 2px var(--radius-lg);
    max-width: 70%;
    padding: 10px 16px;
    font-size: 13px;
}

.message-assistant {
    display: flex;
    gap: 12px;
}

.message-avatar {
    width: 28px;
    height: 28px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 11px;
    color: var(--text-secondary);
}

.message-assistant .message-content {
    flex: 1;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-primary);
    max-width: 70%;
}

.message-assistant .message-content p {
    margin-bottom: 8px;
}

.message-assistant .message-content p:last-child {
    margin-bottom: 0;
}

.message-assistant .message-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

.message-assistant .message-content pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 16px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-assistant .message-content pre code {
    background: none;
    padding: 0;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typing 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Chat Input */
.chat-input-container {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    background: var(--bg-input);
    transition: border-color var(--transition);
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent);
}

.chat-input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    min-height: 22px;
    max-height: 160px;
    padding: 2px 0;
    font-size: 13px;
    line-height: 1.5;
}

.chat-input-wrapper textarea:focus {
    border: none;
}

.chat-input-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chat-send-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--text-inverse);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.chat-send-btn:hover {
    background: var(--accent-hover);
}

.chat-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 16px;
    height: 16px;
}

.chat-model-select {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
}

.chat-model-select select {
    font-size: 11px;
    padding: 4px 28px 4px 8px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: auto;
}

.chat-model-select label {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ---- CONVERSATION LIST ---- */
.conversation-list {
    padding: 8px 0;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background var(--transition);
    font-size: 12px;
    color: var(--text-secondary);
}

.conversation-item:hover {
    background: var(--bg-tertiary);
}

.conversation-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 500;
}

.conversation-item-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.conversation-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.conversation-item:hover .conversation-item-actions {
    opacity: 1;
}

.conversation-item-actions button {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--text-tertiary);
}

.conversation-item-actions button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.conversation-item-actions button svg {
    width: 14px;
    height: 14px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 12px;
    transition: all var(--transition);
    margin-bottom: 8px;
}

.new-chat-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.new-chat-btn svg {
    width: 16px;
    height: 16px;
}

/* ---- PANEL LAYOUTS (CRM, Clients, Docs, Settings) ---- */
.panel {
    padding: 24px;
    height: 100%;
    overflow-y: auto;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.panel-header h2 {
    font-size: 20px;
}

.panel-header-actions {
    display: flex;
    gap: 8px;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-ghost {
    color: var(--text-secondary);
    padding: 6px 10px;
}

.btn-ghost:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ---- TABLES ---- */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-secondary);
}

/* ---- CARDS ---- */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    background: var(--bg-primary);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 14px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* ---- STATS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
}

.stat-value {
    font-family: 'Montserrat', sans-serif;
    font-size: 28px;
    font-weight: 700;
}

.stat-change {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ---- PIPELINE / KANBAN ---- */
.pipeline {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: 400px;
}

.pipeline-column {
    min-width: 260px;
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.pipeline-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--bg-secondary);
}

.pipeline-column-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pipeline-column-count {
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 1px 8px;
    border-radius: 10px;
}

.pipeline-column-body {
    flex: 1;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100px;
}

.pipeline-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: border-color var(--transition);
    background: var(--bg-primary);
}

.pipeline-card:hover {
    border-color: var(--accent);
}

.pipeline-card-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}

.pipeline-card-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    display: flex;
    justify-content: space-between;
}

.pipeline-card-value {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
}

/* ---- FORMS & MODALS ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 15px;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--text-tertiary);
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-close svg {
    width: 16px;
    height: 16px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-family: 'Montserrat', sans-serif;
}

.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ---- TAGS / STATUS BADGES ---- */
.tag {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.tag-active {
    border-color: var(--success);
    color: var(--success);
}

.tag-inactive {
    border-color: var(--text-tertiary);
    color: var(--text-tertiary);
}

.tag-lead {
    border-color: var(--warning);
    color: var(--warning);
}

.tag-prospect {
    border-color: var(--accent);
    color: var(--accent);
}

/* ---- TABS ---- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    cursor: pointer;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* ---- SEARCH / FILTER BAR ---- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
}

.search-input-wrapper svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

.search-input-wrapper input {
    padding-left: 34px;
}

.filter-select {
    width: auto;
    min-width: 140px;
}

/* ---- DOCUMENT CARDS ---- */
.doc-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color var(--transition);
    cursor: pointer;
}

.doc-card:hover {
    border-color: var(--accent);
}

.doc-card-icon {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.doc-card-icon svg {
    width: 18px;
    height: 18px;
}

.doc-card-title {
    font-size: 13px;
    font-weight: 500;
}

.doc-card-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    display: flex;
    gap: 12px;
}

.doc-card-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ---- SETTINGS ---- */
.settings-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
    height: 100%;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav-item {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.settings-nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-nav-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 500;
}

.settings-panel {
    display: none;
    max-width: 600px;
}

.settings-panel.active {
    display: block;
}

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

.settings-section h3 {
    font-size: 15px;
    margin-bottom: 4px;
}

.settings-section p {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.api-key-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.api-key-row:last-child {
    border-bottom: none;
}

.api-key-provider {
    width: 100px;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Montserrat', sans-serif;
}

.api-key-input {
    flex: 1;
}

.api-key-input input {
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.api-key-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    flex-shrink: 0;
}

.api-key-status.connected {
    background: var(--success);
}

/* ---- SYSTEM PROMPT EDITOR ---- */
.prompt-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.prompt-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: border-color var(--transition);
}

.prompt-item:hover {
    border-color: var(--accent);
}

.prompt-item.active-prompt {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.prompt-item-info {
    flex: 1;
}

.prompt-item-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
}

.prompt-item-category {
    font-size: 11px;
    color: var(--text-tertiary);
}

.prompt-item-actions {
    display: flex;
    gap: 4px;
}

.prompt-editor {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.prompt-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.prompt-editor-header input {
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
}

.prompt-editor textarea {
    border: none;
    border-radius: 0;
    min-height: 200px;
    padding: 16px;
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
}

.prompt-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.prompt-char-count {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ---- TOGGLE SWITCH (Dark/Light) ---- */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    width: 40px;
    height: 22px;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-tertiary);
}

.toggle-switch.active {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch-knob {
    width: 16px;
    height: 16px;
    background: var(--bg-primary);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform var(--transition);
}

.toggle-switch.active .toggle-switch-knob {
    transform: translateX(18px);
}

.theme-toggle-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ---- EMPTY STATE ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-tertiary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 12px;
    max-width: 300px;
}

/* ---- TOAST NOTIFICATIONS ---- */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    min-width: 260px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 200ms ease;
}

.toast.toast-error {
    border-color: var(--danger);
}

.toast.toast-success {
    border-color: var(--success);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        z-index: 200;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .settings-layout {
        grid-template-columns: 1fr;
    }

    .form-group-row {
        grid-template-columns: 1fr;
    }

    .pipeline {
        flex-direction: column;
    }

    .pipeline-column {
        width: 100%;
        min-width: 100%;
    }
}

/* ---- LOADING SPINNER ---- */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ---- CONTEXT MENU ---- */
.context-menu {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 4px;
    min-width: 160px;
    z-index: 3000;
    display: none;
}

.context-menu.active {
    display: block;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 3px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.context-menu-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item svg {
    width: 14px;
    height: 14px;
}

.context-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.dash-metric {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: border-color var(--transition);
}

.dash-metric:hover {
    border-color: var(--accent);
}

.dash-metric-value {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-primary);
}

.dash-metric-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.dash-metric-sub {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.dash-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .dash-sections { grid-template-columns: 1fr; }
}

.dash-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.dash-empty {
    font-size: 13px;
    color: var(--text-tertiary);
    padding: 16px 0;
}

.dash-schedule-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    margin-bottom: 4px;
    background: var(--bg-secondary);
}

.dash-schedule-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 44px;
}

.dash-schedule-info { flex: 1; min-width: 0; }

.dash-schedule-title {
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-schedule-loc {
    font-size: 11px;
    color: var(--text-tertiary);
}

.dash-schedule-type {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.dash-activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}

.dash-activity-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.dash-activity-icon svg {
    width: 16px;
    height: 16px;
}

.dash-activity-info { flex: 1; min-width: 0; }

.dash-activity-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.dash-activity-detail {
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-activity-time {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.dash-pipeline {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 0;
}

.dash-pipeline-stage {
    text-align: center;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-width: 80px;
}

.dash-pipeline-count {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.dash-pipeline-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.dash-pipeline-value {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.dash-pipeline-arrow {
    color: var(--text-tertiary);
    font-size: 16px;
}

/* ============================================================
   LISTINGS
   ============================================================ */
.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.listing-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--transition);
}

.listing-card:hover {
    border-color: var(--accent);
}

.listing-card-photo {
    height: 160px;
    background: var(--bg-tertiary);
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.listing-no-photo {
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 500;
}

.listing-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.listing-status-active { border-color: var(--success); color: var(--success); }
.listing-status-reserved { border-color: var(--warning); color: var(--warning); }
.listing-status-sold { border-color: var(--accent); color: var(--accent); }
.listing-badge-rent { top: 8px; left: 8px; right: auto; }

.listing-card-body {
    padding: 12px;
}

.listing-card-price {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-primary);
}

.listing-card-title {
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.listing-card-location {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.listing-card-features {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.listing-card-features span {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
}

.listing-card-portals {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.portal-tag {
    font-size: 9px;
    padding: 1px 5px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-tertiary);
}

.listing-card-owner {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.energy-cert {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    margin-top: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.energy-cert-a, .energy-cert-b { color: #22c55e; }
.energy-cert-c, .energy-cert-d { color: #f59e0b; }
.energy-cert-e, .energy-cert-f, .energy-cert-g { color: #ef4444; }

/* ============================================================
   SHOWINGS
   ============================================================ */
.showing-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
}

.showing-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.showing-datetime {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.showing-date {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.showing-time {
    font-size: 13px;
    color: var(--text-secondary);
}

.showing-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.showing-status-scheduled { color: var(--accent); border-color: var(--accent); }
.showing-status-completed { color: var(--success); border-color: var(--success); }
.showing-status-cancelled { color: var(--danger); border-color: var(--danger); }
.showing-status-no_show { color: var(--warning); border-color: var(--warning); }

.showing-property {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.showing-client {
    font-size: 13px;
    color: var(--text-secondary);
}

.showing-duration, .showing-feedback, .showing-notes {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.showing-interest {
    margin-top: 4px;
}

.showing-interest .star {
    font-size: 14px;
    color: var(--text-tertiary);
}

.showing-interest .star.filled {
    color: #f59e0b;
}

.showing-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

/* ============================================================
   CALENDAR
   ============================================================ */
.cal-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cal-date-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 180px;
    text-align: center;
}

.cal-month-grid {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-secondary);
}

.cal-header-cell {
    padding: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.cal-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-cell {
    min-height: 80px;
    border-top: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    padding: 4px;
    cursor: pointer;
    transition: background var(--transition);
}

.cal-cell:hover {
    background: var(--bg-secondary);
}

.cal-cell-empty {
    background: var(--bg-tertiary);
    cursor: default;
}

.cal-cell-empty:hover {
    background: var(--bg-tertiary);
}

.cal-today {
    background: var(--bg-secondary);
}

.cal-day-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.cal-today .cal-day-num {
    color: var(--accent);
}

.cal-event-dot {
    font-size: 10px;
    padding: 1px 4px;
    margin-bottom: 2px;
    border-radius: 2px;
    color: var(--text-primary);
    background: var(--bg-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.cal-event-time {
    font-weight: 600;
    margin-right: 3px;
}

.cal-more {
    font-size: 10px;
    color: var(--text-tertiary);
    padding: 1px 4px;
}

.cal-week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-week-day {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-height: 200px;
}

.cal-week-day-header {
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.cal-week-dayname {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.cal-week-daynum {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.cal-week-day-events {
    padding: 4px;
}

.cal-week-event {
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: 3px;
    background: var(--bg-secondary);
    cursor: pointer;
}

.cal-week-event:hover {
    background: var(--bg-tertiary);
}

.cal-week-event-time {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
}

.cal-week-event-title {
    font-size: 12px;
    color: var(--text-primary);
}

.cal-week-event-loc {
    font-size: 10px;
    color: var(--text-tertiary);
}

.cal-week-empty {
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 8px;
    text-align: center;
}

.cal-day-view {
    max-width: 600px;
}

.cal-day-event {
    padding: 14px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.cal-day-event-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.cal-day-event-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.cal-day-event-time {
    font-size: 13px;
    color: var(--text-secondary);
}

.cal-day-event-type {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
}

.cal-day-event-detail {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.cal-day-event-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

/* ============================================================
   EMAIL
   ============================================================ */
.email-panel {
    display: none;
    margin-top: 12px;
}

.email-panel.active {
    display: block;
}

.email-log-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 6px;
}

.email-log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.email-direction-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}

.email-inbound {
    background: var(--bg-secondary);
    color: var(--success);
}

.email-outbound {
    background: var(--bg-secondary);
    color: var(--accent);
}

.email-log-subject {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
}

.email-status-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.email-status-draft { color: var(--warning); border-color: var(--warning); }
.email-status-sent { color: var(--success); border-color: var(--success); }

.email-log-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.email-log-preview {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.email-log-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.template-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 6px;
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.template-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.template-category {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.template-subject {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.template-preview {
    font-size: 11px;
    color: var(--text-tertiary);
}

.template-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* ============================================================
   CALLS
   ============================================================ */
.call-log-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 6px;
    align-items: flex-start;
}

.call-log-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.call-log-icon svg {
    width: 16px;
    height: 16px;
}

.call-outbound {
    background: var(--bg-secondary);
    color: var(--accent);
}

.call-inbound {
    background: var(--bg-secondary);
    color: var(--success);
}

.call-log-body { flex: 1; min-width: 0; }

.call-log-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.call-log-client {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.call-log-phone {
    font-size: 12px;
    color: var(--text-tertiary);
}

.call-outcome-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.call-outcome-completed { color: var(--success); border-color: var(--success); }
.call-outcome-interested { color: var(--accent); border-color: var(--accent); }
.call-outcome-callback { color: var(--warning); border-color: var(--warning); }
.call-outcome-no_answer, .call-outcome-voicemail { color: var(--text-tertiary); }
.call-outcome-not_interested { color: var(--danger); border-color: var(--danger); }

.call-log-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.call-log-notes {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.call-log-followup {
    font-size: 11px;
    color: var(--warning);
    margin-top: 4px;
    font-weight: 500;
}

.call-log-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-self: center;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.filter-btn {
    font-size: 12px;
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-body);
}

.filter-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.filter-btn.active {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* ============================================================
   CHECKBOX LABELS & MODAL LARGE
   ============================================================ */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.modal-lg {
    max-width: 720px;
}

.tag-type {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: capitalize;
}

/* ============================================================
   CLIENT TIMELINE
   ============================================================ */
.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.timeline-type {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-tertiary);
    min-width: 60px;
    padding-top: 2px;
}

.timeline-date {
    font-size: 11px;
    color: var(--text-tertiary);
    min-width: 90px;
}

.timeline-detail {
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
}

.timeline-notes {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

@media (max-width: 768px) {
    .cal-week-grid {
        grid-template-columns: 1fr;
    }
    .listings-grid {
        grid-template-columns: 1fr;
    }
    .call-log-item {
        flex-direction: column;
    }
    .portal-search-results {
        grid-template-columns: 1fr;
    }
}

/* ---- PORTAL SEARCH PANEL ---- */
.portal-search-panel {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
}

.portal-search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.portal-search-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.portal-search-filters {
    margin-bottom: 16px;
}

.portal-search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.portal-result-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-primary);
    transition: border-color var(--transition);
}

.portal-result-card:hover {
    border-color: var(--text-tertiary);
}

.portal-result-photo {
    height: 140px;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-tertiary);
    position: relative;
}

.portal-result-body {
    padding: 12px;
}

.listing-badge-portal {
    background: var(--accent);
    color: var(--text-inverse);
}

/* ---- EMAIL STATUS BADGES ---- */
.email-status-received {
    color: var(--success);
    border-color: var(--success);
}

.email-status-failed {
    color: var(--danger);
    border-color: var(--danger);
}

.email-status-sent {
    color: var(--success);
    border-color: var(--success);
}

.email-status-draft {
    color: var(--text-tertiary);
    border-color: var(--text-tertiary);
}

/* ---- LISTING PHOTO UPLOAD ---- */
.listing-photo-dropzone {
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    cursor: pointer;
    margin-bottom: 10px;
    transition: border-color var(--transition), background var(--transition);
}

.listing-photo-dropzone:hover,
.listing-photo-dropzone.drag-over {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--bg-secondary));
}

.listing-photo-item {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    cursor: grab;
}

/* ---- LISTINGS BULK CSV ---- */
.listings-bulk-panel {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 12px;
}

.listings-csv-guideline {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
}

/* ---- CHAT MARKDOWN TABLES ---- */
.message-content .md-table-wrap {
    overflow-x: auto;
    margin: 8px 0;
}

.message-content .md-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.message-content .md-table-wrap th,
.message-content .md-table-wrap td {
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    vertical-align: top;
}

.message-content .md-table-wrap th {
    background: var(--bg-secondary);
    font-weight: 600;
}
