:root {
  --bg: #FAF9F6;
  --card: #FFFFFF;
  --side: #F3F2ED;
  --gold: #776032;
  --gold-dark: #634E28;
  --beige: #E8E1CF;
  --ink: #292B28;
  --muted: #686960;
  --line: #E5E3DC;
  --ok: #356546;
  --ok-soft: #E8F4EC;
  --bad: #A8352D;
  --bad-soft: #F8E6E4;
  --choc: #351E11;
  --logo-gold: #C9A66B;
  --join: #F2C14E;
  --radius: 12px;
  font-family: 'Noto Sans', 'Noto Sans Devanagari', 'Noto Sans Bengali', 'Noto Sans SC', sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* logo */
.logo-box { display: inline-block; background: var(--choc); border: 2px solid var(--logo-gold); border-radius: 10px; padding: 6px 10px; box-shadow: 0 3px 8px rgba(53, 30, 17, .25); line-height: 0; }
.logo-box img { height: 34px; }
.logo-box.big img { height: 54px; }
.label { font-size: 10.5px; letter-spacing: 2.2px; font-weight: 700; color: var(--muted); text-transform: uppercase; }

/* buttons & fields */
.btn { border: none; border-radius: 8px; padding: 0 16px; min-height: 44px; font-weight: 700; font-size: 14px; background: var(--gold); color: #fff; }
.btn:hover { background: var(--gold-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--side); }
.btn.danger { background: var(--bad); }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 700; font-size: 14px; }
.input, select.input { min-height: 48px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; background: #FDFCF9; font-size: 15px; width: 100%; }
.input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; white-space: pre-line; margin-bottom: 12px; }
.notice { background: var(--ok-soft); color: var(--ok); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; }
.muted { color: var(--muted); }

/* login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; background: radial-gradient(circle at 50% 0%, #F1EADB 0%, var(--bg) 60%); }
.login-wrap .label { margin: 18px 0 22px; color: #7A5C24; }
.login-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 14px; padding: 30px 30px 26px; box-shadow: 0 10px 30px rgba(90, 70, 40, .08); }
.login-card h1 { font-size: 30px; margin: 6px 0 6px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); }
.login-foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.lang-select { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 8px; font-size: 13px; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.side { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; background: #FFFDF7; border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.top .crumb { display: none; font-size: 13.5px; }
.top .crumb span { color: #9A9A90; }
.pill { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.link-status { display: flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-size: 11.5px; font-weight: 700; border: 1px solid; }
.link-status i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.link-status.live { background: var(--ok-soft); color: var(--ok); border-color: #C5E2CF; }
.link-status.live i { background: #2F9E55; }
.link-status.off { background: #F3F2ED; color: var(--muted); border-color: var(--line); }
.link-status.off i { background: #B9B0A0; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--gold); color: #fff; font-weight: 700; }
.spacer { flex: 1; }
.pull-hint { text-align: center; font-size: 11.5px; color: var(--muted); padding: 8px 16px 0; }
.content { padding: 14px 16px 90px; }
.page-head { margin: 6px 0 16px; }
.page-head h1 { font-size: 26px; margin: 4px 0; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.card.accent { border-top: 3px solid var(--gold); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 13px; }
.tab.on { background: var(--gold); border-color: var(--gold); color: #fff; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 6; }
.bottom-nav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 6px 0; border-radius: 8px; }
.bottom-nav a.on { color: var(--gold); background: var(--beige); }
.menu { position: absolute; right: 16px; top: 62px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.08); padding: 8px; min-width: 200px; z-index: 20; }
.menu button, .menu a { display: block; width: 100%; text-align: left; border: none; background: none; padding: 10px 12px; border-radius: 8px; font-size: 14px; text-decoration: none; color: var(--ink); }
.menu button:hover, .menu a:hover { background: var(--side); }

/* tables */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
.row-actions .btn { white-space: nowrap; }
th { background: var(--side); text-align: left; font-size: 11px; letter-spacing: 1.2px; color: var(--muted); padding: 10px 12px; white-space: nowrap; }
td { border-top: 1px solid var(--line); padding: 10px 12px; vertical-align: top; }
.tag { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 700; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.wait { background: #FBF1DC; color: #7A4E00; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(41, 43, 40, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 22px; border-top: 3px solid var(--gold); }
.modal h2 { margin: 0 0 14px; font-size: 20px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: 1px; background: var(--side); padding: 2px 8px; border-radius: 6px; }

@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; gap: 6px; width: 250px; background: var(--side); border-right: 1px solid var(--line); padding: 26px 14px 18px; position: sticky; top: 0; height: 100vh; }
  .side .logo-box { align-self: flex-start; margin-left: 12px; }
  .side .label { padding: 16px 12px; }
  .side a { text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14.5px; }
  .side a.on { background: var(--beige); border-color: var(--beige); font-weight: 600; }
  .side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 12px; line-height: 1.5; }
  .top { padding: 14px 28px; }
  .top .logo-box { display: none; }
  .top .crumb { display: block; }
  .content { padding: 24px 28px 40px; }
  .pull-hint { display: none; }
  .bottom-nav { display: none; }
  .page-head h1 { font-size: 32px; }
}

/* roster grid */
.roster th { padding: 6px 4px; text-align: center; font-size: 10.5px; letter-spacing: 0; }
.roster td { white-space: nowrap; }
.rcell { min-width: 38px; min-height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 11.5px; font-weight: 700; padding: 0 4px; }
.rcell.off { background: #292B28; color: #fff; border-color: #292B28; }
.rcell.chg { background: var(--beige); }

/* housekeeping */
.ugroup { margin-bottom: 14px; }
.qgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.qtile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 92px; padding: 10px 8px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); font-weight: 700; font-size: 15px; line-height: 1.2; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.qtile .qi, .bigtab .qi { font-size: 28px; line-height: 1; }
.qtile:active, .bigtab:active { transform: scale(.98); }
.qtile.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.bigtabs { display: grid; gap: 8px; margin-bottom: 14px; }
.bigtab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 72px; padding: 8px 4px; border: 2px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); font-weight: 700; font-size: 14px; line-height: 1.2; text-align: center; }
.bigtab .qi { font-size: 24px; }
.bigtab.on { background: var(--gold); border-color: var(--gold); color: #fff; }
.fhead { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; padding: 8px 12px; border-radius: 10px; background: var(--beige, #E8E1CF); color: var(--ink); font-weight: 800; font-size: 15px; letter-spacing: .02em; }
.fhead span { margin-left: auto; font-weight: 600; font-size: 12px; color: var(--muted, #686960); }
.ghead { display: flex; gap: 8px; align-items: baseline; padding: 4px 2px 6px; flex-wrap: wrap; }
.ghead .muted { font-size: 11.5px; }
.ucard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; margin-bottom: 7px; box-shadow: 0 4px 14px rgba(90, 70, 40, .04); cursor: pointer; }
.ucard.pending { background: #292B28; border-color: #292B28; }
.ucard.pending .ucode { color: #fff; }
.ucard.pending .usub { color: #D6D3CA; }
.ucode { font-size: 15px; font-weight: 700; }
.usub { font-size: 11.5px; color: var(--muted); }
.ugrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.uchip { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 13px; font-weight: 600; }
.pgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ptile { aspect-ratio: 1; border-radius: 10px; border: 2px dashed #B9B0A0; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 22px; position: relative; overflow: hidden; padding: 0; }
.ptile span { font-size: 11.5px; font-weight: 700; }
.ptile.done { border: none; background: #5E574C; }
.ptile.done img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ptile.done span { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; color: #fff; text-shadow: 0 1px 2px #000; }
.jobbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.jobbar .btn { min-height: 56px; font-size: 15px; }

/* heavy alert */
.alert-overlay { position: fixed; inset: 0; z-index: 100; background: #A8352D; color: #fff; display: flex; flex-direction: column; align-items: center; padding: 28px 22px calc(26px + env(safe-area-inset-bottom)); gap: 12px; text-align: center; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { background: #A8352D; } to { background: #8E2424; } }
.alert-pill { background: rgba(0,0,0,.25); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700; letter-spacing: 1.4px; }
.alert-kind { font-size: 15px; font-weight: 700; letter-spacing: 2px; padding-top: 18px; opacity: .9; }
.alert-unit { font-size: 64px; font-weight: 800; line-height: 1; }
.alert-sub { font-size: 14px; opacity: .92; }
.alert-clock { margin-top: 14px; width: 150px; height: 150px; border-radius: 50%; border: 6px solid rgba(255,255,255,.35); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 40px; font-weight: 700; }
.alert-clock span { font-size: 12px; font-weight: 400; opacity: .85; }
.alert-accept { width: 100%; max-width: 480px; min-height: 72px; border: none; border-radius: 16px; background: #fff; color: #356546; font-size: 22px; font-weight: 800; }
.alert-silence { background: none; border: none; color: #fff; opacity: .85; text-decoration: underline; min-height: 44px; }
.jbox { display: inline-flex; border-radius: 6px; overflow: hidden; font-size: 12px; font-weight: 700; vertical-align: middle; }
.jbox b, .jbox i { font-style: normal; padding: 4px 8px; }
.jbox b.g { background: #2F7A45; color: #fff; } .jbox i { background: #E3F1E7; color: var(--ok); }
.jbox b.r { background: var(--bad); color: #fff; } .jbox i.r { background: #F6E1E1; color: var(--bad); }

/* chat */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.chat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chat-box { display: flex; flex-direction: column; gap: 8px; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
.daysep { align-self: center; background: var(--beige); border-radius: 999px; padding: 3px 12px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.msg { align-self: flex-start; max-width: 80%; background: #fff; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 7px 11px; }
.msg.me { align-self: flex-end; background: #EFE8D6; border-color: #E6DCC4; border-radius: 14px 4px 14px 14px; }
.msg .who { font-size: 12px; font-weight: 700; }
.msg .txt { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.msg .at { font-size: 11px; color: var(--muted); text-align: right; }
.msg .readby { font-size: 11.5px; color: var(--gold); font-weight: 700; }
.chat-input { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; align-items: center; padding: 8px 10px; background: #fff; border-top: 1px solid var(--line); z-index: 7; box-sizing: border-box; }
.chat-input > button { flex: 0 0 auto; width: 42px; height: 42px; padding: 0; }
.chat-input label { flex: 1 1 auto; min-width: 0; display: flex; }
.chat-input .input { width: 100%; min-width: 0; font-size: 16px; }
.chat-input .chat-text { resize: none; border-radius: 22px; padding: 10px 14px; min-height: 42px; max-height: 120px; line-height: 1.35; overflow-y: auto; font-family: inherit; display: block; }
.chat-input { align-items: flex-end; }
.chat-input > button[hidden] { display: none; }
/* Open chat = full screen like WhatsApp (phones); the list shrinks when the keyboard opens. */
.chat-screen { position: fixed; left: 0; right: 0; top: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--bg, #FAF9F6); z-index: 20; }
.chat-screen .chat-head { margin: 0; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: #fff; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.chat-screen .chat-box { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 12px; }
.chat-screen .chat-box > :first-child { margin-top: auto; }
.chat-screen.kb .chat-input { padding-bottom: 8px; }
.mention-pop { flex: 0 0 auto; max-height: 40vh; overflow-y: auto; background: #fff; border-top: 1px solid var(--line); }
.mention-pop[hidden] { display: none; }
.mention-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: none; border-bottom: 1px solid var(--line); background: #fff; text-align: left; font-size: 15px; color: var(--ink); }
.mention-pop button .avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.mention-pop button .muted { margin-left: auto; font-size: 12px; }
.at-tag { color: #1D5A9A; font-weight: 700; }
.msg.tagged { border: 2px solid var(--gold); }
.chat-screen .chat-input { position: relative; flex: 0 0 auto; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
body.chat-open { overflow: hidden; }
body.chat-open .bottom-nav { display: none; }
@media (min-width: 900px) {
  .chat-screen { position: relative; top: auto; height: calc(100vh - 150px); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
  .chat-screen .chat-head { padding-top: 8px; }
  .chat-screen .chat-input { padding-bottom: 8px; }
}
@media (min-width: 900px) { .chat-input { left: 250px; bottom: 0; } }

@media print {
  .side, .top, .bottom-nav, .pull-hint, .btn, .tabs, .qgrid, .bigtabs { display: none !important; }
  .content { padding: 0 !important; }
  body { background: #fff; }
  .table-wrap { overflow: visible; border: none; }
  table { min-width: 0 !important; font-size: 11px; }
}

/* Voice note recording (WhatsApp style) */
#c-voice { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; position: relative; z-index: 3; }
.chat-input.recording:not(.locked) #c-voice { transform: scale(1.45); }
.chat-input.locked #c-voice { display: none; }
.rec-bar { position: absolute; left: 0; top: 0; bottom: 0; right: 62px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: #fff; z-index: 2; }
.rec-bar[hidden], .rec-lock[hidden] { display: none; }
.chat-input.locked .rec-bar { right: 0; }
.chat-input:not(.locked) .rec-del, .chat-input:not(.locked) .rec-send { display: none; }
.chat-input.locked .rec-slide { display: none; }
.rec-del { border: none; background: none; font-size: 22px; width: 40px; height: 40px; padding: 0; }
.rec-send { width: 42px; height: 42px; flex: 0 0 auto; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #E0245E; flex: 0 0 auto; animation: recblink 1s infinite; }
@keyframes recblink { 50% { opacity: .15; } }
.rec-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 38px; }
#rec-wave { flex: 1 1 auto; min-width: 0; height: 30px; }
.rec-slide { color: var(--muted); font-size: 13px; white-space: nowrap; }
.rec-lock { position: absolute; right: 10px; bottom: 70px; width: 44px; padding: 10px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 2px 8px rgba(0,0,0,.12); z-index: 3; font-size: 18px; animation: recup 1.2s ease-in-out infinite; }
.rec-lock span { font-size: 14px; color: var(--muted); }
@keyframes recup { 50% { transform: translateY(-6px); } }

/* WhatsApp-style bar buttons */
.chat-input > .wa-plus { border: none; background: none; width: 34px; font-size: 26px; line-height: 1; color: var(--ink); font-weight: 400; }
.chat-input > .wa-cam { border: none; background: none; width: 36px; font-size: 22px; }

/* Photos in chat (WhatsApp style) */
.chat-photo { width: 240px; max-width: 100%; max-height: 320px; object-fit: cover; border-radius: 10px; display: block; }
.photo-preview { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.pp-top { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
.pp-x { border: none; background: rgba(255,255,255,.15); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; }
.pp-img { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pp-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pp-bar { display: flex; gap: 8px; align-items: center; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.pp-bar .input { flex: 1; min-width: 0; border-radius: 999px; font-size: 16px; background: #222; color: #fff; border-color: #333; }
.pp-bar .avatar { flex: 0 0 auto; width: 46px; height: 46px; }

/* ================= WhatsApp-style chat (our colours) ================= */
.ic { width: 24px; height: 24px; display: block; }
/* Chat list */
.wa-list { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.wa-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.wa-row:last-child { border-bottom: none; }
.wa-av { width: 48px; height: 48px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; flex: 0 0 auto; }
.wa-av.sm { width: 38px; height: 38px; font-size: 13px; }
.wa-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.wa-top, .wa-bot { display: flex; align-items: center; gap: 8px; }
.wa-top b { flex: 1; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-time { font-size: 12px; color: var(--muted); }
.wa-time.new { color: var(--gold); font-weight: 700; }
.wa-prev { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--gold); color: #fff; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
/* Chat screen */
.chat-screen .chat-head { display: flex; align-items: center; gap: 8px; }
.wa-back { color: var(--ink); display: inline-flex; padding: 6px 2px; }
.chat-screen .chat-box { background: #F1ECE2; gap: 3px; padding: 10px 12px 12px; }
.daysep { align-self: center; background: #fff; color: var(--muted); border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600; margin: 8px 0; box-shadow: 0 1px .5px rgba(0,0,0,.12); }
.msg { position: relative; max-width: 82%; border: none; border-radius: 0 10px 10px 10px; padding: 6px 9px 5px; background: #fff; box-shadow: 0 1px .6px rgba(0,0,0,.13); margin: 2px 0; transition: transform .15s ease; }
.msg.me { background: #F1E6CC; border-radius: 10px 0 10px 10px; }
.msg .who { font-size: 13px; font-weight: 700; margin-bottom: 1px; }
.msg .txt { font-size: 15.5px; line-height: 1.35; white-space: pre-wrap; word-break: break-word; display: inline; }
.msg .at { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 7px 0 -3px 12px; font-size: 11px; color: #8A8C84; line-height: 1; white-space: nowrap; }
.msg::after { content: ""; display: block; clear: both; }
.msg .readby { display: none; }
.msg.tagged { border: none; box-shadow: 0 0 0 2px var(--gold); }
.msg.flash { animation: waflash 1.2s ease; }
@keyframes waflash { 0%, 60% { box-shadow: 0 0 0 3px var(--gold); } }
.msg.swipe-ok { box-shadow: 0 0 0 2px var(--gold); }
.tks { display: inline-flex; color: #8A8C84; }
.tks.read { color: #3A9BDC; }
.tk { width: 16px; height: 11px; }
.tk.two { width: 19px; }
.pend .tk { width: 13px; height: 13px; }
.fail { color: var(--bad); font-weight: 700; font-size: 12px; }
/* Reply quote */
.quote { display: flex; flex-direction: column; gap: 1px; background: rgba(0,0,0,.05); border-left: 4px solid var(--gold); border-radius: 6px; padding: 5px 9px; margin-bottom: 5px; cursor: pointer; min-width: 0; }
.quote b { font-size: 12.5px; color: var(--gold); }
.quote span { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reply-bar { display: flex; align-items: center; gap: 8px; background: #fff; padding: 8px 10px 0; border-top: 1px solid var(--line); }
.reply-bar[hidden] { display: none; }
.reply-bar .quote { flex: 1; margin: 0; }
.reply-bar button { border: none; background: none; font-size: 18px; color: var(--muted); width: 36px; height: 36px; }
/* Photo in bubble */
.msg.media-photo { padding: 4px 4px 5px; }
.msg.media-photo .txt, .msg.media-photo .who, .msg.media-photo .quote { margin-left: 5px; margin-right: 5px; }
.msg.media-photo .at { margin-right: 6px; }
.ph { display: block; position: relative; padding: 0; border: none; background: none; border-radius: 8px; overflow: hidden; }
.chat-photo { width: 250px; max-width: 100%; max-height: 330px; object-fit: cover; border-radius: 8px; display: block; }
.ph.busy img { filter: brightness(.6); }
/* Spinners (sending) */
.spin { width: 20px; height: 20px; border: 2.5px solid rgba(119,96,50,.25); border-top-color: var(--gold); border-radius: 50%; display: inline-block; animation: waspin .8s linear infinite; }
.spin.big { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-width: 3.5px; border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes waspin { to { transform: rotate(360deg); } }
/* Voice note bubble */
.vn { display: flex; align-items: center; gap: 8px; width: 260px; max-width: 100%; padding: 4px 0 0; }
.vn-play { flex: 0 0 auto; width: 38px; height: 38px; border: none; background: none; color: var(--gold); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.vn-play .ic { width: 30px; height: 30px; }
.vn-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vn-wave { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.vn-wave i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: #C9BFA8; }
.vn-wave i.on { background: var(--gold); }
.vn-meta { font-size: 11px; color: #8A8C84; }
.vn-speed { flex: 0 0 auto; border: none; background: rgba(0,0,0,.08); color: var(--ink); border-radius: 12px; font-size: 12px; font-weight: 700; padding: 3px 8px; }
.msg.media-voice .at { margin-top: -14px; }
/* Jump to newest */
.jump-down { position: absolute; right: 14px; bottom: calc(86px + env(safe-area-inset-bottom)); width: 42px; height: 42px; border-radius: 50%; border: none; background: #fff; color: var(--muted); box-shadow: 0 2px 6px rgba(0,0,0,.2); display: flex; align-items: center; justify-content: center; z-index: 5; }
.jump-down[hidden] { display: none; }
.jump-down span:not(:empty) { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--gold); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
/* Typing bar: lifted off the bottom edge, WhatsApp icons */
.chat-screen .chat-input { padding: 8px 10px calc(14px + env(safe-area-inset-bottom)); gap: 6px; align-items: flex-end; }
.chat-screen.kb .chat-input { padding-bottom: 10px; }
.chat-input > .wa-plus, .chat-input > .wa-cam { border: none; background: none; color: #54564F; width: 40px; height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.chat-input > .wa-plus .ic { width: 28px; height: 28px; }
.chat-input > .avatar { width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.chat-input .chat-text { min-height: 44px; border-radius: 22px; background: #fff; border: 1px solid var(--line); padding: 11px 14px; }
/* Recording strip: same height as the bar, kept above the phone's bottom edge */
.chat-screen .rec-bar { bottom: calc(14px + env(safe-area-inset-bottom)); top: 8px; right: 66px; padding: 0 8px; gap: 10px; }
.chat-screen.kb .rec-bar { bottom: 10px; }
.chat-input.locked .rec-bar { right: 10px; }
.rec-del { color: #54564F; display: inline-flex; align-items: center; justify-content: center; }
.rec-del .ic { width: 26px; height: 26px; }
.rec-send { display: inline-flex; align-items: center; justify-content: center; padding: 0; width: 46px; height: 46px; }
.rec-dot { width: 11px; height: 11px; background: #D93A3A; }
.rec-time { font-size: 17px; }
#rec-wave { height: 32px; }
.rec-lock { bottom: calc(80px + env(safe-area-inset-bottom)); color: var(--muted); padding: 10px 0 4px; }
.rec-lock .ic { width: 22px; height: 22px; }
/* Long-press menu and message info */
.wa-sheet { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.ws-card { width: 100%; max-width: 520px; background: #fff; border-radius: 18px 18px 0 0; padding: 8px 0 calc(10px + env(safe-area-inset-bottom)); }
.ws-card > button { display: block; width: 100%; text-align: left; border: none; background: none; padding: 15px 22px; font-size: 16.5px; color: var(--ink); }
.ws-card > button + button { border-top: 1px solid var(--line); }
.ws-card .ws-cancel { text-align: center; font-weight: 700; color: var(--gold); }
.ws-info { padding: 16px 0 calc(10px + env(safe-area-inset-bottom)); }
.ws-info h3 { margin: 0 22px 12px; font-size: 18px; }
.wi-row { display: flex; align-items: center; gap: 10px; padding: 8px 22px; }
.wi-list { padding: 0 22px 10px 50px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
/* Photo viewer */
.photo-preview.viewer .pp-top { display: flex; align-items: center; gap: 12px; }
.pv-who { color: #fff; display: flex; flex-direction: column; font-size: 13px; }
.pv-who b { font-size: 16px; }
.pv-cap { color: #fff; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); font-size: 15px; text-align: center; }
.pp-bar .avatar { display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.chat-input.recording > label, .chat-input.recording > .wa-plus, .chat-input.recording > .wa-cam { visibility: hidden; }

/* ===== Quick job page: Make up room / Report damage / Lost & found / Call runner ===== */
.qpage { max-width: 560px; margin: 0 auto; }
.qp-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
.qp-head h1 { margin: 0; font-size: 22px; }
.qp-sec { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.qp-lab { font-weight: 800; font-size: 15px; margin-bottom: 10px; }
.unit-in { display: flex; align-items: center; gap: 8px; }
.unit-in.off { opacity: .35; pointer-events: none; }
.ui-c, .unit-in input { height: 62px; border-radius: 12px; font-size: 30px; font-weight: 800; text-align: center; }
.ui-c { width: 56px; display: inline-flex; align-items: center; justify-content: center; background: var(--side); color: var(--muted); border: 1px solid var(--line); }
.unit-in input { flex: 1; min-width: 0; border: 2px solid var(--line); background: #FDFCF9; color: var(--ink); padding: 0 4px; letter-spacing: 2px; }
.unit-in input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(119,96,50,.15); }
.unit-in input.bad { border-color: var(--bad); }
.ui-dash { font-size: 26px; font-weight: 800; color: var(--muted); }
.ui-labels { display: grid; grid-template-columns: 56px 1fr 1fr; gap: 0 30px; margin-top: 4px; font-size: 12px; color: var(--muted); text-align: center; padding-left: 0; }
.qp-msg { margin-top: 10px; font-size: 14px; color: var(--muted); min-height: 20px; }
.qp-msg .ok { color: var(--ok, #356546); font-weight: 800; font-size: 16px; }
.qp-msg .bad { color: var(--bad); font-weight: 700; }
.qp-link { border: none; background: none; color: var(--gold); font-weight: 700; padding: 8px 0 0; font-size: 14px; text-decoration: underline; }
#q-place { margin-top: 8px; font-size: 16px; }
.qp-remarks { min-height: 90px; padding: 12px 14px; font-size: 16px; line-height: 1.4; resize: vertical; font-family: inherit; }
.qp-urgent { display: flex; gap: 10px; align-items: center; font-weight: 800; margin-top: 12px; }
.qp-urgent input { width: 24px; height: 24px; }
.qp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 10px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-weight: 700; font-size: 14px; }
.chip input:checked + span { background: var(--gold); border-color: var(--gold); color: #fff; }
.qp-photos { display: flex; flex-wrap: wrap; gap: 10px; }
.qp-photos:not(:empty) { margin-bottom: 12px; }
.qp-th { position: relative; width: 92px; height: 92px; }
.qp-th img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.qp-x { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: #3A3C38; color: #fff; font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; }
.qp-add { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qp-pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 84px; border: 1.5px dashed #CFC6B0; border-radius: 12px; background: #FDFCF9; color: var(--gold); font-weight: 800; font-size: 15px; }
.qp-pick .ic { width: 30px; height: 30px; }
.qp-err { color: var(--bad); font-weight: 700; min-height: 20px; margin: 4px 2px 8px; }
.qp-send { min-height: 56px; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 14px; margin-bottom: 24px; }
.qp-send .ic { width: 22px; height: 22px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #292B28; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 80; box-shadow: 0 4px 14px rgba(0,0,0,.2); animation: toastin .2s ease; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ＋ attach sheet (WhatsApp style) */
.ws-attach { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 18px 12px calc(12px + env(safe-area-inset-bottom)); }
.ws-attach > button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 10px; font-size: 14px; font-weight: 600; text-align: center; border: none !important; }
.ws-attach > .ws-cancel { grid-column: 1 / -1; border-top: 1px solid var(--line) !important; padding-top: 14px; font-size: 16px; }
.wa-ico { width: 58px; height: 58px; border-radius: 50%; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.wa-ico .ic { width: 28px; height: 28px; }

/* ＋ attach panel: takes the keyboard's place (WhatsApp) */
.attach-panel { flex: 0 0 auto; background: #F4F1EA; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); align-content: start; gap: 18px 6px; padding: 22px 12px calc(12px + env(safe-area-inset-bottom)); overflow-y: auto; }
.attach-panel[hidden] { display: none; }
.attach-panel button { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); font-weight: 500; padding: 0; }
.ap-ico { width: 60px; height: 60px; border-radius: 16px; background: #fff; color: var(--gold); display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.ap-ico .ic { width: 28px; height: 28px; }
/* Recording bar: one row while holding, two rows when hands-free (WhatsApp) */
.rec-bar { flex-direction: column; align-items: stretch; justify-content: center; }
.rec-top { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.rec-row { display: none; }
.chat-input.locked { flex-wrap: wrap; }
.chat-input.locked > label, .chat-input.locked > .wa-plus, .chat-input.locked > .wa-cam, .chat-input.locked > #c-voice, .chat-input.locked > [aria-label="Send"] { display: none; }
.chat-screen .chat-input.locked .rec-bar { position: static; display: flex; width: 100%; gap: 12px; padding: 4px 4px 0; }
.chat-input.locked .rec-top { padding: 0 6px; }
.chat-input.locked .rec-row { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.chat-input.locked .rec-del, .chat-input.locked .rec-send { display: inline-flex; }
.rec-pause { border: none; background: none; color: #D93A3A; width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.rec-pause .ic { width: 30px; height: 30px; }
.chat-input.paused .rec-dot { animation: none; opacity: .35; }

/* While recording the typing box stays focused (keyboard stays up, like WhatsApp) but is not seen. */
.chat-input.recording > label { visibility: visible !important; opacity: 0; pointer-events: none; }
.chat-input.locked > label { display: block !important; position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

/* Swipe to reply (WhatsApp): reply arrow on the left of the bubble */
.swipe-ic { position: absolute; left: -40px; top: 50%; margin-top: -15px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.08); color: #54564F; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; }
.swipe-ic .ic { width: 18px; height: 18px; }
.msg.swipe-ok { box-shadow: 0 1px .6px rgba(0,0,0,.13); }
/* Reply bar with a quick suggestion */
.reply-bar { flex-direction: column; align-items: stretch; gap: 6px; padding-bottom: 4px; }
.rb-main { display: flex; align-items: center; gap: 8px; }
.rb-main .quote { flex: 1; margin: 0; }
.rb-sugg { display: flex; gap: 8px; }
.rb-sugg button { border: 1px solid var(--line); background: #F4F1EA; border-radius: 999px; padding: 6px 16px; font-size: 15px; font-weight: 700; color: var(--ink); }

/* OTW in the middle */
.rb-sugg { justify-content: center; }
.rb-sugg button { min-width: 96px; }

/* Swipe to reply: the page stays still, only the dragged message moves */
@media (max-width: 899px) {
  body.chat-open { position: fixed; inset: 0; width: 100%; overflow: hidden; overscroll-behavior: none; }
  html:has(body.chat-open) { overflow: hidden; overscroll-behavior: none; }
}
.chat-screen { overflow: hidden; overscroll-behavior: none; }
.chat-screen .chat-box { overflow-x: hidden; touch-action: pan-y; overscroll-behavior: contain; }
.chat-screen .chat-head, .chat-screen .chat-input, .attach-panel, .reply-bar { touch-action: manipulation; }

/* Swipe left on my message = Message info page (WhatsApp) */
.swipe-ic.info { left: auto; right: -40px; font-weight: 800; font-family: Georgia, serif; font-size: 17px; font-style: italic; }
.wa-info-page { position: fixed; inset: 0; z-index: 70; background: #F1ECE2; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; }
.wa-info-page.in { transform: translateX(0); }
.wip-head { display: flex; align-items: center; gap: 10px; background: #fff; border-bottom: 1px solid var(--line); padding: calc(8px + env(safe-area-inset-top)) 12px 10px; font-size: 17px; }
.wip-body { flex: 1; overflow-y: auto; padding: 16px 12px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.wip-msg { display: flex; flex-direction: column; }
.wip-msg .msg { align-self: flex-end; }
.wip-card { background: #fff; border-radius: 12px; padding: 4px 14px; box-shadow: 0 1px .6px rgba(0,0,0,.1); }
.wip-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.wip-row .muted { margin-left: auto; font-size: 13px; }
.wip-name { padding: 9px 0 9px 30px; border-top: 1px solid var(--line); font-size: 15px; }

/* Mic: bigger touch area around the button (easier to hit, like WhatsApp) */
#c-voice::before { content: ""; position: absolute; inset: -14px -12px -16px -16px; border-radius: 50%; }
#c-voice { -webkit-tap-highlight-color: transparent; }

/* ===== Touch feel like WhatsApp ===== */
html { -webkit-tap-highlight-color: transparent; }
button, a, .wa-row, .vn, .quote, .ph { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.chat-screen button, .wa-row, .attach-panel button, .qp-pick, .qtile, .bigtab { transition: transform .08s ease, opacity .08s ease, background-color .08s ease; }
.chat-input > .wa-plus:active, .chat-input > .wa-cam:active, .wa-back:active, .rec-del:active, .rec-pause:active, .vn-play:active, .vn-speed:active { opacity: .45; }
.chat-input > .avatar:active, .rec-send:active, .ap-ico:active, .attach-panel button:active .ap-ico { transform: scale(.9); }
.wa-row:active { background: #F4F1EA; }
.qtile:active, .bigtab:active, .qp-pick:active { transform: scale(.97); }
.msg { -webkit-touch-callout: none; }
.msg.appear { animation: waIn .2s cubic-bezier(.2,.8,.2,1); }
@keyframes waIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.msg.held { transform: scale(1.03); box-shadow: 0 6px 18px rgba(0,0,0,.18); transition: transform .15s ease; }
.chat-screen .chat-box { scroll-behavior: auto; -webkit-overflow-scrolling: touch; }

/* Document in chat (WhatsApp style) */
.doc { display: flex; align-items: center; gap: 10px; width: 250px; max-width: 100%; padding: 8px 10px; margin-bottom: 2px; border-radius: 8px; background: rgba(0,0,0,.05); color: var(--ink); text-decoration: none; }
.doc-ic { flex: 0 0 auto; width: 40px; height: 48px; border-radius: 4px; background: #D84B3A; color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.doc-ic .spin { border-color: rgba(255,255,255,.35); border-top-color: #fff; width: 18px; height: 18px; }
.doc-tx { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-tx b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tx span { font-size: 12px; color: var(--muted); }

/* 'Choose document' sheet (WhatsApp) */
.ws-doc { padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); background: #F4F1EA; }
.wsd-head { display: flex; align-items: flex-start; justify-content: center; position: relative; text-align: center; margin-bottom: 14px; }
.wsd-head div { display: flex; flex-direction: column; gap: 2px; }
.wsd-head b { font-size: 16px; }
.wsd-head span { font-size: 13px; color: var(--muted); }
.wsd-head button { position: absolute; right: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(0,0,0,.08); font-size: 14px; color: var(--ink); }
.wsd-list { background: #fff; border-radius: 12px; overflow: hidden; }
.ws-doc .wsd-list button { display: flex; align-items: center; gap: 14px; width: 100%; border: none; background: none; padding: 14px 16px; font-size: 16px; color: var(--ink); text-align: left; }
.ws-doc .wsd-list button + button { border-top: 1px solid var(--line); }
.ws-doc .wsd-list .ic { width: 22px; height: 22px; color: var(--ink); }
.ws-doc .wsd-list button:active { background: #F4F1EA; }
