:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e5e8ec;
  --brand: #0f766e;
  --brand-dark: #0b5e58;
  --brand-soft: #e6f4f2;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #b45309;
  --radius: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { border-radius: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.side { display: none; }
.main { padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 96px); max-width: 760px; margin: 0 auto; }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(env(safe-area-inset-top, 0px) + 14px) 0 10px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 24px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.01em; flex: 1; min-width: 0; }
.top .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-top: 2px; }
.iconbtn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--text); flex: none; }
.iconbtn:active { background: var(--bg); }
.back { margin-inline-start: -4px; border: 0; background: transparent; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: var(--safe-b); }
.nav a { height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--muted); position: relative; }
.nav a.on { color: var(--brand); }
.nav a .badge { position: absolute; top: 8px; inset-inline-start: calc(50% + 6px); }
.fab { position: fixed; inset-inline-end: 18px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 21; height: 56px; padding: 0 22px 0 18px; border-radius: 28px; border: 0; background: var(--brand); color: #fff; font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; box-shadow: 0 8px 22px rgba(15,118,110,.35); }
.fab:active { background: var(--brand-dark); }
.fab svg.i { width: 22px; height: 22px; stroke-width: 2.5; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .side { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--card); border-right: 1px solid var(--line); }
  .side .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 0 8px 18px; }
  .side .logo img { width: 34px; height: 34px; border-radius: 9px; }
  .side a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--text); font-weight: 500; }
  .side a:hover { background: var(--bg); }
  .side a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .side a .badge { margin-inline-start: auto; }
  .side .btn { margin: 0 0 16px; }
  .side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 12px; }
  .nav, .fab { display: none; }
  .main { padding: 8px 32px 60px; width: 100%; }
  .top { padding-top: 22px; }
}

/* ---------- common bits ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 15px; white-space: nowrap; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn.danger { color: var(--red); }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn.block { width: 100%; }
.btn.sm { height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .6; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--bg); color: var(--muted); text-transform: capitalize; }
.tag.green { background: var(--brand-soft); color: var(--brand); }
.tag.red { background: var(--red-soft); color: var(--red); }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.empty { text-align: center; padding: 30px 20px; color: var(--muted); }
.empty svg.i { width: 34px; height: 34px; color: #b8c1cc; margin-bottom: 6px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 2px; }
.section-h { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.section-h.red { color: var(--red); }
.section-h .count { font-weight: 600; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.stat { padding: 12px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); text-align: start; }
.stat b { display: block; font-size: 24px; line-height: 1.1; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat.red b { color: var(--red); }
.stat.green b { color: var(--brand); }

/* who filter */
.who { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 0 10px; font-weight: 600; font-size: 14px; max-width: 46%; }

/* task list */
.list { display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; align-items: center; gap: 12px; padding-block: 12px; padding-inline: 12px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.task:active { background: #fafbfc; }
.ticon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); }
.tbody { flex: 1; min-width: 0; }
.ttitle { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.tmeta { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.tmeta .late { color: var(--red); font-weight: 600; }
.tmeta .who-n { color: var(--brand); font-weight: 600; }
.check { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; flex: none; padding: 0; }
.check span { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #c5ccd5; display: grid; place-items: center; color: transparent; }
.check:hover span { border-color: var(--brand); }
.check svg.i { width: 16px; height: 16px; stroke-width: 3; }
.task.done .ttitle { text-decoration: line-through; color: var(--muted); }
.task.done .ticon { filter: grayscale(1); opacity: .6; }
.task.done .check span { background: var(--brand); border-color: var(--brand); color: #fff; }

/* install banner */
.install { display: flex; gap: 12px; align-items: center; padding-block: 12px; padding-inline: 12px 10px; margin-top: 14px; background: var(--brand); color: #fff; border-radius: var(--radius); }
.install img { width: 40px; height: 40px; border-radius: 11px; background: #fff; flex: none; }
.install div { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.35; }
.install b { display: block; font-size: 15px; }
.install .btn { height: 38px; background: #fff; color: var(--brand); border: 0; padding: 0 14px; }
.install .x { background: transparent; border: 0; color: #fff; opacity: .8; padding: 4px; }

/* calendar strip */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 6px; }
.day { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 0 7px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.day small { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.day b { font-size: 18px; }
.day i { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.day i.has { background: var(--brand); }
.day i.late { background: var(--red); }
.day.today b { color: var(--brand); }
.day.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.day.on small, .day.on b { color: #fff; }
.day.on i.has, .day.on i.late { background: #fff; }
.calbar { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.calbar .month { flex: 1; font-weight: 700; font-size: 16px; }

/* search + chips */
.search { position: relative; margin-top: 4px; }
.search input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding-block: 0; padding-inline: 42px 14px; font-size: 15px; }
.search svg.i { position: absolute; inset-inline-start: 13px; top: 13px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 13.5px; color: var(--muted); }
.chip.on { background: var(--text); border-color: var(--text); color: #fff; }

/* rows (clients, properties, team) */
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; font-size: 15px; }
.avatar.sq { border-radius: 12px; background: #eef2f7; color: #475569; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { font-size: 13px; color: var(--muted); }
.row .right { text-align: end; font-size: 13px; color: var(--muted); flex: none; }

/* detail pages */
.hero { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.hero .ttl { display: flex; gap: 14px; align-items: center; }
.hero h2 { margin: 0; font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.btnrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.facts { display: grid; gap: 10px; }
.fact { display: flex; gap: 12px; align-items: flex-start; }
.fact svg.i { color: var(--muted); margin-top: 1px; }
.fact .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.fact small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }

/* more page */
.menu { display: flex; flex-direction: column; overflow: hidden; }
.menu button, .menu a { display: flex; align-items: center; gap: 14px; padding: 15px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--card); text-align: start; color: var(--text); font-weight: 500; width: 100%; }
.menu > :last-child { border-bottom: 0; }
.menu .grow { flex: 1; }
.menu svg.i { color: var(--muted); }
.menu .red, .menu .red svg.i { color: var(--red); }

/* ---------- sheet (pop-up forms) ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); animation: up .22s ease-out; overscroll-behavior: contain; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #d6dbe1; margin: 4px auto 10px; }
.sheet h2 { margin: 4px 0 14px; font-size: 20px; }
.sheet .form > .lbl:nth-child(2) { margin-top: 0; }
@media (min-width: 700px) { .backdrop { align-items: center; } .sheet { border-radius: 20px; padding-bottom: 20px; } .sheet .grab { display: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }

.form { display: flex; flex-direction: column; }
.lbl { font-size: 13px; font-weight: 600; color: #334155; margin: 14px 0 6px; display: flex; justify-content: space-between; align-items: center; }
.lbl .opt { font-weight: 500; color: var(--muted); }
.lbl button { border: 0; background: none; color: var(--brand); font-weight: 600; font-size: 13px; padding: 0; }
.form input:not([type=radio]):not([type=checkbox]), .form select, .form textarea {
  width: 100%; height: 48px; border: 1px solid #d5dbe2; border-radius: 12px; background: #fff; padding: 0 14px; font-size: 16px; }
.form textarea { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus, .search input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 0; border-color: var(--brand); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type input, .seg input { position: absolute; opacity: 0; pointer-events: none; }
.type span { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 11px 4px 9px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.type span svg.i { color: var(--c); }
.type input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 9%, white); color: var(--text); }
.type input:focus-visible + span, .seg input:focus-visible + span { outline: 2px solid var(--brand); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 80px; }
.seg span { display: flex; align-items: center; justify-content: center; height: 42px; border: 1.5px solid var(--line); border-radius: 11px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; padding: 0 8px; }
.seg input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 22px; }
.err { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 12px; font-weight: 500; }
.phone { display: grid; grid-template-columns: 112px 1fr; gap: 8px; }
.phone select { padding: 0 8px !important; }
.steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 10px; }
.steps li { padding-inline-start: 4px; }
.kbd { display: inline-grid; place-items: center; vertical-align: middle; width: 26px; height: 26px; border-radius: 7px; background: var(--bg); border: 1px solid var(--line); }
.kbd svg.i { width: 16px; height: 16px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login .box { width: 100%; max-width: 400px; }
.login .brand { text-align: center; margin-bottom: 22px; }
.login .brand img { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 8px 24px rgba(15,118,110,.25); }
.login .brand h1 { margin: 12px 0 2px; font-size: 26px; }
.login .brand p { margin: 0; color: var(--muted); }
.login .card { padding: 22px; }
.login .getapp { margin-top: 14px; }

/* ---------- toast / offline ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 84px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { #toast-root { bottom: 28px; } }
.toast { pointer-events: auto; background: #1e293b; color: #fff; border-radius: 12px; padding: 12px 14px 12px 16px; display: flex; gap: 14px; align-items: center; font-weight: 500; font-size: 14px; max-width: 440px; width: max-content; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: up .2s ease-out; }
.toast button { background: none; border: 0; color: #5eead4; font-weight: 700; padding: 4px; }
.toast.bad { background: var(--red); }
.toast.bad button { color: #fff; }
.offline { background: #fff7e6; color: var(--amber); font-size: 13px; font-weight: 600; text-align: center; padding: 8px; border-radius: 10px; margin-top: 6px; }
body.sheet-open #toast-root { top: calc(env(safe-area-inset-top, 0px) + 14px); bottom: auto; }

.section-h.day-h { margin-top: 12px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
.login { position: relative; }
.login-lang { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); inset-inline-end: 16px; }
.side .foot .lang { width: 100%; }

/* ---------- Urdu (right to left) ---------- */
[dir=rtl] svg.i.flip { transform: scaleX(-1); }
html[lang=ur] body { font-family: 'Inter', 'Noto Nastaliq Urdu', serif; line-height: 2; }
html[lang=ur] button, html[lang=ur] input, html[lang=ur] select, html[lang=ur] textarea { font-family: 'Inter', 'Noto Nastaliq Urdu', serif; }
html[lang=ur] .top h1 { font-size: 21px; line-height: 1.9; }
html[lang=ur] .top .sub { margin-top: 0; }
html[lang=ur] .section-h { text-transform: none; letter-spacing: 0; font-size: 14px; }
html[lang=ur] .nav a { font-size: 12px; gap: 0; }
html[lang=ur] .stat span, html[lang=ur] .day small { font-size: 12px; text-transform: none; }
html[lang=ur] .day small { font-size: 10.5px; line-height: 1.7; }
html[lang=ur] .day b { line-height: 1.3; }
html[lang=ur] .ttitle, html[lang=ur] .row .name { line-height: 1.8; }
html[lang=ur] .tmeta, html[lang=ur] .row .sub { line-height: 1.9; }
html[lang=ur] .lbl { font-size: 14px; }
html[lang=ur] .fact small { font-size: 12.5px; }
html[lang=ur] .install div { line-height: 1.8; font-size: 13px; }
html[lang=ur] .toast { line-height: 1.9; }
html[lang=ur] .type span { font-size: 13px; padding-top: 9px; padding-bottom: 6px; gap: 0; }
html[lang=ur] .btn { padding-top: 2px; }
.lang[lang=ur], .tag[lang=ur] { font-family: 'Noto Nastaliq Urdu', serif; }
/* names, titles and notes typed by users keep their own direction (English stays left to right inside Urdu) */
.ttitle, .tmeta > span, .row .name, .row .sub, .hero h2, .sheet h2, .fact .grow, .fact .grow a, .fact .grow .muted, .top h1 { unicode-bidi: plaintext; }
[dir=rtl] .ttitle, [dir=rtl] .tmeta > span, [dir=rtl] .row .name, [dir=rtl] .row .sub, [dir=rtl] .hero h2, [dir=rtl] .fact .grow { text-align: right; }

/* in-app confirm box */
.confirm-layer { z-index: 70; align-items: center; padding: 16px; }
.sheet.confirm { max-width: 380px; border-radius: 18px; padding: 20px; }
.sheet.confirm p { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
.sheet.confirm .actions { grid-template-columns: 1fr 1fr; margin-top: 18px; }
.btn.dangerfill { background: var(--red); border-color: var(--red); color: #fff; }

/* sign-up + welcome */
.authswitch { text-align: center; margin-top: 16px; font-size: 14.5px; color: var(--muted); }
.linkbtn { border: 0; background: none; color: var(--brand); font-weight: 700; padding: 6px 2px; font-size: inherit; }
.welcome { padding: 16px; margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.welcome > b { font-size: 16px; margin-bottom: 2px; }
.wstep { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); text-align: start; font-weight: 600; }
.wstep span { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; font-size: 14px; }
.wstep svg.i { margin-inline-start: auto; color: var(--muted); }

/* password reset */
.code-in { font-size: 24px !important; letter-spacing: .35em; text-align: center; font-weight: 600; }
.nudge { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 14px; padding: 14px; text-align: start; background: #fff7e6; border-color: #f5d9a8; color: var(--amber); font-weight: 600; }
.nudge span { flex: 1; }
