:root {
    --bg-0: #070b14;
    --bg-1: #0d1424;
    --card: rgba(255,255,255,0.04);
    --border: rgba(255,255,255,0.08);
    --text: #e8edf7;
    --muted: #8b9bb8;
    --accent: #6366f1;
    --cyan: #22d3ee;
    --err: #f87171;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background: var(--bg-0);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.45;
}
.mesh {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(99,102,241,.28), transparent),
        radial-gradient(ellipse 60% 40% at 90% 0%, rgba(34,211,238,.14), transparent),
        linear-gradient(180deg, var(--bg-0), var(--bg-1));
}
.muted { color: var(--muted); font-size: .8rem; }
.err { color: var(--err); font-size: .85rem; }
.err.pad { padding: 0 1rem .75rem; }
.link { color: var(--cyan); text-decoration: none; font-size: .8rem; }
.link:hover { text-decoration: underline; }

/* Login */
.staff-login { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card {
    position: relative; z-index: 1;
    width: min(400px, 100%);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.75rem;
    backdrop-filter: blur(12px);
}
.login-card h1 { font-size: 1.35rem; margin-bottom: .35rem; }
.login-card .muted { margin-bottom: 1.25rem; }
.login-card label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .4rem; }
.login-card input {
    width: 100%;
    padding: .85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,.25);
    color: var(--text);
    font: inherit;
    margin-bottom: .85rem;
}
.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.login-card button, .reply button {
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: .85rem 1.2rem;
    font-weight: 600;
    font: inherit;
    cursor: pointer;
}
.login-card button { width: 100%; }
.login-card .err { margin-bottom: .75rem; }

/* App shell */
.staff-app { height: 100vh; overflow: hidden; }
.shell {
    position: relative; z-index: 1;
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
}
.inbox, .thread {
    background: rgba(13,20,36,.85);
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.inbox {
    border-right: none;
    border-radius: 0;
}
.thread { border-radius: 0; }
.inbox-head, .thread-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
}
.inbox-head h1, .thread-head h2 { font-size: 1.05rem; font-weight: 600; }
.inbox-actions, .thread-actions { display: flex; align-items: center; gap: .65rem; }
.inbox-actions select {
    background: rgba(0,0,0,.25);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .35rem .5rem;
    font: inherit;
    font-size: .8rem;
}
.inbox-list { overflow-y: auto; flex: 1; }
.conv-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: .9rem 1.1rem;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
}
.conv-item:hover { background: rgba(255,255,255,0.03); }
.conv-item.active { background: rgba(99,102,241,0.12); }
.conv-item .title { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.conv-item .preview {
    font-size: .78rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-item .when { font-size: .7rem; color: var(--muted); margin-top: .25rem; }
.badge-closed {
    display: inline-block;
    font-size: .65rem;
    padding: .1rem .4rem;
    border-radius: 999px;
    background: rgba(139,155,184,.15);
    color: var(--muted);
    margin-left: .35rem;
    vertical-align: middle;
}
.thread-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}
.placeholder { margin: auto; color: var(--muted); font-size: .9rem; }
.bubble {
    max-width: 75%;
    padding: .6rem .8rem;
    border-radius: 14px;
    font-size: .9rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.bubble.visitor {
    align-self: flex-start;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
}
.bubble.staff {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: #fff;
}
.bubble .who {
    display: block;
    font-size: .65rem;
    opacity: .75;
    margin-bottom: .2rem;
}
.reply {
    display: flex;
    gap: .5rem;
    padding: .85rem 1rem;
    border-top: 1px solid var(--border);
}
.reply textarea {
    flex: 1;
    resize: none;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,.25);
    color: var(--text);
    padding: .65rem .75rem;
    font: inherit;
}
.reply textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: .4rem .7rem;
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}
.ghost:hover { background: rgba(255,255,255,0.05); }
.empty-inbox {
    padding: 2rem 1.1rem;
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
}
@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .inbox { max-height: 40vh; border-bottom: 1px solid var(--border); }
    .thread { min-height: 60vh; }
}
