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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.5;
}

/* --- Nav --- */
.navbar {
    background: #1a1a2e;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.navbar .brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}
.navbar .nav-links { display: flex; gap: 0.25rem; }
.navbar .nav-links a {
    color: #a0a0c0;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}
.navbar .nav-links a:hover,
.navbar .nav-links a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* --- Layout --- */
.container {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* --- Cards --- */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}

/* --- Period Filters --- */
.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.filters a {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    background: #e8ecf1;
    color: #555;
    transition: background 0.15s, color 0.15s;
}
.filters a:hover { background: #d0d6df; }
.filters a.active {
    background: #4A90D9;
    color: #fff;
}

/* --- Funnel --- */
.funnel { display: flex; flex-direction: column; align-items: center; gap: 0; }
.funnel-stage {
    padding: 1rem 1.5rem;
    text-align: center;
    color: #fff;
    font-weight: 600;
    position: relative;
    transition: opacity 0.2s;
    border-radius: 4px;
    margin-bottom: 2px;
}
.funnel-stage:hover { opacity: 0.9; }
.funnel-count {
    font-size: 1.8rem;
    font-weight: 700;
    display: block;
}
.funnel-label {
    font-size: 0.85rem;
    opacity: 0.9;
}
.funnel-pct {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}

/* --- Table --- */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 2px solid #e8ecf1;
    color: #777;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}
td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #f0f0f0;
}
tr:hover td { background: #fafbfc; }
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-green { background: #e6f9e6; color: #2d7a2d; }
.badge-red { background: #fde8e8; color: #b91c1c; }
.badge-blue { background: #e8f0fe; color: #1a56db; }
.badge-yellow { background: #fef3c7; color: #92400e; }
a.btn-chat {
    color: #4A90D9;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
}
a.btn-chat:hover { text-decoration: underline; }

/* --- Search --- */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.search-bar input {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
}
.search-bar input:focus { border-color: #4A90D9; }
.search-bar button {
    padding: 0.5rem 1.2rem;
    background: #4A90D9;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* --- Chat --- */
.chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}
.chat-header h2 { font-size: 1.1rem; }
.chat-header .meta { color: #888; font-size: 0.85rem; }
.chat-messages {
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
}
.msg {
    max-width: 75%;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.msg-in {
    align-self: flex-start;
    background: #e8ecf1;
    color: #333;
    border-bottom-left-radius: 4px;
}
.msg-out {
    align-self: flex-end;
    background: #4A90D9;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-time {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 0.2rem;
}
.chat-input {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}
.chat-input textarea {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 44px;
    max-height: 150px;
    font-family: inherit;
    outline: none;
}
.chat-input textarea:focus { border-color: #4A90D9; }
.chat-input button {
    padding: 0.6rem 1.5rem;
    background: #4A90D9;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    align-self: flex-end;
}
.chat-input button:hover { background: #357abd; }

/* --- Broadcast --- */
.broadcast-form textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
    outline: none;
    margin-bottom: 1rem;
}
.broadcast-form textarea:focus { border-color: #4A90D9; }
.broadcast-info {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.btn-send {
    padding: 0.7rem 2rem;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}
.btn-send:hover { background: #c0392b; }

/* --- Login --- */
.login-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #1a1a2e;
}
.login-card {
    background: #fff;
    padding: 2.5rem 2rem;
    border-radius: 12px;
    width: 360px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.login-card h1 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    text-align: center;
}
.login-card label {
    display: block;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.3rem;
}
.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    outline: none;
}
.login-card input:focus { border-color: #4A90D9; }
.login-card button {
    width: 100%;
    padding: 0.7rem;
    background: #4A90D9;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
}
.login-card button:hover { background: #357abd; }
.login-error {
    background: #fde8e8;
    color: #b91c1c;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* --- Messages (Django) --- */
.django-messages {
    margin-bottom: 1rem;
}
.django-messages .alert {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.alert-success { background: #e6f9e6; color: #2d7a2d; }
.alert-error { background: #fde8e8; color: #b91c1c; }

/* --- Empty state --- */
.empty {
    text-align: center;
    color: #999;
    padding: 3rem 1rem;
    font-size: 0.95rem;
}
