/* Leyscale Connect app. Tokens mirror the Leyscale design system, with WhatsApp
   green as the accent for anything that is about WhatsApp itself. */

:root {
	--violet: #6a4bc4;
	--violet-deep: #533ba1;
	--blue: #2f6fd8;
	--grad: linear-gradient(135deg, var(--violet) 0%, var(--blue) 100%);
	--wa: #25d366;          /* WhatsApp brand green */
	--wa-deep: #128c7e;     /* text and icons on light ground */
	--wa-dark: #075e54;
	--wa-tint: #e7f8ee;
	--wa-bubble: #dcf8c6;   /* outgoing chat bubble */
	--wa-chat-bg: #efeae2;  /* chat wallpaper */
	--ink: #191830;
	--ink-soft: #52516e;
	--line: #e4e2f0;
	--bg: #f7f6fb;
	--surface: #ffffff;
	--tint-violet: #f0ecfd;
	--amber: #a55d00;
	--tint-amber: #fff4e0;
	--danger: #b3261e;
	--tint-danger: #fdecea;
	--font-head: "Sora", "Segoe UI", system-ui, sans-serif;
	--font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
	--font-mono: "IBM Plex Mono", ui-monospace, monospace;
	--r-sm: 8px;
	--r-md: 14px;
	--r-lg: 22px;
	--r-pill: 999px;
	--shadow: 0 2px 4px rgba(25, 24, 48, .04), 0 12px 28px rgba(25, 24, 48, .07);
	--max: 1200px;
	--ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.lw { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font-body); overflow-x: clip; }
.lw h1, .lw h2, .lw h3 { font-family: var(--font-head); color: var(--ink); letter-spacing: -.02em; line-height: 1.2; margin: 0; }
.lw h1 { font-size: clamp(26px, 4vw, 36px); }
.lw h2 { font-size: 22px; }
.lw h3 { font-size: 17px; }
.lw p { margin: 0; }
.lw a { color: var(--violet); }
.lw a:hover { color: var(--violet-deep); }
.lw :focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 6px; }

/* ---- frame ---- */
.lw-stripe { height: 3px; background: linear-gradient(90deg, var(--violet), var(--blue) 60%, var(--wa)); }
.lw-top { background: var(--surface); box-shadow: 0 1px 0 var(--line); position: sticky; top: 0; z-index: 20; }
.lw-top-in { display: flex; align-items: center; gap: 16px; max-width: var(--max); margin: 0 auto; padding: 12px 20px; flex-wrap: wrap; }
.lw-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.lw-logo { display: block; width: auto; height: 48px; flex: none; }
.lw-word { display: flex; flex-direction: column; font-family: var(--font-head); font-weight: 600; font-size: 18px; line-height: 1.1; color: var(--ink); }
.lw-word b { color: var(--wa-deep); font-weight: 700; }
.lw-word small { font: 500 10px/1.4 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin-top: 3px; }
.lw-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.lw-nav a { position: relative; padding: 8px 12px; border-radius: var(--r-pill); font: 600 14px/1.2 var(--font-head); color: var(--ink-soft); text-decoration: none; transition: background .2s, color .2s; }
.lw-nav a:hover, .lw-nav a[aria-current="page"] { background: var(--tint-violet); color: var(--violet-deep); }
.lw-nav .lw-badge { margin-left: 6px; }
.lw-out { font-size: 14px; color: var(--ink-soft) !important; }
.lw-main { flex: 1 0 auto; width: 100%; max-width: var(--max); margin: 0 auto; padding: 28px 20px 64px; }
.lw-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; width: 100%; max-width: var(--max); margin: 0 auto; padding: 18px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-soft); }

/* ---- building blocks ---- */
.lw-eyebrow { display: inline-block; font: 500 12px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--wa-deep); margin-bottom: 10px; }
.lw-fine { font-size: 13px; color: var(--ink-soft); }
.lw-stack { display: flex; flex-direction: column; gap: 20px; }
.lw-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.lw-between { justify-content: space-between; }
.lw-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.lw-cols { display: grid; gap: 20px; grid-template-columns: 1fr 1fr; }
.lw-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow); }
.lw-card h2 + *, .lw-card h3 + * { margin-top: 12px; }
.lw-stat { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; transition: transform .25s var(--ease), box-shadow .25s; }
a.lw-stat:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(25, 24, 48, .1); }
.lw-stat .lw-num { font: 700 34px/1 var(--font-head); color: var(--ink); font-variant-numeric: tabular-nums; }
.lw-stat .lw-lbl { font-size: 14px; color: var(--ink-soft); }
.lw-stat.lw-hot .lw-num { color: var(--wa-deep); }
.lw-stat.lw-warn .lw-num { color: var(--amber); }

.lw-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 22px; border: 0; border-radius: var(--r-pill); background: var(--grad); color: #fff !important; font: 600 15px/1 var(--font-head); text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform .15s, filter .2s, box-shadow .2s; }
.lw-btn:hover { filter: brightness(.95); transform: translateY(-1px); }
.lw-btn:active { transform: translateY(0); }
.lw-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.lw-btn-wa { background: var(--wa); color: #06351c !important; box-shadow: 0 8px 20px rgba(37, 211, 102, .35); }
.lw-btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink) !important; }
.lw-btn-ghost:hover { background: var(--tint-violet); }
.lw-btn-sm { min-height: 34px; padding: 6px 14px; font-size: 13px; }
.lw-btn-danger { background: var(--danger); }
.lw-link { background: none; border: 0; padding: 0; color: var(--violet); font: inherit; cursor: pointer; text-decoration: underline; }

.lw-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font: 500 12px/1.6 var(--font-mono); background: var(--tint-violet); color: var(--violet-deep); white-space: nowrap; }
.lw-pill.wa { background: var(--wa-tint); color: var(--wa-dark); }
.lw-pill.amber { background: var(--tint-amber); color: var(--amber); }
.lw-pill.red { background: var(--tint-danger); color: var(--danger); }
.lw-pill.grey { background: #eeedf3; color: var(--ink-soft); }
.lw-live { width: 8px; height: 8px; border-radius: 50%; background: var(--wa); box-shadow: 0 0 0 0 rgba(37, 211, 102, .6); animation: lw-pulse 2s infinite; }
.lw-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--wa); color: #06351c; font: 700 11px/1 var(--font-head); }

/* ---- forms ---- */
.lw-form { display: flex; flex-direction: column; gap: 14px; }
.lw-form label, .lw-field { display: flex; flex-direction: column; gap: 6px; font: 600 14px/1.3 var(--font-head); color: var(--ink); }
.lw input:not([type="checkbox"]):not([type="radio"]), .lw select, .lw textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 400 15px/1.4 var(--font-body); transition: border-color .2s, box-shadow .2s; }
.lw input:focus, .lw select:focus, .lw textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(106, 75, 196, .15); }
.lw textarea { min-height: 96px; resize: vertical; }
.lw .lw-check { flex-direction: row; align-items: center; gap: 10px; font: 400 14px/1.4 var(--font-body); }
.lw-form .lw-help { font: 400 13px/1.4 var(--font-body); color: var(--ink-soft); }
.lw-inline { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.lw-flash { padding: 10px 14px; border-radius: var(--r-sm); font-size: 14px; }
.lw-flash-e { background: var(--tint-danger); color: var(--danger); }
.lw-flash-m { background: var(--wa-tint); color: var(--wa-dark); }

/* ---- tables ---- */
.lw-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.lw-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lw-table th, .lw-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lw-table th { font: 500 11px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); background: #fbfaff; }
.lw-table tr:last-child td { border-bottom: 0; }
.lw-table tbody tr { transition: background .15s; }
.lw-table tbody tr.lw-click { cursor: pointer; }
.lw-table tbody tr.lw-click:hover { background: #faf9ff; }
.lw-empty { padding: 36px 20px; text-align: center; color: var(--ink-soft); }
.lw-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.lw-chip { padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); font: 500 13px/1.2 var(--font-head); color: var(--ink-soft); cursor: pointer; transition: all .2s; }
.lw-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.lw-chip .n { opacity: .65; margin-left: 4px; }

/* ---- funnel ---- */
.lw-funnel { display: flex; flex-direction: column; gap: 10px; }
.lw-funnel-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 12px; align-items: center; font-size: 14px; }
.lw-bar { height: 10px; border-radius: var(--r-pill); background: #efedf6; overflow: hidden; }
.lw-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--violet), var(--wa)); transition: width 1s var(--ease); }

/* ---- chat (inbox, setup preview, sign-up page) ---- */
.lw-inbox { display: grid; grid-template-columns: 320px 1fr; min-height: 560px; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.lw-threads { border-right: 1px solid var(--line); overflow-y: auto; max-height: 72vh; }
.lw-thread { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font: inherit; cursor: pointer; transition: background .15s; }
.lw-thread:hover, .lw-thread[aria-current="true"] { background: var(--wa-tint); }
.lw-thread b { font-family: var(--font-head); font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.lw-thread span { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lw-thread.unread b::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--wa); flex: none; align-self: center; }
.lw-convo { display: flex; flex-direction: column; min-width: 0; }
.lw-convo-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.lw-chatlog { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 18px; overflow-y: auto; max-height: 58vh; background: var(--wa-chat-bg); }
.lw-compose { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: #f6f6f6; }
.lw-compose textarea { min-height: 44px; height: 44px; }
.lw-bubble { position: relative; max-width: min(78%, 520px); padding: 8px 12px 18px; border-radius: 12px; background: #fff; box-shadow: 0 1px 1px rgba(0, 0, 0, .08); font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; animation: lw-pop .35s var(--ease) both; }
.lw-bubble small { position: absolute; right: 10px; bottom: 3px; font-size: 10px; color: #667781; }
.lw-in { align-self: flex-start; border-top-left-radius: 4px; }
.lw-out { align-self: flex-end; background: var(--wa-bubble); border-top-right-radius: 4px; }
.lw-out.lw-auto { background: #e8f6fb; }
.lw-out.lw-failed { background: var(--tint-danger); }
.lw-chat { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--r-lg); background: var(--wa-chat-bg); box-shadow: var(--shadow); }
.lw-chat .lw-bubble { padding-bottom: 8px; opacity: 0; animation: lw-pop .45s var(--ease) both; }
.lw-chat .lw-bubble:nth-child(1) { animation-delay: .3s; }
.lw-chat .lw-bubble:nth-child(2) { animation-delay: 1.1s; }
.lw-chat .lw-bubble:nth-child(3) { animation-delay: 1.9s; }
.lw-chat .lw-bubble:nth-child(4) { animation-delay: 2.7s; }

/* ---- auth screens ---- */
.lw-auth { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
.lw-auth-narrow { grid-template-columns: minmax(0, 440px); justify-content: center; }
.lw-auth-copy { display: flex; flex-direction: column; gap: 16px; }
.lw-auth-copy > p { font-size: 18px; color: var(--ink-soft); max-width: 46ch; }

/* ---- setup stepper ---- */
.lw-steps { display: flex; gap: 8px; flex-wrap: wrap; counter-reset: s; }
.lw-step { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); font: 600 13px/1 var(--font-head); color: var(--ink-soft); counter-increment: s; }
.lw-step::before { content: counter(s); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #efedf6; font-size: 12px; }
.lw-step.done::before { content: "✓"; background: var(--wa); color: #06351c; }
.lw-step[aria-current="step"] { border-color: var(--violet); color: var(--violet-deep); }

/* ---- drawer, toast, loading ---- */
.lw-drawer { position: fixed; inset: 0 0 0 auto; width: min(460px, 100vw); background: var(--surface); box-shadow: -20px 0 40px rgba(25, 24, 48, .15); padding: 22px; overflow-y: auto; z-index: 40; animation: lw-slide .3s var(--ease) both; }
.lw-scrim { position: fixed; inset: 0; background: rgba(25, 24, 48, .3); z-index: 39; animation: lw-fade .2s both; }
.lw-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 12px 18px; border-radius: var(--r-pill); background: var(--ink); color: #fff; font-size: 14px; z-index: 60; animation: lw-rise .3s var(--ease) both; }
.lw-toast.err { background: var(--danger); }
.lw-loading { display: grid; place-items: center; min-height: 40vh; }
.lw-dots { display: inline-flex; gap: 5px; padding: 12px 16px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.lw-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--wa-deep); animation: lw-type 1.2s infinite; }
.lw-dots i:nth-child(2) { animation-delay: .15s; }
.lw-dots i:nth-child(3) { animation-delay: .3s; }

/* ---- motion ---- */
.lw-enter > * { animation: lw-rise .5s var(--ease) both; }
.lw-enter > *:nth-child(2) { animation-delay: .06s; }
.lw-enter > *:nth-child(3) { animation-delay: .12s; }
.lw-enter > *:nth-child(4) { animation-delay: .18s; }
.lw-enter > *:nth-child(5) { animation-delay: .24s; }
.lw-enter > *:nth-child(n+6) { animation-delay: .3s; }
@keyframes lw-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes lw-pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes lw-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lw-slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes lw-type { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes lw-pulse { 0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, .6); } 70% { box-shadow: 0 0 0 8px rgba(37, 211, 102, 0); } 100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); } }
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
	.lw-chat .lw-bubble { opacity: 1; }
}

/* ---- small screens ---- */
@media (max-width: 860px) {
	.lw-auth, .lw-cols { grid-template-columns: 1fr; }
	.lw-logo { height: 40px; }
	.lw-inbox { grid-template-columns: 1fr; }
	.lw-inbox.lw-open .lw-threads { display: none; }
	.lw-inbox:not(.lw-open) .lw-convo { display: none; }
	.lw-threads { max-height: none; border-right: 0; }
	.lw-funnel-row { grid-template-columns: 100px 1fr 36px; }
	.lw-nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
}
