* { box-sizing: border-box; }
:root {
  --bg: #f4f6f8; --panel: #ffffff; --line: #e4e8ec; --text: #1f2933;
  --muted: #7b8794; --accent: #128c7e; --accent-ink: #ffffff;
  --in: #ffffff; --out: #d9fdd3; --shadow: 0 1px 3px rgba(0,0,0,.06);
}
html, body { height: 100%; margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.error { color: #c0392b; margin-top: 8px; min-height: 18px; font-size: 13px; }

/* login */
.login { height: 100%; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); padding: 32px; border-radius: 14px; box-shadow: var(--shadow);
  width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0 0 8px; }
.login-card input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.login-card button, .reply button {
  background: var(--accent); color: var(--accent-ink); border: 0; padding: 11px;
  border-radius: 8px; font-size: 14px; cursor: pointer; }

/* layout */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; }
.spacer { flex: 1; }
.who { color: var(--muted); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 14px; }
.body { flex: 1; display: flex; min-height: 0; }

/* pill */
.pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-green { background: #e3f6ec; color: #0f7b48; }
.pill-amber { background: #fef3c7; color: #92600a; }
.pill-red { background: #fde8e8; color: #b42318; }
.pill-gray { background: #eceff1; color: #647380; }

/* conversation list */
.list { width: 320px; border-right: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
.conv-list { overflow-y: auto; flex: 1; }
.conv { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv:hover { background: #f7f9fa; }
.conv.active { background: #eef6f5; }
.conv-top { display: flex; justify-content: space-between; align-items: center; }
.conv-name { font-weight: 600; }
.conv-prev { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }

/* thread */
.thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.thread-head { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--line); background: var(--panel); }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; flex-direction: column; max-width: 68%; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 8px 12px; border-radius: 10px; box-shadow: var(--shadow); word-wrap: break-word; }
.msg.in .bubble { background: var(--in); }
.msg.out .bubble { background: var(--out); }
.meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.failed { color: #c0392b; font-weight: 600; }
audio { height: 34px; }

/* reply */
.reply { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.reply input { flex: 1; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.reply button[type="submit"] { padding: 11px 20px; }
.icon-btn { background: #eef2f4; border: 1px solid var(--line); border-radius: 8px; width: 42px; font-size: 18px; cursor: pointer; }
.icon-btn:hover { background: #e5eaed; }
.icon-btn.recording { background: #fde8e8; border-color: #f3b4b4; }

/* media in thread */
.media-img { max-width: 240px; max-height: 260px; border-radius: 8px; display: block; cursor: pointer; }
.cap { margin-top: 4px; }
.agent { font-weight: 600; color: var(--accent); }
.ok { color: #0f7b48; font-size: 13px; margin-top: 6px; }

/* overlays / modals */
.overlay { position: fixed; inset: 0; background: rgba(20,28,34,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border-radius: 14px; width: 480px; max-width: 92vw; max-height: 86vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal-head .x { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-sub { font-weight: 600; margin: 16px 0 8px; }

.staff-list { display: flex; flex-direction: column; gap: 8px; }
.staff-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; gap: 8px; }
.staff-row.inactive { opacity: .6; }
.staff-name { font-weight: 600; }
.staff-email { color: var(--muted); font-size: 13px; }
.staff-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.staff-actions button { font-size: 12px; padding: 5px 8px; border: 1px solid var(--line); background: #f7f9fa; border-radius: 6px; cursor: pointer; }
.staff-actions button:hover { background: #eef2f4; }
.tag { font-size: 11px; background: #e3f6ec; color: #0f7b48; padding: 1px 6px; border-radius: 999px; font-weight: 600; }
.tag.off { background: #fde8e8; color: #b42318; }

.add-user { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-user input, .add-user select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.add-user button { grid-column: 1 / -1; background: var(--accent); color: #fff; border: 0; padding: 10px; border-radius: 8px; cursor: pointer; }

.pw-form { display: flex; flex-direction: column; gap: 10px; }
.pw-form input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.pw-form button { background: var(--accent); color: #fff; border: 0; padding: 11px; border-radius: 8px; cursor: pointer; }
