:root {
    --ink: #17202a;
    --muted: #627084;
    --line: #dfe5eb;
    --bg: #f5f7f9;
    --panel: #ffffff;
    --green: #14a06f;
    --green-soft: #e7f7ef;
    --red: #d64545;
    --amber: #c98517;
    --blue: #2563eb;
    --teal: #0f766e;
    --shadow: 0 16px 40px rgba(23, 32, 42, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.sidebar {
    min-height: 100vh;
    padding: 22px;
    background: #111827;
    color: #f8fafc;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    background: var(--green);
    color: white;
    font-weight: 800;
}

.brand span,
.eyebrow,
.session label {
    color: var(--muted);
    font-size: 12px;
}

.brand span {
    display: block;
    color: #9ca3af;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav button {
    padding: 12px 14px;
    border-radius: 8px;
    background: transparent;
    color: #cbd5e1;
    text-align: left;
}

.nav button.active,
.nav button:hover {
    background: rgba(255, 255, 255, .1);
    color: white;
}

.quick-stats {
    margin-top: 28px;
    display: grid;
    gap: 10px;
}

.stat-pill {
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    background: rgba(255, 255, 255, .06);
}

.stat-pill strong {
    display: block;
    font-size: 24px;
}

.app-shell {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: 28px;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.session {
    display: grid;
    gap: 5px;
}

select,
input,
textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
}

select,
input {
    height: 40px;
    padding: 0 12px;
}

.view {
    display: none;
}

.view.is-visible {
    display: block;
}

.view-inbox.is-visible {
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(340px, 1fr) 310px;
    gap: 16px;
    min-height: calc(100vh - 112px);
}

.conversation-list,
.chat-panel,
.contact-panel,
.setup-note,
.whatsapp-status,
.template-tool {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.list-toolbar {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
}

.conversation-card {
    width: 100%;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: white;
    text-align: left;
}

.conversation-card:hover,
.conversation-card.active {
    background: #eef8f4;
}

.conversation-card h3 {
    margin: 0 0 5px;
    font-size: 15px;
}

.conversation-card p,
.contact-panel p,
.setup-note p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chip {
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #44546a;
    font-size: 12px;
}

.chip.green {
    background: var(--green-soft);
    color: var(--green);
}

.chip.amber {
    background: #fff3d7;
    color: var(--amber);
}

.chat-panel {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-width: 0;
}

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

.chat-header h2,
.contact-panel h2,
.setup-note h2 {
    margin: 0;
    font-size: 18px;
}

.messages {
    overflow: auto;
    padding: 18px;
    background:
        linear-gradient(rgba(255,255,255,.92), rgba(255,255,255,.92)),
        repeating-linear-gradient(45deg, #edf2f7 0 2px, transparent 2px 16px);
}

.message {
    max-width: min(78%, 620px);
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: white;
    border: 1px solid var(--line);
}

.message.out {
    margin-left: auto;
    background: #dcfce7;
    border-color: #b7efcb;
}

.message small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
}

.composer {
    display: grid;
    grid-template-columns: 1fr 112px;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--line);
}

.composer textarea {
    min-height: 64px;
    padding: 10px 12px;
    resize: vertical;
}

.composer button,
.primary-action {
    border-radius: 8px;
    background: var(--green);
    color: white;
    font-weight: 700;
}

.contact-panel {
    padding: 16px;
}

.contact-section {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.contact-section:last-child {
    border-bottom: 0;
}

.field {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.field label {
    color: var(--muted);
    font-size: 12px;
}

.board {
    display: grid;
    grid-template-columns: repeat(6, minmax(160px, 1fr));
    gap: 12px;
    overflow-x: auto;
}

.lane {
    min-height: 520px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.lane h2 {
    margin: 0;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    text-transform: capitalize;
}

.lane-card {
    margin: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.metrics-grid,
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.metric-card,
.team-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow);
}

.metric-card strong {
    display: block;
    font-size: 34px;
}

.team-card {
    display: grid;
    gap: 10px;
}

.team-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.avatar {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 8px;
    background: #e0f2fe;
    color: #075985;
    font-weight: 800;
}

.availability {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--red);
}

.availability.on {
    background: var(--green);
}

.team-card button {
    height: 38px;
    border-radius: 8px;
    background: #eef2f7;
    color: var(--ink);
}

.setup-note {
    margin-top: 16px;
    padding: 18px;
}

.template-tool {
    margin-top: 16px;
    padding: 18px;
}

.template-tool h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}

.template-grid label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.template-grid button {
    height: 40px;
    border-radius: 8px;
    background: var(--blue);
    color: white;
    font-weight: 800;
}

#templateResult {
    margin: 12px 0 0;
    color: var(--muted);
}

.whatsapp-status {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
    padding: 18px;
}

.status-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.status-item {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.status-item span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.status-ok {
    color: var(--green);
    font-weight: 800;
}

.status-bad {
    color: var(--red);
    font-weight: 800;
}

.setup-note code {
    display: inline-block;
    margin: 8px 8px 0 0;
    padding: 6px 8px;
    border-radius: 6px;
    background: #111827;
    color: white;
}

@media (max-width: 1100px) {
    body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
    }

    .view-inbox.is-visible {
        grid-template-columns: 320px 1fr;
    }

    .contact-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .app-shell {
        padding: 14px;
    }

    .topbar,
    .composer {
        grid-template-columns: 1fr;
        display: grid;
    }

    .view-inbox.is-visible {
        grid-template-columns: 1fr;
    }

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