/* IPSCK Photocopy — phone-first UI. Hand-written, no build step. */

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f766e;
  --brand-soft: #ecfdf5;
  --brand-ink: #ffffff;
  --accent: #1d4ed8;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --radius: 16px;
  --tab-h: 64px;
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1214; --card: #1a1f23; --ink: #f3f4f6; --muted: #9ca3af; --line: #2b3238;
    --brand-soft: #0d2b27; --warn-bg: #3a2a08; --danger-bg: #3b1212; --ok-bg: #0f2e1a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 18px; line-height: 1.4;
  color: var(--ink); background: var(--bg);
  min-height: 100vh;
}
body.has-nav main { padding-bottom: calc(var(--tab-h) + var(--sa-b) + 96px); }

/* Top bar */
.top {
  background: var(--brand); color: var(--brand-ink);
  padding: calc(10px + var(--sa-t)) 14px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: sticky; top: 0; z-index: 20;
}
.top a { color: inherit; text-decoration: none; }
.top .title { font-weight: 700; font-size: 18px; flex: 1; text-align: center; }
.top .back { font-size: 26px; width: 40px; line-height: 1; }
.top .who { font-size: 13px; opacity: .85; width: 40px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.offline {
  background: var(--danger); color: #fff; text-align: center; font-size: 14px; padding: 8px 12px;
  position: sticky; top: 0; z-index: 30;
}

main { max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; }

h1 { font-size: 24px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; }
p.help { color: var(--muted); font-size: 15px; margin: 4px 0 12px; }

/* Bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--sa-b));
  height: calc(var(--tab-h) + var(--sa-b));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; position: relative;
  border-radius: 12px; min-width: 0;
}
.tabbar a .ic { font-size: 22px; line-height: 1; }
.tabbar a.on { color: var(--brand); background: var(--brand-soft); }
.tabbar a .ur { display: none; }
.tabbar .dot {
  position: absolute; top: 2px; right: calc(50% - 22px);
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; font-weight: 700;
}

/* Home: today strip + menu */
.strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0 14px; }
.strip div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; }
.strip b { display: block; font-size: 22px; }
.strip span { font-size: 12px; color: var(--muted); }

.menu { display: grid; gap: 12px; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px; font-size: 21px; font-weight: 700;
  color: var(--ink); text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  min-height: 72px;
}
.menu a:active { transform: scale(.985); }
.menu a.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); min-height: 88px; }
.menu .icon { font-size: 30px; width: 40px; text-align: center; }
.menu .badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 16px; }
.menu a.primary .badge { background: rgba(255,255,255,.25); }
.menu a .ur { display: block; font-size: 15px; color: inherit; opacity: .8; text-align: left; direction: rtl; }
.menu a > span:not(.icon):not(.badge) { display: inline-block; }

/* Choice tiles */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.one { grid-template-columns: 1fr; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choices label {
  display: flex; flex-direction: column; justify-content: center; position: relative;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px 10px; text-align: center; font-size: 19px; font-weight: 700; min-height: 68px;
  cursor: pointer; user-select: none;
}
.choices label:active { transform: scale(.98); }
.choices input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.choices label:has(input:checked), .choices label.picked { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.choices label:has(input:checked)::after, .choices label.picked::after {
  content: "✓"; position: absolute; top: 6px; right: 10px; font-size: 14px; color: var(--brand);
}
.choices .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.choices .ur { font-size: .72em; }

/* Quick-pick chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.chips button {
  flex: 1 1 60px; font-size: 18px; font-weight: 700; padding: 12px 6px;
  border-radius: 999px; border: 2px solid var(--line); background: var(--card); color: var(--ink);
}
.chips button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* Fields */
.field { margin: 12px 0; }
.field label.lbl { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=number], input[type=text], input[type=password], select, textarea {
  width: 100%; font-size: 22px; padding: 14px; border: 2px solid var(--line);
  border-radius: var(--radius); background: var(--card); color: var(--ink);
}
input[type=number] { text-align: center; font-weight: 700; font-size: 28px; }
input:focus, select:focus { outline: 3px solid #99f6e4; border-color: var(--brand); }
input[type=file] { font-size: 15px; }
.stepper { display: grid; grid-template-columns: 72px 1fr 72px; gap: 8px; align-items: stretch; }
.stepper button {
  font-size: 34px; font-weight: 700; border-radius: var(--radius); border: 2px solid var(--line);
  background: var(--card); color: var(--ink); min-height: 64px;
}
.stepper button:active { background: var(--brand-soft); }
.filebtn {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px dashed var(--line);
  border-radius: var(--radius); padding: 14px; font-size: 17px; color: var(--muted); cursor: pointer;
}
.filebtn input { display: none; }
.filebtn.has { border-style: solid; border-color: var(--brand); color: var(--brand); }

/* Buttons */
.btn {
  display: block; width: 100%; text-align: center;
  font-size: 21px; font-weight: 700; padding: 18px;
  border-radius: var(--radius); border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); text-decoration: none;
  margin-top: 14px; min-height: 64px;
}
.btn:active { filter: brightness(.92); }
.btn.secondary { background: var(--card); color: var(--ink); border: 2px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn:disabled, .btn.busy { opacity: .6; }
.btn.busy::after { content: " …"; }
.btn .ur { display: inline; margin-left: 10px; color: inherit; opacity: .8; }

/* Sticky action bar at the bottom of forms */
.actions {
  position: sticky; bottom: calc(var(--tab-h) + var(--sa-b)); z-index: 15;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 10px 0 8px; margin-top: 16px;
}
body:not(.has-nav) .actions { bottom: 0; padding-bottom: calc(8px + var(--sa-b)); }
.actions .btn { margin-top: 0; }
.actions .btn + .btn { margin-top: 10px; }

/* Lists */
.list { display: grid; gap: 10px; }
.list a, .list .row {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; color: var(--ink); text-decoration: none; position: relative;
}
.list a::after { content: "›"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 28px; color: var(--muted); }
.list a { padding-right: 36px; }
.list .main { font-weight: 700; font-size: 19px; }
.list .meta { color: var(--muted); font-size: 15px; margin-top: 2px; }
.list .right { float: right; color: var(--muted); font-size: 14px; margin-left: 8px; }
.list a .right { margin-right: 12px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); vertical-align: middle; }
.pill.wait { background: var(--warn-bg); color: var(--warn); }
.pill.done { background: var(--ok-bg); color: var(--ok); }

/* Messages */
.msg { padding: 14px 16px; border-radius: var(--radius); margin-bottom: 14px; font-weight: 600; }
.msg.success { background: var(--ok-bg); color: var(--ok); }
.msg.error { background: var(--danger-bg); color: var(--danger); }
.msg.warning { background: var(--warn-bg); color: var(--warn); }
.msg.info { background: #dbeafe; color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card .big { font-size: 30px; font-weight: 800; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 17px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.summary { position: sticky; top: calc(48px + var(--sa-t)); z-index: 10; }

/* Success screen */
.done-screen { text-align: center; padding: 30px 10px 10px; }
.done-screen .tick {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px;
  background: var(--ok-bg); color: var(--ok); font-size: 56px; line-height: 96px; font-weight: 800;
}
.done-screen h1 { margin: 0 0 6px; }
.done-screen p { color: var(--muted); margin: 0 0 20px; font-size: 17px; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.small { font-size: 14px; color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 20px; }

/* Urdu line under English labels */
.ur { display: block; font-size: .8em; font-weight: 500; color: var(--muted); direction: rtl; margin-top: 2px;
      font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Noto Naskh Arabic", system-ui, sans-serif; }

/* Gate pass print */
@media print {
  .top, .btn, .noprint, .tabbar, .actions, .offline { display: none !important; }
  body { background: #fff; font-size: 14px; color: #000; }
  main { padding-bottom: 0; }
  .card { border-color: #000; }
}

/* Login */
.login { max-width: 380px; margin: 30px auto; }
.login .logo { text-align: center; font-size: 56px; margin-bottom: 6px; }
.login .field { margin: 12px 0; }
.pw { position: relative; }
.pw button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); border: 0; background: none; font-size: 15px; color: var(--muted); padding: 8px; }
#install { display: none; }

/* text-style button (sign out) */
.linkbtn { background: none; border: 0; padding: 12px 16px; color: var(--muted); font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer; }
