:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #64708a;
  --line: #e3e8f2;
  --brand: #0f9d74;
  --brand-ink: #ffffff;
  --brand-soft: #e3f6ef;
  --accent: #3b5bdb;
  --warn: #d9480f;
  --warn-soft: #fff1e8;
  --danger: #c92a2a;
  --ok: #2b8a3e;
  --ai: #7048e8;
  --ai-soft: #f1ecff;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(20 32 51 / 6%), 0 4px 16px rgb(20 32 51 / 5%);
  font-family: 'Hind Siliguri', 'Noto Sans Bengali', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.grid { display: grid; gap: 1rem; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }

.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: #fff; padding: .5rem .9rem; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .92rem; white-space: nowrap; }
.btn:hover { border-color: #c8d0e0; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: .3rem .6rem; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

label.f { display: block; }
label.f > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input:not([type]), select, textarea {
  width: 100%; border: 1px solid #d3dae8; border-radius: 9px; padding: .55rem .7rem; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 80px; }
.check { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; }
.check input { margin-top: .3rem; }

.badge { display: inline-block; padding: .08rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 700; background: #eef1f7; color: var(--muted); }
.badge.ok { background: #e6f6ea; color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: #fdecec; color: var(--danger); }
.badge.ai { background: var(--ai-soft); color: var(--ai); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.alert { padding: .7rem .9rem; border-radius: 10px; background: var(--warn-soft); color: #8a3b0b; border: 1px solid #ffd8bf; }
.alert.info { background: #edf2ff; color: #2c3e9e; border-color: #d0dbff; }
.alert.error { background: #fdecec; color: var(--danger); border-color: #f8c9c9; }
.alert.ok { background: #e6f6ea; color: var(--ok); border-color: #c3e8cd; }

table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; padding: .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.scroll-x { overflow-x: auto; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #0f1b2d; color: #c9d3e6; padding: 1rem .75rem; display: flex; flex-direction: column; gap: .2rem; position: sticky; top: 0; height: 100vh; }
.side .logo { color: #fff; font-weight: 800; font-size: 1.25rem; padding: .3rem .6rem 1rem; display: flex; gap: .5rem; align-items: center; }
.side .logo i { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; font-style: normal; }
.side a { color: #c9d3e6; padding: .5rem .7rem; border-radius: 9px; display: flex; gap: .6rem; align-items: center; font-weight: 500; }
.side a:hover { background: #1b2a42; color: #fff; }
.side a.on { background: var(--brand); color: #fff; }
.side a .n { margin-left: auto; background: var(--warn); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .45rem; }
.side .sep { margin: .6rem .7rem .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #6f7f9c; }
.side .foot { margin-top: auto; font-size: .82rem; padding: .6rem; border-top: 1px solid #22324d; }
.main { padding: 1.4rem 1.6rem 3rem; min-width: 0; }
.main.flush { padding: 0; }
.topline { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.mobile-bar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 30%); }
  .mobile-bar { display: flex; align-items: center; gap: .6rem; background: #0f1b2d; color: #fff; padding: .6rem .9rem; position: sticky; top: 0; z-index: 20; }
  .main { padding: 1rem; }
}

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 330px 1fr 300px; height: 100vh; }
.inbox .list { border-right: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
.inbox .filters { padding: .7rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: .5rem; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs button { border: 0; background: #eef1f7; padding: .25rem .6rem; border-radius: 99px; cursor: pointer; font-size: .8rem; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--ink); color: #fff; }
.convs { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: .6rem; padding: .65rem .75rem; border-bottom: 1px solid #f0f2f7; cursor: pointer; }
.conv:hover { background: #f8f9fc; }
.conv.on { background: var(--brand-soft); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #dbe4ff; color: #364fc7; display: grid; place-items: center; font-weight: 700; flex: none; position: relative; }
.avatar .ch { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; font-size: 10px; display: grid; place-items: center; color: #fff; border: 2px solid #fff; }
.ch.messenger { background: #0866ff; } .ch.instagram { background: #d6249f; } .ch.whatsapp { background: #25d366; } .ch.telegram { background: #229ed9; } .ch.playground { background: #868e96; }
.conv .meta { min-width: 0; flex: 1; }
.conv .top { display: flex; justify-content: space-between; gap: .4rem; }
.conv .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .time { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.conv .last { font-size: .86rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .unread { background: var(--brand); color: #fff; border-radius: 99px; font-size: .7rem; padding: 0 .4rem; font-weight: 700; }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.thread .head { padding: .7rem 1rem; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .45rem; }
.bubble { max-width: 72%; padding: .5rem .75rem; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; position: relative; font-size: .95rem; }
.bubble.in { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.out.ai { background: var(--ai); }
.bubble.out.external { background: #495057; }
.bubble.failed { outline: 2px solid var(--danger); }
.bubble .by { font-size: .7rem; opacity: .8; margin-top: .2rem; display: block; }
.bubble img { max-width: 220px; border-radius: 8px; display: block; margin-bottom: .3rem; }
.sysline { align-self: center; font-size: .78rem; color: var(--muted); background: #eaeef5; padding: .15rem .6rem; border-radius: 99px; }
.composer { background: #fff; border-top: 1px solid var(--line); padding: .7rem; display: flex; gap: .5rem; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; }
.details { border-left: 1px solid var(--line); background: #fff; overflow-y: auto; padding: 1rem; }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 2rem; }
@media (max-width: 1150px) { .inbox { grid-template-columns: 300px 1fr; } .inbox .details { display: none; } .inbox.show-details .details { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: 320px; z-index: 25; box-shadow: -10px 0 30px rgb(0 0 0 / 15%); } }
@media (max-width: 860px) { .inbox { grid-template-columns: 1fr; height: calc(100vh - 48px); } .inbox.has-conv .list { display: none; } .inbox:not(.has-conv) .thread { display: none; } }

/* ---------- auth / landing ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #0f1b2d 0%, #12324a 55%, #0f9d74 140%); }
.auth .card { width: 100%; max-width: 430px; }
.auth .logo { font-weight: 800; font-size: 1.4rem; color: var(--brand); margin-bottom: .3rem; }

.modal-bg { position: fixed; inset: 0; background: rgb(15 27 45 / 45%); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding: 1.2rem 1.3rem; box-shadow: 0 20px 60px rgb(0 0 0 / 25%); }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--danger); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.bars div { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars div.o { background: var(--accent); }
.meter { height: 8px; background: #eef1f7; border-radius: 99px; overflow: hidden; }
.meter > div { height: 100%; background: var(--brand); }
.meter.warn > div { background: var(--warn); }
.plan { border: 2px solid var(--line); border-radius: 14px; padding: 1rem; cursor: pointer; background: #fff; }
.plan.on { border-color: var(--brand); background: var(--brand-soft); }
.plan .price { font-size: 1.5rem; font-weight: 800; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: #f1f3f8; padding: .1rem .35rem; border-radius: 5px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
