:root {
	--brand: #FECB00; --on-brand: #000; --ink: #17120e; --ink-2: #4d443d; --soft: #7b7068; --line: #ebe5de; --bg: #f7f4f0; --card: #fff;
	--good: #1f8a4c; --bad: #b42318; --wa: #25D366; --radius: 14px;
	--safe-b: env(safe-area-inset-bottom, 0px);
	color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 340px 1fr; height: 100vh; height: 100dvh; }
.nav { background: var(--ink); color: #fff; display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; }
.brand i { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #000; display: grid; place-items: center; font-style: normal; }
.brand small { display: block; font-weight: 500; color: #b8aea4; font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: #d9d1c9; font-weight: 600; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav .count { margin-left: auto; background: var(--brand); color: #000; border-radius: 10px; font-size: 12px; padding: 0 7px; min-width: 22px; text-align: center; }
.nav .grow { flex: 1; }
.nav .plan { font-size: 12.5px; color: #cfc6bd; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.1); }
.list { min-width: 0; border-right: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.page { flex: 1; overflow-y: auto; padding: 24px; }
.page-narrow { max-width: 820px; }
.tabs { display: none; }

.head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--card); min-height: 62px; }
.head h1, .head h2 { margin: 0; font-size: 18px; line-height: 1.2; }
.head .sub { font-size: 12.5px; color: var(--soft); }
.head .sp { flex: 1; min-width: 0; }
.head .back { display: none; }

/* Inbox list */
.filters { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.search { margin: 10px 12px 0; }
.search input { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--bg); }
.items { overflow-y: auto; flex: 1; }
.item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid #f2ede7; text-decoration: none; position: relative; }
.item:hover { background: #fbf8f4; }
.item.on { background: #fff7d1; }
.av { width: 40px; height: 40px; border-radius: 50%; background: #efe7dd; display: grid; place-items: center; font-weight: 700; flex: none; color: var(--ink-2); }
.item .t { flex: 1; min-width: 0; }
.item .row { display: flex; gap: 8px; align-items: baseline; }
.item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item time { margin-left: auto; font-size: 12px; color: var(--soft); flex: none; }
.item p { margin: 2px 0 0; color: var(--ink-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.unread b, .item.unread p { color: #000; font-weight: 700; }
.item.unread::before { content: ""; position: absolute; left: 4px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: #e5383b; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; background: #f1ece6; color: var(--ink-2); vertical-align: 1px; }
.pill.human { background: #fff1b8; color: #6b5200; }
.pill.ai { background: #e6f0ff; color: #1d4ed8; }
.pill.miss { background: #fde8e8; color: var(--bad); }
.empty { text-align: center; color: var(--soft); padding: 48px 20px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* Thread */
.thread { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.m { max-width: 78%; display: flex; flex-direction: column; }
.m .meta { font-size: 11.5px; color: var(--soft); margin: 0 6px 3px; display: flex; gap: 6px; align-items: center; }
.m .b { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 9px 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.m.user { align-self: flex-end; align-items: flex-end; }
.m.user .b { background: var(--ink); color: #fff; border-color: var(--ink); border-bottom-right-radius: 6px; }
.m.bot .b { border-bottom-left-radius: 6px; }
.m.agent .b { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.m .teach { font-size: 12px; font-weight: 700; color: #1d4ed8; background: none; border: 0; padding: 0; cursor: pointer; }
.banner { background: #fff4c2; border-bottom: 1px solid #f0d77a; padding: 8px 16px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; }
.banner .sp { flex: 1; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; max-height: 140px; min-height: 44px; background: var(--bg); }
.visitor { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.visitor a.act { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; }
.visitor a.wa { background: #e7f9ee; border-color: #bdeccd; color: #0b6b33; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--brand); color: var(--on-brand); font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid #f1c4c0; }
.icon { width: 44px; padding: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
.card h3 { font-size: 14px; margin: 16px 0 6px; }
.muted { color: var(--soft); }
.f { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.f label { font-weight: 600; font-size: 13.5px; }
.f small { color: var(--soft); font-size: 12.5px; }
.f input, .f textarea, .f select { border: 1.5px solid #ddd5cc; border-radius: 10px; padding: 10px 12px; background: #fff; width: 100%; }
.f input:focus, .f textarea:focus, .f select:focus { outline: none; border-color: var(--ink); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.err { color: var(--bad); font-weight: 600; font-size: 13.5px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--ink); color: #f8f3ec; padding: 14px; border-radius: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { font-size: 12px; color: var(--soft); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.stat strong { display: block; font-size: 28px; line-height: 1.2; }
.rows .r { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f2ede7; }
.rows .r:last-child { border-bottom: 0; }
.rows .r .t { flex: 1; min-width: 0; }
.rows .r .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Auth */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.auth .box { width: min(420px, 100%); background: #fff; border-radius: 20px; padding: 28px; }
.auth h1 { margin: 6px 0 4px; font-size: 24px; }
.auth .brand { color: var(--ink); padding: 0; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(23,18,14,.5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal .box { background: #fff; border-radius: 18px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 20px; }
#toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.25); }

/* Mobile */
@media (max-width: 900px) {
	.shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
	.nav { display: none; }
	.list, .main { grid-row: 1; grid-column: 1; }
	.shell.has-conv .list { display: none; }
	.shell:not(.has-conv).inbox .main { display: none; }
	.shell:not(.inbox) .list { display: none; }
	.head .back { display: inline-flex; }
	.list, .main { min-height: 0; }
	.tabs { display: flex; grid-row: 2; grid-column: 1; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
	.shell.has-conv .tabs { display: none; }
	.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11.5px; font-weight: 700; text-decoration: none; color: var(--soft); position: relative; }
	.tabs a.on { color: var(--ink); }
	.tabs a svg { width: 22px; height: 22px; }
	.tabs .count { position: absolute; top: 3px; left: 54%; background: #e5383b; color: #fff; border-radius: 9px; font-size: 10.5px; padding: 0 5px; }
	.page { padding: 16px; }
	.stats { grid-template-columns: 1fr 1fr; }
	.grid2 { grid-template-columns: 1fr; }
	.m { max-width: 88%; }
}

/* Knowledge: upload documents */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; border: 2px dashed #d9cfc3; border-radius: 14px; padding: 22px 16px; cursor: pointer; transition: border-color .2s, background .2s; }
.drop:hover, .drop.on { border-color: var(--ink); background: #fffbea; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.drop-i { color: var(--ink); }
.drop b { font-size: 15px; }
.drop span, .drop small { color: var(--soft); font-size: 13px; }
#upstate { margin-top: 10px; }
.modal .box.wide { width: min(760px, 100%); }
.imp-list { display: flex; flex-direction: column; gap: 8px; }
.imp { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.imp.off { opacity: .45; }
.imp-b { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.imp-t, .imp textarea, .imp input[data-w], .imp select { border: 1.5px solid #ddd5cc; border-radius: 8px; padding: 7px 10px; width: 100%; background: #fff; font: inherit; }
.imp-t { font-weight: 600; }
.imp summary { cursor: pointer; color: var(--soft); font-size: 13.5px; }
.imp details[open] summary { margin-bottom: 6px; }
.imp details textarea { margin-bottom: 6px; }
.imp-m { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.imp-m select { width: auto; padding: 5px 8px; font-size: 13px; }
.imp-m .muted { font-size: 12.5px; }
/* bookings */
.rows.bookings .r { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line, #ece6df); }
.rows.bookings .r:first-child { border-top: 0; }
.rows.bookings .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.rows.bookings .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.rows.bookings .r.off { opacity: .55; }
.hours { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.btn.danger { color: #b42318; }
.rows.bookings .t b { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; }
/* plan & billing */
a.plan { display: block; color: #cfc6bd; text-decoration: none; }
a.plan:hover u { color: #fff; }
.pc .pr { font-size: 30px; font-weight: 800; margin: 4px 0 8px; }
.pc .pr span { font-size: 14px; font-weight: 500; color: var(--soft, #6b625b); }
.pc ul { margin: 0 0 14px; padding-left: 18px; }
.pc li { margin: 4px 0; }
.pc.hl { border-color: #FECB00; box-shadow: inset 0 0 0 1px #FECB00; }
/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card.stat { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.card.stat span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--soft, #6b625b); }
.card.stat b { font-size: 28px; }
.card.stat small { color: var(--soft, #6b625b); }
table.adm { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
table.adm th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--soft, #6b625b); padding: 8px; border-bottom: 1px solid var(--line, #ece6df); }
table.adm td { padding: 10px 8px; border-bottom: 1px solid var(--line, #ece6df); vertical-align: top; }
.pill.paid { background: #e6f7ec; color: #0b6b2f; }

/* Team inbox, WhatsApp, insights */
.m.note .b { background: #fff6cc; border: 1px dashed #e0c25a; }
.m.note .meta b { color: #6b5200; }
.pill.wa { background: #dcf8e6; color: #11743a; }
.notetoggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #6b625b; padding: 6px 16px 0; }
.assign { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid #e3ddd5; border-radius: 8px; background: #fff; max-width: 150px; }
.lock { background: #f7f4f0; border-radius: 10px; padding: 10px 12px; }
.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; align-items: end; height: 140px; }
.hours .hb { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.hours .hb i { display: block; background: #FECB00; border-radius: 4px 4px 0 0; min-height: 2px; }
.hours .hb span { font-size: 10px; color: #8a8178; text-align: center; height: 14px; }

.packs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.pill.ig { background: #fde7f3; color: #a11867; }
.pill.fb { background: #e3edff; color: #1650c7; }

/* reviews, away mode */
.stars { display: flex; gap: 4px; margin: 4px 0 14px; flex-direction: row-reverse; justify-content: flex-end; }
.star { cursor: pointer; font-size: 34px; line-height: 1; color: #d9d1c8; }
.star input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stars .star:hover, .stars .star:hover ~ .star, .stars .star:has(input:checked), .stars .star:has(input:checked) ~ .star { color: #e8a800; }
.star:has(input:focus-visible) { outline: 3px solid #121214; outline-offset: 2px; border-radius: 4px; }
.awaycard { display: flex; align-items: center; gap: 12px; }
.awaycard .t { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.tm { border-top: 1px solid #ece6df; padding: 14px 0; }
.tm .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tm textarea { width: 100%; margin: 6px 0 8px; padding: 8px 10px; border: 1.5px solid #d9d1c8; border-radius: 10px; font: inherit; }
.cerr { color: #b42318; font-weight: 600; }
.authlang { text-align: center; margin: 14px 0 0; }
.authlang select { width: auto; min-height: 36px; padding: 0 10px; border: 1.5px solid #d9d1c8; border-radius: 10px; background: #fff; font: inherit; font-size: 14px; }

/* setup wizard, install guides, help */
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.steps li a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1.5px solid #e4ddd4; border-radius: 999px; background: #fff; color: inherit; text-decoration: none; font-weight: 600; font-size: 14px; }
.steps li .n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #efe9e1; font-size: 12px; }
.steps li.ok .n { background: #1f9d55; color: #fff; }
.steps li.on a { border-color: #17120e; }
.wiz .card h2 { margin-top: 0; }
.wiznav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid #efe9e1; }
.row2 { display: flex; gap: 8px; }
.row2 input { flex: 1; min-width: 0; min-height: 40px; padding: 0 12px; border: 1.5px solid #d9d1c8; border-radius: 10px; font: inherit; }
.ptabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.ptabs .chip.on { background: #17120e; color: #fff; border-color: #17120e; }
.pguide { margin: 0 0 14px; padding-left: 20px; }
.pguide li { margin: 6px 0; }
.livebox { margin-top: 12px; padding: 12px; border-radius: 12px; background: #f7f4f0; }
.livebox p { margin: 0 0 8px; }
.livebox .ok { color: #17663a; }
.lookprev { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; padding: 16px; border-radius: 12px; background: #f7f4f0; margin-top: 8px; }
.lpb { align-self: flex-start; max-width: 80%; background: #fff; border: 1px solid #e9e3da; border-radius: 14px; padding: 10px 12px; }
.lpl { padding: 10px 16px; border-radius: 999px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.testframe { width: 100%; height: 560px; border: 1px solid #e9e3da; border-radius: 12px; background: #f7f4f0; }
.setupcard .t { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.setupcard .bar { height: 6px; border-radius: 6px; background: #efe9e1; margin: 10px 0 14px; overflow: hidden; }
.setupcard .bar i { display: block; height: 100%; background: #FECB00; }
.art { border-top: 1px solid #efe9e1; padding: 12px 0; }
.art:first-child { border-top: 0; }
.art summary { cursor: pointer; font-weight: 700; }
.art p { margin: 8px 0 0; line-height: 1.6; }
@media (max-width: 640px) { .row2 { flex-direction: column; } .testframe { height: 480px; } }
#pastebox { margin-top: 10px; }
#pastebox summary { cursor: pointer; font-weight: 600; }
#pastebox textarea { width: 100%; padding: 10px 12px; border: 1.5px solid #d9d1c8; border-radius: 10px; font: inherit; }

/* Agent: action lines, returning-visitor note, Activity page */
.m.action { align-self: center; display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: baseline; max-width: 92%; font-size: 12.5px; color: #3d5f46; background: #eef7f0; border: 1px solid #cfe6d5; border-radius: 999px; padding: 4px 12px; }
.m.action .ok { color: #1e9e48; font-weight: 800; }
.m.action .tm { color: #7f9a86; font-size: 11px; }
.memo { margin: 0 16px; padding: 8px 12px; background: #eef4ff; border: 1px solid #d3e0f7; border-radius: 10px; font-size: 13px; color: #2b3e5c; }
.act-row { align-items: flex-start; }
.mailprev { margin-top: 6px; }
.mailprev summary { cursor: pointer; font-size: 13px; color: #4a4a4a; }
.mailprev pre { white-space: pre-wrap; font: inherit; font-size: 13px; background: #faf8f5; border: 1px solid #ece6df; border-radius: 8px; padding: 10px; margin: 6px 0 0; max-height: 260px; overflow: auto; }
