* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0f1419;
  --card: #1a2332;
  --card2: #222e42;
  --line: #2c3a52;
  --text: #e8edf5;
  --muted: #8fa0b8;
  --green: #22c55e;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
}
html { font-size: 15px; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Tahoma, "Noto Kufi Arabic", Arial, sans-serif;
  direction: rtl;
  overscroll-behavior-y: none;
}
#app { display: flex; flex-direction: column; min-height: 100vh; max-width: 640px; margin: 0 auto; }
#topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, #131a24, #0f1419);
  padding: 12px 16px 8px; border-bottom: 1px solid var(--line);
}
#topbar-title { font-size: 1.15rem; font-weight: 700; }
#topbar-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
#view { flex: 1; padding: 14px 14px 90px; }
#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 640px; margin: 0 auto;
  display: flex; background: #131a24; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--muted); text-decoration: none; font-size: .68rem;
}
#bottomnav a.active { color: var(--cyan); }
.nav-ic { font-size: 1.15rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h3 { font-size: .95rem; margin-bottom: 10px; color: var(--muted); font-weight: 600; }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi .k-label { font-size: .72rem; color: var(--muted); margin-bottom: 6px; }
.kpi .k-val { font-size: 1.25rem; font-weight: 700; }
.kpi .k-sub { font-size: .7rem; color: var(--muted); margin-top: 4px; }
.kpi.green { border-right: 3px solid var(--green); } .kpi.green .k-val { color: var(--green); }
.kpi.blue { border-right: 3px solid var(--blue); } .kpi.blue .k-val { color: var(--blue); }
.kpi.amber { border-right: 3px solid var(--amber); } .kpi.amber .k-val { color: var(--amber); }
.kpi.red { border-right: 3px solid var(--red); } .kpi.red .k-val { color: var(--red); }
.kpi.purple { border-right: 3px solid var(--purple); } .kpi.purple .k-val { color: var(--purple); }
.kpi.cyan { border-right: 3px solid var(--cyan); } .kpi.cyan .k-val { color: var(--cyan); }

.stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stage { background: var(--card2); border-radius: 10px; padding: 8px; text-align: center; }
.stage .s-label { font-size: .65rem; color: var(--muted); }
.stage .s-val { font-size: 1rem; font-weight: 700; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { color: var(--muted); font-weight: 600; text-align: right; padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 6px; border-bottom: 1px solid #232f44; }
tr:last-child td { border-bottom: none; }
.tbl-wrap { overflow-x: auto; }

.btn {
  display: inline-block; border: none; border-radius: 10px; padding: 10px 18px;
  font-size: .9rem; font-weight: 700; font-family: inherit; cursor: pointer;
  background: var(--blue); color: #fff; text-align: center; text-decoration: none;
}
.btn:active { opacity: .85; }
.btn.green { background: var(--green); }
.btn.gray { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.red { background: var(--red); }
.btn.block { display: block; width: 100%; }
.btn.sm { padding: 6px 12px; font-size: .78rem; }

form .frow { margin-bottom: 10px; }
label { display: block; font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 12px; font-size: .95rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); }
input[type=number] { direction: ltr; text-align: right; }
.fgrid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fgrid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .68rem; font-weight: 700; }
.chip.green { background: #14532d; color: #86efac; }
.chip.blue { background: #1e3a5f; color: #93c5fd; }
.chip.amber { background: #4a3508; color: #fcd34d; }
.chip.red { background: #4c1d1d; color: #fca5a5; }
.chip.gray { background: var(--card2); color: var(--muted); }
.chip.purple { background: #2e1f5e; color: #c4b5fd; }

.warn-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid #232f44; font-size: .8rem; }
.warn-item:last-child { border-bottom: none; }
.warn-item .w-ic { flex-shrink: 0; }
.warn-item.red { color: #fca5a5; }
.warn-item.amber { color: #fcd34d; }

.list-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.list-item .li-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list-item .li-title { font-weight: 700; font-size: .9rem; }
.list-item .li-meta { color: var(--muted); font-size: .72rem; margin-top: 4px; line-height: 1.7; }
.list-item .li-nums { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.list-item .li-num { font-size: .72rem; color: var(--muted); }
.list-item .li-num b { color: var(--text); font-size: .85rem; }

.group-head { display: flex; justify-content: space-between; align-items: center; background: var(--card2); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; font-weight: 700; font-size: .85rem; cursor: pointer; }
.group-head .g-count { color: var(--muted); font-size: .72rem; font-weight: 400; }

.fab {
  position: fixed; bottom: 78px; left: 16px; z-index: 25;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--cyan); color: #04222a; font-size: 1.7rem; font-weight: 700;
  box-shadow: 0 4px 14px rgba(6,182,212,.4); cursor: pointer;
}

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg); border-radius: 18px 18px 0 0; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; padding: 18px 16px 30px; }
.modal h2 { font-size: 1rem; margin-bottom: 14px; }

#toast {
  position: fixed; bottom: 90px; right: 50%; transform: translateX(50%);
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 20px; border-radius: 999px; font-size: .82rem; z-index: 60;
  opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; }
#toast.err { border-color: var(--red); color: #fca5a5; }
#toast.ok { border-color: var(--green); color: #86efac; }

.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input { flex: 1; }
.search-row select { width: auto; min-width: 110px; }

.muted { color: var(--muted); }
.small { font-size: .72rem; }
.mt8 { margin-top: 8px; } .mb8 { margin-bottom: 8px; }
.num { font-variant-numeric: tabular-nums; }
.neg { color: var(--red); font-weight: 700; }
.pos { color: var(--green); }
.row-flex { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: .85rem; }
