/* Agent dashboard styles */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e6e8ec;
  --line-2: #eef0f3;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eef3ff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --side: #0f172a;
  --side-2: #16213a;
  --side-ink: #cbd5e1;
  --side-muted: #64748b;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .07);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }

/* ---------- Layout ---------- */

.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.view { min-width: 0; min-height: 0; }

/* ---------- Sidebar ---------- */

.sidebar { display: flex; flex-direction: column; gap: 6px; padding: 18px 12px 14px; background: var(--side); color: var(--side-ink); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; color: #fff; font-weight: 650; font-size: 15px; }
.brand-mark { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: #fff; }
.brand-mark svg { width: 18px; height: 18px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--side-ink);
  font-weight: 500; text-align: left; cursor: pointer;
}
.nav-item svg { flex: none; width: 18px; height: 18px; opacity: .85; }
.nav-item:hover { background: var(--side-2); color: #fff; }
.nav-item.is-active { background: var(--side-2); color: #fff; }
.nav-item.is-active svg { opacity: 1; color: #93b4f8; }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.agent-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: var(--side-2); }
.agent-avatar {
  position: relative; flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: #334155; color: #fff; font-weight: 650; font-size: 13.5px;
}
.presence { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--side-2); background: var(--side-muted); }
.presence.is-online { background: #22c55e; }
.presence.is-away { background: #f59e0b; }
.agent-info { min-width: 0; display: flex; flex-direction: column; }
.agent-name { color: #fff; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-select { padding: 0; border: 0; background: transparent; color: var(--side-ink); font-size: 12.5px; cursor: pointer; }
.status-select option { color: var(--ink); }
.signout { align-self: flex-start; padding: 2px 10px; border: 0; background: transparent; color: var(--side-muted); font-size: 12.5px; cursor: pointer; }
.signout:hover { color: #fff; }

/* ---------- Shared bits ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
  border: 1px solid transparent; border-radius: 8px; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s ease, border-color .15s ease;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: #f8fafc; border-color: #d7dbe2; }
.btn-danger-ghost { background: #fff; border-color: var(--line); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: #fecaca; }
.btn-icon { padding: 7px; background: transparent; color: var(--ink-2); }
.btn-icon svg { width: 20px; height: 20px; }
.btn-block { width: 100%; padding: 10px 14px; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 2px; }

.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 650; font-size: 13px; letter-spacing: .02em;
}
.avatar-sm { width: 34px; height: 34px; font-size: 12.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; margin: 0 auto; }

.tag { padding: 1px 7px; border-radius: 6px; background: #f1f3f6; color: var(--ink-2); font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag-new { background: var(--warn-soft); color: var(--warn); }
.tag-typing { background: var(--ok-soft); color: var(--ok); }
.tag-done { background: var(--ok-soft); color: var(--ok); }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-title { margin-bottom: 4px; color: var(--ink); font-size: 14px; font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }

.input {
  width: 100%; padding: 8px 11px; border: 1px solid #d7dbe2; border-radius: 8px; background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
textarea.input { resize: vertical; }
.input-sm { max-width: 120px; }
.mono { font-family: var(--mono); font-size: 13px; }

/* ---------- Inbox ---------- */

.view-inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; height: 100%; }

.list-pane { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.pane-header { display: flex; flex-direction: column; gap: 12px; padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.pane-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pane-title h1 { font-size: 18px; font-weight: 650; }

.segmented { display: inline-flex; padding: 3px; border-radius: 8px; background: #f1f3f6; }
.segmented button { padding: 4px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 550; cursor: pointer; }
.segmented .is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.search { position: relative; display: block; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--faint); }
.search input { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.search input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }

.conv-list { flex: 1; overflow-y: auto; margin: 0; padding: 6px; list-style: none; }
.conv-list:empty { display: none; }
.conv {
  display: flex; gap: 12px; width: 100%; padding: 12px 10px; border: 0; border-radius: 10px;
  background: transparent; text-align: left; cursor: pointer;
}
.conv:hover { background: #f6f7f9; }
.conv.is-active { background: var(--accent-soft); }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; }
.conv-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { flex: none; color: var(--faint); font-size: 12px; }
.conv-preview { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.is-unread .conv-preview { color: var(--ink); font-weight: 550; }
.conv-tags { display: flex; gap: 6px; margin-top: 5px; }
.pill {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700;
}

/* Thread */
.thread-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.thread-empty { margin: auto; max-width: 300px; padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.thread-empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.thread-empty-icon svg { width: 26px; height: 26px; }
.thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread-header { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.thread-title { flex: 1; min-width: 0; }
.thread-name { font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn { display: none; margin-left: -8px; }

.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 24px 28px; }
.msg { display: flex; flex-direction: column; max-width: min(560px, 75%); }
.msg-visitor { align-self: flex-start; align-items: flex-start; }
.msg-agent { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-visitor .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-agent .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg-meta { margin-top: 4px; padding: 0 4px; color: var(--faint); font-size: 11.5px; }
.msg-system { align-self: center; padding: 4px 12px; border-radius: 999px; background: #eceff3; color: var(--muted); font-size: 12px; }
.day-sep { align-self: center; margin: 6px 0; color: var(--faint); font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.typing { display: flex; align-items: center; gap: 8px; padding: 0 28px 8px; color: var(--muted); font-size: 12.5px; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.composer-wrap { padding: 4px 20px 16px; }
.composer { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.composer:focus-within { border-color: #93b4f8; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.composer textarea {
  display: block; width: 100%; min-height: 46px; max-height: 180px; padding: 12px 14px 4px;
  border: 0; outline: 0; resize: none; background: transparent;
}
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 8px 14px; }
.hint { color: var(--faint); font-size: 12px; }
kbd { padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: #f8fafc; color: var(--muted); font-family: var(--font); font-size: 11px; }

.canned {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); z-index: 5;
  max-height: 240px; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
}
.canned-item { display: flex; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; cursor: pointer; }
.canned-item:hover, .canned-item.is-active { background: var(--accent-soft); }
.canned-key { flex: none; min-width: 64px; color: var(--accent); font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.canned-body { min-width: 0; color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.closed-note { margin: 4px 20px 16px; padding: 12px 14px; border: 1px dashed #d7dbe2; border-radius: 10px; background: #fff; color: var(--muted); font-size: 13px; text-align: center; }

/* Details */
.details-pane { overflow-y: auto; padding: 24px 20px; background: var(--panel); border-left: 1px solid var(--line); }
.details-empty { padding-top: 40px; color: var(--muted); font-size: 13px; text-align: center; }
.details-head { padding-bottom: 18px; border-bottom: 1px solid var(--line-2); text-align: center; }
.details-name { margin-top: 10px; font-size: 15px; font-weight: 650; }
.details-email { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.details-section { padding: 16px 0; border-bottom: 1px solid var(--line-2); }
.details-section:last-child { border-bottom: 0; }
.details-section h3 { margin-bottom: 10px; color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.kv { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 7px 10px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv a { color: var(--accent); text-decoration: none; }
.kv a:hover { text-decoration: underline; }
.past { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.past-item { padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; }
.past-date { color: var(--faint); font-size: 12px; }
.past-preview { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--muted); }

/* ---------- Pages (offline, settings) ---------- */

.page { height: 100%; overflow-y: auto; }
.page-inner { max-width: 880px; margin: 0 auto; padding: 32px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 20px; font-weight: 650; }
.page-head p { margin-top: 4px; color: var(--muted); }

.offline-list { display: flex; flex-direction: column; gap: 12px; }
.offline-card { padding: 16px 18px; }
.offline-card.is-handled { opacity: .7; }
.offline-head { display: flex; align-items: center; gap: 12px; }
.offline-who { flex: 1; min-width: 0; }
.offline-name { font-weight: 600; }
.offline-email { color: var(--accent); font-size: 13px; text-decoration: none; overflow-wrap: anywhere; }
.offline-time { flex: none; color: var(--faint); font-size: 12.5px; }
.offline-body { margin: 12px 0 14px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.offline-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); font-size: 12.5px; }
.offline-actions { display: flex; align-items: center; gap: 8px; }

.settings-form .card { margin-bottom: 16px; padding: 4px 20px; }
.card-title { margin: 16px 0 4px; font-size: 14px; font-weight: 650; }
.field { display: grid; grid-template-columns: 240px minmax(0, 1fr); align-items: start; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line-2); }
.card-title + .field { border-top: 0; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; }
.field-help { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.color-row { display: flex; align-items: center; gap: 8px; max-width: 220px; }
.color-row input[type="color"] { flex: none; width: 40px; height: 36px; padding: 2px; border: 1px solid #d7dbe2; border-radius: 8px; background: #fff; cursor: pointer; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 38px; height: 22px; border-radius: 11px; background: #cbd5e1; transition: background .15s ease; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s ease; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 2px; }
.switch-text { font-size: 13px; color: var(--ink-2); }

.card-danger .card-title { color: var(--danger); }
.form-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 16px 0 4px; background: linear-gradient(rgba(245, 246, 248, 0), var(--bg) 35%); }

/* ---------- Sign-in screen ---------- */

body:has(#auth:not([hidden])) { background: #fff; }
.auth { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: minmax(380px, 46%) 1fr; background: #fff; overflow-y: auto; }

.auth-brand {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 40px 56px; overflow: hidden; color: #cbd5e1;
  background:
    radial-gradient(900px 520px at 110% -10%, rgba(37, 99, 235, .45), transparent 60%),
    radial-gradient(700px 480px at -20% 110%, rgba(56, 189, 248, .18), transparent 60%),
    linear-gradient(160deg, #0b1220 0%, #0f1b33 55%, #0b1220 100%);
}
/* Faint dot grid for texture */
.auth-brand::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.auth-brand > * { position: relative; }
.auth-brand .brand { padding: 0; }
.auth-pitch { max-width: 440px; }
.auth-pitch h2 { color: #fff; font-size: 32px; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.auth-pitch p { margin-top: 14px; font-size: 15.5px; line-height: 1.6; color: #a9b6cb; }
.auth-points { display: flex; flex-direction: column; gap: 12px; margin: 28px 0 0; padding: 0; list-style: none; font-size: 14.5px; color: #dbe3ef; }
.auth-points li { display: flex; align-items: center; gap: 10px; }
.auth-points li::before {
  content: ""; flex: none; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(37, 99, 235, .25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4 8-9' fill='none' stroke='%2393b4f8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.auth-foot { font-size: 12.5px; color: #64748b; }

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 48px 24px; background: #fff; }
.auth-card { width: 100%; max-width: 380px; }
.auth-panel h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.auth-panel > p { margin: 6px 0 28px; color: var(--muted); }
.auth-panel .input { margin: 6px 0 16px; padding: 11px 12px; }
.auth-panel .btn-block { margin-top: 4px; padding: 11px 14px; font-size: 14px; }
.auth-help { color: var(--faint); font-size: 12.5px; }
.auth-error { margin: -4px 0 12px; color: var(--danger); font-size: 13px; }
.link-btn { display: block; margin: 12px auto 0; padding: 4px; border: 0; background: transparent; color: var(--accent); font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.admin-note { margin: 0 0 8px; color: var(--muted); font-size: 13px; text-align: right; }

.toast-region { position: fixed; left: 50%; bottom: 20px; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 10px; background: #0f172a; color: #fff; font-size: 13px; box-shadow: 0 10px 30px rgba(15, 23, 42, .25); animation: toast-in .2s ease both; }
.toast-error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Websites ---------- */

.site-filter { display: flex; flex-direction: column; gap: 4px; margin: 0 4px 14px; }
.site-filter-label { padding: 0 2px; color: var(--side-muted); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.site-filter select {
  width: 100%; padding: 8px 10px; border: 1px solid #263252; border-radius: 8px;
  background: var(--side-2); color: #fff; font-size: 13.5px; cursor: pointer;
}
.site-filter select:focus { outline: 0; border-color: #4b6cc4; }
.site-filter option { color: var(--ink); background: #fff; }

.tag-site { background: #eef3ff; color: #1d4ed8; }
.offline-from { display: inline-flex; align-items: center; gap: 8px; }

.site-picker { display: flex; align-items: center; gap: 8px; }
.site-picker-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.site-picker select { width: auto; min-width: 180px; }
/* Pop-up dialog (native <dialog>: Escape closes, focus stays inside) */
.dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 16px;
  background: #fff; color: var(--ink); box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
}
.dialog::backdrop { background: rgba(15, 23, 42, .55); }
.dialog[open] { animation: dialog-in .18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.dialog-card { display: flex; flex-direction: column; padding: 24px 24px 20px; }
.dialog-head { display: flex; gap: 14px; margin-bottom: 20px; }
.dialog-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.dialog-icon svg { width: 22px; height: 22px; }
.dialog-head h2 { font-size: 17px; font-weight: 650; }
.dialog-head p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.dialog-card .field-label { margin-bottom: 6px; }
.dialog-card .input { padding: 10px 12px; }
.dialog-help { margin: 6px 0 16px; color: var(--muted); font-size: 12.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--line-2); }

.snippet-card { margin-bottom: 16px; padding: 4px 20px 18px; }
.guide { margin-top: 14px; border-top: 1px solid var(--line-2); padding-top: 12px; font-size: 13.5px; }
.guide summary { color: var(--accent); font-weight: 600; cursor: pointer; }
.guide-steps { margin: 12px 0 0; padding-left: 22px; color: var(--ink-2); }
.guide-steps > li { margin-bottom: 10px; }
.guide-steps strong { color: var(--ink); }
.guide-platforms { margin: 8px 0 0; padding-left: 18px; }
.guide-platforms li { margin-bottom: 5px; }
.guide code { padding: 1px 5px; border-radius: 4px; background: #f1f3f6; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

.card-danger { border-color: #fecaca; }
.delete-row { display: flex; gap: 8px; max-width: 420px; }
.delete-row .input { flex: 1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:not(:disabled):hover { background: #b91c1c; }
.card-danger code { padding: 1px 5px; border-radius: 4px; background: var(--danger-soft); color: var(--danger); font-family: var(--mono); font-size: 12.5px; }
.card-desc { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.card-desc code { font-family: var(--mono); font-size: 12.5px; }
.snippet { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.snippet code { flex: 1; min-width: 0; overflow-x: auto; color: var(--ink-2); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }

.agents-card { padding: 4px 20px 8px; margin-bottom: 16px; }
.agents-table td { vertical-align: top; }
.agents-table td:not(:first-child), .agents-table th:not(:first-child) { text-align: left; }
.agent-cell { display: flex; align-items: flex-start; gap: 10px; }
.agent-cell .muted { font-size: 12.5px; }
.presence-dot { flex: none; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--faint); }
.presence-dot.is-online { background: #22c55e; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.check-note { margin-top: 4px; color: var(--faint); font-size: 12px; }
.help-card { padding: 4px 20px 16px; }
.help-card ol { margin: 4px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 13.5px; }
.help-card li { margin-bottom: 6px; }

/* ---------- Analytics ---------- */

.page-wide { max-width: 1160px; }
.analytics { display: flex; flex-direction: column; gap: 16px; transition: opacity .15s ease; }
.analytics.is-loading { opacity: .55; }
.analytics:empty::before { content: "Loading…"; color: var(--muted); }

.hero { padding: 22px 24px; }
.hero-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.hero-value { margin-top: 4px; font-size: 48px; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }
.hero-delta { margin-top: 8px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.hero-delta.is-good { color: var(--ok); }
.hero-delta.is-bad { color: var(--danger); }
.hero-help { margin-top: 10px; color: var(--faint); font-size: 12.5px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; }
.tile-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.tile-value { margin-top: 4px; font-size: 24px; font-weight: 650; }
.tile-note { margin-top: 2px; color: var(--faint); font-size: 12px; }

.viz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.viz-card { padding: 18px 20px; min-width: 0; }
.viz-title { font-size: 14px; font-weight: 650; }
.viz-subtitle { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.viz-chart { position: relative; margin-top: 14px; }
.viz-chart svg { display: block; overflow: visible; }
.viz-chart rect[tabindex]:focus { outline: none; }
.viz-chart rect[tabindex]:focus-visible { outline: 2px solid rgba(37, 99, 235, .35); }
.viz-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-legend { display: flex; gap: 16px; margin-top: 10px; color: var(--ink-2); font-size: 12.5px; }
.viz-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 3px; }
.viz-tooltip {
  position: absolute; z-index: 5; min-width: 140px; padding: 8px 10px; pointer-events: none;
  background: #0f172a; color: #e2e8f0; border-radius: 8px; font-size: 12px; box-shadow: 0 8px 24px rgba(15, 23, 42, .2);
}
.viz-tooltip-title { margin-bottom: 4px; color: #94a3b8; font-size: 11.5px; }
.viz-tooltip-row { display: flex; align-items: center; gap: 6px; }
.viz-tooltip-row strong { color: #fff; font-variant-numeric: tabular-nums; }
.viz-key { width: 12px; height: 2px; border-radius: 1px; }
.viz-data { margin-top: 10px; font-size: 12.5px; }
.viz-data summary { color: var(--accent); cursor: pointer; }
.viz-data .data-table { margin-top: 8px; }

.hbars { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.hbar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 12px; font-size: 13px; }
.hbar-label { color: var(--ink-2); }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-fill { flex: none; max-width: calc(100% - 40px); height: 16px; border-radius: 0 4px 4px 0; }
.hbar-value { color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 600; }

.data-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td:not(:first-child), .data-table th:not(:first-child) { text-align: right; }

/* ---------- Responsive ---------- */

@media (max-width: 1240px) {
  .view-inbox { grid-template-columns: 320px minmax(0, 1fr); }
  .details-pane { display: none; }
}

@media (max-width: 1000px) {
  .viz-grid { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { display: none; }
  .auth-main { background: linear-gradient(180deg, #f5f7fb, #fff 40%); }
}

@media (max-width: 820px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: column; align-items: flex-start; }
  .hero-value { font-size: 40px; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { flex-direction: row; align-items: center; gap: 4px; padding: 8px 10px; overflow-x: auto; }
  .brand { padding: 0 6px 0 0; }
  .brand-name, .mode-note, .nav-label, .agent-name { display: none; }
  .nav { flex-direction: row; }
  .nav-item { width: auto; }
  .sidebar-foot { flex-direction: row; margin: 0 0 0 auto; }
  .agent-card { padding: 4px 8px; background: transparent; }
  .view-inbox { grid-template-columns: minmax(0, 1fr); }
  .app.show-thread .list-pane { display: none; }
  .app:not(.show-thread) .thread-pane { display: none; }
  .back-btn { display: inline-flex; }
  .messages { padding: 16px; }
  .composer-wrap { padding: 4px 12px 12px; }
  .hint { display: none; }
  .msg { max-width: 85%; }
  .page-inner { padding: 20px 16px 40px; }
  .field { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
