/* iLULA WhatsApp Portal */
:root {
  --brand: #4C2169; --brand-2: #5A49F8; --brand-soft: #EFEBFF; --brand-ink: #2B1340;
  --bg: #F6F5FA; --card: #fff; --line: #E7E4EF; --ink: #1D1A24; --muted: #6B6776;
  --ok: #1F8A5B; --ok-soft: #E3F5EC; --warn: #B7791F; --warn-soft: #FDF3E1; --bad: #C2384B; --bad-soft: #FCE8EB;
  --wa: #25D366; --radius: 14px; --shadow: 0 1px 2px rgba(29,26,36,.05), 0 4px 16px rgba(76,33,105,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 Inter, Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .brand { font-family: Poppins, Inter, system-ui, sans-serif; letter-spacing: -.01em; }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--brand-ink); color: #E9E2F5; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 600; font-size: 16px; line-height: 1.2; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand-2), #8D5BD6); display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand small { display: block; font: 500 11px Inter, sans-serif; color: #B9A9D6; letter-spacing: .04em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #D9CFEA; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(255,255,255,.12); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 10px 8px; }
.nav .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9C8BBB; padding: 6px 12px 2px; }
.side .me { margin-top: auto; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.06); font-size: 13px; }
.side .me b { color: #fff; display: block; }
.side .me form { margin: 8px 0 0; }
.side .me button { background: none; border: 0; color: #C9B8E6; padding: 0; cursor: pointer; font: inherit; }
.main { padding: 28px 32px 48px; min-width: 0; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.viewas { background: var(--warn-soft); color: #6B4A12; border: 1px solid #F1DDB4; padding: 8px 14px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }

/* cards & grid */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card .head h2 { margin: 0; }
.stat .k { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .v { font: 600 28px Poppins, sans-serif; margin: 4px 0 2px; }
.meter { height: 8px; border-radius: 99px; background: var(--brand-soft); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), #8D5BD6); border-radius: 99px; }
.meter.hot i { background: linear-gradient(90deg, #E0A33A, var(--bad)); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 20px; color: inherit; }
a.row:hover { background: #FAF9FD; text-decoration: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .title + .badge, .row .badge.inl { margin-top: 2px; }
.row .end { flex: none; text-align: right; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row .sub { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .tags { display: flex; gap: 6px; margin: 2px 0; flex-wrap: wrap; }
.bubble.sys { align-self: center; background: #F0EEF4; color: var(--muted); font-size: 13px; border-radius: 99px; padding: 5px 14px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 600; flex: none; font-size: 14px; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }

/* badges & buttons */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.grey { background: #F0EEF4; color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: var(--brand-2); color: #fff; padding: 9px 16px; border-radius: 10px; font: 600 14px Inter, sans-serif; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: #fff; color: var(--bad); border-color: #F2C6CD; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.wa { background: var(--wa); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 500; font-size: 14px; }
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs a:hover { text-decoration: none; }
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 18px; background: var(--ok-soft); color: #145C3C; border: 1px solid #BFE6D2; }
.flash.err { background: var(--bad-soft); color: #8A1F30; border-color: #F2C6CD; }

/* forms */
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; background: #fff; color: var(--ink); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(90,73,248,.25); border-color: var(--brand-2); }
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }
.inline { display: inline; margin: 0; }
.search { display: flex; gap: 8px; }
.search input { max-width: 320px; }

/* chat */
.chat { display: grid; grid-template-columns: 320px 1fr; min-height: 560px; }
.chat .people { border-right: 1px solid var(--line); overflow-y: auto; max-height: 72vh; }
.chat .people a.row.on { background: var(--brand-soft); }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread .bar { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.msgs { flex: 1; padding: 20px; overflow-y: auto; max-height: 60vh; background: #FBFAFD; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 74%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.bubble.in { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.bot { background: var(--brand-soft); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.human { background: #DCF8E6; align-self: flex-end; border-bottom-right-radius: 4px; }
.compose { border-top: 1px solid var(--line); padding: 14px 20px; display: flex; gap: 10px; align-items: flex-end; }
.compose textarea { min-height: 46px; height: 46px; }

/* tables */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 20px; border-bottom: 1px solid var(--line); }
table.t td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }

/* upsell */
.offer { display: flex; flex-direction: column; gap: 8px; }
.offer .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; font-size: 20px; }
.offer p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.plan { border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; background: #fff; }
.plan.cur { border-color: var(--brand-2); background: #FBFAFF; }
.plan .price { font: 600 24px Poppins, sans-serif; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #E6DEFF 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #F1E3FF 0, transparent 60%), var(--bg); }
.auth .card { width: 100%; max-width: 400px; padding: 32px; }
.auth .brand { color: var(--brand-ink); padding: 0 0 16px; }
.auth .brand small { color: var(--muted); }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .side .brand { padding: 4px 8px; flex: 1 0 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav .sep, .nav .label { display: none; }
  .side .me { display: none; }
  .main { padding: 20px 16px 40px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; }
  .chat .people { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--line); }
}
