:root {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1f2838;
  --border: #2a3448;
  --text: #eef2f8;
  --muted: #9aa7bd;
  --primary: #4f8cff;
  --primary-ink: #ffffff;
  --good: #34c77b;
  --warn: #f0b429;
  --bad: #f05a5a;
  --info: #58b6e0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

#app {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 76px; /* mch bottom nav */
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px calc(14px + env(safe-area-inset-top, 0));
  padding-top: max(14px, env(safe-area-inset-top, 0));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbar h1 { font-size: 1.1rem; margin: 0; }
.topbar .sub { font-size: 0.8rem; color: var(--muted); }

.content { padding: 16px; flex: 1; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1rem; margin: 0 0 12px; }
.card .hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 14px; }

/* ===== Forms ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}
.field .req { color: var(--bad); }
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}
input[readonly], input:disabled, select:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}
input[inputmode="numeric"] { direction: ltr; text-align: right; }
.field .error-msg {
  display: none;
  color: var(--bad);
  font-size: 0.82rem;
  margin-top: 6px;
}
.field.invalid input,
.field.invalid select { border-color: var(--bad); }
.field.invalid .error-msg { display: block; }

.field .prefilled-tag {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--info);
  background: rgba(88, 182, 224, 0.12);
  border-radius: 6px;
  padding: 1px 7px;
  margin-right: 6px;
}

/* screenshot upload */
.upload {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: var(--surface-2);
}
.upload.has-file { border-color: var(--good); color: var(--text); }
.upload input[type="file"] { display: none; }
.upload .preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
  margin-top: 10px;
  display: block;
}
.upload .clear-file {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--bad);
  background: none;
  border: none;
  cursor: pointer;
  width: auto;
  padding: 4px;
}

/* ===== Buttons ===== */
button, .btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost {
  background: none;
  color: var(--primary);
  font-weight: 600;
}

/* ===== Status badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.badge.submitted { color: var(--info); background: rgba(88,182,224,0.14); }
.badge.approved  { color: var(--primary); background: rgba(79,140,255,0.14); }
.badge.ready     { color: var(--good); background: rgba(52,199,123,0.14); }
.badge.paid      { color: var(--good); background: rgba(52,199,123,0.2); }
.badge.review    { color: var(--warn); background: rgba(240,180,41,0.14); }
.badge.needs_fix { color: var(--warn); background: rgba(240,180,41,0.18); }
.badge.on_hold   { color: var(--muted); background: rgba(154,167,189,0.14); }
.badge.rejected  { color: var(--bad); background: rgba(240,90,90,0.14); }

/* ===== Claim list ===== */
.claim {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.claim .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.claim .amount { font-size: 1.15rem; font-weight: 800; }
.claim .meta { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }

/* feedback blocks inside a claim */
.feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border-right: 3px solid var(--border);
  background: var(--surface-2);
}
.feedback.ok { border-color: var(--good); }
.feedback.data_error { border-color: var(--warn); }
.feedback.supervision_bonus { border-color: var(--primary); }
.feedback .salary {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  font-size: 0.86rem;
}
.feedback .salary .total {
  font-weight: 800;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 4px;
}

/* ===== Bottom nav ===== */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 540px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 20;
}
.bottomnav a {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.bottomnav a.active { color: var(--primary); }
.bottomnav a .ic { font-size: 1.3rem; line-height: 1; }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo .diamond { font-size: 3rem; }
.login-logo h1 { font-size: 1.4rem; margin: 10px 0 4px; }
.login-logo p { color: var(--muted); margin: 0; font-size: 0.9rem; }
.test-accounts {
  margin-top: 18px;
  font-size: 0.8rem;
  color: var(--muted);
}
.test-accounts button {
  width: auto;
  padding: 6px 10px;
  margin: 4px 4px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ===== Misc ===== */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}
.empty .big { font-size: 2.4rem; }
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; padding: 30px; color: var(--muted); }

.toast {
  position: fixed;
  bottom: 86px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-size: 0.9rem;
  max-width: 90%;
}
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }

.offline-bar {
  background: var(--warn);
  color: #1a1400;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px;
}

.install-hint {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.install-hint button {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ===== صفحات السياسات (خصوصية/شروط) ===== */
.legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom, 0));
}
.legal .back {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.legal h1 { font-size: 1.4rem; margin: 0 0 6px; }
.legal .updated { color: var(--muted); font-size: 0.85rem; margin: 0 0 20px; }
.legal h2 {
  font-size: 1.08rem;
  margin: 26px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.legal p, .legal li { line-height: 1.9; }
.legal ul { padding-right: 20px; }
.legal a { color: var(--primary); }
.legal .note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-right: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 20px 0;
}
.legal .fill { color: var(--warn); font-weight: 700; }

/* روابط السياسات أسفل الدخول */
.legal-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--muted);
}
.legal-footer a { color: var(--muted); text-decoration: underline; }
.legal-footer span { margin: 0 6px; }

/* ===== اختيار استلام الراتب (تسليم/شحن) ===== */
.seg { display: flex; gap: 8px; }
.seg-btn {
  width: auto;
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}
.seg-btn.active {
  background: rgba(79, 140, 255, 0.16);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 800;
}
.field .choice-hint { color: var(--muted); font-size: 0.8rem; margin-top: 6px; }
