/* Census Lakhipur – styles. Light theme only: high contrast for use outdoors. */
:root {
  --paper: #ffffff;
  --wash: #f5f6f8;
  --ink: #1d2330;
  --muted: #5b6475;
  --line: #e1e4ea;
  --red: #a61e22;
  --red-dark: #7f1519;
  --red-soft: #fbeeee;
  --ok: #1f6b45;
  --ok-soft: #e8f4ed;
  --warn: #7a5200;
  --warn-soft: #fff4d6;
  --radius: 10px;
  --tap: 52px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: inherit; }
body {
  margin: 0; background: var(--wash); color: var(--ink);
  font: 16px/1.5 "Noto Sans", "Noto Sans Bengali", system-ui, -apple-system, Roboto, sans-serif;
}
:lang(as) body, .as { font-family: "Noto Sans Bengali", "Noto Sans", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red); }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- app bar ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: var(--red); color: #fff;
  display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 8px 0 12px;
}
.bar::after { /* gamosa border */
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px;
  background: repeating-linear-gradient(90deg, var(--red) 0 8px, #fff 8px 12px);
}
.bar h1 { font-size: 1.1rem; font-weight: 700; margin: 0; flex: 1; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .icon-btn { color: #fff; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; font-size: 1.35rem; line-height: 1;
}
.icon-btn:active { background: rgba(255,255,255,.18); }

main.page { max-width: 760px; margin: 0 auto; padding: 18px 14px 40px; }
.page-title { font-size: 1.35rem; margin: 4px 0 4px; line-height: 1.3; }
.sub { color: var(--muted); margin: 0 0 16px; }
.section-h { font-size: 1rem; font-weight: 700; margin: 22px 0 8px; }

/* ---------- surfaces ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.panel.tight { padding: 0; overflow: hidden; }

/* ---------- forms ---------- */
label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-weight: 600; margin: 0 0 6px; }
label.field > small { display: block; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px; background: var(--paper);
  border: 1.5px solid #c9ced8; border-radius: var(--radius); font-size: 1.05rem;
}
textarea.input { min-height: 110px; }
.input:focus, select.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.input.pin { letter-spacing: .6em; font-size: 1.5rem; text-align: center; font-weight: 700; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: var(--radius);
  border: 2px solid var(--red); background: var(--red); color: #fff; font-weight: 700;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:active { background: var(--red-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--paper); color: var(--red); }
.btn.ghost:active { background: var(--red-soft); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--red); min-height: 44px; padding: 0 8px; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .input:focus-visible, .tile:focus-visible, .list-row:focus-visible, .chip:focus-visible {
  outline: 3px solid var(--ink); outline-offset: 2px;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.actions > * { flex: 1 1 140px; }

/* ---------- messages ---------- */
.msg { border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; border-left: 5px solid; }
.msg.error { background: var(--red-soft); border-color: var(--red); color: #5e0f12; }
.msg.ok { background: var(--ok-soft); border-color: var(--ok); color: #123f29; }
.msg.warn { background: var(--warn-soft); border-color: #c98a00; color: #4d3400; }
.msg.info { background: #eef2fb; border-color: #3d5aa8; color: #1d2d5a; }
.msg p { margin: 4px 0; }
.msg ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- home tiles ---------- */
.hello { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.hello .name { font-size: 1.25rem; font-weight: 700; margin: 0; }
.hello .meta { color: var(--muted); margin: 2px 0 0; word-break: break-word; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 108px; padding: 14px; text-align: left; cursor: pointer; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
}
.tile .ico { font-size: 1.7rem; line-height: 1; }
.tile b { font-size: 1.02rem; }
.tile small { color: var(--muted); }
.tile.primary { background: var(--red); color: #fff; border-color: var(--red); grid-column: 1 / -1; min-height: 88px; }
.tile.primary small { color: #ffe3e3; }
.tile.soon { opacity: .55; cursor: default; }
.tile:active:not(.soon) { transform: scale(.985); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }

/* ---------- lists ---------- */
.search { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 60px); z-index: 5; background: var(--wash); padding: 4px 0 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid #c9ced8;
  background: var(--paper); cursor: pointer; font-weight: 600; font-size: .92rem;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  padding: 12px 14px; background: var(--paper); border: 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.list-row:last-child { border-bottom: 0; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .t { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; }
.list-row .s { color: var(--muted); font-size: .9rem; display: block; word-break: break-word; }
.list-row .chev { color: var(--muted); font-size: 1.3rem; }
.count-line { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge.red { background: var(--red-soft); color: var(--red-dark); }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.grey { background: #eceef2; color: #444c5c; }
.badge.amber { background: var(--warn-soft); color: var(--warn); }

dl.kv { margin: 0; display: grid; grid-template-columns: minmax(110px, 38%) 1fr; }
dl.kv dt { color: var(--muted); padding: 8px 0; border-bottom: 1px solid var(--line); }
dl.kv dd { margin: 0; padding: 8px 0 8px 10px; border-bottom: 1px solid var(--line); word-break: break-word; }

/* ---------- import ---------- */
.step-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.step-card h3 { margin: 0 0 2px; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.step-card .n { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--red); color: var(--red);
  display: inline-grid; place-items: center; font-size: .9rem; font-weight: 700; flex: 0 0 auto; }
.step-card.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.map-grid { display: grid; gap: 10px; margin: 10px 0; }
.map-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; align-items: center; }
.map-row span { font-weight: 600; font-size: .95rem; }
.map-row .req { color: var(--red); }
.result-counts { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.scroll-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.scroll-list div { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.scroll-list div:last-child { border-bottom: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1.5px solid var(--line); border-radius: 8px; margin: 6px 0; cursor: pointer; background: var(--paper); }
.choice input { margin-top: 4px; width: 20px; height: 20px; accent-color: var(--red); }
.choice:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- misc ---------- */
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.mt { margin-top: 16px; }
.brand { text-align: center; padding: 34px 16px 6px; }
.brand img { width: 76px; height: 76px; border-radius: 18px; }
.brand h1 { font-size: 1.45rem; margin: 12px 0 0; }
.brand p { color: var(--muted); margin: 4px 0 0; }
.links { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 10px; }
.lang-switch { display: flex; justify-content: center; gap: 8px; margin: 16px 0 0; }

.boot { min-height: 70vh; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--red-soft); border-top-color: var(--red); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

#busy { position: fixed; inset: 0; background: rgba(20, 24, 33, .45); z-index: 50; display: grid; place-items: center; padding: 20px; }
.busy-box { background: var(--paper); border-radius: 14px; padding: 22px 24px; display: flex; gap: 14px; align-items: center; max-width: 340px; }
.busy-box p { margin: 0; font-weight: 600; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); z-index: 60; max-width: calc(100% - 28px);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 600;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.offline-strip { background: #3a3f4b; color: #fff; text-align: center; font-size: .9rem; padding: 6px 10px; }
