:root {
  --teal: #0e7c6e;
  --teal-dark: #0a5f55;
  --mint: #f1fff3;
  --mint-2: #dff7e2;
  --mint-3: #c9eed0;
  --forest: #2f5b2b;
  --ink: #0b2e2a;
  --muted: #52716c;
  --orange: #f07f24;
  --green: #3fb950;
  --blue: #1f6feb;
  --red: #d64545;
  --amber: #c27c0e;
  --card: #ffffff;
  --line: #cfe9d4;
  --shadow: 0 6px 18px rgba(11, 46, 42, .10);
  --radius: 18px;
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --mint: #0f1d1b; --mint-2: #16302c; --mint-3: #1d3d38; --card: #132623; --ink: #e5f4f0; --muted: #9bbab4;
    --line: #23433e; --forest: #3f7a39; --shadow: 0 6px 18px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: #0b2e2a; color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); }
[hidden] { display: none !important; }

#shell { max-width: 480px; min-height: 100%; margin: 0 auto; background: var(--mint); position: relative; display: flex; flex-direction: column; }
@media (min-width: 520px) { #shell { min-height: calc(100% - 32px); margin: 16px auto; border-radius: 28px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.4); } }
#view { flex: 1; display: flex; flex-direction: column; padding-bottom: 96px; }
#view.no-tabs { padding-bottom: 24px; }

/* Header + sheet (the Figma "teal band with rounded mint card" pattern) */
.hdr { background: var(--teal); color: #fff; padding: 22px 20px 56px; position: relative; }
.hdr.tall { padding-bottom: 72px; }
.hdr-row { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.hdr h1 { font-size: 20px; margin: 0; flex: 1; text-align: center; font-weight: 600; }
.hdr h1.left { text-align: start; font-size: 22px; }
.hdr .sub { opacity: .9; margin-top: 4px; font-size: 14px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: inherit; display: grid; place-items: center; cursor: pointer; position: relative; flex: none; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.icon-btn:focus-visible, .btn:focus-visible, .tile:focus-visible, .row:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.icon-btn svg { width: 22px; height: 22px; }
[dir="rtl"] .flip svg { transform: scaleX(-1); }
.badge { position: absolute; top: 4px; inset-inline-end: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--orange); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.sheet { background: var(--mint); border-radius: 36px 36px 0 0; margin-top: -36px; padding: 24px 18px; flex: 1; position: relative; }
.hdr-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.hdr-card { background: var(--mint); color: var(--ink); border: 0; border-radius: 16px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; cursor: pointer; }
.hdr-card svg { width: 26px; height: 26px; color: var(--teal); }
.hdr-card.active { outline: 3px solid var(--orange); }
.hdr-card small { font-weight: 500; color: var(--muted); }

/* Buttons + forms */
.btn { border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 600; font-size: 16px; cursor: pointer; background: var(--teal); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; }
.btn:hover { background: var(--teal-dark); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--mint-2); color: var(--teal); }
.btn.orange { background: var(--orange); }
.btn.danger { background: transparent; color: var(--red); border: 1.5px solid currentColor; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.sm { padding: 8px 14px; font-size: 14px; min-height: 36px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 500; font-size: 14px; margin: 0 6px 6px; }
.input { width: 100%; border: 1.5px solid transparent; background: var(--mint-2); border-radius: 16px; padding: 12px 16px; font-size: 16px; outline: none; }
.input:focus { border-color: var(--teal); background: var(--card); }
textarea.input { min-height: 110px; resize: vertical; }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.err { color: var(--red); font-size: 14px; margin: 4px 6px 10px; min-height: 1em; }
.hint { color: var(--muted); font-size: 13px; margin: 0 6px 12px; }
.link { background: none; border: 0; color: var(--teal); font-weight: 600; cursor: pointer; padding: 8px; font-size: 14px; }

/* Splash */
.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 28px; text-align: center; gap: 18px; }
.splash img { width: 240px; max-width: 80%; }
.splash p { color: var(--muted); max-width: 300px; line-height: 1.5; margin: 0 0 8px; }
.splash .btn { width: 220px; }
.lang-switch { position: absolute; top: 16px; inset-inline-end: 16px; }

/* Home grid */
.greet-name { font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 10px; }
.tile { background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px; border-radius: 16px; color: var(--ink); }
.tile .ico { width: 78px; height: 78px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; position: relative; }
.tile .ico svg { width: 40px; height: 40px; }
.tile .ico .brand { font-weight: 800; font-size: 13px; letter-spacing: .5px; }
.tile span.lbl { font-size: 12.5px; font-weight: 600; text-align: center; line-height: 1.25; }
.tile .ico .badge { top: -6px; inset-inline-end: -6px; }
.home-banner { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; gap: 12px; align-items: center; margin-bottom: 22px; cursor: pointer; border: 0; width: 100%; text-align: start; color: var(--ink); }
.home-banner .ring-sm { flex: none; }
.home-banner b { display: block; }
.home-banner small { color: var(--muted); }

/* Tab bar */
#tabbar { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); width: min(448px, calc(100% - 32px)); background: var(--teal); border-radius: 28px; display: flex; justify-content: space-around; padding: 8px; z-index: 5; box-shadow: 0 10px 24px rgba(11,46,42,.25); }
#tabbar button { background: none; border: 0; color: rgba(255,255,255,.7); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; cursor: pointer; padding: 6px 18px; border-radius: 18px; position: relative; }
#tabbar button.on { color: #fff; background: rgba(255,255,255,.14); }
#tabbar svg { width: 22px; height: 22px; }
#tabbar .badge { top: 0; inset-inline-end: 8px; }

/* Stats + ring (Track Engine header) */
.stats { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; margin-bottom: 18px; }
.stat { margin-bottom: 10px; }
.stat small { color: var(--muted); display: flex; align-items: center; gap: 6px; font-size: 13px; }
.stat b { font-size: 26px; display: block; margin-inline-start: 4px; }
.stat b.teal { color: var(--teal); }
.ring-card { background: var(--forest); color: #fff; border-radius: 26px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 140px; }
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; font-weight: 700; font-size: 20px; }
.ring-card small { font-weight: 600; }
.search { display: flex; align-items: center; gap: 8px; background: var(--mint-2); border: 1.5px solid var(--teal); border-radius: 14px; padding: 0 12px; margin-bottom: 14px; }
.search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.search input { border: 0; background: none; outline: none; padding: 12px 0; flex: 1; font-size: 15px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink); }
.chip.on { background: var(--teal); color: #fff; border-color: var(--teal); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.row { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px; display: flex; gap: 12px; align-items: center; cursor: pointer; border: 0; width: 100%; text-align: start; color: var(--ink); }
.row .av { width: 50px; height: 50px; border-radius: 14px; background: var(--forest); color: #fff; display: grid; place-items: center; flex: none; }
.row .av svg { width: 26px; height: 26px; }
.row .av.teal { background: var(--teal); }
.row .body { flex: 1; min-width: 0; }
.row .t { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.row .meta small { color: var(--muted); font-size: 12px; }
.bar { height: 6px; background: var(--mint-2); border-radius: 3px; overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: var(--teal); border-radius: 3px; }
.pill { font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pill.active, .pill.in_progress { background: #e1efff; color: var(--blue); }
.pill.open { background: #fff1e3; color: #b85a0c; }
.pill.completed, .pill.closed { background: #dcf5e1; color: #1f7a33; }
.pill.on_hold, .pill.quoted { background: #fff4d6; color: var(--amber); }
.pill.cancelled { background: #fde4e4; color: var(--red); }
.pill.overdue { background: #fde4e4; color: var(--red); }
.group-h { font-size: 13px; color: var(--muted); font-weight: 600; margin: 14px 4px 8px; }
.sec-h { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 10px; }
.sec-h h2 { font-size: 18px; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty svg { width: 48px; height: 48px; opacity: .5; }
.empty p { margin: 8px 0 16px; }

/* Job detail */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.job-top { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.job-top h2 { margin: 0; font-size: 18px; }
.job-top p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.note { background: #fff7ec; border-inline-start: 4px solid var(--orange); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 12px; color: #5a3a12; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note { background: #3a2a14; color: #ffd9a8; } }
.cta { background: var(--orange); color: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.cta h3 { margin: 0 0 4px; font-size: 16px; }
.cta p { margin: 0 0 12px; font-size: 14px; opacity: .95; }
.cta .btn { background: #fff; color: var(--orange); }
.timeline { position: relative; padding: 4px 0; }
.tl-item { display: grid; grid-template-columns: 92px 22px 1fr; gap: 8px; min-height: 58px; }
.tl-date { text-align: end; font-size: 11.5px; color: var(--muted); padding-top: 2px; line-height: 1.35; }
.tl-date b { display: block; color: var(--ink); font-weight: 600; font-size: 12px; }
.tl-rail { position: relative; display: flex; justify-content: center; }
.tl-rail::before { content: ""; position: absolute; top: 18px; bottom: -4px; width: 0; border-inline-start: 2px dashed var(--mint-3); }
.tl-item:last-child .tl-rail::before { display: none; }
.tl-item.done .tl-rail::before { border-inline-start-style: solid; border-color: var(--green); }
.dot { width: 16px; height: 16px; border-radius: 50%; background: var(--mint-3); margin-top: 2px; position: relative; z-index: 1; border: 3px solid var(--mint); box-sizing: content-box; }
.tl-item.done .dot { background: var(--green); }
.tl-item.current .dot { background: var(--orange); box-shadow: 0 0 0 5px rgba(240,127,36,.25); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(240,127,36,.05); } }
@media (prefers-reduced-motion: reduce) { .tl-item.current .dot { animation: none; } }
.tl-body { padding-bottom: 14px; }
.tl-body .t { font-weight: 600; font-size: 14.5px; color: var(--forest); }
.tl-item.pending .tl-body .t { color: var(--muted); font-weight: 500; }
.tl-item.current .tl-body .t { color: var(--orange); }
.tl-body small { color: var(--muted); font-size: 12px; }
.tl-body .n { font-size: 13px; margin-top: 4px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file { display: inline-flex; align-items: center; gap: 6px; background: var(--mint-2); color: var(--teal); padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; text-decoration: none; max-width: 100%; }
.file svg { width: 16px; height: 16px; flex: none; }
.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; display: block; background: var(--mint-2); }
.progress-hd { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress-hd .bar { height: 10px; border-radius: 5px; }
.progress-hd b { font-size: 14px; white-space: nowrap; }

/* Messages */
.msgs { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.msg { max-width: 85%; padding: 10px 12px; border-radius: 14px; font-size: 14px; background: var(--card); box-shadow: var(--shadow); white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--teal); color: #fff; }
.msg small { display: block; font-size: 11px; opacity: .75; margin-top: 4px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 46px; height: 46px; }

/* Notifications */
.notif { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: start; color: var(--ink); }
.notif .av { width: 40px; height: 40px; border-radius: 12px; background: var(--teal); color: #fff; display: grid; place-items: center; flex: none; }
.notif .av svg { width: 20px; height: 20px; }
.notif .t { font-weight: 600; font-size: 14.5px; }
.notif .b { font-size: 13px; color: var(--muted); margin-top: 2px; }
.notif small { color: var(--teal); font-size: 12px; display: block; margin-top: 4px; }
.notif.unread .t::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-inline-end: 6px; vertical-align: middle; }

/* Profile */
.avatar { width: 96px; height: 96px; border-radius: 50%; background: var(--mint-2); border: 4px solid var(--mint); display: grid; place-items: center; font-size: 34px; font-weight: 700; color: var(--teal); margin: -76px auto 10px; position: relative; }
.profile-name { text-align: center; }
.profile-name h2 { margin: 0; font-size: 20px; }
.profile-name p { margin: 4px 0 18px; color: var(--muted); font-size: 13px; }
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu button, .menu a { display: flex; align-items: center; gap: 14px; padding: 10px 6px; background: none; border: 0; cursor: pointer; font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: none; border-radius: 12px; text-align: start; }
.menu button:hover, .menu a:hover { background: var(--mint-2); }
.menu .mi { width: 46px; height: 46px; border-radius: 14px; background: var(--teal); color: #fff; display: grid; place-items: center; }
.menu .mi svg { width: 22px; height: 22px; }
.menu .grow { flex: 1; }
.menu .val { color: var(--muted); font-size: 13px; }

/* Content pages */
.prose { font-size: 15px; line-height: 1.65; }
.prose h3 { margin: 18px 0 6px; font-size: 16px; }
.prose img.hero { width: 100%; border-radius: 16px; margin: 8px 0; }
.logo-top { display: block; width: 210px; max-width: 70%; margin: 4px auto 18px; }
.contact-list a { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); margin-bottom: 10px; font-weight: 600; }
.contact-list svg { width: 22px; height: 22px; color: var(--teal); }
.contact-list small { display: block; color: var(--muted); font-weight: 500; }

#toast { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--mint); padding: 12px 18px; border-radius: 14px; font-size: 14px; z-index: 20; max-width: calc(100% - 40px); box-shadow: var(--shadow); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--mint-3); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ring-sm .val { font-size: 13px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.home-banner .pill { white-space: normal; display: inline-block; line-height: 1.3; }
.kv dd, .file span { unicode-bidi: plaintext; }

/* Notch / home-indicator safe areas (native apps and installed PWA) */
.hdr { padding-top: calc(22px + env(safe-area-inset-top, 0px)); }
.splash { padding-top: calc(40px + env(safe-area-inset-top, 0px)); }
.lang-switch { top: calc(16px + env(safe-area-inset-top, 0px)); }
#tabbar { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
#view { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
#view.no-tabs { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
#toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.menu a { cursor: pointer; }
