/* ═══════════════════════════════════════════════════════════════
   CoLandlord — Design System
   Premium dark-mode SaaS interface
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #22223a;
    --bg-input: #16162a;
    --border: #2a2a45;
    --border-light: #3a3a55;
    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #6a6a85;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --sidebar-width: 220px;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--accent-hover);
}

/* ── App Layout ─────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

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

.logo-icon {
    font-size: 1.6rem;
}

.logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

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

.nav-item.active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.2rem;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.logout-btn {
    color: var(--text-muted) !important;
    font-size: 0.9rem;
}

.logout-btn:hover {
    color: var(--danger) !important;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

/* .page-header and .page-header h1 are defined in the Canvas & Controller section */

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 16px;
}

.page-content {
    padding: 24px;
}

.page-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card.pulse {
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {

    0%,
    100% {
        border-color: var(--border);
    }

    50% {
        border-color: var(--danger);
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
    }
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    display: block;
    line-height: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ── Sections ───────────────────────────────────────────────── */
.section {
    margin-bottom: 32px;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ── Cards ───────────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.property-card,
.decision-card,
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    overflow: hidden;
}

/* Property Card Cover Thumbnail */
.property-card-thumb {
    display: block;
    width: calc(100% + 48px);
    height: 160px;
    margin: -24px -24px 16px;
    overflow: hidden;
    border-radius: var(--radius) var(--radius) 0 0;
}

.property-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.property-card:hover .property-card-thumb img {
    transform: scale(1.03);
}

.property-card:hover,
.decision-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

.property-type-icon {
    font-size: 1.8rem;
}

.property-name {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.property-address {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.property-rent {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 12px;
}

.property-stats {
    display: flex;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.property-notes {
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* ── Decision Cards ─────────────────────────────────────────── */
.decision-card {
    display: block;
    color: inherit;
}

.decision-card.urgent {
    border-left: 3px solid var(--danger);
}

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

.decision-time {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.decision-summary {
    margin-bottom: 8px;
    line-height: 1.5;
}

.decision-recommendation {
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ── Issue Detail ───────────────────────────────────────────── */
.back-link {
    display: inline-block;
    margin-bottom: 24px;
    color: var(--text-secondary);
    font-weight: 500;
}

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

.issue-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.issue-header-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

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

.issue-category,
.issue-risk {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 4px 12px;
    background: var(--bg-input);
    border-radius: 20px;
}

.issue-dates {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    gap: 20px;
}

.info-card {
    padding: 24px;
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.info-card.highlight {
    border-left: 3px solid var(--accent);
    background: linear-gradient(135deg, var(--bg-card), rgba(99, 102, 241, 0.05));
}

.original-text {
    color: var(--text-secondary);
    font-style: italic;
    white-space: pre-wrap;
}

/* ── Decision Detail ────────────────────────────────────────── */
.decision-detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.decision-detail-card.pending {
    border-color: var(--warning);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.1);
}

.decision-detail-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.decision-summary-text p {
    margin-bottom: 8px;
    line-height: 1.6;
}

.decision-form {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.decision-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.decision-result {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── Messages ───────────────────────────────────────────────── */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-bubble {
    padding: 16px;
    border-radius: var(--radius);
    max-width: 80%;
}

.message-bubble.inbound {
    background: var(--bg-card);
    border: 1px solid var(--border);
    align-self: flex-start;
}

.message-bubble.outbound {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.2);
    align-self: flex-end;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.message-sender {
    font-weight: 600;
    text-transform: capitalize;
    color: var(--accent);
}

.message-time {
    color: var(--text-muted);
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.data-table th {
    background: var(--bg-input);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.clickable-row {
    cursor: pointer;
    transition: var(--transition);
}

.clickable-row:hover {
    background: var(--bg-card-hover);
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-lg {
    font-size: 0.85rem;
    padding: 6px 16px;
}

.badge-new,
.badge-active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
}

.badge-triaged {
    background: rgba(6, 182, 212, 0.15);
    color: var(--info);
}

.badge-escalated,
.badge-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-approved {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-rejected,
.badge-closed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-deferred {
    background: rgba(156, 163, 175, 0.15);
    color: var(--text-muted);
}

.badge-modified {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.badge-in_progress {
    background: rgba(6, 182, 212, 0.15);
    color: var(--info);
}

.badge-resolved {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-vacant {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-maintenance {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-former {
    background: rgba(156, 163, 175, 0.15);
    color: var(--text-muted);
}

.badge-applicant {
    background: rgba(6, 182, 212, 0.15);
    color: var(--info);
}

.badge-unregistered {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.urgency {
    font-weight: 600;
    font-size: 0.85rem;
}

.urgency-emergency {
    color: var(--danger);
}

.urgency-urgent {
    color: var(--warning);
}

.urgency-routine {
    color: var(--text-secondary);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: white;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: var(--warning);
    color: #1a1a2e;
}

.btn-warning:hover {
    background: #d97706;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-full {
    width: 100%;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

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

/* ── Modals ─────────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 520px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* ── Auth Pages ─────────────────────────────────────────────── */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.auth-container {
    text-align: center;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    max-width: 420px;
    width: 90vw;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    margin-bottom: 32px;
}

.auth-logo {
    font-size: 3rem;
    display: block;
    margin-bottom: 16px;
}

.auth-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-top: 8px;
}

.auth-form {
    text-align: left;
}

.auth-footer {
    margin-top: 24px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Responsive ─────────────────────────────────────────────── */

/* Cover Delete Button */
.cover-delete-form {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
}

.cover-delete-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-photo:hover .cover-delete-btn {
    opacity: 1;
}

.cover-delete-btn:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* Unit Upload */
.unit-upload-form {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
}

.unit-card-thumb {
    width: calc(100% + 32px);
    height: 120px;
    margin: -16px -16px 12px;
    overflow: hidden;
}

.unit-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* Unit Thumbnail Delete */
.unit-card-thumb {
    position: relative;
}

.unit-thumb-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
}

.unit-card-thumb:hover .cover-delete-btn {
    opacity: 1;
}

/* Unit Photo Actions */
.unit-photo-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.unit-photo-count {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.7rem;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: block;
    }

    .page-header {
        display: flex;
        align-items: center;
    }

    .page-content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

    .decision-buttons {
        flex-direction: column;
    }

    .message-bubble {
        max-width: 95%;
    }

    .selector-units {
        grid-template-columns: 1fr !important;
    }

    .context-bar {
        flex-direction: column;
        gap: 4px !important;
    }
}

/* ── Button Variants ───────────────────────────────────────── */
.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 6px;
}

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 6px;
    border-radius: 4px;
    transition: var(--transition);
    opacity: 0.6;
}

.btn-icon:hover {
    opacity: 1;
    background: var(--bg-input);
}

/* ── Property Actions ──────────────────────────────────────── */
.property-actions-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.property-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

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

.property-name a:hover {
    color: var(--accent);
}

/* ── Building Summary ──────────────────────────────────────── */
.building-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
    padding: 10px 0;
}

/* ── Units ──────────────────────────────────────────────────── */
.unit-card {
    border-left: 3px solid var(--accent);
}

.unit-number-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 32px;
    padding: 0 10px;
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 6px;
}

.tenant-chip {
    display: inline-block;
    padding: 2px 10px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* ── Section Header ────────────────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header .section-title {
    margin-bottom: 0;
}

/* ── Tenant Selector ───────────────────────────────────────── */
.page-subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 1rem;
}

.selector-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    grid-column: 1 / -1;
}

.selector-group-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.selector-group-address {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.selector-units {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.selector-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    text-align: center;
}

.selector-card:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-2px);
    color: var(--text-primary);
}

.selector-card.standalone {
    padding: 24px;
}

.selector-card.building-card {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.selector-icon {
    font-size: 1.8rem;
}

.selector-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.selector-address {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.selector-count {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* ── Context Bar ───────────────────────────────────────────── */
.context-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ── Page Actions Split ────────────────────────────────────── */
.page-actions-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-actions-split .back-link {
    margin-bottom: 0;
}

/* ── Profile Card ──────────────────────────────────────────── */
.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
}

.profile-info h2 {
    font-size: 1.3rem;
    margin-bottom: 6px;
}

.profile-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-property {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.profile-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

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

.detail-item.detail-full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.detail-value {
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* ── Mini Stat Cards ───────────────────────────────────────── */
.stats-grid-sm {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card.mini {
    padding: 16px;
    text-align: center;
}

.stat-card.mini .stat-value {
    font-size: 1.6rem;
}

.stat-card.mini .stat-label {
    font-size: 0.75rem;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: var(--font);
}

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

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-panel {
    display: none;
}

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

/* ── Message Bubbles ───────────────────────────────────────── */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.message-bubble.inbound {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-bubble.outbound {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-bottom-right-radius: 4px;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-sender {
    font-weight: 600;
}

.message-bubble p {
    margin: 0;
}

/* ── Send Message Form ─────────────────────────────────────── */
.send-form {
    margin-top: 8px;
}

.send-input-row {
    display: flex;
    gap: 8px;
}

.send-input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: var(--transition);
}

.send-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Lease Cards ───────────────────────────────────────────── */
.lease-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    transition: var(--transition);
}

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

.lease-rent {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success);
}

.lease-dates {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.lease-detail {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ── Empty State Small ─────────────────────────────────────── */
.empty-state.empty-sm {
    padding: 32px 20px;
}

.empty-state.empty-sm .empty-icon {
    font-size: 2rem;
}

/* ── Clickable Tenant Names ────────────────────────────────── */
.tenant-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.tenant-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ── Responsive: Tenant Detail ─────────────────────────────── */

/* Cover Delete Button */
.cover-delete-form {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
}

.cover-delete-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-photo:hover .cover-delete-btn {
    opacity: 1;
}

.cover-delete-btn:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* Unit Upload */
.unit-upload-form {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
}

.unit-card-thumb {
    width: calc(100% + 32px);
    height: 120px;
    margin: -16px -16px 12px;
    overflow: hidden;
}

.unit-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* Unit Thumbnail Delete */
.unit-card-thumb {
    position: relative;
}

.unit-thumb-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
}

.unit-card-thumb:hover .cover-delete-btn {
    opacity: 1;
}

/* Unit Photo Actions */
.unit-photo-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.unit-photo-count {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.7rem;
}

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

    .stats-grid-sm {
        grid-template-columns: repeat(2, 1fr);
    }

    .message-bubble {
        max-width: 90%;
    }
}

/* ── Conversation Cards ────────────────────────────────────── */
.conversation-card {
    display: flex;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.conversation-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateX(4px);
}

.conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #06b6d4, #22d3ee);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

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

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

.conv-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.conv-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.conv-preview {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0 0 6px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-you {
    color: var(--accent);
    font-weight: 600;
}

.conv-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.conv-property,
.conv-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.badge-xs {
    font-size: 0.65rem;
    padding: 2px 6px;
}

/* ── Filter Bar ────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar select,
.filter-bar input {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    transition: var(--transition);
}

.filter-bar select:focus,
.filter-bar input:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-bar .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
}

/* ── Risk Level ────────────────────────────────────────────── */
.risk {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.risk-low {
    color: var(--success);
}

.risk-medium {
    color: var(--warning);
}

.risk-high {
    color: #f97316;
}

.risk-critical {
    color: var(--danger);
    font-weight: 800;
}

/* ── Ghost Button ──────────────────────────────────────────── */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    text-decoration: none;
    padding: 8px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
}

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

/* ── Leases Page ───────────────────────────────────────────── */
.lease-list-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px 24px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.lease-list-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}

.lease-list-card.expiring {
    border-left: 3px solid var(--warning);
}

.lease-list-card.expired {
    border-left: 3px solid var(--danger);
    opacity: 0.7;
}

.lease-main {
    flex: 1;
    min-width: 0;
}

.lease-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.lease-title a {
    color: var(--accent);
    text-decoration: none;
}

.lease-title a:hover {
    text-decoration: underline;
}

.lease-info-row {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.lease-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Financial Overview ────────────────────────────────────── */
.finance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.finance-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.finance-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.finance-value {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--success), #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.finance-value.warning {
    background: linear-gradient(135deg, var(--warning), #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.finance-value.danger {
    background: linear-gradient(135deg, var(--danger), #f87171);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.finance-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.property-finance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.property-finance-row:last-child {
    border-bottom: none;
}

.property-finance-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.property-finance-amount {
    font-weight: 700;
    color: var(--success);
}

/* ── Form Row (side-by-side fields) ────────────────────────── */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════════
   CANVAS & CONTROLLER — Split Pane Layout
   ═══════════════════════════════════════════════════════════════ */

/* ── Page Header — flex row for title + toggle ── */
.page-header {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    gap: 12px;
}

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    flex: 1;
}

.ai-ctrl-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-ctrl-toggle:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.ai-ctrl-toggle.inactive {
    color: var(--text-muted);
    border-color: var(--border);
    background: var(--bg-secondary);
}

.ai-ctrl-toggle.inactive:hover {
    color: var(--accent);
    background: var(--accent-glow);
}

/* ── Split Pane Container ── */
.split-pane {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* Constraints flex children to scroll rather than push boundaries */
}

.canvas-pane {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-width: 0;
    transition: flex 0.3s ease;
}

/* ── Draggable Divider ── */
.split-divider {
    width: 5px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    transition: background 0.2s, width 0.3s;
    z-index: 10;
}

.split-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 32px;
    border-radius: 2px;
    background: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
}

.split-divider:hover,
.split-divider.active {
    background: var(--accent);
    width: 5px;
}

.split-divider:hover::after,
.split-divider.active::after {
    opacity: 1;
}

.split-divider.collapsed {
    width: 0;
    overflow: hidden;
    cursor: default;
}

/* ── Controller Pane (AI Chat Column) ── */
.ctrl-pane {
    width: 380px;
    min-width: 0;
    background: var(--bg-secondary);
    border-left: none;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.ctrl-pane.collapsed {
    width: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* Controller Header */
.ctrl-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

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

.ctrl-header-icon {
    font-size: 1.3rem;
}

.ctrl-header-info strong {
    font-size: 0.9rem;
    color: var(--text-primary);
    display: block;
}

.ctrl-header-info small {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.ctrl-header-actions {
    display: flex;
    gap: 4px;
}

.ctrl-btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ctrl-btn-icon:hover {
    background: var(--bg-card);
    color: var(--accent);
    border-color: var(--accent);
}

/* Controller Messages Area */
.ctrl-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    scroll-behavior: smooth;
}

.ctrl-welcome {
    text-align: center;
    padding: 40px 16px;
}

.ctrl-welcome-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 12px;
}

.ctrl-welcome p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* Controller Messages */
.ctrl-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: flex-start;
    animation: none;
}

.ctrl-msg-animate {
    animation: ctrl-fade-in 0.25s ease;
}

@keyframes ctrl-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ctrl-msg-user {
    flex-direction: row-reverse;
}

.ctrl-msg-avatar {
    font-size: 1rem;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-card);
}

.ctrl-msg-user .ctrl-msg-avatar {
    background: var(--accent-glow);
}

.ctrl-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 85%;
    color: var(--text-primary);
}

.ctrl-msg-ai .ctrl-msg-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.ctrl-msg-user .ctrl-msg-bubble {
    background: var(--accent);
    color: white;
}

.ctrl-msg-bubble strong {
    color: inherit;
    font-weight: 600;
}

.ctrl-msg-bubble code {
    background: rgba(255,255,255,0.08);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.ctrl-msg-bubble pre {
    background: var(--bg-primary);
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 6px 0;
    font-size: 0.8rem;
}

.ctrl-msg-bubble ul {
    margin: 4px 0;
    padding-left: 16px;
}

.ctrl-msg-bubble li {
    margin: 2px 0;
}

.ctrl-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.ctrl-link:hover {
    text-decoration: underline;
}

/* Typing indicator */
.ctrl-typing .ctrl-msg-bubble {
    padding: 14px 18px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }

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

/* Controller Input Area */
.ctrl-input-area {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.ctrl-input-area textarea {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text-primary);
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.ctrl-input-area textarea:focus {
    border-color: var(--accent);
}

.ctrl-btn-send {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}

.ctrl-btn-send:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

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

/* ── Mobile — Controller auto-hides ── */
@media (max-width: 1024px) {
    .ctrl-pane {
        position: fixed;
        right: 0;
        top: 57px;
        bottom: 0;
        width: 340px !important;
        z-index: 90;
        box-shadow: -4px 0 20px rgba(0,0,0,0.4);
    }

    .ctrl-pane.collapsed {
        width: 0 !important;
        box-shadow: none;
    }

    .split-divider {
        display: none;
    }
}





/* ═══════════════════════════════════════════════════════════════
   AI CHAT — FULL PAGE
   ═══════════════════════════════════════════════════════════════ */

.aichat-layout {
    display: flex;
    height: calc(100vh - 80px);
    margin: -24px;
    overflow: hidden;
}

/* Session Sidebar */
.aichat-sidebar {
    width: 260px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.aichat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
}

.aichat-sidebar-header h3 {
    margin: 0;
    font-size: 14px;
    color: #495057;
}

.aichat-btn-new-session {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #495057;
    transition: all 0.2s;
}

.aichat-btn-new-session:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

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

.aichat-session-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 8px 8px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: background 0.15s;
}

.aichat-session-content {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.aichat-session-item:hover {
    background: var(--bg-card-hover);
}

.aichat-session-item.active {
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
}

.aichat-session-delete {
    opacity: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.aichat-session-item:hover .aichat-session-delete {
    opacity: 0.5;
}

.aichat-session-delete:hover {
    opacity: 1 !important;
    background: rgba(239, 68, 68, 0.15);
}

.aichat-session-preview {
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.aichat-session-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.aichat-session-empty,
.aichat-session-loading {
    text-align: center;
    padding: 24px 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.cover-photo {
    position: relative;
    width: 100%;
    max-width: 1000px;
    height: auto !important;
    min-height: 100px;
    max-height: 500px !important;
    border-radius: 16px;
    margin: 0 0 24px 0;
    cursor: pointer;
    background: #0f172a;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cover-photo img {
    max-width: 100% !important;
    max-height: 500px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important; /* Show whole image, no zoom */
    display: block;
    transition: transform 0.3s;
}

/* Main Chat Area */
.aichat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
}

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

/* Messages */
.aichat-msg {
    max-width: 680px;
    margin: 0 auto 24px;
    padding: 0 16px;
}

.aichat-msg-animate {
    animation: aichat-fadein 0.3s ease;
}

@keyframes aichat-fadein {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aichat-msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.aichat-msg-avatar {
    font-size: 18px;
}

.aichat-msg-header strong {
    font-size: 13px;
    color: var(--text-primary);
}

.aichat-msg-content {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-primary);
    padding-left: 26px;
}

.aichat-msg-content strong {
    color: #ffffff;
}

.aichat-msg-content code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.aichat-msg-content pre {
    background: #1a1a2e;
    color: #e9ecef;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.aichat-msg-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.aichat-msg-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.aichat-msg-content li {
    margin: 4px 0;
}

.aichat-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
    transition: all 0.2s;
}

.aichat-link:hover {
    color: #764ba2;
    border-bottom-color: #764ba2;
}

.aichat-msg-user .aichat-msg-content {
    color: var(--text-primary);
}

.aichat-msg-ai {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

/* Welcome State */
.aichat-welcome {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    padding: 80px 24px 40px;
}

.aichat-welcome-logo {
    font-size: 56px;
    margin-bottom: 16px;
}

.aichat-welcome h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.aichat-welcome p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 32px;
}


/* ── AI Assistant Chat ───────────────────────────────────────── */
.aichat-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.aichat-suggestions button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.aichat-suggestions button:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.aichat-sug-icon {
    font-size: 20px;
}

.aichat-input-bar {
    border-top: 1px solid var(--border);
    padding: 16px 24px 12px;
    background: var(--bg-secondary);
}

.aichat-input-wrapper {
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

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

.aichat-input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 160px;
    line-height: 1.5;
    padding: 4px 0;
    color: var(--text-primary);
}

.aichat-btn-send {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.aichat-disclaimer {
    display: block;
    text-align: center;
    color: #adb5bd;
    font-size: 11px;
    margin-top: 8px;
}

/* ── Repair Research ────────────────────────────────────────── */
.repair-research {
    background-color: #f8faff;
    padding: 24px;
    border-radius: 16px;
}

.vendor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.vendor-card {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ═══════════════════════════════════════════════════════════════
   PROPERTY IMAGE GALLERY — REFINED & STABLE
   ═══════════════════════════════════════════════════════════════ */

/* FIXED: Cover Photo Scaling */
.cover-photo {
    position: relative;
    width: 100%;
    max-width: 900px; /* Constrain width */
    border-radius: 16px;
    margin: 0 0 24px 0;
    cursor: pointer;
    background: #0f172a;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.cover-photo img {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cover-photo:hover img {
    transform: scale(1.03);
}

.cover-photo-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Overlays & Actions */
.cover-delete-form, .unit-thumb-delete {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
}

.cover-delete-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cover-photo:hover .cover-delete-btn,
.unit-card-thumb:hover .cover-delete-btn {
    opacity: 1;
}

.cover-delete-btn:hover {
    background: #ef4444;
}

/* Unit Cards Management */
.unit-card-thumb {
    position: relative;
    width: calc(100% + 32px);
    margin: -16px -16px 12px;
    cursor: pointer;
    background: #0f172a;
}

.unit-card-thumb img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
    border-radius: 14px 14px 0 0;
}

.unit-photo-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #2d2d48;
}

.unit-photo-count {
    font-size: 0.75rem;
    color: #9898b0;
}

/* Gallery Modal System */
.gallery-modal-content {
    max-width: 1000px;
    max-height: 90vh;
    border-radius: 20px;
    background: var(--bg-card);
}

.gallery-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    padding: 24px;
}

.gallery-modal-item {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: #0f172a;
    border: 2px solid transparent;
}

.gallery-modal-item.is-primary {
    border-color: var(--accent);
}

.gallery-modal-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-modal-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-modal-item:hover .gallery-modal-actions {
    opacity: 1;
}

.gallery-action-btn {
    flex: 1;
    background: white;
    color: #0f172a;
    border: none;
    padding: 6px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
}

.gallery-action-danger {
    background: #fee2e2;
    color: #ef4444;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .cover-photo {
        border-radius: 12px;
    }
    
    .gallery-modal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   PROPERTY DETAIL TABS
   ═══════════════════════════════════════════════════════════════ */

/* Tab Bar */
.detail-tabs {
    display: flex;
    gap: 4px;
    margin: 24px 0 0;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.detail-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.detail-tab:hover {
    color: var(--text-primary);
    background: rgba(102, 126, 234, 0.05);
}

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

/* Tab Panels */
.tab-panel {
    display: none;
    padding-top: 24px;
}

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

/* ── Vitals Grid ───────────────────────────────────────────── */
.vitals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.vital-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vital-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.vital-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.vital-value-lg {
    font-size: 1.4rem;
    font-weight: 700;
}

.vital-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.vital-highlight {
    border-color: var(--accent);
    border-left: 3px solid var(--accent);
}

/* ── Occupancy Cards ───────────────────────────────────────── */
.occupancy-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.occupancy-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
}

.occupancy-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.occupancy-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.occupancy-info strong {
    font-size: 0.95rem;
}

/* ── Lease Summary ─────────────────────────────────────────── */
.lease-summary-card {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.lease-detail {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── AI Tasks ──────────────────────────────────────────────── */
.ai-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.ai-task-item:hover {
    border-color: var(--accent);
    background: rgba(102, 126, 234, 0.05);
}

.ai-task-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}

.ai-task-badge.badge-emergency,
.ai-task-badge.badge-urgent {
    background: #fef2f2;
    color: #ef4444;
}

.ai-task-badge.badge-routine {
    background: #f0f9ff;
    color: #3b82f6;
}

.ai-task-desc {
    flex: 1;
    font-size: 0.9rem;
}

.ai-task-status {
    flex-shrink: 0;
}

/* ── Small Empty State ─────────────────────────────────────── */
.empty-state-sm {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
}

.empty-state-sm span {
    font-size: 1.5rem;
}

.empty-state-sm p {
    margin: 0;
    font-size: 0.9rem;
}

/* ── Technical Profile Form ────────────────────────────────── */
.tech-form .section {
    margin-bottom: 8px;
}

/* ── Infrastructure Toggle Sections ────────────────────────── */
.infra-section {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    background: var(--bg-secondary);
    margin-bottom: 16px;
}

.infra-toggle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.infra-toggle-header .section-title {
    margin: 0;
}

.infra-toggle {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    min-width: 200px;
}

.infra-details {
    display: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.infra-details.open {
    display: block;
}

.section-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 4px 0 12px;
}

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

.tech-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .tech-grid-2col {
        grid-template-columns: 1fr;
    }
}

/* ── Appliances List ───────────────────────────────────────── */
.appliances-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.appliance-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
}

.appliance-row input {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

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

/* ── Document Vault ────────────────────────────────────────── */
.doc-upload-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.doc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
}

.doc-item:hover {
    border-color: var(--border-light);
}

.doc-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.doc-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.doc-info strong {
    font-size: 0.9rem;
}

.doc-info .text-muted {
    font-size: 0.75rem;
}

.doc-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* ── Document Preview Modal ───────────────────────────────── */
.doc-preview-modal {
    max-width: 900px;
    width: 90%;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.doc-preview-modal .modal-header {
    flex-shrink: 0;
}

.doc-preview-body {
    flex: 1;
    overflow: auto;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 0 16px 16px;
}


.text-muted {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ── Responsive Tab Overrides ──────────────────────────────── */
@media (max-width: 768px) {
    .detail-tabs {
        overflow-x: auto;
    }
    
    .detail-tab {
        padding: 10px 16px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    .vitals-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .lease-summary-card {
        grid-template-columns: 1fr 1fr;
    }
    
    .doc-item {
        flex-wrap: wrap;
    }
    
    .doc-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ═══════════════════════════════════════════════════════════════
   COMMAND CENTER — Merged Dashboard + AI Chat
   ═══════════════════════════════════════════════════════════════ */

.cmd-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    overflow: hidden;
    margin: -24px;
}

/* ── KPI Strip ── */
.cmd-kpi-strip {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
}

.cmd-kpi {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    min-width: 180px;
    flex: 1;
    position: relative;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.cmd-kpi:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.cmd-kpi-alert {
    border-color: var(--danger);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
    animation: cmd-pulse 2s ease-in-out infinite;
}

.cmd-kpi-warn {
    border-color: var(--warning, #f59e0b);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.12);
}

@keyframes cmd-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.15); }
    50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.3); }
}

.cmd-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 2px;
}

.cmd-kpi-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cmd-kpi-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
}

.cmd-kpi-data {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.cmd-kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.cmd-kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.cmd-kpi-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress bars inside KPI cards */
.cmd-kpi-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
    margin: 3px 0;
}

.cmd-kpi-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}

.cmd-kpi-bar-green {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.cmd-kpi-bar-indigo {
    background: linear-gradient(90deg, #6366f1, #818cf8);
}

/* ── Pinned Briefing Widget ── */
.cmd-briefing-pin {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    flex-shrink: 0;
    animation: cmd-slide-down 0.3s ease;
}

@keyframes cmd-slide-down {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.cmd-briefing-pin-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.cmd-briefing-pin-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.cmd-briefing-pin-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.cmd-briefing-pin-close:hover {
    background: rgba(255,255,255,0.05);
}

/* ── Chat Layout ── */
.cmd-chat-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Session Sidebar (Hidden by default) ── */
.cmd-sidebar {
    width: 0;
    overflow: hidden;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    transition: width 0.3s ease;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.cmd-sidebar.open {
    width: 280px;
}

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

.cmd-sidebar-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

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

/* ── Chat Main Area ── */
.cmd-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.cmd-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

/* ── Welcome / Briefing Screen ── */
.cmd-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 40px 20px;
}

.cmd-welcome-content {
    text-align: center;
    max-width: 640px;
    width: 100%;
}

.cmd-welcome-logo {
    font-size: 3.5rem;
    margin-bottom: 8px;
}

.cmd-welcome-content h2 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.cmd-briefing-text {
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin: 24px 0;
    line-height: 1.7;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.cmd-briefing-text strong {
    color: var(--text-primary);
}

.cmd-briefing-text ul {
    margin: 8px 0;
    padding-left: 20px;
}

.cmd-briefing-text li {
    margin-bottom: 6px;
}

/* ── Welcome Action Buttons ── */
.cmd-welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.cmd-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid var(--border);
    text-align: left;
}

.cmd-action-primary {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: white;
    border: none;
}

.cmd-action-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.cmd-action-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
}

.cmd-action-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.cmd-action-secondary span {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.85rem;
}

/* ── Welcome Loader ── */
.cmd-welcome-loader {
    text-align: center;
}

.cmd-loader-pulse {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    margin: 0 auto 16px;
    animation: cmd-loader-anim 1.2s ease-in-out infinite;
}

@keyframes cmd-loader-anim {
    0%, 100% { transform: scale(0.85); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
}

.cmd-welcome-loader p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ── Input Bar ── */
.cmd-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 24px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.cmd-toolbar {
    display: flex;
    flex-shrink: 0;
}

.cmd-toolbar-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cmd-toolbar-btn:hover {
    background: var(--bg-card);
    color: var(--primary);
    border-color: var(--primary);
}

.cmd-input-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cmd-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.cmd-input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    padding: 10px 12px;
    resize: none;
    max-height: 160px;
    line-height: 1.5;
}

.cmd-btn-send {
    background: var(--primary);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.cmd-btn-send:hover {
    background: var(--primary-hover, #4f46e5);
    transform: scale(1.05);
}

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

/* ── Responsive ── */
@media (max-width: 768px) {
    .cmd-kpi-strip {
        padding: 12px 16px;
        gap: 8px;
    }

    .cmd-kpi {
        min-width: 130px;
        padding: 10px 12px;
    }

    .cmd-kpi-value {
        font-size: 1.1rem;
    }

    .cmd-kpi-title {
        display: none;
    }

    .cmd-sidebar.open {
        position: absolute;
        z-index: 100;
        width: 280px;
        height: 100%;
        top: 0;
        left: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    .cmd-messages {
        padding: 16px;
    }

    .cmd-input-bar {
        padding: 8px 16px 12px;
    }
}

