/* WYOHIDA DMS — single stylesheet. Mobile first, light + dark themes. */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --border: #dde4ee;
  --border-strong: #c5d0de;
  --text: #0f1b2d;
  --text-2: #3c4a5e;
  --muted: #64748b;
  --primary: var(--brand-primary, #15467a);
  --primary-2: var(--brand-primary-2, #0f3760);
  --primary-soft: var(--brand-primary-soft, #e7eef7);
  --on-primary: #ffffff;
  --accent: var(--brand-accent, #e2691f);
  --accent-soft: var(--brand-accent-soft, #fdeee4);
  --ok: #138a52;      --ok-soft: #e3f6ec;
  --warn: #b26b00;    --warn-soft: #fff4dc;
  --danger: #c62828;  --danger-soft: #fde8e8;
  --info: #0b6aa8;    --info-soft: #e3f2fc;
  --diamond: #1b7fb8; --gold: #b8860b; --silver: #6b7785; --bronze: #a0522d;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 4px 16px rgba(15, 27, 45, .06);
  --shadow-lg: 0 12px 40px rgba(15, 27, 45, .18);
  --radius: 14px;
  --radius-s: 10px;
  --topbar-h: 60px;
  --menu-w: 272px;
  --font: 'Hind Siliguri', 'Noto Sans Bengali', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121b2d;
  --surface-2: #172238;
  --surface-3: #1d2a43;
  --border: #26344f;
  --border-strong: #34476a;
  --text: #eef3fb;
  --text-2: #c9d4e5;
  --muted: #9fb0c8;
  --primary: #5aa2ff;
  --primary-2: #7ab4ff;
  --primary-soft: #16294a;
  --on-primary: #06152b;
  --accent: #ff8a3d;
  --accent-soft: #3a2a10;
  --ok: #4cd394;      --ok-soft: #10301f;
  --warn: #ffc14d;    --warn-soft: #3a2c0c;
  --danger: #ff7a7a;  --danger-soft: #3d1717;
  --info: #6cc3ff;    --info-soft: #0f2c42;
  --diamond: #6cc3ff; --gold: #f5c542; --silver: #c3ccd8; --bronze: #e19a6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  font-family: var(--font); font-size: 15.5px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.03rem; font-weight: 600; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
small, .muted { color: var(--muted); }
::selection { background: var(--primary-soft); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- utilities ---------- */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.gap-xs { gap: 4px; } .gap-s { gap: 8px; } .gap { gap: 14px; } .gap-l { gap: 22px; }
.grow { flex: 1; } .min0 { min-width: 0; }
.between { justify-content: space-between; } .end { justify-content: flex-end; } .center { justify-content: center; }
.w100 { width: 100%; }
.mt { margin-top: 14px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 14px; }
.right { text-align: right; } .tc { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.mono { font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
.text-ok { color: var(--ok); } .text-danger { color: var(--danger); } .text-warn { color: var(--warn); }
.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
}
@media (min-width: 1200px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.show-sm { display: none !important; }
@media (max-width: 860px) { .hide-sm { display: none !important; } .show-sm { display: inline-flex !important; } }
@media (max-width: 420px) { .hide-xs { display: none !important; } }

/* ---------- shell ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: var(--text); }
.brand-logo { height: 38px; width: auto; max-width: 110px; object-fit: contain; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: #fff; overflow: hidden;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-text b { font-size: .98rem; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pubnav { display: flex; align-items: center; gap: 4px; }
.pubnav a { padding: 8px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.pubnav a:hover { background: var(--surface-3); }
.pubnav a.btn { color: var(--on-primary); margin-left: 6px; }
.tb-actions { flex: none; }
.lang-btn span { font-weight: 700; font-size: .86rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; flex: none;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .85rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 46px; height: 46px; font-size: 1rem; }

.body { display: flex; align-items: flex-start; }
.main { flex: 1; min-width: 0; min-height: calc(100vh - var(--topbar-h)); padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

/* Right side menu: fixed column on desktop, slide-in drawer on phones */
.sidemenu {
  width: var(--menu-w); flex: none; background: var(--surface); border-left: 1px solid var(--border);
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  display: flex; flex-direction: column;
}
.menu-btn { display: none; }
@media (max-width: 1023px) {
  .menu-btn { display: inline-flex; }
  .sidemenu {
    position: fixed; z-index: 60; right: 0; top: 0; height: 100vh; height: 100dvh; width: min(86vw, 320px);
    transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
    padding-top: env(safe-area-inset-top);
  }
  .sidemenu.open { transform: none; }
}
.sidemenu.public { position: fixed; z-index: 60; right: 0; top: 0; height: 100vh; width: min(86vw, 320px); box-shadow: var(--shadow-lg); }
.sidemenu.public:not(.open) { display: none; }
.scrim { position: fixed; inset: 0; z-index: 55; background: rgba(5, 12, 25, .45); }
@media (min-width: 1024px) { .shell-app .scrim { display: none; } }
.menu-user { display: flex; align-items: center; gap: 10px; padding: 16px 14px; border-bottom: 1px solid var(--border); }
.menu-user small { display: block; }
.menu-list { display: flex; flex-direction: column; padding: 8px; gap: 2px; flex: 1; }
.menu-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 10px 4px; font-weight: 600; }
.menu-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500;
}
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.menu-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.tier-text { font-weight: 700; }
.tier-diamond { color: var(--diamond); } .tier-gold { color: var(--gold); } .tier-silver { color: var(--silver); } .tier-bronze { color: var(--bronze); }

/* ---------- page ---------- */
.page { padding: 16px 14px; max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page.narrow { max-width: 520px; padding-top: 28px; }
.page.medium { max-width: 820px; }
@media (min-width: 720px) { .page { padding: 22px 24px; } }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.page-head h1 { word-break: break-word; }
.page-head p { margin-top: 2px; }
.page-head > .grow { flex: 1 1 240px; }
.page-actions { margin-left: auto; }

/* ---------- card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-body { padding: 16px; }
.card-body.col { display: flex; }

/* ---------- stat tiles ---------- */
.stat {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); color: var(--text); font: inherit; cursor: default;
}
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--primary); }
.stat:disabled { opacity: 1; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.stat-label { font-size: .8rem; color: var(--muted); line-height: 1.2; }
.stat-value { font-size: 1.3rem; font-weight: 700; line-height: 1.25; word-break: break-word; }
.stat-sub { font-size: .76rem; color: var(--muted); }
.stat-go { color: var(--muted); flex: none; }
.tone-primary .stat-icon { background: var(--primary-soft); color: var(--primary); }
.tone-ok .stat-icon { background: var(--ok-soft); color: var(--ok); }
.tone-warn .stat-icon { background: var(--warn-soft); color: var(--warn); }
.tone-danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.tone-info .stat-icon { background: var(--info-soft); color: var(--info); }
.tone-accent .stat-icon { background: var(--accent-soft); color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px;
  padding: 8px 16px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.05); background: var(--accent); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
:root[data-theme="dark"] .btn-ok { color: #04210f; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #2a0606; }
.btn-ok:hover, .btn-danger:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: .86rem; border-radius: 9px; }
.btn-lg { min-height: 52px; padding: 10px 22px; font-size: 1.05rem; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; }
.btn-block { width: 100%; }

/* ---------- forms ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .full { grid-column: 1 / -1; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: .88rem; font-weight: 600; color: var(--text-2); }
.req { color: var(--danger); margin-left: 3px; }
.field-hint { font-size: .78rem; color: var(--muted); }
.field-error { font-size: .8rem; color: var(--danger); font-weight: 500; }
.input {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; /* 16px stops iOS zoom */
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.has-error .input { border-color: var(--danger); }
textarea.input { min-height: 84px; resize: vertical; }
select.input { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 6px 0; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.search { position: relative; flex: 1; min-width: 180px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 38px; }
.form-section { font-weight: 700; font-size: .95rem; color: var(--primary); padding-top: 6px; border-bottom: 1px dashed var(--border); padding-bottom: 6px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.toolbar > * { min-width: 0; }
.toolbar .field { flex: 1 1 160px; }

/* ---------- photo input ---------- */
.photo-input { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.photo-preview, .photo-ph { width: 120px; height: 120px; border-radius: 12px; object-fit: cover; border: 1px solid var(--border); flex: none; }
.photo-ph { display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-diamond { background: var(--info-soft); color: var(--diamond); border-color: var(--diamond); }
.badge-gold { background: var(--warn-soft); color: var(--gold); border-color: var(--gold); }
.badge-silver { background: var(--surface-3); color: var(--silver); border-color: var(--silver); }
.badge-bronze { background: var(--accent-soft); color: var(--bronze); border-color: var(--bronze); }

/* ---------- tabs (wrap — never side-scroll) ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; background: var(--surface-3); border-radius: 12px; }
.tab { flex: 1 1 auto; border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 12px; border-radius: 9px; cursor: pointer; min-height: 38px; }
.tab.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: .75rem; }

/* ---------- tables ---------- */
.table-wrap { width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 760px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--border); border-radius: 12px; margin: 0 0 10px; padding: 6px 2px; background: var(--surface); }
  .table td { border: 0; padding: 5px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; max-width: 45%; }
  .table td.num { text-align: right; }
  .card .table-wrap { padding: 10px; }
}

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.kv dt { color: var(--muted); font-size: .88rem; flex: none; max-width: 48%; }
.kv dd { margin: 0; text-align: right; font-weight: 500; word-break: break-word; }
@media (min-width: 720px) { .kv.two { grid-template-columns: 1fr 1fr; column-gap: 28px; } }

/* ---------- alerts / empty / spinner ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid; }
.alert .icon { flex: none; margin-top: 2px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert b, .alert p { color: inherit; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px 12px; color: var(--muted); text-align: center; }
.spinner-wrap { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 40px; color: var(--muted); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- modal (bottom sheet on phones) ---------- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(5, 12, 25, .5); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-height: 92vh; display: flex; flex-direction: column; border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg); padding-bottom: env(safe-area-inset-bottom); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (min-width: 720px) {
  .modal-back { align-items: center; padding: 20px; }
  .modal { max-width: 560px; border-radius: 18px; }
  .modal-wide { max-width: 920px; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-lg); background: var(--text); color: var(--bg); animation: rise .2s ease; }
.toast-danger { background: var(--danger); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* ---------- maps ---------- */
.map { width: 100%; height: 320px; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; z-index: 1; background: var(--surface-3); }
.map.tall { height: 460px; }
@media (max-width: 720px) { .map.tall { height: 380px; } }
.leaflet-container { font: inherit; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(.75) contrast(1.1) saturate(.8); }
.map-pin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, button.list-item:hover { background: var(--surface-2); }
button.list-item { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; text-align: left; cursor: pointer; }
.list-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.list-icon.unread { background: var(--accent-soft); color: var(--accent); }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-3); }

/* ---------- home (public) ---------- */
.hero { position: relative; overflow: hidden; color: #fff; background: linear-gradient(135deg, #0d2c4c 0%, #15467a 60%, #1d5a96 100%); }
.hero::after { content: ''; position: absolute; right: -120px; top: -120px; width: 380px; height: 380px; border-radius: 50%; background: rgba(255,255,255,.07); }
.hero-inner { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 42px 18px 46px; display: grid; gap: 22px; }
.hero h1 { color: #fff; font-size: clamp(1.6rem, 5vw, 2.6rem); font-weight: 800; }
.hero p { color: #dbe8fb; font-size: 1.05rem; max-width: 640px; }
.hero .btn { border-color: transparent; }
.hero .btn-light { background: #fff; color: #15467a; }
.hero .btn-outline { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.4); }
.brand-strip { display: flex; gap: 12px; flex-wrap: wrap; }
.brand-chip { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; padding: 8px 14px; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-chip img { height: 34px; width: auto; background: #fff; border-radius: 6px; padding: 3px 6px; }
.section { max-width: 1180px; margin: 0 auto; padding: 34px 16px; display: flex; flex-direction: column; gap: 18px; }
.section-title { display: flex; flex-direction: column; gap: 4px; }
.feature-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.feature .list-icon { margin-bottom: 4px; }
.gallery { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; }
.gallery figcaption { padding: 8px 10px; font-size: .85rem; font-weight: 600; }
.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer .section { padding: 22px 16px; gap: 6px; font-size: .9rem; }
.steps { counter-reset: s; display: grid; gap: 10px; }
.steps li { list-style: none; counter-increment: s; display: flex; gap: 12px; align-items: flex-start; }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; flex: none; font-size: .85rem; }
.steps { padding: 0; margin: 0; }

/* ---------- field work ---------- */
.day-hero { border-radius: var(--radius); padding: 18px; color: #fff; background: linear-gradient(135deg, #15467a, #1d5a96); display: flex; flex-direction: column; gap: 12px; }
.day-hero.break { background: linear-gradient(135deg, #b26b00, #e08e00); }
.day-hero.ended { background: linear-gradient(135deg, #334155, #475569); }
.day-hero.idle { background: linear-gradient(135deg, #0f766e, #14958a); }
.day-hero h2, .day-hero p, .day-hero small { color: #fff; }
.day-hero .btn { border-color: transparent; }
.day-hero .btn-light { background: #fff; color: #103658; }
.day-hero .btn-outline { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.45); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; display: inline-block; box-shadow: 0 0 0 0 rgba(74,222,128,.7); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
.reason-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.reason { border: 1px solid var(--border-strong); border-radius: 12px; padding: 12px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.reason.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------- product picker ---------- */
.products { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .products { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.product { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.product.oos { opacity: .6; }
.qty { display: flex; align-items: center; gap: 4px; flex: none; }
.qty input { width: 58px; text-align: center; min-height: 38px; padding: 4px; }
.cartbar { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); }
.cartbar b, .cartbar small { color: var(--bg); }

/* ---------- import wizard ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: 14px; padding: 26px 16px; text-align: center; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.preview-scroll { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.preview-scroll table { border-collapse: collapse; font-size: .82rem; min-width: 100%; }
.preview-scroll td, .preview-scroll th { padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.preview-scroll th { background: var(--surface-2); position: sticky; top: 0; }
.map-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ---------- letters (screen + print, A4) ---------- */
.letter-stage { background: var(--surface-3); border-radius: var(--radius); padding: 14px; overflow-x: auto; }
.letter {
  background: #fff; color: #111; width: 210mm; max-width: none; min-height: 297mm; margin: 0 auto; padding: 14mm 15mm;
  box-shadow: 0 2px 12px rgba(0,0,0,.15); font-size: 11.5pt; line-height: 1.5;
  font-family: 'Hind Siliguri', 'Noto Sans Bengali', 'Segoe UI', Arial, sans-serif;
}
.letter * { color: #111; }
.letter h1, .letter h2, .letter h3 { color: #103658; }
.lh { display: flex; gap: 14px; align-items: center; border-bottom: 3px solid #15467a; padding-bottom: 8px; }
.lh img { height: 64px; width: auto; max-width: 150px; object-fit: contain; }
.lh-mark { width: 60px; height: 60px; border-radius: 12px; background: #15467a; color: #fff !important; display: grid; place-items: center; font-size: 26px; font-weight: 800; flex: none; }
.lh-name { font-size: 20pt; font-weight: 800; color: #103658 !important; letter-spacing: .3px; line-height: 1.1; }
.lh-sub { font-size: 9.5pt; color: #333 !important; }
.lh-strip { background: #15467a; height: 4px; margin-top: 3px; }
.l-meta { display: flex; justify-content: space-between; gap: 12px; margin: 12px 0; font-size: 10.5pt; flex-wrap: wrap; }
.l-title { text-align: center; font-size: 14pt; font-weight: 800; text-decoration: underline; margin: 10px 0 12px; color: #103658 !important; letter-spacing: .5px; }
.l-table { width: 100%; border-collapse: collapse; margin: 8px 0 10px; font-size: 10pt; }
.l-table th, .l-table td { border: 1px solid #9aa7b8; padding: 5px 7px; text-align: left; vertical-align: top; }
.l-table th { background: #e9f0fa; }
.l-table .num { text-align: right; white-space: nowrap; }
.l-terms { margin: 6px 0 10px 18px; padding: 0; font-size: 9.6pt; }
.l-terms li { margin: 2px 0; }
.l-box { border: 1px solid #9aa7b8; border-radius: 6px; padding: 8px 10px; margin: 8px 0; background: #f7f9fc; }
.l-sign { display: flex; justify-content: space-between; gap: 18px; margin-top: 22px; flex-wrap: wrap; }
.l-sign > div { min-width: 170px; text-align: center; font-size: 10pt; }
.l-sign .line { border-top: 1px solid #333; margin-top: 46px; padding-top: 4px; }
.l-sign img { height: 52px; margin: 0 auto -10px; object-fit: contain; }
.l-foot { margin-top: 16px; border-top: 1px solid #ccd5e1; padding-top: 6px; font-size: 8.5pt; color: #555 !important; text-align: center; }
.l-stamp { display: inline-block; border: 2px solid #c62828; color: #c62828 !important; font-weight: 800; padding: 2px 10px; transform: rotate(-4deg); border-radius: 6px; font-size: 11pt; }
.l-congrats { text-align: center; font-size: 24pt; font-weight: 800; color: #b8860b !important; margin: 4px 0; }
.avoid-break { break-inside: avoid; page-break-inside: avoid; }

@media print {
  @page { size: A4; margin: 0; }
  .letter { zoom: 1 !important; }
  html, body { background: #fff !important; }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 210mm; }
  .letter-stage { background: none; padding: 0; overflow: visible; }
  .letter { box-shadow: none; margin: 0; width: 210mm; max-width: none; min-height: auto; }
  .no-print { display: none !important; }
}

/* demo mode banner */
.demo-bar { background: var(--accent); color: #1b1200; font-size: .82rem; font-weight: 600; text-align: center; padding: 5px 10px; }

/* brand logo */
.brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.hero-logo { background: #fff; border-radius: 18px; padding: 14px; width: min(240px, 60vw); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.hero-inner { align-items: center; }
@media (min-width: 860px) { .hero-inner { grid-template-columns: 1fr auto; } }
.lh-logo { height: 70px; width: auto; }

.brand-initial { background: var(--primary); color: #fff; font-weight: 800; font-size: 1.2rem; display: grid; place-items: center; }
.platform-hero { background: linear-gradient(135deg, #0b2440 0%, #123a63 55%, #1b5b95 100%); }
.platform-hero .hero-logo { width: min(320px, 80vw); padding: 8px; }
.tenant-card { display: flex; flex-direction: column; gap: 10px; }
.tenant-card .tc-head { display: flex; align-items: center; gap: 12px; }
.tenant-logo { width: 52px; height: 52px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--border); flex: none; display: grid; place-items: center; font-weight: 800; color: var(--primary); }
.slug-preview { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; background: var(--surface-3); border-radius: 8px; padding: 6px 10px; word-break: break-all; }
.color-row { display: flex; gap: 12px; flex-wrap: wrap; }
.color-row input[type=color] { width: 54px; height: 40px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); padding: 2px; }

/* HR */
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }
a.alert { text-decoration: none; color: inherit; }

/* ======================================================================
   Phone layout: compact, app-like (bottom tab bar, tighter spacing)
   ====================================================================== */
.bottomnav, .show-phone { display: none; }
@media (max-width: 760px) {
  :root { --topbar-h: 54px; --radius: 12px; }
  body { font-size: 14.5px; }
  h1 { font-size: 1.2rem; }
  h2 { font-size: 1.06rem; }
  .hide-phone { display: none !important; }
  .show-phone { display: flex; }

  /* top bar */
  .topbar { padding: 0 6px 0 10px; gap: 6px; }
  .brand { gap: 8px; }
  .brand-logo, .brand-mark { height: 32px; }
  .brand-mark { width: 32px; border-radius: 8px; }
  .brand-text b { font-size: .92rem; }
  .brand-text small { font-size: .7rem; }
  .has-bottomnav .topbar .menu-btn { display: none; }   /* the bottom bar has "More" */
  .avatar { width: 32px; height: 32px; font-size: .78rem; }

  /* page */
  .page { padding: 10px 10px 14px; gap: 12px; }
  .page.narrow { padding-top: 14px; }
  .page-head { gap: 8px; }
  .page-head p { font-size: .84rem; }
  .page-head > .grow { flex-basis: 100%; }
  .page-actions { margin-left: 0; width: 100%; gap: 6px !important; }
  .page-actions .btn { flex: 1 1 auto; min-height: 38px; padding: 6px 10px; font-size: .84rem; gap: 6px; }
  .page-actions .btn .icon { width: 17px; height: 17px; }

  /* cards & tiles */
  .card-head { padding: 10px 12px; }
  .card-body { padding: 12px; }
  .stats { gap: 8px; }
  .stat { padding: 10px; gap: 9px; align-items: flex-start; }
  .stat-icon { width: 32px; height: 32px; border-radius: 9px; }
  .stat-icon .icon { width: 18px; height: 18px; }
  .stat-label { font-size: .74rem; }
  .stat-value { font-size: 1.08rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }
  .stat-sub { font-size: .7rem; }
  .stat-go { display: none; }

  /* buttons & forms */
  .btn { min-height: 40px; padding: 7px 13px; font-size: .9rem; border-radius: 10px; }
  .btn-lg { min-height: 46px; font-size: .98rem; }
  .btn-sm { min-height: 32px; padding: 4px 10px; font-size: .82rem; }
  .btn-icon { width: 38px; min-height: 38px; padding: 0; }
  .input { font-size: 16px; }                           /* no zoom on focus */
  .toolbar { gap: 8px; }

  /* tabs: compact, still wrapping */
  .tabs { gap: 4px; padding: 3px; border-radius: 10px; }
  .tab { min-height: 34px; padding: 6px 8px; font-size: .82rem; border-radius: 8px; }

  /* table rows as compact cards: first column is the title, the rest in two columns */
  .table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px;
    margin: 0 0 8px; padding: 10px 12px; border-radius: 10px; }
  .table td { display: block; padding: 0; font-size: .86rem; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  .table td.num { text-align: left; white-space: normal; }
  .table td::before { display: block; max-width: none; font-size: .68rem; line-height: 1.3; margin-bottom: 1px; }
  .table td:first-child { grid-column: 1 / -1; font-size: .95rem; }
  .table td:first-child::before { display: none; }
  .table td[data-label=""] { grid-column: 1 / -1; }
  .table td[data-label=""]::before { display: none; }
  .table td:empty { display: none; }
  .card .table-wrap { padding: 8px; }
  .toolbar .search { flex: 1 1 100%; }

  /* sheets (modals) */
  .modal-head { padding: 12px 14px; }
  .modal-body { padding: 12px 14px; gap: 12px; }
  .modal-foot { padding: 10px 14px; gap: 8px; }
  .modal-foot .btn { flex: 1 1 auto; }

  .alert { padding: 10px 12px; font-size: .88rem; }
  .day-hero { padding: 14px; }
  .kv > div { padding: 7px 0; }

  /* bottom tab bar */
  .has-bottomnav .main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(10, 30, 60, .06);
  }
  .bn-item {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 6px 2px; border: 0; background: transparent; border-radius: 10px; color: var(--muted);
    font: inherit; font-size: .68rem; font-weight: 600; cursor: pointer; min-height: 52px;
  }
  .bn-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .bn-item.on { color: var(--primary); }
  .bn-item.on .icon { background: var(--primary-soft); border-radius: 99px; padding: 3px 14px; width: 50px; height: 28px; box-sizing: border-box; }
  .toaster, .toasts { bottom: calc(80px + env(safe-area-inset-bottom)) !important; }
}

/* gallery: many images at once */
.bulk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.bulk-item { position: relative; border: 1px solid var(--border); border-radius: 10px; padding: 6px; background: var(--surface-2); display: flex; flex-direction: column; gap: 6px; }
.bulk-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px; background: #fff; }
.bulk-item .input { min-height: 34px; padding: 4px 8px; font-size: .82rem; }
.bulk-x { position: absolute; top: 8px; right: 8px; width: 28px; min-height: 28px; background: rgba(255,255,255,.9); border-radius: 50%; }
.bulk-ok { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; }
.bulk-item.done img { opacity: .6; }

/* letters on small screens: the whole A4 page is shown scaled to fit (see fitLetters in app.js) */
.letter-stage.fitted { overflow: hidden; }
@media (max-width: 760px) { .letter-stage { padding: 6px; border-radius: 10px; } }

/* notifications */
.bell { position: relative; }
.bell-count { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; }
.notif-list { display: flex; flex-direction: column; overflow: hidden; }
.notif { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 12px 14px; border: 0;
  border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--surface-2); }
.notif.new { background: var(--primary-soft); }
.notif-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--primary); flex: none; }
.notif-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notif-text span { color: var(--text-2); font-size: .9rem; overflow-wrap: anywhere; }
.notif-text small { font-size: .74rem; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: none; }
pre.code { background: var(--surface-3); border-radius: 8px; padding: 8px 10px; margin: 6px 0; white-space: pre-wrap; font-size: .9rem; }

/* choose recipients */
.pick-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.pick-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.pick-row:last-child { border-bottom: 0; }
.pick-row.on { background: var(--primary-soft); }
.pick-row input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
