:root {
  --teal: #0f766e; --teal-dark: #115e59; --teal-soft: #ccfbf1;
  --bg: #f1f5f4; --card: #ffffff; --text: #17302d; --muted: #6b7f7c; --line: #dce5e3;
  --amber: #b45309; --amber-soft: #fef3c7; --red: #b91c1c; --red-soft: #fee2e2; --green-soft: #dcfce7; --green: #166534;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", "Noto Sans", sans-serif; font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
#app { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--bg); position: relative; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

/* login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px; padding-top: calc(24px + env(safe-area-inset-top)); gap: 16px; overflow: auto; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; background: var(--teal); margin: 0 auto; display: grid; place-items: center; }
.login .logo img { width: 44px; height: 44px; }
.login h1 { margin: 0; text-align: center; font-size: 24px; }
.login p.sub { margin: 0; text-align: center; color: var(--muted); }
.login form { display: flex; flex-direction: column; gap: 12px; background: var(--card); padding: 18px; border-radius: 16px; border: 1px solid var(--line); }
.login label { font-size: 14px; color: var(--muted); display: block; margin-bottom: 4px; }
.login input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); }
.login input:focus { outline: 2px solid var(--teal); border-color: transparent; }
.err { color: var(--red); background: var(--red-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.btn { background: var(--teal); color: #fff; border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 600; }
.btn:disabled { opacity: .6; }
.langbtn { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 14px; color: var(--teal-dark); }
.login .lang-row { display: flex; justify-content: flex-end; }

/* shell */
.top { background: var(--teal); color: #fff; display: flex; align-items: center; gap: 8px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
.top .title { flex: 1; min-width: 0; }
.top .title b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .title small { opacity: .85; font-size: 13px; }
.top .langbtn, .top .iconbtn { border-color: rgba(255,255,255,.5); color: #fff; }
.iconbtn { background: transparent; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; padding: 4px 12px; font-size: 14px; color: #fff; }
.banner { background: var(--amber-soft); color: var(--amber); padding: 6px 14px; font-size: 13px; text-align: center; }
main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tabs { display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 12px 0; font-weight: 600; color: var(--muted); border-top: 3px solid transparent; }
.tabs button.on { color: var(--teal-dark); border-top-color: var(--teal); }

/* chat list */
.search { padding: 10px 12px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
.search input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--text); }
.chat { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--card); border: 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); display: grid; place-items: center; font-weight: 700; flex: none; }
.chat .mid { flex: 1; min-width: 0; }
.chat .row1 { display: flex; justify-content: space-between; gap: 8px; }
.chat .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat .time { font-size: 12px; color: var(--muted); flex: none; }
.chat .row2 { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.chat .last { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: var(--teal); color: #fff; border-radius: 999px; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); margin-left: 6px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* chat detail */
.detail { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 5; }
.detail .top .back { background: transparent; border: 0; color: #fff; font-size: 24px; padding: 0 8px 0 0; line-height: 1; }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: #e3ecea; border-radius: 999px; padding: 2px 12px; margin: 6px 0; }
.bub { max-width: 82%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); background: #fff; }
.bub .who { font-size: 11px; font-weight: 700; margin-bottom: 2px; opacity: .8; }
.bub .when { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.bub.guest { align-self: flex-start; border-bottom-left-radius: 4px; }
.bub.bot { align-self: flex-end; background: var(--teal-soft); border-color: #99e6d8; border-bottom-right-radius: 4px; }
.bub.staff { align-self: flex-end; background: var(--amber-soft); border-color: #fcd98a; border-bottom-right-radius: 4px; }
.bub.failed .when { color: var(--red); font-weight: 600; }
.viewonly { padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: center; }

/* plan tab */
.cards { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.big { font-size: 30px; font-weight: 700; }
.big small { font-size: 15px; font-weight: 500; color: var(--muted); }
.bar { height: 10px; background: #e3ecea; border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.bar.warn i { background: #d97706; } .bar.full i { background: var(--red); }
.note { font-size: 13px; padding: 6px 10px; border-radius: 8px; margin-top: 8px; }
.note.warn { background: var(--amber-soft); color: var(--amber); } .note.full { background: var(--red-soft); color: var(--red); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; } .kv span:first-child { color: var(--muted); }
.st { padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--green-soft); color: var(--green); }
.st.grace { background: var(--amber-soft); color: var(--amber); } .st.expired, .st.cancelled { background: var(--red-soft); color: var(--red); }
.muted { color: var(--muted); }
