:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --outgoing: #0f766e;
    --incoming: #f1f5f9;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Auth Card */
.auth-card {
    background: var(--surface);
    width: 100%;
    max-width: 410px;
    padding: 32px 24px;
    border-radius: 20px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    margin: 16px;
}

.brand-header {
    text-align: center;
    margin-bottom: 20px;
}

.brand-badge {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary);
    color: #fff;
    font-size: 28px;
    font-weight: 800;
    display: grid;
    place-items: center;
    margin: 0 auto 12px;
}

.brand-header p {
    color: var(--muted);
    font-size: 13.5px;
    margin-top: 6px;
    line-height: 1.45;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: var(--surface-alt);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.auth-tab {
    padding: 9px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
}

.auth-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input,
.add-contact-box input,
.search-box input,
.message-composer input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    background: var(--surface);
    color: var(--text);
}

.auth-form input:focus,
.add-contact-box input:focus,
.search-box input:focus,
.message-composer input:focus {
    border-color: var(--primary);
}

.auth-form button,
.message-composer button {
    padding: 12px 18px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.auth-form button:hover,
.message-composer button:hover {
    background: var(--primary-dark);
}

.auth-hint {
    margin-top: 14px;
    font-size: 12.5px;
    color: var(--muted);
    text-align: center;
}

/* Main App Shell */
.app-shell {
    width: 100%;
    max-width: 1080px;
    height: 92vh;
    background: var(--surface);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.1);
    margin: 12px;
}

.sidebar {
    width: 330px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--surface-alt);
}

.sidebar-top {
    padding: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-pill strong {
    display: block;
    font-size: 15px;
}

.user-pill small {
    display: block;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-dot {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.ghost-btn {
    padding: 7px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.add-contact-box {
    display: flex;
    gap: 8px;
    padding: 12px 14px 6px;
}

.add-contact-box button {
    width: 44px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}

.search-box {
    padding: 6px 14px 10px;
}

.section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    padding: 4px 16px 8px;
    letter-spacing: 0.4px;
}

.contacts-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.contact-item {
    padding: 12px 16px;
    border-bottom: 1px solid #eef2f6;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-item:hover {
    background: #e2e8f0;
}

.contact-item.active {
    background: #ccfbf1;
}

.contact-phone {
    font-size: 14.5px;
    font-weight: 600;
}

.contact-tag {
    font-size: 11px;
    color: var(--muted);
}

/* Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

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

.chat-header h2 {
    font-size: 16px;
}

.chat-header small {
    color: var(--muted);
    font-size: 12px;
}

.messages-feed {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
}

.empty-state {
    margin: auto;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.msg-bubble {
    max-width: 72%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-out {
    align-self: flex-end;
    background: var(--outgoing);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg-in {
    align-self: flex-start;
    background: var(--incoming);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-meta {
    font-size: 11px;
    opacity: 0.78;
}

.message-composer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    background: var(--surface);
}

@media (max-width: 760px) {
    .app-shell {
        flex-direction: column;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .sidebar {
        width: 100%;
        height: 42%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .chat-panel {
        height: 58%;
    }
}
