/* =====================================================================
   css/mk-app.css — dashboard, chat and admin (loaded after mk.css on
   app.html and admin.html only).
   ===================================================================== */
body.app { background: var(--cream); }
.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: calc(100vh - var(--head-h)); }
.side { background: var(--paper); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: var(--head-h); height: calc(100vh - var(--head-h)); overflow: auto; }
.side a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--ink-2) !important; text-decoration: none !important; font-weight: 600; font-size: 15px; margin-bottom: 2px; position: relative; }
.side a:hover { background: var(--line-2); }
.side a[aria-current="page"] { background: var(--em-50); color: var(--em-800) !important; box-shadow: inset 3px 0 0 var(--em-600); }
.side a svg { width: 20px; height: 20px; }
.side .badge-count { position: static; margin-left: auto; box-shadow: none; }
.side .credits { margin: 18px 4px 0; padding: 16px; border-radius: 16px; background: linear-gradient(150deg, var(--em-700), var(--em-950)); color: #DDEFE6; font-size: 14px; }
.side .credits b { display: block; font-size: 28px; color: #fff; line-height: 1.1; }
.side .credits .btn { margin-top: 12px; width: 100%; }
.app-main { padding: 28px clamp(16px, 3vw, 36px) 60px; min-width: 0; }
.app-main.flush { padding: 0; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title h1 { font-size: 28px; margin: 0; }
.tabbar { display: none; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .app-main { padding-bottom: 96px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--paper); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted) !important; text-decoration: none !important; padding: 6px 0; position: relative; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--em-700) !important; }
  .tabbar .badge-count { top: 0; right: calc(50% - 22px); }
}
.tile { padding: 20px; }
.tile .k { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 30px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; margin-top: 6px; }
.list-row { display: flex; gap: 14px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }
.notif { cursor: pointer; border-radius: 12px; }
.notif:hover { background: var(--cream); }
.notif.unseen { background: var(--em-50); }
.notif-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--em-50); color: var(--em-700); flex: none; }
.notif-ico svg { width: 20px; height: 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--cream); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.st { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.st.pending { background: var(--amber-50); color: #7A4B00; }
.st.confirmed { background: var(--em-50); color: var(--em-800); }
.st.rejected { background: var(--red-50); color: #8E241C; }
.linkish { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; font: inherit; cursor: pointer; }
.pack { cursor: pointer; position: relative; border: 2px solid var(--line); transition: border-color .15s, box-shadow .15s; }
.pack:has(input:checked) { border-color: var(--em-600); box-shadow: 0 0 0 4px rgba(18,128,95,.12); }
.pack input { position: absolute; opacity: 0; }
.pack .amt { font-size: 30px; font-weight: 800; color: var(--ink); }
.pay-steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.pay-steps li { counter-increment: s; position: relative; padding: 0 0 18px 44px; }
.pay-steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--em-700); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.qr { width: 240px; height: auto; object-fit: contain; border-radius: 16px; border: 1px solid var(--line); background: #fff; padding: 10px; }
.copyable { display: inline-flex; align-items: center; gap: 8px; background: var(--cream); border: 1px dashed var(--line); padding: 8px 12px; border-radius: 10px; font-weight: 700; color: var(--ink); }
.photo-pick { display: flex; gap: 18px; align-items: center; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 360px 1fr; height: calc(100vh - var(--head-h)); background: var(--paper); }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: 18px 16px 10px; border-bottom: 1px solid var(--line-2); }
.chat-list-head h2 { font-size: 22px; margin-bottom: 12px; }
.chat-search { display: flex; align-items: center; gap: 8px; background: var(--cream); border-radius: 12px; padding: 0 12px; border: 1px solid var(--line); }
.chat-search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.mk .chat-search input { border: 0; background: transparent; box-shadow: none; min-height: 42px; padding: 0; }
.chat-tabs { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; }
.chat-tabs button { border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 7px 12px; font: 700 13px/1 var(--font); color: var(--muted); cursor: pointer; white-space: nowrap; }
.chat-tabs button[aria-pressed="true"] { background: var(--em-700); border-color: var(--em-700); color: #fff; }
.chat-rows { overflow-y: auto; flex: 1; padding: 6px; }
.chat-row { width: 100%; display: flex; gap: 12px; align-items: center; padding: 12px; border: 0; background: transparent; border-radius: 14px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.chat-row:hover { background: var(--cream); }
.chat-row.on { background: var(--em-50); }
.chat-row-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-row-top b { color: var(--ink); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-top time { font-size: 12px; color: var(--faint); flex: none; }
.chat-row-bot { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chat-row-bot .prev { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; color: var(--muted); }
.chat-row.unread .prev { color: var(--ink); font-weight: 700; }
.chat-row.unread time { color: var(--em-600); font-weight: 700; }
.chat-row .you { color: var(--faint); font-weight: 500; }
.chat-row .pill { background: var(--em-600); color: #fff; border-radius: 99px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.chat-row .mini { font-size: 12px; color: var(--faint); display: inline-flex; }
.chat-row .mini svg { width: 14px; height: 14px; }
.chat-row .grow { display: block; }
.chat-row .grow > span { display: flex; }
.chat-empty, .chat-welcome { text-align: center; padding: 48px 24px; color: var(--muted); }
.chat-empty > svg, .chat-welcome > svg { width: 52px; height: 52px; color: var(--em-500); opacity: .35; margin-bottom: 10px; }
.chat-welcome { margin: auto; max-width: 440px; }
.chat-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; background: radial-gradient(circle at 20% 10%, rgba(26,153,113,.06), transparent 45%), var(--cream); }
.th-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--paper); border-bottom: 1px solid var(--line); }
.th-back { display: none; }
.th-who { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--ink) !important; text-decoration: none !important; flex: 1; }
.th-who b { font-size: 16px; }
.th-status { display: block; font-size: 13px; color: var(--muted); }
.th-status.on { color: var(--em-600); font-weight: 700; }
.th-actions { display: flex; gap: 4px; }
.th-find { display: flex; gap: 10px; align-items: center; padding: 8px 14px; background: var(--paper); border-bottom: 1px solid var(--line-2); }
.th-banner:empty { display: none; }
.th-banner { padding: 10px 14px 0; }
.msgs { flex: 1; overflow-y: auto; padding: 16px clamp(12px, 3vw, 40px) 8px; display: flex; flex-direction: column; gap: 2px; }
.msgs.drop { outline: 3px dashed var(--em-500); outline-offset: -10px; }
.sys { align-self: center; max-width: 520px; text-align: center; font-size: 12.5px; color: #7A5B12; background: var(--gold-100); border-radius: 12px; padding: 8px 14px; margin: 6px 0 12px; }
.day { align-self: center; margin: 14px 0 8px; }
.day span { background: var(--paper); border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 99px; }
.msg { display: flex; flex-direction: column; max-width: min(72%, 560px); position: relative; margin-top: 10px; }
.msg.g { margin-top: 2px; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }
.msg .b { padding: 8px 12px 6px; border-radius: 18px; font-size: 15px; line-height: 1.5; box-shadow: var(--sh-1); overflow-wrap: anywhere; min-width: 84px; }
.msg.me .b { background: var(--em-700); color: #fff; border-bottom-right-radius: 6px; }
.msg.them .b { background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.g.me .b { border-top-right-radius: 6px; }
.msg.g.them .b { border-top-left-radius: 6px; }
.msg.me .b a { color: #CFE8FF !important; }
.msg .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; opacity: .75; margin-top: 2px; white-space: nowrap; }
.msg .tick { display: inline-flex; }
.msg .tick svg { width: 15px; height: 15px; }
.msg .tick.seen { color: #9BE7FF; }
.msg .b.deleted { font-style: italic; background: transparent; color: var(--muted); border: 1px dashed var(--line); box-shadow: none; }
.msg .b.deleted svg { width: 14px; height: 14px; }
.msg .b.uploading { opacity: .75; display: flex; gap: 8px; align-items: center; }
.msg .b.uploading svg { width: 18px; height: 18px; }
.msg .quote { border-left: 3px solid var(--gold-500); background: rgba(0,0,0,.05); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; font-size: 13px; cursor: pointer; }
.msg.me .quote { background: rgba(255,255,255,.14); }
.msg .quote b { display: block; font-size: 12px; }
.msg .img img { display: block; max-width: min(280px, 100%); max-height: 320px; border-radius: 12px; margin: 2px -4px 4px; object-fit: cover; }
.msg .file { display: flex; gap: 10px; align-items: center; text-decoration: none !important; color: inherit !important; padding: 4px 0; }
.msg .file svg { width: 30px; height: 30px; flex: none; }
.msg .file small { display: block; opacity: .75; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 200px; padding: 2px 0; }
.vplay { width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.2); color: inherit; display: grid; place-items: center; cursor: pointer; flex: none; }
.msg.them .vplay { background: var(--em-50); color: var(--em-700); }
.vplay svg { width: 16px; height: 16px; fill: currentColor; }
.vbar { flex: 1; height: 4px; background: rgba(127,127,127,.3); border-radius: 4px; overflow: hidden; }
.vbar span { display: block; height: 100%; width: 0; background: currentColor; transition: width .2s linear; }
.reacts { display: flex; gap: 4px; margin-top: -6px; z-index: 1; }
.reacts span { background: var(--paper); border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; font-size: 13px; box-shadow: var(--sh-1); }
.msg-tools { position: absolute; top: -16px; display: none; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: 99px; padding: 2px; box-shadow: var(--sh-2); z-index: 3; }
.msg.me .msg-tools { right: 6px; }
.msg.them .msg-tools { left: 6px; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { display: flex; }
.msg-tools button { border: 0; background: transparent; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.msg-tools button:hover { background: var(--line-2); }
.msg-tools svg { width: 16px; height: 16px; }
@media (hover: none) {
  .msg-tools { display: flex; position: static; margin-top: 4px; box-shadow: none; background: transparent; border: 0; }
}
.msg.flash .b { animation: flash 1.2s; }
.msg.hit .b { outline: 3px solid var(--gold-500); }
@keyframes flash { 30% { box-shadow: 0 0 0 4px var(--gold-500); } }
.typing { align-self: flex-start; margin: 0 clamp(12px, 3vw, 40px) 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 10px 14px; display: flex; gap: 4px; width: max-content; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 0 14px 8px; }
.quick:empty { display: none; }
.quick .chip { background: var(--paper); border: 1px solid var(--em-100); color: var(--em-800); cursor: pointer; white-space: nowrap; font-size: 13px; }
.reply-bar { display: flex; align-items: center; gap: 10px; margin: 0 12px; padding: 8px 12px; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--gold-500); border-radius: 12px 12px 0 0; font-size: 13px; }
.reply-bar b { display: block; color: var(--em-700); }
.reply-bar span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
.mk .composer textarea { flex: 1; min-height: 46px; max-height: 160px; resize: none; border-radius: 23px; padding: 12px 16px; background: var(--cream); line-height: 1.4; }
.composer .send { width: 46px; height: 46px; flex: none; border-radius: 50%; border: 0; background: var(--line); color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: background .15s; }
.composer .send.ready { background: var(--em-700); color: #fff; }
.composer .send svg { width: 20px; height: 20px; }
.composer .icon-btn { height: 46px; }
#micBtn.rec { background: var(--red); color: #fff; width: auto; padding: 0 12px; border-radius: 99px; animation: pulse 1.4s infinite; }
.rec-time { font: 700 13px/1 var(--font); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(200,55,45,.18); } }
.emoji-pop { position: absolute; bottom: 72px; left: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-3); padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; z-index: 10; width: 300px; }
.emoji-pop.hide { display: none; }
.emoji-pop button { border: 0; background: transparent; font-size: 22px; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; }
.emoji-pop button:hover { background: var(--line-2); }
.pop { position: fixed; z-index: 400; animation: pop .12s; }
.pop .menu { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-3); padding: 6px; min-width: 220px; }
.pop .menu > * { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; border: 0; background: transparent; border-radius: 10px; font: 600 14px/1.2 var(--font); color: var(--ink-2) !important; text-decoration: none !important; cursor: pointer; text-align: left; }
.pop .menu > *:hover { background: var(--line-2); }
.pop .menu .danger { color: var(--red) !important; }
.pop .menu svg { width: 17px; height: 17px; }
.react-pop { display: flex; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: 99px; box-shadow: var(--sh-3); padding: 4px; }
.react-pop button { border: 0; background: transparent; font-size: 22px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; transition: transform .1s; }
.react-pop button:hover { transform: scale(1.2); background: var(--line-2); }
.react-pop button.on { background: var(--em-50); }
.star-pick { display: flex; gap: 4px; margin: 8px 0 16px; }
.star-pick button { border: 0; background: none; font-size: 34px; color: var(--line); cursor: pointer; line-height: 1; }
.star-pick button.on { color: var(--gold-500); }
@media (max-width: 900px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - var(--head-h) - 64px); height: calc(100dvh - var(--head-h) - 64px); }
  .chat[data-view="thread"] .chat-list { display: none; }
  .chat[data-view="list"] .chat-pane { display: none; }
  .th-back { display: inline-grid; }
  .msg { max-width: 86%; }
  body.in-thread .tabbar { display: none; }
  body.in-thread .chat { height: calc(100vh - var(--head-h)); height: calc(100dvh - var(--head-h)); }
}

/* UPI app button only where UPI apps exist (phones) */
@media (hover: hover) and (pointer: fine) { .upi-phone { display: none; } }

@media (max-width: 640px) { .app-main .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .app-main .tile { padding: 16px; } .app-main .tile .v { font-size: 26px; } }
/* Two-column dashboard layouts that stack on phones and tablets */
.cols-main-side { grid-template-columns: 1.4fr 1fr; align-items: start; }
.cols-form-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 24px; }
.sticky-side { position: sticky; top: calc(var(--head-h) + 16px); }
.app-main .grid > * { min-width: 0; }
@media (max-width: 1000px) {
  .cols-main-side, .cols-form-side { grid-template-columns: 1fr; }
  .sticky-side { position: static; }
}
/* Admin: the tab bar scrolls sideways on narrow screens instead of overlapping */
.page-title .seg { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.page-title .seg button { white-space: nowrap; flex: none; }
@media (max-width: 640px) { .page-title { flex-direction: column; align-items: stretch; } .page-title .seg { display: flex; } }
