/* ==========================================================================
   TCF Solar Care — mobile-first styles
   Built for low-end Android phones: large tap targets, high contrast,
   no heavy effects, works in both LTR (English) and RTL (Urdu).
   ========================================================================== */

:root {
  --green-900: #0A4726;
  --green-700: #0F7B3E;
  --green-600: #12874A;
  --green-100: #E4F3EA;
  --green-050: #F2F9F5;

  --yellow-600: #E0A200;
  --yellow-500: #F5B301;
  --yellow-100: #FFF4D6;

  --red-600: #C62828;
  --red-100: #FDECEC;
  --blue-600: #1565C0;
  --blue-100: #E7F0FB;
  --amber-600: #B26A00;
  --amber-100: #FFF1DC;

  --ink-900: #14261C;
  --ink-700: #3A4A41;
  --ink-500: #6B7A72;
  --ink-300: #B6C1BB;
  --ink-100: #E6EBE8;
  --paper: #FFFFFF;
  --bg: #F5F7F6;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(20, 38, 28, .10), 0 4px 14px rgba(20, 38, 28, .06);
  --nav-h: 62px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ur: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: transparent;
  color: var(--ink-900);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: contain;
}

/* ==========================================================================
   AMBIENT SKY — set by assets/theme.js, drifts with the real sun.
   Decorative only: it sits behind everything and never carries text.
   ========================================================================== */
html {
  background:
    linear-gradient(
      to bottom,
      var(--amb-sky-1, #4E92D8) 0%,
      var(--amb-sky-2, #8FC0EC) 46%,
      var(--amb-sky-3, #D9EAFA) 100%
    ) fixed;
  transition: background-color 2s linear;
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(120% 62% at 78% 6%, var(--amb-glow, #8FC0EC) 0%, transparent 62%),
    linear-gradient(to bottom,
      var(--amb-sky-1, #4E92D8) 0%,
      var(--amb-sky-2, #8FC0EC) 46%,
      var(--amb-sky-3, #D9EAFA) 100%);
  transition: background 1.6s linear;
}
/* A veil keeps the content plane readable no matter how saturated the sky is. */
body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--amb-veil, rgba(255,255,255,.62));
  transition: background 1.6s linear;
}

/* every themed token animates so the drift is felt, not seen */
.card, .item, .stat, .tabbar, .topbar, .acc, .notif, .check, .chip,
.field input, .field select, .field textarea, .sheet, .bubble {
  transition: background-color .9s linear, color .9s linear, border-color .9s linear;
}

@media (prefers-reduced-motion: reduce) {
  html, body::before, body::after, .card, .item, .stat, .tabbar, .topbar,
  .acc, .notif, .check, .chip, .sheet, .bubble { transition: none !important; }
}

body[dir="rtl"] { font-family: var(--font-ur); line-height: 1.9; }

img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: 16px; }

/* ---------- layout ------------------------------------------------------ */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--green-700);
  color: #fff;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  padding-top: calc(10px + env(safe-area-inset-top));
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar .brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.topbar .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: #fff; display: grid; place-items: center;
  font-size: 19px; flex: none;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: .1px; }
.topbar .sub { font-size: 11.5px; opacity: .85; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-btn {
  background: rgba(255,255,255,.16); border: 0; color: #fff;
  border-radius: 9px; padding: 8px 11px; font-size: 13px; font-weight: 600;
  cursor: pointer; flex: none;
}
.topbar-btn:active { background: rgba(255,255,255,.28); }

main { flex: 1; padding: 14px 14px calc(var(--nav-h) + 26px); max-width: 720px; width: 100%; margin: 0 auto; }

/* ---------- bottom nav -------------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  background: var(--paper);
  border-top: 1px solid var(--ink-100);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  background: none; border: 0; padding: 8px 2px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--ink-500); font-size: 10.5px; font-weight: 600; cursor: pointer;
  position: relative;
}
.tabbar button .ic { font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--green-700); }
.tabbar button.active::before {
  content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 3px;
  background: var(--green-700); border-radius: 0 0 3px 3px;
}
.tabbar .dot {
  position: absolute; top: 5px; right: 50%; margin-right: -20px;
  background: var(--red-600); color: #fff; font-size: 9.5px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; display: grid;
  place-items: center; padding: 0 4px;
}
body[dir="rtl"] .tabbar .dot { right: auto; left: 50%; margin-left: -20px; margin-right: 0; }

/* ---------- cards ------------------------------------------------------- */
.card {
  background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 15px; margin-bottom: 13px;
}
.card.tight { padding: 12px; }
.card h2 { font-size: 15.5px; margin: 0 0 10px; font-weight: 700; }
.card h3 { font-size: 14px; margin: 14px 0 7px; font-weight: 700; color: var(--ink-700); }

.section-title {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--ink-500); font-weight: 700; margin: 20px 2px 9px;
}
body[dir="rtl"] .section-title { letter-spacing: 0; text-transform: none; font-size: 13.5px; }

/* ---------- hero -------------------------------------------------------- */
.hero {
  background: linear-gradient(135deg, var(--green-700), var(--green-900));
  color: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 13px;
}
.hero .greet { font-size: 12.5px; opacity: .82; margin: 0; }
.hero .name { font-size: 20px; font-weight: 700; margin: 2px 0 3px; }
.hero .cid { font-size: 12px; opacity: .8; margin: 0; font-variant-numeric: tabular-nums; }
.hero .specs { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.hero .spec {
  background: rgba(255,255,255,.15); border-radius: 8px;
  padding: 6px 9px; font-size: 11.5px;
}
.hero .spec b { display: block; font-size: 13.5px; font-weight: 700; }

/* ---------- stats ------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 13px; }
.stat {
  background: var(--paper); border-radius: var(--radius-sm); padding: 12px 9px;
  text-align: center; box-shadow: var(--shadow);
}
.stat .n { font-size: 23px; font-weight: 800; line-height: 1.1; }
.stat .l { font-size: 10.5px; color: var(--ink-500); margin-top: 3px; font-weight: 600; }
.stat.ok .n { color: var(--green-700); }
.stat.warn .n { color: var(--amber-600); }
.stat.bad .n { color: var(--red-600); }

/* ---------- banners ----------------------------------------------------- */
.banner {
  border-radius: var(--radius-sm); padding: 12px 13px; margin-bottom: 13px;
  font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start;
  font-weight: 500;
}
.banner .bic { font-size: 18px; line-height: 1.2; flex: none; }
.banner.due { background: var(--amber-100); color: var(--amber-600); border: 1px solid #F0D9AE; }
.banner.done { background: var(--green-100); color: var(--green-900); border: 1px solid #C4E4D1; }
.banner.info { background: var(--blue-100); color: var(--blue-600); border: 1px solid #C9DEF6; }
.banner.err { background: var(--red-100); color: var(--red-600); border: 1px solid #F5CFCF; }

/* ---------- buttons ----------------------------------------------------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: 0; border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 15.5px; font-weight: 700; cursor: pointer;
  background: var(--green-700); color: #fff; text-decoration: none;
  min-height: 50px;
}
.btn:active { background: var(--green-900); }
.btn:disabled { opacity: .55; }
.btn.secondary { background: var(--green-100); color: var(--green-900); }
.btn.secondary:active { background: #D2E9DB; }
.btn.ghost { background: transparent; color: var(--green-700); border: 1.5px solid var(--ink-100); }
.btn.danger { background: var(--red-600); }
.btn.small { padding: 9px 13px; font-size: 13.5px; min-height: 0; width: auto; }
.btn-row { display: flex; gap: 9px; }
.btn-row .btn { flex: 1; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action {
  background: var(--paper); border: 0; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 15px 12px; text-align: start;
  cursor: pointer; display: flex; flex-direction: column; gap: 7px;
  min-height: 92px;
}
.action:active { background: var(--green-050); }
.action .ic { font-size: 24px; line-height: 1; }
.action .lbl { font-size: 13.5px; font-weight: 700; color: var(--ink-900); }

/* An odd fifth action spans the row rather than leaving a gap beside it.
   Laid out horizontally so the taller two-column tiles above still look like
   the primary four. */
.action.wide {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 11px;
  min-height: 0;
  padding: 14px 14px;
  border: 1.5px solid var(--green-100);
}
.action.wide .lbl { flex: 1; }

/* ---------- forms ------------------------------------------------------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; color: var(--ink-700); }
.field .hint { font-size: 12px; color: var(--ink-500); margin: -3px 0 6px; font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%; padding: 13px 13px; border: 1.5px solid var(--ink-100);
  border-radius: var(--radius-sm); background: var(--paper); color: var(--ink-900);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green-600); }
.field textarea { min-height: 96px; resize: vertical; }
.field select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7A72' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px; }
body[dir="rtl"] .field select { background-position: left 13px center; padding-right: 13px; padding-left: 38px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--ink-100); background: var(--paper);
  border-radius: 999px; padding: 9px 14px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; color: var(--ink-700);
}
.chip.on { background: var(--green-700); border-color: var(--green-700); color: #fff; }

.check {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px;
  border: 1.5px solid var(--ink-100); border-radius: var(--radius-sm);
  margin-bottom: 9px; cursor: pointer; background: var(--paper);
}
.check.on { border-color: var(--green-600); background: var(--green-050); }
.check input { width: 22px; height: 22px; accent-color: var(--green-700); flex: none; margin: 1px 0 0; }
.check .ctext { display: block; font-size: 14.5px; font-weight: 600; }
/* Block, so the method sits under the task name instead of running on from it. */
.check .csub { display: block; font-size: 12px; color: var(--ink-500); font-weight: 400; margin-top: 2px; }

/* ---------- photo picker ------------------------------------------------ */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 9px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--ink-100); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .rm {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px;
  border-radius: 13px; border: 0; background: rgba(0,0,0,.62); color: #fff;
  font-size: 15px; cursor: pointer; line-height: 1; display: grid; place-items: center;
}
.photo-add {
  aspect-ratio: 1; border: 2px dashed var(--ink-300); border-radius: var(--radius-sm);
  background: var(--paper); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; cursor: pointer; color: var(--green-700);
  font-size: 11.5px; font-weight: 700;
}
.photo-add .ic { font-size: 23px; }

/* ---------- lists / items ---------------------------------------------- */
.item {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px; margin-bottom: 10px;
}
.item .row1 { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; }
.item .ttl { font-size: 14.5px; font-weight: 700; margin: 0; }
.item .meta { font-size: 11.5px; color: var(--ink-500); margin: 3px 0 0; }
.item .body { font-size: 13.5px; color: var(--ink-700); margin: 8px 0 0; white-space: pre-wrap; }
.item .note {
  margin-top: 10px; padding: 10px; border-radius: var(--radius-sm);
  background: var(--green-050); border-inline-start: 3px solid var(--green-600);
  font-size: 13px;
}
.item .note b { display: block; font-size: 11.5px; color: var(--green-700); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .4px; }

/* Inverter trouble mirrored in from the R&M tracker — read-only, so it is
   marked off from the repairs the principal submitted themselves. */
.item.tracked { border-inline-start: 3px solid var(--blue-600); }

.sub-note {
  font-size: 12.5px; color: var(--ink-500); margin: -4px 2px 10px; line-height: 1.5;
}

.badge {
  display: inline-block; padding: 4px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap; flex: none;
}
.badge.b-open    { background: var(--red-100); color: var(--red-600); }
.badge.b-prog    { background: var(--blue-100); color: var(--blue-600); }
.badge.b-wait    { background: var(--amber-100); color: var(--amber-600); }
.badge.b-done    { background: var(--green-100); color: var(--green-900); }
.badge.b-grey    { background: var(--ink-100); color: var(--ink-700); }

/* ---------- progress track --------------------------------------------- */
.track { display: flex; gap: 4px; margin-top: 11px; }
.track .seg { flex: 1; height: 5px; border-radius: 3px; background: var(--ink-100); }
.track .seg.on { background: var(--green-600); }
.track-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-500); margin-top: 5px; }

/* ---------- chat -------------------------------------------------------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100dvh - 56px - var(--nav-h) - env(safe-area-inset-top)); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.bubble { max-width: 82%; padding: 10px 13px; border-radius: 15px; margin-bottom: 9px; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.bubble .who { font-size: 10.5px; font-weight: 700; opacity: .7; margin-bottom: 3px; }
.bubble .tm { font-size: 10px; opacity: .6; margin-top: 4px; text-align: end; }
.bubble.me { background: var(--green-700); color: #fff; margin-inline-start: auto; border-end-end-radius: 5px; }
.bubble.them { background: var(--paper); box-shadow: var(--shadow); border-end-start-radius: 5px; }
.chat-input {
  display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--ink-100);
}
.chat-input textarea {
  flex: 1; border: 1.5px solid var(--ink-100); border-radius: 22px;
  padding: 11px 15px; resize: none; max-height: 110px; min-height: 46px; outline: none;
}
.chat-input textarea:focus { border-color: var(--green-600); }
.chat-input button {
  width: 46px; height: 46px; border-radius: 23px; border: 0;
  background: var(--green-700); color: #fff; font-size: 19px; cursor: pointer; flex: none;
}

/* ---------- guide ------------------------------------------------------- */
.acc { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; overflow: hidden; }
.acc-head {
  width: 100%; border: 0; background: none; padding: 15px 14px;
  display: flex; align-items: center; gap: 11px; cursor: pointer; text-align: start;
}
.acc-head .ic { font-size: 21px; flex: none; }
.acc-head .t { flex: 1; font-size: 14.5px; font-weight: 700; }
.acc-head .ch { color: var(--ink-500); font-size: 13px; transition: transform .15s; }
.acc.open .acc-head .ch { transform: rotate(180deg); }
.acc-body { padding: 0 14px 15px; font-size: 14px; color: var(--ink-700); display: none; }
.acc.open .acc-body { display: block; }
.acc-body p { margin: 0 0 11px; }
.acc-body ul, .acc-body ol { margin: 0 0 11px; padding-inline-start: 21px; }
.acc-body li { margin-bottom: 7px; }
.acc-body h4 { font-size: 13.5px; color: var(--green-700); margin: 16px 0 7px; }
.warn-box {
  background: var(--amber-100); border-inline-start: 3px solid var(--yellow-500);
  padding: 11px 12px; border-radius: var(--radius-sm); margin: 0 0 11px;
  font-size: 13.5px; color: #6B4C00; font-weight: 500;
}

.sched { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sched th, .sched td { padding: 9px 5px; border-bottom: 1px solid var(--ink-100); text-align: center; }
.sched th { background: var(--green-050); font-size: 11px; color: var(--green-900); font-weight: 700; }
.sched td:first-child, .sched th:first-child { text-align: start; font-weight: 600; }
.sched .tick { color: var(--green-700); font-weight: 800; font-size: 14px; }

/* ---------- login ------------------------------------------------------- */
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: 26px 20px; background: linear-gradient(160deg, var(--green-700) 0%, var(--green-900) 62%, #072F1A 100%);
}
.login-card { background: var(--paper); border-radius: 20px; padding: 24px 20px; box-shadow: 0 12px 34px rgba(0,0,0,.24); max-width: 420px; width: 100%; margin: 0 auto; }
.login-logo { text-align: center; margin-bottom: 18px; }
.login-logo .mark { font-size: 40px; }
.login-logo h1 { font-size: 21px; margin: 6px 0 2px; color: var(--green-900); }
.login-logo p { font-size: 12.5px; color: var(--ink-500); margin: 0; }
.login-foot { text-align: center; font-size: 12.5px; color: rgba(255,255,255,.8); margin-top: 18px; }
.login-foot a { color: #fff; font-weight: 700; }
.lang-switch {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); inset-inline-end: 14px;
  background: rgba(255,255,255,.18); border: 0; color: #fff; border-radius: 8px;
  padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ---------- sheet / modal ---------------------------------------------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(10,26,18,.55); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 720px;
  border-radius: 20px 20px 0 0; max-height: 92dvh; overflow-y: auto;
  padding: 0 14px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet-head {
  position: sticky; top: 0; background: var(--bg); padding: 15px 0 11px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; z-index: 2;
}
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-head .x { background: var(--ink-100); border: 0; width: 34px; height: 34px; border-radius: 17px; font-size: 17px; cursor: pointer; flex: none; }
.grabber { width: 40px; height: 4px; background: var(--ink-300); border-radius: 2px; margin: 9px auto 0; }

/* ---------- misc -------------------------------------------------------- */
.empty { text-align: center; padding: 38px 20px; color: var(--ink-500); }
.empty .ic { font-size: 40px; margin-bottom: 9px; opacity: .55; }
.empty p { font-size: 13.5px; margin: 0; }

.spinner {
  width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
.spinner.dark { border-color: var(--ink-100); border-top-color: var(--green-700); }
@keyframes spin { to { transform: rotate(360deg); } }

.center-load { display: flex; justify-content: center; padding: 40px 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px); z-index: 120;
  background: var(--ink-900); color: #fff; padding: 12px 18px;
  border-radius: 11px; font-size: 13.5px; font-weight: 600;
  max-width: 90vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.28);
}
.toast.ok { background: var(--green-700); }
.toast.bad { background: var(--red-600); }

.sync-bar {
  background: var(--amber-100); color: var(--amber-600); font-size: 12.5px;
  padding: 9px 14px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-weight: 600;
}
.sync-bar button { background: var(--amber-600); color: #fff; border: 0; border-radius: 7px; padding: 6px 11px; font-size: 12px; font-weight: 700; cursor: pointer; }

.help-line {
  display: flex; align-items: center; gap: 11px; padding: 13px;
  background: var(--green-050); border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink-900); margin-top: 10px;
}
.help-line .ic { font-size: 22px; }
.help-line .t { font-size: 14px; font-weight: 700; }
.help-line .s { font-size: 12px; color: var(--ink-500); }

.notif {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px; margin-bottom: 9px; border-inline-start: 3px solid var(--yellow-500);
}
.notif .nt { font-size: 14px; font-weight: 700; margin: 0; }
/* plaintext: each line of a bilingual message takes its own direction, so an
   Urdu line under English text reads right to left and sits on the right. */
.notif .nb { font-size: 13.5px; color: var(--ink-700); margin: 5px 0 0; white-space: pre-wrap; unicode-bidi: plaintext; text-align: start; }
.notif .nd { font-size: 11px; color: var(--ink-500); margin: 6px 0 0; }

/* ---------- watermark --------------------------------------------------- */
.watermark {
  text-align: center; font-size: 11.5px; color: var(--ink-500);
  padding: 18px 12px 6px; letter-spacing: .2px; line-height: 1.6;
}
.watermark b { color: var(--ink-700); font-weight: 700; }
.watermark .v { display: block; font-size: 10.5px; opacity: .7; margin-top: 2px; }
body[dir="rtl"] .watermark { font-size: 12.5px; }

.watermark-light { color: rgba(255,255,255,.72); }
.watermark-light b { color: rgba(255,255,255,.92); }

/* Welcome-screen signature. Sits on the dark green login gradient, so it is
   always light-on-dark regardless of the ambient theme. */
.welcome-sig {
  text-align: center;
  padding: 20px 12px 6px;
  line-height: 1.55;
}
.welcome-sig .ws-line {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .2px;
  color: rgba(255,255,255,.86);
}
.welcome-sig .ws-name {
  margin: 3px 0 0;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
}
.welcome-sig .ws-v {
  display: block;
  margin-top: 7px;
  font-size: 10.5px;
  color: rgba(255,255,255,.55);
}

.sheet .watermark { padding-top: 10px; }

.hidden { display: none !important; }

/* ==========================================================================
   REFRESH ROW — sits above the hero on Home.
   ========================================================================== */
.refresh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  min-height: 32px;
}
.refresh-when {
  font-size: 12.5px;
  color: var(--ink-500);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 7px 14px;
  border: 1.5px solid var(--ink-100);
  border-radius: 999px;
  background: var(--paper);
  color: var(--green-700);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.refresh-btn:active { background: var(--green-050); }
.refresh-btn:disabled { opacity: .6; cursor: default; }
.refresh-btn .ric { font-size: 15px; line-height: 1; }

/* ==========================================================================
   NOTIFICATION OPT-IN CARD
   ========================================================================== */
.notif-card .notif-sub {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--ink-500);
}

/* ==========================================================================
   FIRST-RUN DISCLAIMER — modal, no dismiss except the acknowledge button.
   ========================================================================== */
.disc-bg {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(10, 24, 18, .62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  overflow-y: auto;
}
.disc-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px 22px;
  max-width: 420px;
  width: 100%;
  margin: auto;
  text-align: center;
}
.disc-card .disc-ic { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.disc-card h2 {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 700;
  color: var(--green-900);
}
.disc-card p {
  margin: 0 0 12px;
  font-size: 14.5px;
  line-height: 1.62;
  color: var(--ink-700);
  text-align: start;
}
.disc-card .disc-key {
  background: var(--amber-100);
  color: var(--amber-600);
  border: 1px solid #F0D9AE;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-weight: 600;
  margin-bottom: 18px;
}
.disc-card .btn { width: 100%; }

/* ---------- announcement dialog ------------------------------------------
   Reuses the disclaimer shell. Same contract: acknowledging is the only way
   out. Body text can run long, so it scrolls inside the card rather than
   pushing the button off screen.
   ------------------------------------------------------------------------- */
.ann-card { text-align: start; }
.ann-card .disc-ic { text-align: center; }
.ann-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--green-600);
  text-align: start;
}
.ann-card h2 { margin: 0 0 10px; text-align: start; }
.ann-card .ann-body {
  margin: 0 0 12px;
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  /* Each line takes its own direction (see .notif .nb). */
  unicode-bidi: plaintext;
  text-align: start;
}
.ann-card .ann-meta {
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--ink-500);
}

[data-mode="dark"] .ann-kicker { color: #79D9A2; }

/* ---------- announcement and message at the top of Home -------------------
   A new announcement waits above the panel animation with everything else
   dimmed; acknowledged, a copy of it (.ann-fly) slides down into the list.
   An unread message from head office sits there too and opens Messages.
   ------------------------------------------------------------------------- */
.ann-pin {
  background: var(--paper); border-radius: var(--radius); padding: 16px 16px 14px;
  margin: 0 0 14px; border-inline-start: 4px solid var(--yellow-500);
  box-shadow: 0 0 0 2px rgba(245, 179, 1, .35), 0 12px 32px rgba(20, 38, 28, .18);
  position: relative; z-index: 2; text-align: start;
}
.ann-pin.enter { animation: annIn .45s cubic-bezier(.2, .8, .2, 1); }
.ann-pin h2 { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: var(--green-900); }
.ann-pin .ann-body {
  margin: 0 0 10px; font-size: 14.5px; line-height: 1.6; color: var(--ink-700);
  max-height: 40vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  white-space: pre-wrap; unicode-bidi: plaintext; text-align: start;
}
.ann-pin .ann-meta { margin: 0 0 14px; font-size: 12px; color: var(--ink-500); }
.ann-pin .btn { width: 100%; }
body.ann-locked #view > :not(#annPin),
body.ann-locked .tabbar, body.ann-locked .topbar, body.ann-locked .sync-bar {
  opacity: .35; filter: saturate(.5); pointer-events: none; transition: opacity .3s;
}
.ann-fly { position: absolute; z-index: 60; margin: 0; overflow: hidden; pointer-events: none; box-sizing: border-box; }
.ann-fly .btn, .ann-fly .ann-kicker, .ann-fly .ann-meta { animation: annFade .25s forwards; }
.ann-fly .ann-body { overflow: hidden; }
.ann-spacer { overflow: hidden; }
.notif.ann-await { display: none; }
.notif.ann-landing { visibility: hidden; }
.notif.ann-landed { animation: annGlow 1.8s ease-out; }
@keyframes annIn { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes annFade { to { opacity: 0; } }
@keyframes annGlow {
  0% { box-shadow: 0 0 0 3px var(--yellow-500), var(--shadow); }
  100% { box-shadow: 0 0 0 0 rgba(245, 179, 1, 0), var(--shadow); }
}

.msg-pin {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: start;
  background: var(--paper); color: inherit; font: inherit; cursor: pointer;
  border: 0; border-inline-start: 4px solid var(--green-600); border-radius: var(--radius);
  box-shadow: 0 0 0 2px rgba(18, 135, 74, .22), var(--shadow); padding: 12px 13px; margin: 0 0 14px;
}
.msg-pin.enter { animation: annIn .45s cubic-bezier(.2, .8, .2, 1); }
.msg-pin:active { transform: scale(.99); }
.msg-pin .msg-ic { font-size: 24px; line-height: 1; }
.msg-pin .msg-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.msg-pin b { font-size: 13px; color: var(--green-600); }
.msg-pin .msg-body {
  font-size: 14px; color: var(--ink-900); line-height: 1.45; unicode-bidi: plaintext;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.msg-pin .msg-tm { font-size: 11.5px; color: var(--ink-500); }
.msg-pin .msg-go { font-size: 24px; color: var(--green-600); font-weight: 700; }
[data-mode="dark"] .msg-pin b, [data-mode="dark"] .msg-pin .msg-go { color: #79D9A2; }
[data-mode="dark"] .ann-pin h2 { color: inherit; }
@media (prefers-reduced-motion: reduce) {
  .ann-pin.enter, .msg-pin.enter, .notif.ann-landed { animation: none; }
}

/* ==========================================================================
   FIRST-RUN WALKTHROUGH
   ========================================================================== */
.tour-bg {
  position: fixed;
  inset: 0;
  z-index: 125;
  background: rgba(10, 24, 18, .66);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.tour-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 22px 22px;
  max-width: 420px;
  width: 100%;
  margin: auto;
  text-align: center;
}
.tour-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
}
.tour-count {
  font-size: 12px;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}
.tour-skip {
  border: none;
  background: transparent;
  color: var(--ink-500);
  font-family: inherit;
  font-size: 13.5px;
  padding: 6px 8px;
  cursor: pointer;
  text-decoration: underline;
}
.tour-ic { font-size: 42px; line-height: 1; margin: 6px 0 10px; }
.tour-card h2 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 700;
  color: var(--green-900);
  line-height: 1.3;
}
.tour-card p {
  margin: 0;
  font-size: 15px;
  line-height: 1.62;
  color: var(--ink-700);
  text-align: start;
}
.tour-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 18px 0 16px;
  flex-wrap: wrap;
}
.tour-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-100);
}
.tour-dots span.past { background: var(--green-100); }
.tour-dots span.on { background: var(--green-700); transform: scale(1.25); }
.tour-never {
  display: flex;
  align-items: center;
  gap: 9px;
  justify-content: center;
  font-size: 14px;
  color: var(--ink-700);
  margin: 0 0 16px;
  cursor: pointer;
}
.tour-never input { width: 17px; height: 17px; accent-color: var(--green-700); flex: none; }
.tour-nav { display: flex; gap: 10px; }
.tour-nav .btn { flex: 1; }

/* ==========================================================================
   DARK PHASES — dusk and night. theme.js sets data-mode="dark" on <html>.
   Only the tokens that were hard-coded for a light surface are restated here;
   everything else already reads from the themed custom properties.
   ========================================================================== */
[data-mode="dark"] {
  --red-600: #FF8A8A;   --red-100: #3A1E1E;
  --blue-600: #7FB3F0;  --blue-100: #16283E;
  --amber-600: #FFC559; --amber-100: #3A2E14;
  --yellow-500: #FFC93C;
}
[data-mode="dark"] .topbar { background: #0E1B2E; box-shadow: 0 2px 10px rgba(0,0,0,.45); }
[data-mode="dark"] .topbar .logo { background: rgba(255,255,255,.10); }
[data-mode="dark"] .hero {
  background: linear-gradient(135deg, #1B3556, #0C1B30);
  border: 1px solid rgba(255,255,255,.08);
}
[data-mode="dark"] .banner.done { border-color: #23503A; }
[data-mode="dark"] .banner.due  { border-color: #57451F; }
[data-mode="dark"] .banner.info { border-color: #234164; }
[data-mode="dark"] .banner.err  { border-color: #5A2B2B; }
[data-mode="dark"] .warn-box { background: #3A2E14; color: #FFD98A; }
[data-mode="dark"] .toast { background: #E8EFF6; color: #10203A; }
[data-mode="dark"] .toast.ok { background: #2E9E63; color: #fff; }
[data-mode="dark"] .toast.bad { background: #C0453F; color: #fff; }
[data-mode="dark"] .btn { color: #06121F; }
[data-mode="dark"] .btn.secondary { color: var(--green-900); }
[data-mode="dark"] .badge.b-open  { background: #3A1E1E; color: #FF9A9A; }
[data-mode="dark"] .badge.b-prog  { background: #16283E; color: #8FBEF5; }
[data-mode="dark"] .badge.b-wait  { background: #3A2E14; color: #FFCE6E; }
[data-mode="dark"] .badge.b-done  { background: #10402A; color: #78E0A6; }
[data-mode="dark"] .badge.b-grey  { background: #26344A; color: #A9BACE; }
[data-mode="dark"] .sched th { background: #17273C; color: #BFE6CE; }
[data-mode="dark"] .chat-input { background: var(--paper); }
[data-mode="dark"] .photo-add { background: transparent; }
[data-mode="dark"] .sheet-head { background: transparent; }
[data-mode="dark"] .sheet { background: #0F1B2C; }
[data-mode="dark"] .help-line { background: #16293C; }
[data-mode="dark"] .refresh-btn { background: transparent; border-color: rgba(255,255,255,.16); color: #79D9A2; }
[data-mode="dark"] .refresh-btn:active { background: rgba(255,255,255,.06); }
[data-mode="dark"] .disc-bg { background: rgba(0,0,0,.72); }
[data-mode="dark"] .disc-card { background: #0F1B2C; }
[data-mode="dark"] .disc-card h2 { color: #79D9A2; }
[data-mode="dark"] .disc-card .disc-key { border-color: #57451F; }
[data-mode="dark"] .tour-bg { background: rgba(0,0,0,.74); }
[data-mode="dark"] .tour-card { background: #0F1B2C; }
[data-mode="dark"] .tour-card h2 { color: #79D9A2; }
[data-mode="dark"] .tour-dots span { background: rgba(255,255,255,.16); }
[data-mode="dark"] .tour-dots span.past { background: rgba(121,217,162,.45); }
[data-mode="dark"] .tour-dots span.on { background: #79D9A2; }

/* ==========================================================================
   ILLUSTRATIONS
   ========================================================================== */
.ill { display: block; width: 100%; height: auto; overflow: visible; }

.ill-hero {
  transform: translate(var(--px, 0px), var(--py, 0px));
  transition: transform .35s cubic-bezier(.22,.8,.3,1);
}
.ill-sec { width: 40px; height: 40px; flex: none; }
.ill-empty { width: 132px; height: auto; margin: 0 auto 12px; }
.ill-badge { width: 26px; height: 26px; }

/* The scene's sky IS the ambient sky, at full strength — this is the one place
   the drift is looked at directly rather than felt behind the content. */
.hero-scene {
  position: relative; margin: -16px -16px 14px; padding: 0;
  border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
  background:
    radial-gradient(90% 78% at 78% 12%, var(--amb-glow, #8FC0EC) 0%, transparent 66%),
    linear-gradient(to bottom,
      var(--amb-sky-1, #4E92D8) 0%,
      var(--amb-sky-2, #8FC0EC) 52%,
      var(--amb-sky-3, #D9EAFA) 100%);
  transition: background 1.6s linear;
}
.hero-scene .ill-hero { width: 100%; }
.hero-hint {
  position: absolute; inset-inline-start: 12px; bottom: 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
  color: rgba(255,255,255,.86); background: rgba(0,0,0,.28);
  padding: 4px 9px; border-radius: 999px; backdrop-filter: blur(3px);
  pointer-events: none; opacity: 0; animation: hintIn .5s 1.1s forwards;
}
@keyframes hintIn { to { opacity: 1; } }

/* --- motion ------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .ill-rays { animation: illSpin 46s linear infinite; }
  .ill-mill { animation: illSpin 7s linear infinite; }
  .ill-cloud { animation: illDrift 34s ease-in-out infinite alternate; }
  .ill-cloud:nth-of-type(2) { animation-duration: 46s; animation-delay: -8s; }
  .ill-led { animation: illBlink 2.6s ease-in-out infinite; }
  .ill-star { animation: illTwinkle 3.4s ease-in-out infinite; }
  .ill-star:nth-of-type(2n) { animation-delay: -1.2s; }
  .ill-star:nth-of-type(3n) { animation-delay: -2.3s; }
  .ill-drop { animation: illDrip 2.8s ease-in infinite; }
  .ill-waves path { animation: illPing 2.4s ease-out infinite; }
  .ill-waves path:nth-child(2) { animation-delay: .25s; }
  .ill-waves path:nth-child(3) { animation-delay: .5s; }
  .ill-hero.is-dirty .ill-broom { animation: illSweep 2.6s ease-in-out infinite; }
  .ill-hero.is-cleaning .ill-broom { animation: illSweep .45s ease-in-out infinite; }
  .ill-sun.whee .ill-rays { animation: illSpin 1.15s cubic-bezier(.2,.7,.3,1) 2; }
  .ill-mill.gust { animation: illSpin .55s linear 4; }
  .ill-sparkle.pop { animation: illPop .9s ease-out; }
  .ill-charge { transition: y .8s cubic-bezier(.3,.9,.3,1), height .8s cubic-bezier(.3,.9,.3,1); }
}
@keyframes illSpin { to { transform: rotate(360deg); } }
@keyframes illDrift { from { transform: translateX(-9px); } to { transform: translateX(14px); } }
@keyframes illBlink { 0%,72%,100% { opacity: 1; } 82% { opacity: .28; } }
@keyframes illTwinkle { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes illDrip { 0% { transform: translateY(-8px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(5px); opacity: 0; } }
@keyframes illPing { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes illSweep { 0%,100% { transform: rotate(0deg); } 50% { transform: rotate(-17deg); } }
@keyframes illPop { 0% { transform: scale(.4); opacity: 0; } 40% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }

/* --- time-of-day scrubber ---------------------------------------------- */
.timebar {
  display: flex; align-items: center; gap: 6px; overflow-x: auto;
  padding: 4px 0 2px; margin-bottom: 12px; scrollbar-width: none;
}
.timebar::-webkit-scrollbar { display: none; }
.timebar .tb {
  border: 1px solid rgba(255,255,255,.34); background: rgba(255,255,255,.18);
  color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 12px;
  font-weight: 700; white-space: nowrap; cursor: pointer; backdrop-filter: blur(4px);
}
.timebar .tb.on { background: #fff; color: var(--green-900); border-color: #fff; }
.timebar .tb.live { border-style: dashed; }

/* --- section headings in the guide -------------------------------------- */
.acc-head .ill-sec { margin-inline-end: 2px; }

/* --- camera capture ------------------------------------------------------ */
.cam-wrap {
  position: fixed; inset: 0; z-index: 200; background: #05080D;
  display: flex; flex-direction: column;
}
.cam-top {
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.cam-top .ct { font-size: 15px; font-weight: 700; }
.cam-top .cs { font-size: 11.5px; opacity: .72; }
.cam-top button {
  background: rgba(255,255,255,.15); border: 0; color: #fff; width: 36px; height: 36px;
  border-radius: 18px; font-size: 16px; cursor: pointer; flex: none;
}
.cam-stage { flex: 1; position: relative; overflow: hidden; background: #000; }
.cam-stage video, .cam-stage canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.cam-guide {
  position: absolute; inset: 8% 6%; border: 2px dashed rgba(255,255,255,.5);
  border-radius: 14px; pointer-events: none;
}
.cam-guide span {
  position: absolute; top: -11px; inset-inline-start: 12px; background: #05080D;
  color: rgba(255,255,255,.82); font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 999px;
}
.cam-stamp {
  position: absolute; inset-inline-start: 12px; bottom: 12px; color: #fff;
  font-size: 11px; line-height: 1.5; text-shadow: 0 1px 3px rgba(0,0,0,.9);
  pointer-events: none; font-variant-numeric: tabular-nums;
}
.cam-bar {
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.cam-shot {
  width: 70px; height: 70px; border-radius: 35px; border: 4px solid rgba(255,255,255,.35);
  background: #fff; cursor: pointer; margin: 0 auto; flex: none;
}
.cam-shot:active { transform: scale(.94); }
.cam-side {
  background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 10px;
  padding: 10px 13px; font-size: 12.5px; font-weight: 700; cursor: pointer; min-width: 74px;
}
.cam-err {
  color: #FFD3D3; background: rgba(190,60,60,.22); border: 1px solid rgba(255,140,140,.4);
  margin: 16px; padding: 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.6;
}

/* --- required photo slots ------------------------------------------------ */
.slot {
  display: flex; gap: 12px; align-items: center; padding: 11px;
  border: 1.5px solid var(--ink-100); border-radius: var(--radius-sm);
  margin-bottom: 9px; background: var(--paper);
}
.slot.filled { border-color: var(--green-600); background: var(--green-050); }
.slot.missing { border-color: var(--red-600); }
.slot .thumb {
  width: 62px; height: 62px; border-radius: 9px; flex: none; overflow: hidden;
  background: var(--ink-100); display: grid; place-items: center; font-size: 21px;
}
.slot .thumb img { width: 100%; height: 100%; object-fit: cover; }
.slot .meta { flex: 1; min-width: 0; }
.slot .sname { font-size: 14px; font-weight: 700; display: flex; align-items: center;
  gap: 7px; flex-wrap: wrap; line-height: 1.3; }
.slot .sreq {
  font-size: 9.5px; font-weight: 800; letter-spacing: .5px; padding: 2px 6px;
  border-radius: 4px; background: var(--red-100); color: var(--red-600);
}
.slot.filled .sreq { background: var(--green-100); color: var(--green-900); }
.slot .ssub { font-size: 11.5px; color: var(--ink-500); margin-top: 2px; }
.slot .sact {
  border: 0; background: var(--green-700); color: #fff; border-radius: 9px;
  padding: 11px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  flex: none; max-width: 108px; line-height: 1.25;
}
.slot.filled .sact { background: var(--ink-100); color: var(--ink-700); }
[data-mode="dark"] .slot { background: var(--paper-tint); }

/* ==========================================================================
   MAINTENANCE CERTIFICATE
   A printable record the principal attaches when escalating to their Region.
   Deliberately fixed light-on-white and pinned LTR: this sheet is a document
   that leaves the app as a PDF, so it must not inherit the dark theme or the
   Urdu RTL flow the rest of the interface uses.
   ========================================================================== */
.cert-bg {
  position: fixed; inset: 0; z-index: 90; background: var(--bg);
  display: flex; flex-direction: column;
}
.cert-bar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: var(--green-700); color: #fff;
}
.cert-bar > span { flex: 1; font-weight: 700; font-size: 15px; min-width: 0; }
.cert-x {
  border: 0; background: rgba(255, 255, 255, .18); color: #fff; font-size: 16px;
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; flex: none;
}
.cert-print {
  border: 0; background: #fff; color: var(--green-900); font-weight: 800;
  font-size: 13.5px; padding: 10px 14px; border-radius: 9px; cursor: pointer; flex: none;
}
.cert-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 12px calc(env(safe-area-inset-bottom) + 26px);
}

.cert-doc {
  background: #fff; color: #14261C; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 18px; position: relative;
  font-family: var(--font); line-height: 1.5;
}

.cert-head { text-align: center; border-bottom: 2px solid #0F7B3E; padding-bottom: 14px; }
.cert-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; }
.cert-mark {
  width: 40px; height: 40px; border-radius: 50%; background: #0F7B3E; color: #fff;
  display: grid; place-items: center; font-size: 22px; flex: none;
}
.cert-brand > div { text-align: left; }
.cert-org { margin: 0; font-size: 14.5px; font-weight: 800; color: #0A4726; }
.cert-dept { margin: 0; font-size: 11.5px; color: #5C6B63; letter-spacing: .4px; }
.cert-doc h1 { font-size: 20px; margin: 0; color: #0A4726; letter-spacing: -.2px; }
.cert-sub { margin: 4px 0 0; font-size: 12.5px; color: #5C6B63; }

.cert-campus {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
  margin: 16px 0; padding: 13px; background: #F2F9F5; border-radius: 10px;
}
.cert-campus span {
  display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  color: #5C6B63; font-weight: 700;
}
.cert-campus b { font-size: 14px; word-break: break-word; }

.cert-stamp { display: flex; justify-content: center; margin: 18px 0; }
.cert-stamp-in {
  border: 3px double #0F7B3E; color: #0F7B3E; border-radius: 10px;
  padding: 9px 20px; text-align: center; transform: rotate(-6deg);
  display: inline-flex; flex-direction: column; gap: 1px;
}
.cs-top { font-size: 9px; font-weight: 800; letter-spacing: 1.6px; }
.cs-mid { font-size: 25px; font-weight: 900; letter-spacing: 3px; line-height: 1.1; }
.cs-bot { font-size: 9.5px; font-weight: 700; letter-spacing: .4px; }
.cert-unstamped {
  margin: 16px 0; padding: 11px 13px; border-radius: 10px; font-size: 12.5px;
  background: #FFF1DC; color: #8A5200; border: 1px solid #F0D9AE;
}

.cert-h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: #0F7B3E;
  margin: 22px 0 9px; padding-bottom: 5px; border-bottom: 1px solid #E6EBE8;
}

.cert-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cert-stats > div {
  background: #F5F7F6; border-radius: 9px; padding: 10px 6px; text-align: center;
}
.cert-stats b { display: block; font-size: 19px; color: #0A4726; line-height: 1.2; }
.cert-stats span { font-size: 9.5px; color: #5C6B63; line-height: 1.3; display: block; margin-top: 2px; }

.cert-verdict {
  margin-top: 12px; padding: 12px 13px; border-radius: 10px;
  border-inline-start: 4px solid #5C6B63; background: #F5F7F6;
}
.cert-verdict b { display: block; font-size: 14.5px; margin-bottom: 3px; }
.cert-verdict span { font-size: 12.5px; color: #3A4A41; }
.cert-verdict.v-good { background: #E4F3EA; border-inline-start-color: #12874A; }
.cert-verdict.v-good b { color: #0A4726; }
.cert-verdict.v-fair { background: #FFF1DC; border-inline-start-color: #B26A00; }
.cert-verdict.v-fair b { color: #8A5200; }
.cert-verdict.v-poor { background: #FDECEC; border-inline-start-color: #C62828; }
.cert-verdict.v-poor b { color: #A31F1F; }

.cert-tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.cert-tbl th {
  text-align: left; font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px;
  color: #5C6B63; border-bottom: 1.5px solid #E6EBE8; padding: 6px 5px; white-space: nowrap;
}
.cert-tbl td { padding: 6px 5px; border-bottom: 1px solid #F0F3F1; vertical-align: top; }
.cert-tbl td.tk { text-align: center; font-weight: 700; }
.cert-tbl tbody tr:nth-child(even) { background: #FAFCFB; }

/* The full history is wide; let it scroll on a phone rather than crushing
   the columns, and shrink it to fit the page only when printing. */
.cert-tbl.hist { display: block; overflow-x: auto; white-space: nowrap; }

.cbar {
  display: inline-block; width: 44px; height: 6px; border-radius: 3px;
  background: #E6EBE8; overflow: hidden; vertical-align: middle; margin-inline-end: 5px;
}
.cbar-fill { display: block; height: 100%; background: #12874A; }

.cert-legend { font-size: 10.5px; color: #5C6B63; margin: 12px 0 0; line-height: 1.6; }
.cert-foot { margin-top: 20px; padding-top: 12px; border-top: 1px solid #E6EBE8; }
.cert-foot p { font-size: 10.5px; color: #5C6B63; margin: 0 0 6px; line-height: 1.6; }
.cert-credit { font-weight: 700; color: #0F7B3E !important; }

/* The QR code and certificate ID that let a printed SMC be checked online. */
.cert-verify {
  display: flex; align-items: center; gap: 14px; margin-top: 16px;
  padding: 12px; border: 1px solid #C4E4D1; border-radius: 10px; background: #F2F9F5;
}
.cv-qr {
  width: 92px; height: 92px; flex-shrink: 0; background: #fff; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.cv-qr svg { width: 100%; height: 100%; display: block; }
.cv-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cv-text b { font-size: 13px; color: #0A4726; }
.cv-text span { font-size: 10.5px; color: #5C6B63; line-height: 1.5; }
.cv-text .cv-id {
  font-size: 13px; font-weight: 800; color: #14261C; letter-spacing: .4px;
  font-variant-numeric: tabular-nums;
}

/* The week a maintenance log is for — shown, not chosen. */
.period-card { display: flex; flex-direction: column; gap: 2px; }
.period-l { font-size: 12px; font-weight: 700; color: var(--ink-500); }
.period-v { font-size: 18px; color: var(--green-900); }
.period-s { font-size: 12px; color: var(--ink-500); line-height: 1.5; }
[data-mode="dark"] .period-v { color: #78E0A6; }

/* ---------- print: the certificate alone, nothing of the app ------------- */
@media print {
  html { background: #fff !important; }
  body { background: #fff !important; }
  body > * { display: none !important; }
  body > #certBg {
    display: block !important; position: static !important; background: #fff !important;
  }
  #certBg .cert-bar, #certBg .banner { display: none !important; }
  #certBg .cert-scroll { overflow: visible !important; padding: 0 !important; }
  .cert-doc {
    box-shadow: none !important; border-radius: 0 !important; padding: 0 !important;
    font-size: 11px;
  }
  .cert-tbl.hist { display: table; white-space: normal; font-size: 9.5px; }
  .cert-h2, .cert-tbl { break-inside: auto; }
  .cert-tbl tr, .cert-stamp, .cert-verdict, .cert-stats,
  .cert-attach, .cert-foot, .cert-verify { break-inside: avoid; }
  .cert-h2 { break-after: avoid; }
  .cert-tbl thead { display: table-header-group; }
  @page { size: A4 portrait; margin: 12mm; }
}

/* The certificate is a document, not part of the interface — keep it on the
   printed white ground even when the app itself is in dark mode. */
[data-mode="dark"] .cert-bg { background: var(--bg); }
[data-mode="dark"] .cert-doc { background: #fff; color: #14261C; }

/* ---------- cert logo (app icon in certificate header) -------------------- */
.cert-logo { width: 52px; height: 52px; object-fit: contain; border-radius: 10px; flex-shrink: 0; }

/* ---------- cert attach instruction --------------------------------------- */
.cert-attach {
  margin: 20px 0 0;
  padding: 12px 14px;
  background: #EEF6F1;
  border: 1px solid #C2DDC9;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #0F7B3E;
  line-height: 1.55;
}

/* ---------- install-to-home-screen prompt ---------------------------------
   Shown only when the app is running in a browser tab. Principals who get the
   link on WhatsApp otherwise end up with a bookmark that always opens with an
   address bar, and read that as "the app is broken".
   ------------------------------------------------------------------------- */
.install-card {
  background: var(--paper);
  border: 1.5px solid var(--green-100);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.install-head { display: flex; align-items: flex-start; gap: 11px; }
.install-icon {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0; object-fit: contain;
}
.install-title { margin: 0 0 3px; font-size: 14px; font-weight: 700; color: var(--ink-900); }
.install-why { margin: 0; font-size: 12px; color: var(--ink-500); line-height: 1.45; }
.install-how {
  margin: 11px 0 0;
  padding: 10px 11px;
  background: var(--green-050);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--ink-900);
  line-height: 1.5;
}
.install-card .btn { margin-top: 11px; }
.install-later {
  display: block;
  margin: 9px auto 0;
  border: 0;
  background: none;
  color: var(--ink-500);
  font-size: 12.5px;
  font-family: inherit;
  padding: 6px 10px;
  cursor: pointer;
}
.install-later:hover { color: var(--ink-900); }

/* Stuck inside WhatsApp's browser or a non-Safari iOS browser: the address bar
   cannot be dismissed from here, so make the way out unmissable. */
.install-card.urgent {
  border-color: var(--amber-600);
  border-width: 2px;
  margin: 0 0 14px;
}
.install-card.urgent .install-how { background: var(--amber-100); }

[data-mode="dark"] .install-how { background: rgba(255, 255, 255, .06); }
[data-mode="dark"] .install-card.urgent .install-how { background: var(--amber-100); }

/* ---------- a feature switched off for now ("Coming soon") --------------- */
.action.soon, .btn.soon { opacity: .5; filter: grayscale(1); cursor: not-allowed; box-shadow: none; }
.action.soon:active { background: var(--paper); }
.soon-tag { display: inline-block; align-self: flex-start; padding: 2px 9px; border-radius: 999px;
  background: var(--ink-900); color: var(--paper); font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.btn .soon-tag { margin-inline-start: 6px; vertical-align: 1px; }
.soon-note { margin: 10px 2px 0; font-size: 13px; line-height: 1.5; color: var(--ink-700); }

/* ---------- the weekly log: the one action that leads -------------------- */
.action.hero {
  grid-column: 1 / -1;
  flex-direction: row; align-items: center; gap: 14px;
  min-height: 0; padding: 16px 16px;
  background: linear-gradient(135deg, var(--green-900) 0%, var(--green-700) 55%, #1FA463 100%);
  box-shadow: 0 8px 22px rgba(15, 123, 62, .32);
  position: relative; overflow: hidden;
}
.action.hero::after {               /* a soft sun in the corner */
  content: ''; position: absolute; inset-inline-end: -30px; top: -40px; width: 120px; height: 120px;
  border-radius: 50%; background: radial-gradient(circle, rgba(245, 179, 1, .45), rgba(245, 179, 1, 0) 70%);
  pointer-events: none;
}
.action.hero:active { background: linear-gradient(135deg, var(--green-900), var(--green-700)); transform: scale(.99); }
.action.hero .ic {
  flex: none; width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px;
  background: var(--yellow-500); box-shadow: 0 0 0 4px rgba(245, 179, 1, .28);
}
.action.hero .lbl { flex: 1; color: #fff; font-size: 16px; font-weight: 800; line-height: 1.25; }
.action.hero .hero-sub { display: block; margin-top: 4px; font-size: 12.5px; font-weight: 600; color: #FFE7A3; }
.action.hero.done .hero-sub { color: #C9F2D9; }
.action.hero .hero-go { flex: none; color: #fff; font-size: 30px; font-weight: 300; line-height: 1; opacity: .9; }
.action.hero.due { animation: heroGlow 2.4s ease-in-out infinite; }
@keyframes heroGlow {
  0%, 100% { box-shadow: 0 8px 22px rgba(15, 123, 62, .32), 0 0 0 0 rgba(245, 179, 1, .0); }
  50%      { box-shadow: 0 8px 22px rgba(15, 123, 62, .32), 0 0 0 6px rgba(245, 179, 1, .35); }
}
@media (prefers-reduced-motion: reduce) { .action.hero.due { animation: none; } }
.topbar-btn.icon { display: grid; place-items: center; padding: 8px 10px; min-width: 38px; min-height: 34px; }
.topbar-btn.icon svg { display: block; }

/* ---------- the weekly-log policy line ----------------------------------- */
.log-warning {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 12px; padding: 11px 13px; border-radius: 12px;
  background: #FDECEA; border: 1.5px solid #F2B8B5; color: #8C1D18;
  font-size: 13px; line-height: 1.45; text-align: left;
}
.log-warning b { color: #B3261E; }
[data-mode="dark"] .log-warning { background: #3A1E1E; border-color: #6B2D2A; color: #FFB4AB; }
[data-mode="dark"] .log-warning b { color: #FF8A80; }

/* ---------- permissions screen ------------------------------------------- */
.perm-card { text-align: start; }
.perm-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--ink-100); }
.perm-row:last-of-type { border-bottom: 1px solid var(--ink-100); }
.perm-ic { font-size: 24px; flex: none; }
.perm-tx { flex: 1; min-width: 0; }
.perm-tx b { display: block; font-size: 14.5px; color: var(--ink-900); }
.perm-tx span { display: block; font-size: 12.5px; line-height: 1.4; color: var(--ink-500); margin-top: 2px; }
.perm-row .btn.sm { width: auto; flex: none; padding: 8px 14px; font-size: 13px; }
.perm-ok { flex: none; font-weight: 700; font-size: 13px; color: var(--green-700); }
.perm-no { flex: none; font-weight: 700; font-size: 13px; color: #B3261E; }
.perm-help { margin: 12px 0 0; font-size: 12.5px; line-height: 1.5; color: #8C1D18; background: #FDECEA;
  border-radius: 10px; padding: 9px 11px; }
.perm-card #permDone { margin-top: 14px; }
.perm-must { margin: 12px 0 0; font-size: 13px; font-weight: 700; color: #B3261E; }
.perm-out { display: block; width: 100%; margin-top: 10px; padding: 10px; border: 0; background: none;
  color: var(--ink-500); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
