/* ===== CVH Deal Pipeline Hub — Mobile-First Dark Theme ===== */
:root {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --text: #e8e8e8;
    --text-muted: #8892a4;
    --accent: #4f8cff;
    --accent-hover: #3a7aff;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --border: #2a2a4a;
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-container {
    width: 100%;
    max-width: 380px;
}
.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-header h1 {
    font-size: 28px;
    margin-bottom: 4px;
}
.login-header p {
    color: var(--text-muted);
}
.login-form .form-group {
    margin-bottom: 16px;
}

/* ===== Top Navigation ===== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand a {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 18px;
}
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg-input); }
.nav-btn-add {
    background: var(--accent) !important;
    color: white !important;
    font-weight: 600;
}
.nav-user { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-muted); font-size: 14px; }
.nav-logout {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ===== Bottom Navigation (Mobile) ===== */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 6px 0;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    z-index: 100;
}
.bottom-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    padding: 6px;
    min-height: 44px;
    justify-content: center;
}
.bottom-tab.active { color: var(--accent); }
.tab-icon { font-size: 20px; }
.tab-label { font-size: 11px; margin-top: 2px; }

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 80px;
}

/* ===== Flash Messages ===== */
.flash-messages { margin-bottom: 16px; }
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
}
.flash-success { background: rgba(46, 204, 113, 0.15); color: var(--success); border: 1px solid rgba(46, 204, 113, 0.3); }
.flash-danger { background: rgba(231, 76, 60, 0.15); color: var(--danger); border: 1px solid rgba(231, 76, 60, 0.3); }
.flash-info { background: rgba(79, 140, 255, 0.15); color: var(--accent); border: 1px solid rgba(79, 140, 255, 0.3); }

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h1 { font-size: 24px; font-weight: 700; }
.back-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}

/* ===== Stat Cards ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.stat-number { font-size: 32px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-new .stat-number { color: var(--accent); }
.stat-reviewing .stat-number { color: var(--warning); }
.stat-pursuing .stat-number { color: var(--success); }

/* ===== Source Badges ===== */
.source-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-sm { padding: 3px 10px; font-size: 11px; }
.badge-auction { background: rgba(231, 76, 60, 0.2); color: #e74c3c; }
.badge-mls { background: rgba(79, 140, 255, 0.2); color: #4f8cff; }
.badge-wholesaler { background: rgba(46, 204, 113, 0.2); color: #2ecc71; }
.badge-distressed { background: rgba(243, 156, 18, 0.2); color: #f39c12; }
.badge-manual { background: rgba(136, 146, 164, 0.2); color: #8892a4; }
.badge-count {
    background: rgba(255,255,255,0.15);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* ===== Deal Cards ===== */
.deal-cards {
    display: grid;
    gap: 12px;
}
.deal-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s;
}
.deal-card:hover { border-color: var(--accent); }
.deal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.deal-card-address { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.deal-card-town { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.deal-card-details {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.deal-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.deal-price { font-size: 18px; font-weight: 700; color: var(--success); }
.deal-date { font-size: 12px; color: var(--text-muted); }
.deal-score { font-size: 13px; color: var(--accent); }

/* ===== Status ===== */
.deal-status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 10px;
}
.status-new { background: rgba(79, 140, 255, 0.2); color: var(--accent); }
.status-reviewing { background: rgba(243, 156, 18, 0.2); color: var(--warning); }
.status-pursuing { background: rgba(46, 204, 113, 0.2); color: var(--success); }
.status-passed { background: rgba(136, 146, 164, 0.2); color: var(--text-muted); }
.status-closed { background: rgba(231, 76, 60, 0.2); color: var(--danger); }

.status-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.status-form {
    display: flex;
    gap: 8px;
    min-width: max-content;
}
.status-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    white-space: nowrap;
}
.status-btn:hover { border-color: var(--accent); color: var(--text); }
.status-active { border-color: var(--accent); color: white; }
.status-active.status-new { background: rgba(79, 140, 255, 0.3); border-color: var(--accent); }
.status-active.status-reviewing { background: rgba(243, 156, 18, 0.3); border-color: var(--warning); }
.status-active.status-pursuing { background: rgba(46, 204, 113, 0.3); border-color: var(--success); }
.status-active.status-passed { background: rgba(136, 146, 164, 0.3); border-color: var(--text-muted); }
.status-active.status-closed { background: rgba(231, 76, 60, 0.3); border-color: var(--danger); }

/* ===== Deal Detail ===== */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
}
.detail-title h1 { font-size: 22px; margin-top: 8px; }
.detail-location { color: var(--text-muted); font-size: 14px; }
.detail-price { font-size: 28px; font-weight: 700; color: var(--success); white-space: nowrap; }
.detail-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.detail-section h2 { font-size: 16px; margin-bottom: 12px; color: var(--text-muted); }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.detail-item label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.detail-item span { font-size: 16px; font-weight: 600; }
.score { color: var(--accent); }
.link-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.notes-content {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    background: var(--bg-input);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Activity Feed ===== */
.activity-feed { }
.activity-item {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-action { font-weight: 600; text-transform: capitalize; }
.activity-details { color: var(--text-muted); }
.activity-time { color: var(--text-muted); margin-left: auto; font-size: 12px; white-space: nowrap; }

/* ===== Filters ===== */
.filters { margin-bottom: 16px; }
.filter-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-form select {
    padding: 10px 14px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    min-height: 44px;
    flex: 1;
    min-width: 120px;
}

/* ===== Forms ===== */
.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.form-section h2 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-muted);
}
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    min-height: 44px;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-actions {
    margin-top: 16px;
    padding-bottom: 20px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    min-height: 44px;
    transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); }
.btn-full { width: 100%; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state a { color: var(--accent); }

/* ===== Section ===== */
.section { margin-bottom: 24px; }
.section h2 { font-size: 18px; margin-bottom: 12px; }

/* ===== Responsive ===== */
.mobile-only { display: none; }
.desktop-only { display: flex; }
.mobile-hide { }

@media (max-width: 768px) {
    .mobile-only { display: flex; }
    .desktop-only { display: none !important; }
    .mobile-hide { display: none !important; }

    .container { padding-bottom: 100px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-header { flex-direction: column; }
    .detail-price { font-size: 24px; }
    .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) {
    .container { padding: 24px 32px; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .deal-cards { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1025px) {
    .deal-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Watching Status ===== */
.status-watching { background: rgba(155, 89, 182, 0.2); color: #9b59b6; }
.stat-watching .stat-number { color: #9b59b6; }
.status-active.status-watching { background: rgba(155, 89, 182, 0.3); border-color: #9b59b6; }
.deal-card-watching { border-left: 3px solid #9b59b6; }

/* ===== Outcome Badges ===== */
.outcome-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}
.outcome-developed { background: rgba(46, 204, 113, 0.2); color: #2ecc71; }
.outcome-flipped { background: rgba(79, 140, 255, 0.2); color: #4f8cff; }
.outcome-held { background: rgba(243, 156, 18, 0.2); color: #f39c12; }
.outcome-demolished { background: rgba(231, 76, 60, 0.2); color: #e74c3c; }
.outcome-stalled { background: rgba(136, 146, 164, 0.2); color: #8892a4; }
.outcome-relisted { background: rgba(155, 89, 182, 0.2); color: #9b59b6; }
.outcome-unknown { background: rgba(136, 146, 164, 0.15); color: #666; }

/* ===== Outcome Form Toggle ===== */
.outcome-form-toggle {
    margin-top: 12px;
}
.outcome-form-toggle summary {
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    padding: 8px 0;
}
.outcome-form {
    margin-top: 12px;
}
.outcome-form .form-group {
    margin-bottom: 12px;
}

/* ===== Sold Price on Cards ===== */
.deal-sold {
    font-size: 13px;
    color: #9b59b6;
    font-weight: 600;
}

/* ===== Section Link ===== */
.section-link {
    display: inline-block;
    margin-top: 12px;
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
}
.section-link:hover { text-decoration: underline; }
